//--------------------------------------------------------------------- #include #pragma hdrstop #include "CaptureEdit.h" #include "Exception.h" //--------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPImage" #pragma link "TPTextileImage" #pragma link "RzButton" #pragma link "RzCmboBx" #pragma link "RzTrkBar" #pragma link "RzLabel" #pragma link "RzPanel" #pragma resource "*.dfm" //--------------------------------------------------------------------- #define IDS_CAPTUREEDIT StringTable[0] #define IDS_IMAGETOTALCOUNT StringTable[1] #define IDS_IMAGENUMBER StringTable[2] #define IDS_IMAGERANGE StringTable[3] #define IDS_STARTPOINT StringTable[4] #define IDS_ENDPOINT StringTable[5] #define IDS_IN StringTable[6] #define IDS_OUT StringTable[7] //--------------------------------------------------------------------- TList *CaptureData; //--------------------------------------------------------------------- __fastcall TCaptureEditForm::TCaptureEditForm(TComponent* AOwner) : TForm(AOwner) { //============================================================================ StringTable.Create(DirectoryBin, Language, "CaptureEdit"); SetSmallFont(Font); SetSmallFont(Label5->Font); Caption = IDS_CAPTUREEDIT; Imagetotal->Caption = IDS_IMAGETOTALCOUNT; ImageList->Caption = IDS_IMAGENUMBER; Label1->Caption = IDS_IMAGERANGE; Label2->Caption = IDS_STARTPOINT; Label3->Caption = IDS_ENDPOINT; Label4->Caption = IDS_OUT; Label5->Caption = IDS_COMMON_ZOOM; Label6->Caption = IDS_IN; Close->Caption = IDS_COMMON_EXIT; //============================================================================ } //--------------------------------------------------------------------------- void __fastcall TCaptureEditForm::FormCreate(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TCaptureEditForm::FormResize(TObject *Sender) { // ScrollBar2->Left = ClientWidth - 15; // ScrollBar1->Width = ClientWidth - 15; // PieceImage1->Width = ClientWidth - 15; // ScrollBar1->Top = ClientHeight - 15; // ScrollBar2->Height = ClientHeight - 85 - 15; //65 - 15; // PieceImage1->Height = ClientHeight - 85 - 15; // 65 - 15; } //--------------------------------------------------------------------- void __fastcall TCaptureEditForm::ListNumberChange(TObject *Sender) { int i = ListNumber->ItemIndex; ImageCount->Caption = CaptureData->Count; FCData = (TCaptureData *)CaptureData->Items[i]; Label7->Caption = Format("(%d, %d)", OPENARRAY(TVarRec, ((int)FCData->Range.Left,(int)FCData->Range.Top))); Label8->Caption = Format("(%d, %d)", OPENARRAY(TVarRec, ((int)FCData->Range.Right,(int)FCData->Range.Bottom))); if (PieceImage1->Bitmap->Create(FCData->Bitmap->Width, FCData->Bitmap->Height, FCData->Bitmap->BitsPerPixel)) { // PieceImage1->Bitmap->CopyFromRect(FCData->Mask, 0, 0, SRCCOPY); // PieceImage1->Bitmap->CopyFromRect(FCData->Bitmap, 0, 0, SRCAND); FCData->Mask->CopyToTexpia(PieceImage1->Bitmap, 0, 0, PieceImage1->Bitmap->Width, PieceImage1->Bitmap->Height, 0, 0, SRCCOPY); // convert by celberus FCData->Bitmap->CopyToTexpia(PieceImage1->Bitmap, 0, 0, PieceImage1->Bitmap->Width, PieceImage1->Bitmap->Height, 0, 0, SRCAND); // convert by celberus PieceImage1->Repaint(); } else {SAVE_EXCEPTION(EC_MEMORY_LACK); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK);} } //--------------------------------------------------------------------------- void __fastcall TCaptureEditForm::ScrollBar1Change(TObject *Sender) { if(CaptureData->Count > 0) { ScrollBar1->Max = FCData->Bitmap->Width; PieceImage1->PositionX = ScrollBar1->Position; } } //--------------------------------------------------------------------------- void __fastcall TCaptureEditForm::ScrollBar2Change(TObject *Sender) { if(CaptureData->Count > 0) { ScrollBar2->Max = FCData->Bitmap->Height; PieceImage1->PositionY = ScrollBar2->Position; } } //--------------------------------------------------------------------------- void __fastcall TCaptureEditForm::ZoomInOutChange(TObject *Sender) { if(ZoomInOut->Position < 0) PieceImage1->SetZoom(1, qqq(2, (ZoomInOut->Position * -1)), NULL); else if(ZoomInOut->Position >0) PieceImage1->SetZoom(qqq(2, ZoomInOut->Position), 1, NULL); else PieceImage1->SetZoom(1, 1, NULL); } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- int __fastcall TCaptureEditForm::qqq(int a, int b) { int result = 1; for(int i=0; i < b; i++) result *= a; return result; } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TCaptureEditForm::InitForm() { ListNumber->Text = "1"; for (int i = 1; i <= CaptureData->Count; i++) { ListNumber->Items->Add(IntToStr(i)); } ListNumber->ItemIndex = 0; if (CaptureData->Count) ListNumberChange(ListNumber); } //---------------------------------------------------------------------------