timage sprite animation and png transparency lazarus / 39-Graphics ---------------------------------------------------------------------- jw · 2010-03-19 16:34 because this was hard for me I'll go ahead and post the code 1st png's with transparent backgrounds are supported just not directly by a timage why? I don't know.  First you've got to define a TCustomBitmap and create a TPortableNetworkGraphic then assign this to a timage. 2nd timagelists hold array's of images of the same height and width.  The default height and width of timagelist is 16 x 16 if you load a bigger image into it without setting timagelist height and width it will overload the timagelist and it will do weird stuff. below is code that throws 4 animating sprites on the screen useing timage timagelist and a timer. if I could post the project I would the timiagelist is loaded with 0-8 images or 9 images.  It's a rotating snowflake broken down from a free animted gif and converted to transparent png's Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   ExtCtrls; type   { TForm1 }   TForm1 = class(TForm)     Image1: TImage;     Image2: TImage;     Image3: TImage;     Image4: TImage;     ImageList1: TImageList;     Timer1: TTimer;     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);     procedure FormCreate(Sender: TObject);     procedure Timer1Timer(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1;   Img: TCustomBitmap;   count: integer; implementation { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin img:=TPortableNetworkGraphic.Create; end; procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin   img.Free; end; procedure TForm1.Timer1Timer(Sender: TObject); begin   count:=count + 1;   if count > 8 then count :=0;   ImageList1.GetBitmap(count, img);   Image1.Picture.Assign(img);   Image2.Picture.Assign(img);   Image3.Picture.Assign(img);   Image4.Picture.Assign(img); end; initialization   {$I unit1.lrs} end. ---------------------------------------------------------------------- GordonShumway · 2010-05-04 12:22 Thank you, man I was going crazy trying to figure out why it wasn't working properly. THANK YOU! ---------------------------------------------------------------------- Gintas · 2010-05-26 11:10 I wonder does it works without flickering and in Lazarus sprites example ---------------------------------------------------------------------- Leledumbo · 2010-05-27 03:11 QuoteI wonder does it works without flickering and in Lazarus sprites exampleThat example only requires DoubleBuffered to be set true to avoid flickering.