代码如下:
已经uses gifimage了,我用gifanimator也不行啊!!同样的错误啊!procedure TForm1.Button1Click(Sender: TObject); 
var 
Stream:TResourceStream; 
Gif:TGraphic; 
Begin
Stream:=TResourceStream.Create(HINSTANCE,'t1z','GIF');
Try
GIF:=TGraphic.Create;
Try
GIF.LoadfromStream(Stream);
Image1.Picture.Assign(GIF);
Finally
GIF.Free;
end;
Finally
Stream.Free;
end;
end;

解决方案 »

  1.   

    Try:image1.Picture.Bitmap.Assign(GIF);
      

  2.   

    可以的,会把gif自动转成bitmap显示出来。看看tgifimage.assignto的实现procedure TGIFImage.AssignTo(Dest: TPersistent);
    begin
      if (Dest is TBitmap) then
        Dest.Assign(Bitmap)
      else
        inherited AssignTo(Dest);
    end;
      

  3.   

    请到这里下载最新版本和DEMO,几年没更新了,今年刚刚更新。
    http://www.tolderlund.eu/delphi/下面这段是官方DEMO代码。uses
      GIFimage;procedure TFormDemo.ButtonLoadClick(Sender: TObject);
    var
      Stream : TStream;
      GIF : TGIFImage;
    begin
      // Do not use buffering.
      // This is safe since we have complete control over the TImage's canvas
      include(GIFImageDefaultDrawOptions, goDirectDraw);  // Create a stream to load the GIF resource from
      Stream := TResourceStream.Create(hInstance, 'download', 'GIF');
      try
        GIF := TGIFImage.Create;
        try
          // Load the GIF from the resource stream
          GIF.LoadFromStream(Stream);
          // Display the GIF in the TImage
          ImageGIF.Picture.Assign(GIF);
        finally
          GIF.Free;
        end;
      finally
        Stream.Free;
      end;
    end;procedure TFormDemo.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      // Since we are using the goDirectDraw options, we MUST stop the GIF paint
      // thread before the form is destroyed.
      ImageGIF.Picture.Graphic := nil;
    end;