//--------------------------------------------------------------------------- #include #pragma hdrstop #include "SFXViewer.h" //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- __fastcall TViewerSFX::TViewerSFX() { a = 0; b = 1; t = 0; BStart = true; Timer = new TTimer(NULL); Timer->Enabled = false; Timer->Interval = 500; Timer->OnTimer = TimerTimer; bmp = new Graphics::TBitmap(); tmp = new Graphics::TBitmap(); tlo = new Graphics::TBitmap(); Image1 = new TImage(NULL); } //--------------------------------------------------------------------------- __fastcall TViewerSFX::~TViewerSFX() { bmp->Free(); tmp->Free(); Image1->Free(); Timer->Free(); } //--------------------------------------------------------------------------- void __fastcall TViewerSFX::ViewSFXImage(TImage *Image, String PathName, int X, int Y, int count) { Image1 = Image; path = PathName; tlo->LoadFromFile(path + "0.bmp"); top = Y; left = X; Count = count; Timer->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TViewerSFX::Stop() { BStart = false; Timer->Enabled = false; bmp->Height = 0; b = 0; a = 1000; } //--------------------------------------------------------------------------- void __fastcall TViewerSFX::Enabled(bool stan) { BStart = stan; Timer->Enabled = stan; } //--------------------------------------------------------------------------- void __fastcall TViewerSFX::TimerTimer(TObject *Sender) { if(BStart) { t++; if(t > Count) t = 1; Timer->Enabled = false; try { String FileName = path + IntToStr(t) + ".bmp"; bmp->LoadFromFile(FileName); tmp->Width = bmp->Width; tmp->Height = 1; for(a = 0; a < bmp->Height; a += 2) { if(BStart) { tmp->Canvas->CopyRect(Rect(0, 0, bmp->Width, 1), bmp->Canvas, Rect(0, a, bmp->Width, a + 1)); Image1->Canvas->Draw(left, top + a, tmp); tmp->Canvas->CopyRect(Rect(0, 0, bmp->Width, 1), tlo->Canvas, Rect(0, a + 1, bmp->Width, a + 2)); Image1->Canvas->Draw(left, top + a + 1, tmp); } Application->ProcessMessages(); } for(b = bmp->Height - 1; b > 0; b -= 2) { if(BStart) { tmp->Canvas->CopyRect(Rect(0, 0, bmp->Width, 1), bmp->Canvas, Rect(0, b, bmp->Width, b + 1)); Image1->Canvas->Draw(left, top + b, tmp); } Application->ProcessMessages(); } Timer->Enabled = true; }catch(...){;} } else Timer->Enabled = false; } //---------------------------------------------------------------------------