清给出具体代码谢谢

解决方案 »

  1.   

    gifimageprocedure TfrmMain.btnGoClick(Sender: TObject);
    const
      ErrorDescription: array[TGIFError] of String = ('None',
                                                      'Operation Cancelled',
                                                      'Internal Error',
                                                      'Invalid File Format',
                                                      'Image contains too many Colors (>256)',
                                                      'Index out of Bounds',
                                                      'Windows GDI Error',
                                                      'File not Found',
                                                      'Resource not Found');
    var
      GIF: TGIFImage;
      Success: Boolean;
      Bitmap: TBitmap;
    begin
      GIF := TGIFImage.Create(nil);
      try
        Success := GIF.LoadFromFile(editInput.Text);    if Success then begin
          { There are 2 ways to do this: }      { 1st Method:
            GIF.Bitmap.SaveToFile(editOutput.Text);
          }      { 2nd Method: }
          Bitmap := TBitmap.Create;
          try
            Bitmap.Assign(GIF);  { or Bitmap.Assign(GIF.Bitmap); }
            { Now you're free to manipulate Bitmap before saving it... }
            Bitmap.SaveToFile(editOutput.Text);
          finally
            Bitmap.Free;
          end;
          ShowMessage('GIF Converted. Success!');
        end
        else begin
          ShowMessage(Format('Load Failed. Error Code = %d [%s]',
                             [Ord(GIF.LastError), ErrorDescription[GIF.LastError]]));
        end;
      finally
        GIF.Free;
      end;
    end;