sorry for the loooooong wait on a reply, but it does work you've definitly made your point. The control of animation from a timer allows me to have my zorder, and different background modes for the transparency is awesome. But after much testing I'm haveing trouble actuallty animating the animated gif accross the screen without lot's of flicker. I constructed a double buffer but it still flickers badly when moveing the image or I lose the transparency in the buffering and end up with a black background.
here's a cludge that does work, I buffer to a paintbox then copy from the paintbox canvas to a timage box. The timage doesn't flicker when moveing, which I don't understand since a double buffer quick redraw to the paintbox after a move should have worked.
this is a nice enough animated gif library I'd like to make it a lazarus package for lazarus if possible like wile64's is.
unit fmain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, AnimatedGif;
type
{ TForm1 }
TForm1 = class(TForm)
Button5: TButton;
IdleTimer1: TIdleTimer;
buffer: TPaintBox;
panel1: TImage;
procedure Button5Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure IdleTimer1Timer(Sender: TObject);
private
procedure AddImage();
public
{ public declarations }
//Buffer: TCustomBitmap;
gif: record
image: TAnimatedGif;
r: TRect;
end;
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.AddImage();
begin
//Buffer:=TPortableNetworkGraphic.Create;
// Buffer.Width:=buffer.Width;
//Buffer.Height:=buffer.Height;
with gif do
begin
image := TAnimatedGif.Create('monkey.gif');
image.EraseColor := self.Color;
r.top := 0;
r.bottom := buffer.height;
r.left := 0;
r.right := buffer.width;
end;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
addimage;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
panel1.left:=panel1.left+5;
panel1.Canvas.CopyRect(Rect(0,0,buffer.Width,buffer.Height),
buffer.Canvas,Rect(0,0,buffer.Width,buffer.Height));
end;
procedure TForm1.IdleTimer1Timer(Sender: TObject);
begin
with gif do
begin
image.Update(buffer.Canvas,r);
end;
panel1.Canvas.CopyRect(Rect(0,0,buffer.Width,buffer.Height),
buffer.Canvas,Rect(0,0,buffer.Width,buffer.Height));
end;
initialization
{$I fmain.lrs}
end.