//--------------------------------------------------------------------- #include #include #include #pragma hdrstop #include "Main.h" #include "About.h" #include "CaptureEdit.h" #include "ColorChart.h" #include "ColorLibrary_f.h" #include "EnlargeCanvas.h" #include "Environment.h" #include "FileManager_F.h" #include "FullView.h" #include "History.h" #include "ProtectCard.h" #include "MainImage.h" #include "MainMenu.h" #include "NewCanvas.h" #include "PenManager.h" #include "ResizeCanvas.h" #include "StatusProgress.h" #include "TPrint_F.h" #include "Undo.h" #include "Define.h" #include "CaptureEdit.h" #include "UserColor_F.h" //--------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ltimg_bc.lib" #pragma link "lttwn_bc.lib" #pragma resource "*.dfm" #pragma resource "Cursor.res" //--------------------------------------------------------------------------- #define IDS_TDCSP StringTable[0] #define IDS_TDCSA StringTable[1] #define IDS_FILE StringTable[2] #define IDS_F256COLOR StringTable[3] #define IDS_FFULLCOLOR StringTable[4] #define IDS_FFILEMANAGER StringTable[5] #define IDS_FREOPEN StringTable[6] #define IDS_FCLOSE StringTable[7] #define IDS_FCLOSEALL StringTable[8] #define IDS_FRESIZECANVAS StringTable[9] #define IDS_FENLARGECANVAS StringTable[10] #define IDS_FSCANNING StringTable[11] #define IDS_FSCANNERSETUP StringTable[12] #define IDS_FSMALLFONT StringTable[13] #define IDS_FLARGEFONT StringTable[14] #define IDS_FEXIT StringTable[15] #define IDS_EDIT StringTable[16] #define IDS_ECUT StringTable[17] #define IDS_ECOPY StringTable[18] #define IDS_EPASTE StringTable[19] #define IDS_CAPTURE StringTable[20] #define IDS_COVERWRITE StringTable[21] #define IDS_CINSERT StringTable[22] #define IDS_CEDIT StringTable[23] #define IDS_CDELETEALL StringTable[24] #define IDS_IMAGE StringTable[25] #define IDS_IINTENSITYDETECT StringTable[26] #define IDS_ISOLARIZE StringTable[27] #define IDS_IEFFECT StringTable[28] #define IDS_IEPOSTERIZE StringTable[29] #define IDS_IEMOSAIC StringTable[30] #define IDS_IEAVERAGE StringTable[31] #define IDS_IEMEDIAN StringTable[32] #define IDS_IESHARPEN StringTable[33] #define IDS_IEADDNOISE StringTable[34] #define IDS_IEEMBOSS StringTable[35] #define IDS_IEUNDERLAY StringTable[36] #define IDS_IEEDGEENHANCE StringTable[37] #define IDS_IEOILIFY StringTable[38] #define IDS_ISPATIALFILTER StringTable[39] #define IDS_ISGRADIENT StringTable[40] #define IDS_ISLAPLACIAN StringTable[41] #define IDS_ISSOBEL StringTable[42] #define IDS_ISPREWITT StringTable[43] #define IDS_ISSHIFTANDDIFFERENCE StringTable[44] #define IDS_ISLINESEGMENT StringTable[45] #define IDS_VIEW StringTable[46] #define IDS_VSPECIALPEN StringTable[47] #define IDS_VFULLVIEW StringTable[48] #define IDS_VPALETTE StringTable[49] #define IDS_VMAINMENU StringTable[50] #define IDS_VSTATUSBAR StringTable[51] #define IDS_WINDOW StringTable[52] #define IDS_WCASCADE StringTable[53] #define IDS_WTILE StringTable[54] #define IDS_WARRANGEICONS StringTable[55] #define IDS_WMINIMIZEALL StringTable[56] #define IDS_HELP StringTable[57] #define IDS_HABOUT StringTable[58] //--------------------------------------------------------------------------- TMainForm *MainForm; //--------------------------------------------------------------------------- // TMainForm //--------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent *Owner) : TForm(Owner) { bFirst = 0; if(GetSystemMetrics(SM_CXSCREEN)>=1280&&GetSystemMetrics(SM_CYSCREEN)>=1024){ HorzScrollBar->Tracking=false; HorzScrollBar->Visible=false; VertScrollBar->Tracking=false; VertScrollBar->Visible=false; } else { HorzScrollBar->Tracking=true; HorzScrollBar->Visible=true; VertScrollBar->Tracking=true; VertScrollBar->Visible=true; } } //--------------------------------------------------------------------- void __fastcall TMainForm::FormActivate(TObject *Sender) { TMainImageForm *Child = NULL; TPCanvasInfor p; TPException ec = EC_NONE; AnsiString FileName, DirName; if (bFirst==1) { if (ParamStr(1) != "") { FileName = ExtractFileName(ParamStr(1)); DirName = ExtractFileDir(ParamStr(1)); OpenFile(DirName, DirName + "\\" + FileName, gffCPT, 8); } else { if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } p.Orientation = coPortrait; p.DotsPerInch = 160; p.SetSize(cstA4); if ((ec = Child->InitForm(p, 8))!=EC_NONE) goto fail; } bFirst = 2; ToolsRearrange(); } return; fail: if (Child) delete Child; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormCreate(TObject *Sender) { int Items; TIniFile *IniFile; TPException ec = EC_NONE; Application->OnActivate = ApplicationActivate; Application->OnHint = ShowHint; Screen->OnActiveFormChange = UpdateMenuItems; Screen->Cursors[crPen] = LoadCursor(HInstance, "TEXPIAPEN"); LoadFromMainRegIniFile(); MessageStringTable.Create(DirectoryBin, Language, "Message"); if ((ProtectCard = new TProtectCard)==NULL) { ec = EC_INTERFACE_NONE; goto fail; } #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC Items = ProtectCard->Init(RegFilename); if (Items==0 || (Items&PCN_CARPET)!=PCN_CARPET) { ec = EC_INTERFACE_NONE; goto fail; } if (!ProtectCard->CheckPassword()) { ec = EC_INTERFACE_NONE; goto fail; } #else Items = ProtectCard->Init(Password); if (Items<1 || (Items&PCN_CARPET)!=PCN_CARPET) { ec = EC_INTERFACE_NONE; goto fail; } #endif #endif CommonStringTable.Create(DirectoryBin, Language, "Common"); StringTable.Create(DirectoryBin+"\\Textile", Language, "Main"); if ((SmallFont = new TFont)==NULL) { ec = EC_MEMORY_LACK; goto fail; } IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { LoadFont(IniFile, SmallFont, "Font"); bAutoSave = IniFile->ReadBool("AutoSave", "Check", false); if (bAutoSave) { AutosaveTimer->Interval = IniFile->ReadInteger("AutoSave", "Min", 5) * 60000; } delete IniFile; } else { SmallFont->Name = DefaultFontName; SmallFont->Size = 10; } if ((Tablet = new TTablet)==NULL) { ec = EC_MEMORY_LACK; goto fail; } Tablet->Init(Handle, RegFilename.c_str()); if ((PrinterColor = new TPrinterColor)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((StandardColor = new TStandardColor(DirectoryColor+"\\Standard.tpc"))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((TextileColor = new TTextileColor(DirectoryColor+"\\Textile.tpc"))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((Pantone1000 = new TPantone1000(DirectoryColor+"\\Thousand.ptc"))==NULL) { //k3dogs Palette¿¡¼­ ec = EC_MEMORY_LACK; goto fail; //Pantone Color Code¸¦ } //ã±â À§Çؼ­ if ((PantoneTextile = new TPantoneTextile(DirectoryColor+"\\Textile.ptc"))==NULL) { //20001211 ec = EC_MEMORY_LACK; goto fail; } if ((MainMenuForm = new TMainMenuForm(this))==NULL) goto fail; MainMenuForm->Parent = this; MainMenuForm->Visible = true; MainMenuForm->OnUpdateMenu = UpdateMenuItems; if ((PenManagerForm = new TPenManagerForm(this))==NULL) goto fail; PenManagerForm->Parent = this; PenManagerForm->Visible = true; PenManagerForm->OnUpdateMenu = UpdateMenuItems; if ((FullViewForm = new TFullViewForm(this))==NULL) goto fail; FullViewForm->Parent = this; FullViewForm->Visible = true; FullViewForm->OnSuperChange = MainMenuForm->SuperChange; FullViewForm->OnUpdateMenu = UpdateMenuItems; if ((PaletteForm = new TPaletteForm(this))==NULL) goto fail; PaletteForm->Parent = this; PaletteForm->Visible = true; PaletteForm->OnChoiceColor = MainMenuForm->ChoiceColor; PaletteForm->OnColorChange = MainMenuForm->ColorChange; PaletteForm->OnCursorIndexChange = MainMenuForm->CursorIndexChange; PaletteForm->OnUpdateMenu = UpdateMenuItems; ToolsRearrange(); if ((ColorChartForm = new TColorChartForm(this))==NULL) goto fail; ColorChartForm->Parent = this; if ((ColorLibraryForm = new TColorLibraryForm(this))==NULL) goto fail; ColorLibraryForm->Parent = this; ColorLibraryForm->OnColorChange = ::RepaintColor; if ((UserColorLibForm = new TUserColorLibForm(this))==NULL) goto fail; UserColorLibForm->Parent = this; if ((CaptureData = new TList)==NULL) { ec = EC_MEMORY_LACK; goto fail; } ClipboardFormat = RegisterClipboardFormat("Texpro"); if ((StatusProgress = new TStatusProgress(StatusBar, StatusBarHint))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((FileHistory = new TFileHistory(DirectoryItem + "\\Main.ini", 8, FReopenItem, &OpenFile))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((Undo = new TUndo)==NULL) { ec = EC_MEMORY_LACK; goto fail; } Undo->Method = UM_STACK; bFirst = 1; CompressMethod = cmZLib; if (L_IsTwainAvailable(Handle)) { FScanningItem->Enabled = true; FScannerSetupItem->Enabled = true; } else { FScanningItem->Enabled = false; FScannerSetupItem->Enabled = false; } srand(clock()); //======================================== /* // before code ifdef lock_crypkey.... // Caption = IDS_TDCSP; #ifdef LOCK_IFC Caption = "Texpro Design CAD System - Carpet (Professional)"; #else switch (Items >> 14) { case 1: Caption = "Texpro Design CAD System - Carpet (Education)"; break; case 2: Caption = "Texpro Design CAD System - Carpet (Demo)"; break; default: Caption = "Texpro Design CAD System - Carpet (Professional)"; break; } #endif */ #ifdef LOCK_CRYPKEY #ifdef EDUCATION Caption = "Texpro Design CAD System - Carpet (Education)"; #endif #ifdef DEMO Caption = "Texpro Design CAD System - Carpet (Demo)"; #endif #ifdef PROFESSIONAL Caption = "Texpro Design CAD System - Carpet (Professional)"; #endif #else #ifdef LOCK_IFC Caption = "Texpro Design CAD System - Carpet (Professional)"; #else switch (Items >> 14) { case 1: Caption = "Texpro Design CAD System - Carpet (Education)"; break; case 2: Caption = "Texpro Design CAD System - Carpet (Demo)"; break; default: Caption = "Texpro Design CAD System - Carpet (Professional)"; break; } #endif #endif FileItem->Caption = IDS_FILE; FNewCanvas256Item->Caption = IDS_F256COLOR; FNewCanvasFullItem->Caption = IDS_FFULLCOLOR; FManagerItem->Caption = IDS_FFILEMANAGER; FReopenItem->Caption = IDS_FREOPEN; FCloseItem->Caption = IDS_FCLOSE; // FCloseAllItem->Caption = IDS_FCLOSEALL; FResizeCanvasItem->Caption = IDS_FRESIZECANVAS; FEnlargeCanvasItem->Caption = IDS_FENLARGECANVAS; FScannerSetupItem->Caption = IDS_FSCANNERSETUP; FScanningItem->Caption = IDS_FSCANNING; FPrinterSetupItem->Caption = IDS_COMMON_PRINTERSETUP; FPrintingItem->Caption = IDS_COMMON_PRINTING; FFontItem->Caption = IDS_COMMON_FONTSETUP; FEnvironmentItem->Caption = IDS_COMMON_ENVIRONMENTSETUP; // FExitItem->Caption = IDS_COMMON_EXIT; FExitItem->Caption = IDS_FEXIT; EditItem->Caption = IDS_EDIT; ECutItem->Caption = IDS_ECUT; ECopyItem->Caption = IDS_ECOPY; EPasteItem->Caption = IDS_EPASTE; CaptureItem->Caption = IDS_CAPTURE; COverwriteItem->Caption = IDS_COVERWRITE; CInsertItem->Caption = IDS_CINSERT; CDeleteAllItem->Caption = IDS_CDELETEALL; CEditItem->Caption = IDS_CEDIT; ImageItem->Caption = IDS_IMAGE; IIntensityDetectItem->Caption = IDS_IINTENSITYDETECT; ISolarizeItem->Caption = IDS_ISOLARIZE; ImageEffectsItem->Caption = IDS_IEFFECT; IEPosterizeItem->Caption = IDS_IEPOSTERIZE; IEMosaicItem->Caption = IDS_IEMOSAIC; IEAverageItem->Caption = IDS_IEAVERAGE; IEMedianItem->Caption = IDS_IEMEDIAN; IESharpenItem->Caption = IDS_IESHARPEN; IEAddNoiseItem->Caption = IDS_IEADDNOISE; IEEmbossItem->Caption = IDS_IEEMBOSS; IEUnderlayItem->Caption = IDS_IEUNDERLAY; IEEdgeEnhanceItem->Caption = IDS_IEEDGEENHANCE; IEOilifyItem->Caption = IDS_IEOILIFY; ImageSpatialFiltersItem->Caption = IDS_ISPATIALFILTER; ISGradientItem->Caption = IDS_ISGRADIENT; ISLaplacianItem->Caption = IDS_ISLAPLACIAN; ISSobelItem->Caption = IDS_ISSOBEL; ISPrewittItem->Caption = IDS_ISPREWITT; ISShiftandDifferenceItem->Caption = IDS_ISSHIFTANDDIFFERENCE; ISLineSegmentItem->Caption = IDS_ISLINESEGMENT; ViewItem->Caption = IDS_VIEW; VPenItem->Caption = IDS_VSPECIALPEN; VFullViewItem->Caption = IDS_VFULLVIEW; VPaletteItem->Caption = IDS_VPALETTE; VMainMenuItem->Caption = IDS_VMAINMENU; VStatusBarItem->Caption = IDS_VSTATUSBAR; WindowItem->Caption = IDS_WINDOW; WCascadeItem->Caption = IDS_WCASCADE; WTileItem->Caption = IDS_WTILE; WArrangeItem->Caption = IDS_WARRANGEICONS; WMinimizeItem->Caption = IDS_WMINIMIZEALL; HelpItem->Caption = IDS_HELP; HAboutItem->Caption = IDS_HABOUT; //======================================== return; fail: ::doDestroy(Undo); ::doDestroy(FileHistory); ::doDestroy(StatusProgress); ::doDestroy(CaptureData); ::doDestroy(UserColorLibForm); ::doDestroy(ColorLibraryForm); ::doDestroy(ColorChartForm); ::doDestroy(PaletteForm); ::doDestroy(FullViewForm); ::doDestroy(PenManagerForm); ::doDestroy(MainMenuForm); ::doDestroy(PantoneTextile); ::doDestroy(Pantone1000); ::doDestroy(TextileColor); ::doDestroy(StandardColor); ::doDestroy(PrinterColor); ::doDestroy(Tablet); ::doDestroy(SmallFont); ::doDestroy(ProtectCard); if (ec == EC_NONE) ec = EC_FORM_NOT_CREATE; EXCEPTION_MESSAGE_OK(ec); Application->Terminate(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormDestroy(TObject *Sender) { ::doDestroy(Undo); ::doDestroy(FileHistory); ::doDestroy(StatusProgress); if (CaptureData) { CDeleteAllItemClick(NULL); delete CaptureData; CaptureData = NULL; } ::doDestroy(UserColorLibForm); ::doDestroy(ColorLibraryForm); ::doDestroy(ColorChartForm); ::doDestroy(PaletteForm); ::doDestroy(FullViewForm); ::doDestroy(PenManagerForm); ::doDestroy(MainMenuForm); ::doDestroy(PantoneTextile); ::doDestroy(Pantone1000); ::doDestroy(TextileColor); ::doDestroy(StandardColor); ::doDestroy(PrinterColor); ::doDestroy(Tablet); ::doDestroy(SmallFont); ::doDestroy(ProtectCard); Screen->OnActiveFormChange = NULL; } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormResize(TObject *Sender) { int w = StatusBar->Width-(160+80+100+100+200); StatusBar->Panels->Items[StatusBarHint]->Width = w<100 ? 100 : w; if (StatusProgress) StatusProgress->Resize(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormShow(TObject *Sender) { if (MDIChildCount>0) ToolsRearrange(); } //--------------------------------------------------------------------- void __fastcall TMainForm::FNewCanvas256ItemClick(TObject *Sender) { TCursor cur; TMainImageForm *Child = NULL; TNewCanvasForm *Form = NULL; TPException ec = EC_NONE; MainMenuForm->ExitForm(1); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #else ProtectCard->Read(); #endif #endif if ((Form = new TNewCanvasForm(NULL))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if (Form->ShowModal()==mrOk) { cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitForm(Form->CanvasInfor, 8))!=EC_NONE) goto fail; Screen->Cursor = cur; } delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif return; fail: if (Form) { if (Child) delete Child; Screen->Cursor = cur; delete Form; } EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FNewCanvasFullItemClick(TObject *Sender) { TCursor cur; TMainImageForm *Child = NULL; TNewCanvasForm *Form; TPException ec = EC_NONE; MainMenuForm->ExitForm(1); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #else ProtectCard->Read(); #endif #endif Form = new TNewCanvasForm(NULL); if (Form->ShowModal()==mrOk) { cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitForm(Form->CanvasInfor, 24))!=EC_NONE) goto fail; Screen->Cursor = cur; } delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif return; fail: if (Child) delete Child; Screen->Cursor = cur; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FResizeCanvasItemClick(TObject *Sender) { TCursor cur; TResizeCanvasForm *Form; MainMenuForm->ExitForm(1); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #endif #endif Form = new TResizeCanvasForm(this); Form->CanvasInfor = MainImageForm->CanvasInfor; if (Form->ShowModal()==mrOk) { cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->ResizeCanvas(Form->NewDPI, Form->NewSize.cx, Form->NewSize.cy); Screen->Cursor = cur; } delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif } //--------------------------------------------------------------------------- void __fastcall TMainForm::FEnlargeCanvasItemClick(TObject *Sender) { TCursor cur; TEnlargeCanvasForm *Form; MainMenuForm->ExitForm(1); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #endif #endif Form = new TEnlargeCanvasForm(this); Form->CanvasInfor = MainImageForm->CanvasInfor; if (Form->ShowModal()==mrOk) { cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->EnlargeCanvas(Form->NewSize.cx, Form->NewSize.cy); Screen->Cursor = cur; } delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif } //--------------------------------------------------------------------- void __fastcall TMainForm::FManagerItemClick(TObject *Sender) { TFileManagerForm *Form; MainMenuForm->ExitForm(1); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #else ProtectCard->Read(); #endif #endif if ((Form = new TFileManagerForm(this)) == NULL) goto fail; if (MainImageForm) { Form->Extension = MainImageForm->iMainImage->Bitmap->BitsPerPixel; } else { Form->Extension = 8; } Form->CompressCheckBox->Checked = (CompressMethod == cmNone) ? false: true; Form->FilterComboBox->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex|" "Texpro Textile Full Colors File (*.tfc)|*.tfc|" "Texpro Textile 3D File (*.t3d)|*.t3d|" "Texpro Weave File (*.wea)|*.wea|" "Texpro Weave File - V7.01 (*.wav)|*.wav|" "Texpro Knit File (*.knt)|*.knt|" "Texpro Carpet File (*.cpt)|*.cpt|" "Microsoft Windows Bitmap (*.bmp)|*.bmp|" "Macintosh PICT (*.pct)|*.pct|" "PC Paintbrush File Format (*.pcx)|*.pcx|" "PNG (*.png)|*.png|" "PSD (*.psd)|*.psd|" "SUN Raster (*.ras)|*.ras|" "Targa Image File (*.tga)|*.tga|" "TIFF uncomp (*.tif)|*.tif"; Form->OnRead = FMOnRead; Form->OnFileName = FMOnFileName; // Form->OnMerge = FMOnMerge; // Form->OnSave = FMOnSave; if (MainImageForm) { Form->SpeedButtonSave->Enabled = true; Form->SpeedButtonSaveAs->Enabled = true; Form->OnSave = FMOnSave; Form->OnMerge = FMOnMerge; } else { Form->SpeedButtonSave->Enabled = false; Form->SpeedButtonSaveAs->Enabled = false; } Form->ShowModal(); delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif return; fail: EXCEPTION_MESSAGE_OK(EC_FORM_NOT_CREATE); } //--------------------------------------------------------------------- void __fastcall TMainForm::FCloseItemClick(TObject *Sender) { if (ActiveMDIChild) ActiveMDIChild->Close(); } //--------------------------------------------------------------------------- /* void __fastcall TMainForm::FCloseAllItemClick(TObject *Sender) { MainMenuForm->ExitForm(1); for (int i=MDIChildCount-1; i>=0; i--) { MDIChildren[i]->Close(); } } */ //--------------------------------------------------------------------- void __fastcall TMainForm::FScanningItemClick(TObject *Sender) { RECT r; BITMAPHANDLE hBitmap; int nRet; RGBQUAD rgb[256]; HDC dcSrc = NULL, dcDst = NULL; Byte c[256]; int x, y, w, h, ec; Byte *bp; TCursor OldCursor = Screen->Cursor; Screen->Cursor = crDefault; TPItemImage *ti = MainImageForm->iMainImage; memset(&hBitmap, 0, sizeof(BITMAPHANDLE)); if (L_InitBitmap(&hBitmap, 0, 0, 24)Handle, &hBitmap)Bitmap->BitsPerPixel==8) { if (L_ColorResBitmap(&hBitmap, &hBitmap, 8, CRF_OPTIMIZEDPALETTE, NULL, 250, NULL, NULL)WorkArea->Reset(true); r.left = 0; r.top = 0; r.right = ti->Bitmap->Width; r.bottom = ti->Bitmap->Height; ti->Bitmap->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); L_GetBitmapColors(&hBitmap, 0, 256, rgb); ti->Bitmap->PutColors(0, 256, rgb); if (hBitmap.Width>ti->Bitmap->Width) w = ti->Bitmap->Width; else w = hBitmap.Width; if (hBitmap.Height>ti->Bitmap->Height) h = ti->Bitmap->Height; else h = hBitmap.Height; if ((dcSrc = L_CreateLeadDC(&hBitmap))==NULL) { ec = EC_RESOURCE_LACK; goto fail; } if ((dcDst = ti->Bitmap->CreateDC())==NULL) { ec = EC_RESOURCE_LACK; goto fail; } BitBlt(dcDst, 0, 0, w, h, dcSrc, 0, 0, SRCCOPY); ti->Bitmap->DeleteDC(dcDst); dcDst = NULL; L_DeleteLeadDC(dcSrc); dcSrc = NULL; r.right = w; r.bottom = h; memset(c, 0, 256); if (!ti->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yBitmap->GetScanLine(y); for (x=0; xBitmap->PutScanLine(y); } ti->Bitmap->StopScanLine(); for (x=0; x<250; x++) { MainImageForm->Palette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } MainImageForm->Palette->ToRGBQUAD(rgb, 256); ti->Bitmap->PutColors(0, 256, rgb); for (x=251; x>=1; x--) { if (c[x]==1) { MainImageForm->Palette->UseColor = x; break; } } } else { if (L_ColorResBitmap(&hBitmap, &hBitmap, 24, CRF_BYTEORDERBGR, NULL, 0, NULL, NULL)WorkArea->Reset(true); r.left = 0; r.top = 0; r.right = ti->Bitmap->Width; r.bottom = ti->Bitmap->Height; ti->Bitmap->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); if (hBitmap.Width>ti->Bitmap->Width) w = ti->Bitmap->Width; else w = hBitmap.Width; if (hBitmap.Height>ti->Bitmap->Height) h = ti->Bitmap->Height; else h = hBitmap.Height; if ((dcSrc = L_CreateLeadDC(&hBitmap))==NULL) { ec = EC_RESOURCE_LACK; goto fail; } if ((dcDst = ti->Bitmap->CreateDC())==NULL) { ec = EC_RESOURCE_LACK; goto fail; } BitBlt(dcDst, 0, 0, w, h, dcSrc, 0, 0, SRCCOPY); ti->Bitmap->DeleteDC(dcDst); L_DeleteLeadDC(dcSrc); r.right = w; r.bottom = h; } MainImageForm->WorkArea->SetRectangle(r); MainImageForm->WorkAreaChange(); L_FreeBitmap(&hBitmap); RepaintColor(); Screen->Cursor = OldCursor; return; fail: ti->Bitmap->StopScanLine(); if (dcSrc) { if (dcDst) ti->Bitmap->DeleteDC(dcDst); L_DeleteLeadDC(dcSrc); } L_FreeBitmap(&hBitmap); Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); /* RECT r; BITMAPHANDLE hBitmap; int nRet; RGBQUAD rgb[256]; HDC dcSrc = NULL, dcDst = NULL; Byte c[256]; int x, y, w, h; Byte *bp; TCursor OldCursor = Screen->Cursor; Screen->Cursor = crDefault; TTexpiaImage *ti = MainImageForm->iMainImage; memset(&hBitmap, 0, sizeof(BITMAPHANDLE)); try { if (L_InitBitmap(&hBitmap, 0, 0, 24)Handle, &hBitmap)Bitmap->BitsPerPixel==8) { if (L_ColorResBitmap(&hBitmap, &hBitmap, 8, CRF_OPTIMIZEDPALETTE, NULL, 250, NULL, NULL)WorkArea->Reset(true); r.left = 0; r.top = 0; r.right = ti->Bitmap->Width; r.bottom = ti->Bitmap->Height; ti->Bitmap->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); L_GetBitmapColors(&hBitmap, 0, 256, rgb); ti->Bitmap->PutColors(0, 256, rgb); if (hBitmap.Width>ti->Bitmap->Width) w = ti->Bitmap->Width; else w = hBitmap.Width; if (hBitmap.Height>ti->Bitmap->Height) h = ti->Bitmap->Height; else h = hBitmap.Height; if ((dcSrc = L_CreateLeadDC(&hBitmap))==NULL) throw EC_RESOURCE_LACK; if ((dcDst = ti->Bitmap->CreateDC())==NULL) throw EC_RESOURCE_LACK; BitBlt(dcDst, 0, 0, w, h, dcSrc, 0, 0, SRCCOPY); ti->Bitmap->DeleteDC(dcDst); dcDst = NULL; L_DeleteLeadDC(dcSrc); dcSrc = NULL; r.right = w; r.bottom = h; memset(c, 0, 256); if (!ti->Bitmap->StartScanLine()) throw EC_MEMORY_LACK; for (y=0; yBitmap->GetScanLine(y); for (x=0; xBitmap->PutScanLine(y); } ti->Bitmap->StopScanLine(); for (x=0; x<=249; x++) { MainImageForm->Palette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } MainImageForm->Palette->ToRGBQUAD(rgb, 256); ti->Bitmap->PutColors(0, 256, rgb); for (x=251; x>=1; x--) { if (c[x]==1) { MainImageForm->Palette->UseColor = x; break; } } MainImageForm->WorkArea->SetRectangle(r); MainImageForm->WorkAreaChange(); L_FreeBitmap(&hBitmap); } else { if (L_ColorResBitmap(&hBitmap, &hBitmap, 24, CRF_BYTEORDERBGR, NULL, 0, NULL, NULL)WorkArea->Reset(true); r.left = 0; r.top = 0; r.right = ti->Bitmap->Width; r.bottom = ti->Bitmap->Height; ti->Bitmap->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); if (hBitmap.Width>ti->Bitmap->Width) w = ti->Bitmap->Width; else w = hBitmap.Width; if (hBitmap.Height>ti->Bitmap->Height) h = ti->Bitmap->Height; else h = hBitmap.Height; if ((dcSrc = L_CreateLeadDC(&hBitmap))==NULL) throw EC_RESOURCE_LACK; if ((dcDst = ti->Bitmap->CreateDC())==NULL) throw EC_RESOURCE_LACK; BitBlt(dcDst, 0, 0, w, h, dcSrc, 0, 0, SRCCOPY); ti->Bitmap->DeleteDC(dcDst); L_DeleteLeadDC(dcSrc); r.right = w; r.bottom = h; MainImageForm->WorkArea->SetRectangle(r); MainImageForm->WorkAreaChange(); L_FreeBitmap(&hBitmap); } } catch (int ec) { ti->Bitmap->StopScanLine(); if (dcSrc) { if (dcDst) ti->Bitmap->DeleteDC(dcDst); L_DeleteLeadDC(dcSrc); } L_FreeBitmap(&hBitmap); EXCEPTION_MESSAGE_OK(ec); } RepaintColor(); Screen->Cursor = OldCursor; */ } //--------------------------------------------------------------------- void __fastcall TMainForm::FScannerSetupItemClick(TObject *Sender) { int nRet; nRet = L_TwainSelect(Application->Handle); if (nRetInitForm(); if (Form->ShowModal()==mrOk) { if ((Pattern = new TTexpiaBitmap)==NULL) goto fail; DPI = MainImageForm->CanvasInfor.DotsPerInch; FitSize = Form->cbFitSize->Checked; if (FitSize) { WW = GetDeviceCaps(Printer()->Handle, HORZRES)*MainImageForm->CanvasInfor.DotsPerInch/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); HH = GetDeviceCaps(Printer()->Handle, VERTRES)*MainImageForm->CanvasInfor.DotsPerInch/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); } switch (Form->PrintHeader) { case phNo: r.cx = StrToInt(Form->SpinEditRepeatX->Text); r.cy = StrToInt(Form->SpinEditRepeatY->Text); if (!MainImageForm->ComboHeaderNoMethod(Pattern, r, StrToInt(Form->EditRepeat->Text), Form->ComboBoxRepeat->ItemIndex)) goto fail; if (FitSize) { rx = (double)WW / Pattern->Width; ry = (double)HH / Pattern->Height; if (rx < ry) { if (rx < 1.0) DPI = DPI / rx; } else { if (ry < 1.0) DPI = DPI / ry; } } else { DPI = DPI * 100 / StrToInt(Form->EditZoom->Text); } break; case phYes: if (!MainImageForm->ComboHeaderYesMethod(Pattern)) goto fail; if (FitSize) { rx = (double)WW / Pattern->Width; ry = (double)HH / Pattern->Height; if (rx < ry) { if (rx < 1.0) DPI = DPI / rx; } else { if (ry < 1.0) DPI = DPI / ry; } } else { DPI = DPI * 100 / StrToInt(Form->EditZoom->Text); } break; case phUsedColor: if (!MainImageForm->ComboHeaderUsedColorMethod(Pattern, false)) goto fail; break; case phMosaic: mx = Form->MosaicXEdit->Value; my = Form->MosaicYEdit->Value; if (!MainImageForm->ComboHeaderMosaicMethod(Pattern, mx, my)) goto fail; break; } if (!SendToPrinter(Pattern, DPI, "Textile - "+MainImageForm->FileName, Form->SpinEditPage->Value, Form->cbMethod->ItemIndex)) goto fail; delete Pattern; } delete Form; return; fail: if (Pattern) delete Pattern; if (Form) delete Form; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FPrinterSetupItemClick(TObject *Sender) { PrinterSetupDialog->Execute(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FFontItemClick(TObject *Sender) { MainMenuForm->ExitForm(1); FontDialog1->Font->Assign(SmallFont); if (FontDialog1->Execute()) { SmallFont->Assign(FontDialog1->Font); TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { SaveFont(IniFile, SmallFont, "Font"); delete IniFile; } ColorLibraryForm->SetFont(); ColorChartForm->SetFont(); PenManagerForm->SetFont(); FullViewForm->SetFont(); PaletteForm->SetFont(); AboutBox->SetFont(); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FEnvironmentItemClick(TObject *Sender) { int unit; MainMenuForm->ExitForm(1); TEnvironmentForm *Form = new TEnvironmentForm(this); Form->ShowModal(); TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { unit = IniFile->ReadInteger("MainImage", "Unit", 0); if (unit == 0) { MainImageForm->CurrentUnit = uCm; MainImageForm->UnitChange(uCm); } else if (unit == 1) { MainImageForm->CurrentUnit = uInch; MainImageForm->UnitChange(uInch); } else { MainImageForm->CurrentUnit = uDot; MainImageForm->UnitChange(uDot); } bAutoSave = IniFile->ReadBool("AutoSave", "Check", false); if (bAutoSave) { AutosaveTimer->Interval = IniFile->ReadInteger("AutoSave", "Min", 5) * 60000; } delete IniFile; } delete Form; if (MainImageForm) MainImageForm->ApplyEnvironment(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FExitItemClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------- void __fastcall TMainForm::ECutItemClick(TObject *Sender) { MainImageForm->EditCut(); } //--------------------------------------------------------------------- void __fastcall TMainForm::ECopyItemClick(TObject *Sender) { MainImageForm->EditCopy(); } //--------------------------------------------------------------------- void __fastcall TMainForm::EPasteItemClick(TObject *Sender) { MainImageForm->EditPaste(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::CaptureItemClick(TObject *Sender) { if(MainMenuForm->Item == T_FILL) MainMenuForm->ExitForm(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::COverwriteItemClick(TObject *Sender) { if (CaptureData->Count) CaptureData->Delete(0); CaptureData->Insert(0, MainImageForm->MakeCapture()); UpdateMenuItems(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainForm::CInsertItemClick(TObject *Sender) { CaptureData->Insert(0, MainImageForm->MakeCapture()); UpdateMenuItems(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainForm::CEditItemClick(TObject *Sender) { TCaptureEditForm *Form = new TCaptureEditForm(this); Form->InitForm(); Form->ShowModal(); delete Form; } //--------------------------------------------------------------------------- void __fastcall TMainForm::CDeleteAllItemClick(TObject *Sender) { TCaptureData *cd; while (CaptureData->Count) { cd = (TCaptureData *)CaptureData->First(); CaptureData->Remove(cd); delete cd; } UpdateMenuItems(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainForm::IIntensityDetectItemClick(TObject *Sender) { L_UINT uLow = 0, uHigh = 255; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetRange DlgGetRange = (TDlgGetRange)GetProcAddress(hLibrary, "L_DlgGetRange"); if (DlgGetRange(Handle, bh, &uLow, &uHigh, DLG_IMG_SHOWPREVIEW, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_IntensityDetectBitmap(bh, uLow, uHigh); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ISolarizeItemClick(TObject *Sender) { L_INT nChange = 0; L_UINT32 uProcess = 0; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (DlgGetChange(Handle, bh, &nChange, &uProcess, DLG_IMG_SHOWPREVIEW | DLG_IMG_SOLARIZE, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (nChange>=0) { MainImageForm->UndoSave(UK_PATTERN); L_SolarizeBitmap(bh, nChange); MainImageForm->iMainImage->Repaint(); } Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEPosterizeItemClick(TObject *Sender) { L_INT nChange = 2; L_UINT32 uProcess = 0; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (DlgGetChange(Handle, bh, &nChange, &uProcess, DLG_IMG_SHOWPREVIEW | DLG_IMG_POSTERIZE, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (nChange) { MainImageForm->UndoSave(UK_PATTERN); L_PosterizeBitmap(bh, nChange); MainImageForm->iMainImage->Repaint(); } Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEMosaicItemClick(TObject *Sender) { L_INT nChange = 2; L_UINT32 uProcess; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (DlgGetChange(Handle, bh, &nChange, &uProcess, DLG_IMG_SHOWPREVIEW | DLG_IMG_MOSAIC, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (nChange) { MainImageForm->UndoSave(UK_PATTERN); L_MosaicBitmap(bh, nChange); MainImageForm->iMainImage->Repaint(); } Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEAverageItemClick(TObject *Sender) { L_INT nChange = 3; L_UINT32 uProcess; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (DlgGetChange(Handle, bh, &nChange, &uProcess, DLG_IMG_SHOWPREVIEW | DLG_IMG_AVERAGE, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (nChange) { MainImageForm->UndoSave(UK_PATTERN); L_AverageFilterBitmap(bh, nChange); MainImageForm->iMainImage->Repaint(); } Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEMedianItemClick(TObject *Sender) { L_INT nChange = 3; L_UINT32 uProcess; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (DlgGetChange(Handle, bh, &nChange, &uProcess, DLG_IMG_SHOWPREVIEW | DLG_IMG_MEDIAN, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (nChange) { MainImageForm->UndoSave(UK_PATTERN); L_MedianFilterBitmap(bh, nChange); MainImageForm->iMainImage->Repaint(); } Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IESharpenItemClick(TObject *Sender) { L_INT nChange = 0; L_UINT32 uProcess; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (DlgGetChange(Handle, bh, &nChange, &uProcess, DLG_IMG_SHOWPREVIEW | DLG_IMG_SHARPEN, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (nChange) { MainImageForm->UndoSave(UK_PATTERN); L_SharpenBitmap(bh, nChange); MainImageForm->iMainImage->Repaint(); } Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEAddNoiseItemClick(TObject *Sender) { L_UINT uRange; L_UINT uChannel; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetNoise DlgGetNoise = (TDlgGetNoise)GetProcAddress(hLibrary, "L_DlgGetNoise"); if (DlgGetNoise(Handle, bh, &uRange, &uChannel, DLG_IMG_SHOWPREVIEW, NULL)==SUCCESS) { MainImageForm->UndoSave(UK_PATTERN); TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; L_AddBitmapNoise(bh, uRange, uChannel); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEEmbossItemClick(TObject *Sender) { L_UINT uDirectory, uDepth = 50; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetEmboss DlgGetEmboss = (TDlgGetEmboss)GetProcAddress(hLibrary, "L_DlgGetEmboss"); if (DlgGetEmboss(Handle, bh, &uDirectory, &uDepth, DLG_IMG_SHOWPREVIEW | DLG_IMG_EMBOSS, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_EmbossBitmap(bh, uDirectory, uDepth); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEUnderlayItemClick(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEEdgeEnhanceItemClick(TObject *Sender) { BITMAPHANDLE WrkBitmap, *bh = MainImageForm->iMainImage->Bitmap->Handle; L_INT nRet; TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; nRet = L_CopyBitmap(&WrkBitmap, bh); if (nRet==SUCCESS) { nRet = L_SpatialFilterBitmap(&WrkBitmap, FLT_LAPLACE_1); if (nRet==SUCCESS) { MainImageForm->UndoSave(UK_PATTERN); nRet = L_CombineBitmap(bh, 0, 0, BITMAPWIDTH(bh), BITMAPHEIGHT(bh), &WrkBitmap, 0, 0, CB_OP_ADD); MainImageForm->iMainImage->Repaint(); } L_FreeBitmap(&WrkBitmap); } Screen->Cursor = cur; } //--------------------------------------------------------------------------- void __fastcall TMainForm::IEOilifyItemClick(TObject *Sender) { /* L_INT nChange = 3; L_UINT32 uProcess; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (DlgGetChange(Handle, bh, &nChange, &uProcess, DLG_IMG_SHOWPREVIEW | DLG_IMG_OILIFY, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (nChange) { MainImageForm->Undo->Save(UK_PATTERN); L_OilifyBitmap(bh, nChange); MainImageForm->iMainImage->Repaint(); } Screen->Cursor = cur; } FreeLibrary(hLibrary); } */ } //--------------------------------------------------------------------------- void __fastcall TMainForm::ISGradientItemClick(TObject *Sender) { LPSPATIALFLT pSpatialFlt; LPBINARYFLT pBinaryFlt; L_BOOL bSpatial; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetFilter DlgGetFilter = (TDlgGetFilter)GetProcAddress(hLibrary, "L_DlgGetFilter"); if (DlgGetFilter(Handle, bh, &pSpatialFlt, &pBinaryFlt, &bSpatial, DLG_IMG_SHOWPREVIEW | DLG_IMG_GRADIENT, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_SpatialFilterBitmap(bh, pSpatialFlt); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ISLaplacianItemClick(TObject *Sender) { LPSPATIALFLT pSpatialFlt; LPBINARYFLT pBinaryFlt; L_BOOL bSpatial; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetFilter DlgGetFilter = (TDlgGetFilter)GetProcAddress(hLibrary, "L_DlgGetFilter"); if (DlgGetFilter(Handle, bh, &pSpatialFlt, &pBinaryFlt, &bSpatial, DLG_IMG_SHOWPREVIEW | DLG_IMG_LAPLACIAN, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_SpatialFilterBitmap(bh, pSpatialFlt); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ISSobelItemClick(TObject *Sender) { LPSPATIALFLT pSpatialFlt; LPBINARYFLT pBinaryFlt; L_BOOL bSpatial; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetFilter DlgGetFilter = (TDlgGetFilter)GetProcAddress(hLibrary, "L_DlgGetFilter"); if (DlgGetFilter(Handle, bh, &pSpatialFlt, &pBinaryFlt, &bSpatial, DLG_IMG_SHOWPREVIEW | DLG_IMG_SOBEL, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_SpatialFilterBitmap(bh, pSpatialFlt); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ISPrewittItemClick(TObject *Sender) { LPSPATIALFLT pSpatialFlt; LPBINARYFLT pBinaryFlt; L_BOOL bSpatial; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetFilter DlgGetFilter = (TDlgGetFilter)GetProcAddress(hLibrary, "L_DlgGetFilter"); if (DlgGetFilter(Handle, bh, &pSpatialFlt, &pBinaryFlt, &bSpatial, DLG_IMG_SHOWPREVIEW | DLG_IMG_PREWITT, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_SpatialFilterBitmap(bh, pSpatialFlt); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ISShiftandDifferenceItemClick(TObject *Sender) { LPSPATIALFLT pSpatialFlt; LPBINARYFLT pBinaryFlt; L_BOOL bSpatial; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetFilter DlgGetFilter = (TDlgGetFilter)GetProcAddress(hLibrary, "L_DlgGetFilter"); if (DlgGetFilter(Handle, bh, &pSpatialFlt, &pBinaryFlt, &bSpatial, DLG_IMG_SHOWPREVIEW | DLG_IMG_SHIFTDIFF, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_SpatialFilterBitmap(bh, pSpatialFlt); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::ISLineSegmentItemClick(TObject *Sender) { LPSPATIALFLT pSpatialFlt; LPBINARYFLT pBinaryFlt; L_BOOL bSpatial; BITMAPHANDLE *bh = MainImageForm->iMainImage->Bitmap->Handle; HINSTANCE hLibrary = LoadLibrary("ltdlg10n.dll"); if (hLibrary) { TDlgGetFilter DlgGetFilter = (TDlgGetFilter)GetProcAddress(hLibrary, "L_DlgGetFilter"); if (DlgGetFilter(Handle, bh, &pSpatialFlt, &pBinaryFlt, &bSpatial, DLG_IMG_SHOWPREVIEW | DLG_IMG_LINESEG, NULL)==SUCCESS) { TCursor cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->UndoSave(UK_PATTERN); L_SpatialFilterBitmap(bh, pSpatialFlt); MainImageForm->iMainImage->Repaint(); Screen->Cursor = cur; } FreeLibrary(hLibrary); } } //--------------------------------------------------------------------- void __fastcall TMainForm::VPenItemClick(TObject *Sender) { if (VPenItem->Checked) { VPenItem->Checked = false; PenManagerForm->Visible = false; } else { VPenItem->Checked = true; PenManagerForm->Visible = true; } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VFullViewItemClick(TObject *Sender) { if (VFullViewItem->Checked) { VFullViewItem->Checked = false; FullViewForm->Visible = false; } else { VFullViewItem->Checked = true; FullViewForm->Visible = true;; FullViewForm->InitForm(MainImageForm->iMainImage); } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VPaletteItemClick(TObject *Sender) { if (VPaletteItem->Checked) { VPaletteItem->Checked = false; PaletteForm->Visible = false; } else { VPaletteItem->Checked = true; PaletteForm->Visible = true; PaletteForm->InitForm(MainImageForm->Palette); } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VMainMenuItemClick(TObject *Sender) { MainMenuForm->ExitForm(1); if (VMainMenuItem->Checked) { VMainMenuItem->Checked = false; MainMenuForm->Visible = false; } else { VMainMenuItem->Checked = true; MainMenuForm->Visible = true; } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VStatusBarItemClick(TObject *Sender) { if (VStatusBarItem->Checked) { VStatusBarItem->Checked = false; StatusBar->Visible = false; } else { VStatusBarItem->Checked = true; StatusBar->Visible = true; } UpdateMenuItems(Sender); } //--------------------------------------------------------------------------- void __fastcall TMainForm::VToolsRearrangeItemClick(TObject *Sender) { ToolsRearrange(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WCascadeItemClick(TObject *Sender) { Cascade(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WTileItemClick(TObject *Sender) { Tile(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WArrangeItemClick(TObject *Sender) { ArrangeIcons(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WMinimizeItemClick(TObject *Sender) { int i; //---- Must be done backwards through the MDIChildren array ---- for (i=MDIChildCount-1; i >= 0; i--) MDIChildren[i]->WindowState = wsMinimized; } //--------------------------------------------------------------------------- void __fastcall TMainForm::HAboutItemClick(TObject *Sender) { AboutBox->ShowModal(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::Timer50msTimer(TObject *Sender) { if (MainImageForm) MainImageForm->Timer50ms(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::Timer200msTimer(TObject *Sender) { if (MainImageForm) MainImageForm->Timer200ms(); MainMenuForm->Timer200ms(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::Timer1000msTimer(TObject *Sender) { TDateTime Date1; Date1 = Now(); String S; DateTimeToString(S,"yyyy-mm-dd ampm hh-nn-ss",Date1.CurrentDateTime()); StatusBar->Panels->Items[StatusBarDate]->Text = S; // StatusBar->Panels->Items[StatusBarDate]->Text = DateTimeToStr(Now()); if (MainImageForm) MainImageForm->Timer1000ms(); #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC if (ProtectCard->isHacking) Application->Terminate(); #endif #endif } //---------------------------------------------------------------------------- void __fastcall TMainForm::UpdateMenuItems(TObject *Sender) { if (bFirst==0) return; UpdateTools(Sender); FResizeCanvasItem->Enabled = MDIChildCount > 0; FEnlargeCanvasItem->Enabled = MDIChildCount > 0; FCloseItem->Enabled = MDIChildCount > 0; // FCloseAllItem->Enabled = MDIChildCount > 0; FPrintingItem->Enabled = MDIChildCount > 0; EditItem->Enabled = MDIChildCount > 0; CaptureItem->Enabled = false; ImageItem->Enabled = false; COverwriteItem->Enabled = false; CInsertItem->Enabled = false; if (MainImageForm) { if (MainImageForm->iMainImage) { if (MainImageForm->iMainImage->Bitmap->BitsPerPixel==24) { CaptureItem->Enabled = true; ImageItem->Enabled = true; } } if (MainImageForm->WorkArea) { if (MainImageForm->WorkArea->Mask) { COverwriteItem->Enabled = true; CInsertItem->Enabled = true; } } } CEditItem->Enabled = CaptureData->Count>0; CDeleteAllItem->Enabled = CaptureData->Count>0; ViewItem->Enabled = MDIChildCount > 0; VPenItem->Checked = PenManagerForm->Visible; VFullViewItem->Checked = FullViewForm->Visible; VPaletteItem->Checked = PaletteForm->Visible; VMainMenuItem->Checked = MainMenuForm->Visible; VStatusBarItem->Checked = StatusBar->Visible; VToolsRearrangeItem->Enabled = MDIChildCount > 0; WCascadeItem->Enabled = MDIChildCount > 0; WTileItem->Enabled = MDIChildCount > 0; WArrangeItem->Enabled = MDIChildCount > 0; WMinimizeItem->Enabled = MDIChildCount > 0; FNewCanvasFullItem->Enabled = true; FScannerSetupItem->Enabled = true; FScanningItem->Enabled = true; Timer50ms->Enabled = MDIChildCount > 0; Timer200ms->Enabled = MDIChildCount > 0; Timer1000ms->Enabled = MDIChildCount > 0; PenManagerForm->Enabled = MDIChildCount > 0; FullViewForm->Enabled = MDIChildCount > 0; PaletteForm->Enabled = MDIChildCount > 0; MainMenuForm->Enabled = MDIChildCount > 0; } //--------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------- void TMainForm::WTPacket(TMessage &msg) { WTPKT Result = Tablet->WTMPacket(msg); // StatusBar->Panels->Items[StatusBarHint]->Text = Format("%d x %d", // OPENARRAY(TVarRec, ((int)Tablet->MaxNPressure, (int)Tablet->prsNew))); if (Result&PK_CURSOR) PenManagerForm->Pen->Cursor = Tablet->curNew; } //--------------------------------------------------------------------- void __fastcall TMainForm::ApplicationActivate(TObject *Sender) { TMainImageForm *mif = (TMainImageForm *)ActiveMDIChild; if (Tablet) Tablet->Activate(); if (mif) mif->FormActivate(mif); } //--------------------------------------------------------------------- void __fastcall TMainForm::ShowHint(TObject *Sender) { Application->HintPause = 100; StatusBar->Panels->Items[StatusBarHint]->Text = Application->Hint; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ToolsRearrange() { PenFormPos = Point(ClientWidth-PenManagerForm->Width-2, 2); FullViewFormPos = Point(ClientWidth-FullViewForm->Width-2, PenFormPos.y+PenManagerForm->Height+1); PaletteFormPos = Point(ClientWidth-PaletteForm->Width-2, FullViewFormPos.y+FullViewForm->Height+1); MainMenuFormPos = Point(ClientWidth-MainMenuForm->Width-2, PaletteFormPos.y+PaletteForm->Height+1); PenManagerForm->Left = PenFormPos.x; PenManagerForm->Top = PenFormPos.y; FullViewForm->Left = FullViewFormPos.x; FullViewForm->Top = FullViewFormPos.y; PaletteForm->Left = PaletteFormPos.x; PaletteForm->Top = PaletteFormPos.y; MainMenuForm->Left = MainMenuFormPos.x; MainMenuForm->Top = MainMenuFormPos.y; } //--------------------------------------------------------------------- TPException __fastcall TMainForm::FMOnRead(TFMReadParameter rp) { TCursor cur; TMainImageForm *Child = NULL; TPException ec; MainMenuForm->ExitForm(1); cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitFormFile(rp.DirName, rp.FileName, rp.ExtIndex, rp.bpp)) != EC_NONE) goto fail; Screen->Cursor = cur; return EC_NONE; fail: if (Child) delete Child; Screen->Cursor = cur; return ec; } //--------------------------------------------------------------------- bool __fastcall TMainForm::FMOnMerge(AnsiString FileName, TGraphicFileFormat ExtIndex) { #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC ProtectCard->Check(); #endif #endif return MainImageForm->InitMerge(FileName, ExtIndex); } //--------------------------------------------------------------------- AnsiString __fastcall TMainForm::FMOnFileName(AnsiString FileName, TGraphicFileFormat ExtIndex) { char *s; AnsiString fn; s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { switch (ExtIndex) { case gffTEX: fn = FileName+".tex"; break; case gffTFC: fn = FileName+".tfc"; break; case gffT3D: fn = FileName+".t3d"; break; case gffWEA: fn = FileName+".wea"; break; case gffWAV: fn = FileName+".wav"; break; case gffKNT: fn = FileName+".knt"; break; case gffCPT: fn = FileName+".cpt"; break; case gffBMP: fn = FileName+".bmp"; break; case gffPCT: fn = FileName+".pct"; break; case gffPCX: fn = FileName+".pcx"; break; case gffPNG: fn = FileName+".png"; break; case gffPSD: fn = FileName+".psd"; break; case gffRAS: fn = FileName+".ras"; break; case gffTGA: fn = FileName+".tga"; break; case gffTIF: fn = FileName+".tif"; break; } return fn; } else { return FileName; } } //--------------------------------------------------------------------- TPException __fastcall TMainForm::FMOnSave(AnsiString DirName, AnsiString FileName, TGraphicFileFormat ExtIndex, TCompressMethod cm) { #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC ProtectCard->Check(); #endif #endif return MainImageForm->SaveToFile(DirName, FileName, ExtIndex, cm); } //--------------------------------------------------------------------------- void __fastcall TMainForm::OpenFile(AnsiString DirName, AnsiString FileName, int Index, WORD bpp) { TCursor cur; TMainImageForm *Child = NULL; TPException ec = EC_NONE; MainMenuForm->ExitForm(1); cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitFormFile(DirName, FileName, Index, bpp))!=EC_NONE) goto fail; Screen->Cursor = cur; return; fail: if (Child) delete Child; Screen->Cursor = cur; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TMainForm::UpdateTools(TObject *Sender) { MainImageForm = (TMainImageForm *)ActiveMDIChild; if (MainImageForm) { MainMenuForm->UpdateItem(); RepaintColor(); // FullViewForm->InitForm(MainImageForm->iMainImage->Bitmap); // PenManagerForm->FormChange(MainImageForm->Palette); } else { PaletteForm->InitForm(NULL); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { MainMenuForm->iMainImageKeyUp(Key); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormKeyPress(TObject *Sender, char &Key) { MainMenuForm->iMainImageKeyDown(Key); } //--------------------------------------------------------------------------- void __fastcall TMainForm::AutosaveTimerTimer(TObject *Sender) { if (MainImageForm && bAutoSave) MainImageForm->TimerAutoSave(); } //---------------------------------------------------------------------------