TGIFImage *pGIF = NULL;
TTimer* Timer1 = NULL;
int FrameCount = 0;
void __fastcall Timer1Timer(TObject *Sender);
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
DoubleBuffered = true;
Timer1 = new TTimer(Form1);
Timer1->Enable = false;
Timer1->OnTimer = Timer1Timer;
pGIF = new TGIFImage;
pGIF->LoadFromFile("1.gif");
Timer1->Interval = 200;
Timer1->Enable = true;
}
void __fastcall Timer1Timer(TObject *Sender){
Repaint();
}
void __fastcall TForm1::FormPaint(TObject *Sender){
Canvas->Lock();
Graphics::TBitmap *bmp = new Graphics::TBitmap;
try{
bmp->Assign(aGIF->Images->operator [](i)->Bitmap);
bmp->Transparent = true;
bmp->TransparentColor = clBlack;
bmp->PixelFormat = pf24bit;
// SetStretchBltMode(Canvas->Handle ,STRETCH_DELETESCANS);
// Canvas->StretchDraw(TRect(0,0,100,100),bmp);
Canvas->Draw(0,0,bmp);
}catch(...){
ShowMessage("Can't display!");
}
delete bmp;
if(++ FrameCount >= pGIF->Images->Count)
FrameCount = 0;
Canvas->Unlock();
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete Timer1;
delete pGIF;
}