home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------
- #include <vcl.h>
- #include <printers.hpp>
- #pragma hdrstop
-
- #include "Main.h"
- #include "ListDiag.h"
- #include "ColorRes.h"
- #include "Info.h"
- #include "About.h"
- #include "..\..\..\include\l_ocxcb.h"
- //---------------------------------------------------------------------
- #pragma link "LTOCX10N"
- #pragma resource "*.dfm"
-
- #define MAX_STRING_LIST 8
-
- TMainForm *MainForm;
-
- char szLoadFilter[] = "All files (*.*)|*.*|LEAD|*.cmp|JPEG|*.jpg|CALS 1|*.cal|Compuserve PNG|*.png|"\
- "EPS|*.eps|GEM|*.gem|GIF|*.gif|IOCA|*.ica|Mac PICT|*.pct|"\
- "MacPaint|*.mac|MSP|*.msp|PCX|*.pcx|PSD|*.psd|SUN|*.ras|TGA|*.tga|"\
- "TIFF|*.tif;*.jtf|BMP|*.bmp|FPX|*.fpx|DIC|*.dic|ICO|*.ico|CUR|*.cur|AWD|*.awd";
-
- char szSaveFilter[] = "LEAD|*.cmp|JPEG|*.jpg|CALS|*.cal|PNG|*.png|" \
- "EPS|*.eps|GEM|*.gem|GIF|*.gif|IOCA|*.ica|Mac PICT|*.pct|" \
- "MacPaint|*.mac|MSP|*.msp|PCX|*.pcx|PSD|*.psd|SUN|*.ras|TGA|*.tga|"\
- "TIF|*.tif|TIF CCITT|*.tif|TIF JPEG|*.jtf|TIF LZW|*.tif|BMP|*.bmp|FPX|*.fpx|"\
- "RLE|*.rle|TIF CMYK|*.tif|TIF LZW CMYK|*.tif|TIF RLE|*.tif|TIF RLE CMYK|*.tif|"\
- "DICOM Gray|*.dic|DICOM Color|*.dic|ICON|*.ico|CURSOR|*.cur|"\
- "TIF YCC|*.tif|TIF LZW YCC|*.tif|TIF RLE YCC|*.tif|EXIF|*.tif|EXIF YCC|*.tif|"\
- "EXIF JPEG|*.jpg|AWD|*.awd";
-
- String aGradientList[]= {"North","North-East","East","South-East","South","South-West","West","North-West"};
- String aLaplacianList[] = {"Filter 1", "Filter 2", "Filter 3","Diagonal", "Horizontal", "Vertical", "", "" };
- String aHorzVertList[] = { "Horizontal", "Vertical", "", "", "", "", "" , "" };
- String aShiftDiffList[] = { "Diagonal", "Horizontal", "Vertical", "", "", "", "", "" };
- String aLineSegmentList[] = { "Horizontal", "Vertical", "Left to Right", "Right to Left", "", "", "", "" };
- String aBinaryFilterList[] = { "Omnidirectional", "Horizontal", "Vertical", "Diagonal", "", "", "", ""};
- String aChannelList[] = { "Master", "Red", "Green", "Blue", "", "", "", "" };
- String aEffectList[] = {
- "Wipe left to right",
- "Wipe right to left",
- "Wipe top to bottom",
- "Wipe bottom to top",
- "Wipe left-top to right-bottom",
- "Wipe left-bottom to right-top",
- "Wipe right-top to left-bottom",
- "Wipe right-bottom to left-top",
- "Wipe horizontal interlace left to right twice",
- "Wipe vertical interlace top to bottom twice",
- "Wipe horizontal interlace left to right then back",
- "Wipe vertical interlace top to bottom then back",
- "Wipe vertical interlace left to right twice",
- "Wipe vertical interlace right to left twice",
- "Wipe horizontal interlace top to bottom twice",
- "Wipe horizontal interlace bottom to top twice",
- "Wipe vertical interlace left to right then back",
- "Wipe vertical interlace right to left then back",
- "Wipe horizontal interlace top to bottom then back",
- "Wipe horizontal interlace bottom to top then back",
- "Wipe horizontal interlace left to right and right to left",
- "Wipe vertical interlace top to bottom and bottom to top",
- "Wipe vertical interlace left and right to center",
- "Wipe vertical interlace center to left and right",
- "Wipe horizontal interlace top and bottom to center",
- "Wipe horizontal interlace center to top and bottom",
- "Wipe vertical interlace left and right to center then back",
- "Wipe vertical interlace center to left and right then back",
- "Wipe horizontal interlace top and bottom to center then back",
- "Wipe horizontal interlace center to top and bottom then back",
- "Wipe2 left-top and right-bottom to center",
- "Wipe2 left-bottom and right-top to center",
- "Wipe2 center to left-top and right-bottom",
- "Wipe2 center to left-bottom and right-top",
- "Wipe2 left-bottom and right-bottom to top",
- "Wipe2 left-top and right-top to bottom",
- "Wipe2 right-top and right-bottom to left",
- "Wipe2 left-top and left-bottom to right",
- "Wipe2 left top to bottom and right bottom to top",
- "Wipe2 top left to right and bottom right to left",
- "Wipe4 corners out",
- "Wipe4 center to left and right then top and bottom",
- "Wipe4 top and bottom then left and right to center",
- };
-
- //---------------------------------------------------------------------
- __fastcall TMainForm::TMainForm(TComponent *Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FormCreate(TObject *Sender)
- {
- HiddenLead->UnlockSupport(L_SUPPORT_EXPRESS, L_KEY_EXPRESS);
- HiddenLead->UnlockSupport(L_SUPPORT_GIFLZW, L_KEY_GIFLZW);
- HiddenLead->UnlockSupport(L_SUPPORT_TIFLZW, L_KEY_TIFLZW);
- HiddenLead->Visible = FALSE;
- Application->OnHint = ShowHint;
- Screen->OnActiveFormChange = UpdateMenuItems;
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::ShowHint(TObject *Sender)
- {
- StatusBar->SimpleText = Application->Hint;
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::CreateMDIChild(String Name)
- {
- TMDIChild *Child;
- int nRet;
-
- //--- create a new MDI child window ----
- Child = new TMDIChild(Application);
- Child->Lead1->EnableProgressEvent = Statusbar1->Checked;
- Child->InitStatusProcess("Loading: " + Name);
- try
- {
- nRet = Child->Lead1->Load(Name,0,0,1);
- Child->ResetStatusProcess();
- if(nRet == 0)
- {
- Child->Lead1->AutoAnimate=true;
- Child->Lead1->AutoRepaint=false;
- Child->Lead1->PaintPalette=HiddenLead->PaintPalette;
- Child->Lead1->PaintDither=HiddenLead->PaintDither;
- Child->Lead1->BitonalScaling=HiddenLead->BitonalScaling;
- Child->Lead1->EnableProgressEvent=HiddenLead->EnableProgressEvent;
- Child->Lead1->AutoRepaint=true;
- Child->ZoomMode=PAINTSIZEMODE_NORMAL;
- Child->ZoomSize=100;
- Child->RegionTool=RGNMARK_NONE;
- Child->Caption = Name;
- }
- else
- Child->Close();
- }
- catch(...)
- {
- Child->Close();
- }
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FileNewItemClick(TObject *Sender)
- {
- CreateMDIChild("NONAME" + IntToStr(MDIChildCount + 1));
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FileOpenItemClick(TObject *Sender)
- {
- OpenDialog->Filter = szLoadFilter;
- if (OpenDialog->Execute())
- CreateMDIChild(OpenDialog->FileName);
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FileCloseItemClick(TObject *Sender)
- {
- if (ActiveMDIChild)
- {
- ActiveMDIChild->Close();
- }
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FileSaveItemClick(TObject *Sender)
- {
- //---- save current file (ActiveMDIChild points to the window) ----
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FileSaveAsItemClick(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->SaveImage();
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FileExitItemClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::CutItemClick(TObject *Sender)
- {
- //---- cut selection to clipboard ----
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::CopyItemClick(TObject *Sender)
- {
- if (((TMDIChild *)ActiveMDIChild)->Lead1->Copy(COPY_EMPTY + COPY_DIB + COPY_PALETTE)!=0)
- Application->MessageBox("Error copying to clipboard","Error",MB_ICONINFORMATION);
- UpdateMenuItems(Sender);
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::PasteItemClick(TObject *Sender)
- {
- TMDIChild *Child;
-
- if(HiddenLead->Paste(PASTE_ISREADY)!=0)
- {
- Child = new TMDIChild(Application);
- Child->Caption = "Clipboard image";
- Child->Lead1->AutoAnimate=true;
- Child->Lead1->AutoRepaint=false;
- Child->Lead1->PaintPalette=HiddenLead->PaintPalette;
- Child->Lead1->PaintDither=HiddenLead->PaintDither;
- Child->Lead1->BitonalScaling=HiddenLead->BitonalScaling;
- Child->Lead1->EnableProgressEvent=HiddenLead->EnableProgressEvent;
- Child->Lead1->AutoRepaint=true;
- Child->ZoomMode=PAINTSIZEMODE_NORMAL;
- Child->ZoomSize=100;
- Child->RegionTool=RGNMARK_NONE;
- if(Child->Lead1->Paste(0)!= 0)
- Child->Close();
- }
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::WindowCascadeItemClick(TObject *Sender)
- {
- Cascade();
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::WindowTileItemClick(TObject *Sender)
- {
- Tile();
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::WindowArrangeItemClick(TObject *Sender)
- {
- ArrangeIcons();
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::WindowMinimizeItemClick(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::UpdateMenuItems(TObject *Sender)
- {
- FileCloseItem->Enabled = MDIChildCount > 0;
- FileSaveAsItem->Enabled = MDIChildCount > 0;
- CopyItem->Enabled = MDIChildCount > 0;
- PasteItem->Enabled = (HiddenLead->Paste(PASTE_ISREADY)!=0);
- SaveBtn->Enabled = MDIChildCount > 0;
- CopyBtn->Enabled = MDIChildCount > 0;
- PasteBtn->Enabled = PasteItem->Enabled;
- WindowCascadeItem->Enabled = MDIChildCount > 0;
- WindowTileItem->Enabled = MDIChildCount > 0;
- WindowArrangeItem->Enabled = MDIChildCount > 0;
- WindowMinimizeItem->Enabled = MDIChildCount > 0;
- View1->Enabled = MDIChildCount > 0;
- Image1->Enabled = MDIChildCount > 0;
- Color1->Enabled = MDIChildCount > 0;
- Print1->Enabled = MDIChildCount > 0;
- SelectRegion1->Enabled = MDIChildCount > 0;
- if(MDIChildCount>0)
- {
- Effects1->Checked =(((TMDIChild *)ActiveMDIChild)->Lead1->PaintEffect!=EFX_EFFECT_NONE);
- if(((TMDIChild *)ActiveMDIChild)->Lead1->Bitmap!=0)
- CancelRegion1->Enabled=((TMDIChild *)ActiveMDIChild)->Lead1->HasRgn;
- else
- CancelRegion1->Enabled=false;
- int zm=((TMDIChild *)ActiveMDIChild)->ZoomMode;
- int wz=((TMDIChild *)ActiveMDIChild)->ZoomSize;
- N2x1->Checked=false;
- N3x1->Checked=false;
- N4x1->Checked=false;
- N121->Checked=false;
- N131->Checked=false;
- N141->Checked=false;
- switch(zm)
- {
- case PAINTSIZEMODE_NORMAL:
- Normal1->Checked=true;
- break;
- case PAINTSIZEMODE_FIT:
- FitToWindow1->Checked=true;
- break;
- case PAINTSIZEMODE_ZOOM:
- if(wz==1 || wz==2 || wz==3)
- {
- ZoomIn1->Checked=true;
- ZoomOut1->Checked=false;
- }
- else
- {
- ZoomOut1->Checked=true;
- ZoomIn1->Checked=false;
- }
- switch(wz)
- {
- case 1: N2x1->Checked=true; break;
- case 2: N3x1->Checked=true; break;
- case 3: N4x1->Checked=true; break;
- case 4: N121->Checked=true; break;
- case 5: N131->Checked=true; break;
- case 6: N141->Checked=true; break;
- }
- }
- }
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FormDestroy(TObject *Sender)
- {
- Screen->OnActiveFormChange = NULL;
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::Statusbar1Click(TObject *Sender)
- {
- int i;
-
- if(Statusbar1->Checked == false)
- {
- HiddenLead->EnableProgressEvent = Statusbar1->Checked = true;
- }
- else
- Statusbar1->Checked = false;
- for(i=0;i<MDIChildCount-1;i++)
- {
- ((TMDIChild *)MDIChildren[i])->Lead1->EnableProgressEvent = Statusbar1->Checked;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Normal1Click(TObject *Sender)
- {
- Normal1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->Lead1->PaintSizeMode = PAINTSIZEMODE_NORMAL;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode = PAINTSIZEMODE_NORMAL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::FitToWindow1Click(TObject *Sender)
- {
- FitToWindow1->Checked = true;
- ((TMDIChild *)ActiveMDIChild)->Lead1->PaintSizeMode = PAINTSIZEMODE_FIT;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode = PAINTSIZEMODE_FIT;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Print1Click(TObject *Sender)
- {
- int w,h;
- TPrinter *Printer;
-
- Printer = new TPrinter;
- Cursor=crHourGlass;
- Printer->BeginDoc();
- w = ((TMDIChild *)ActiveMDIChild)->Lead1->BitmapWidth;
- h = ((TMDIChild *)ActiveMDIChild)->Lead1->BitmapHeight;
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Printing Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Render((int)Printer->Handle,0,0,w,h);
- Printer->EndDoc();
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- Cursor=crDefault;
- delete Printer;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::PrintSetup1Click(TObject *Sender)
- {
- PrinterSetupDialog1->Execute();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Rectangle1Click(TObject *Sender)
- {
- Rectangle1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->RegionTool=RGNMARK_RECT;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::None1Click(TObject *Sender)
- {
- None1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->RegionTool=RGNMARK_NONE;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Ellispe1Click(TObject *Sender)
- {
- Ellispe1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->RegionTool=RGNMARK_ELLIPSE;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::RoundedRectangle1Click(TObject *Sender)
- {
- RoundedRectangle1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->RegionTool=RGNMARK_ROUNDRECT;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Freehand1Click(TObject *Sender)
- {
- Freehand1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->RegionTool=RGNMARK_FREEHAND;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::CancelRegion1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->CancelRegion();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::N2x1Click(TObject *Sender)
- {
- ZoomIn1->Checked=true;
- ZoomOut1->Checked=false;
- N2x1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode=PAINTSIZEMODE_ZOOM;
- ((TMDIChild *)ActiveMDIChild)->ZoomImage(2,true);
- ((TMDIChild *)ActiveMDIChild)->ZoomSize=1;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::N3x1Click(TObject *Sender)
- {
- N3x1->Checked=true;
- ZoomIn1->Checked=true;
- ZoomOut1->Checked=false;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode=PAINTSIZEMODE_ZOOM;
- ((TMDIChild *)ActiveMDIChild)->ZoomImage(3,true);
- ((TMDIChild *)ActiveMDIChild)->ZoomSize=2;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::N4x1Click(TObject *Sender)
- {
- N4x1->Checked=true;
- ZoomIn1->Checked=true;
- ZoomOut1->Checked=false;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode=PAINTSIZEMODE_ZOOM;
- ((TMDIChild *)ActiveMDIChild)->ZoomImage(4,true);
- ((TMDIChild *)ActiveMDIChild)->ZoomSize=3;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::N121Click(TObject *Sender)
- {
- N121->Checked=true;
- ZoomIn1->Checked=false;
- ZoomOut1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode=PAINTSIZEMODE_ZOOM;
- ((TMDIChild *)ActiveMDIChild)->ZoomImage(2,false);
- ((TMDIChild *)ActiveMDIChild)->ZoomSize=4;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::N131Click(TObject *Sender)
- {
- N131->Checked=true;
- ZoomIn1->Checked=false;
- ZoomOut1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode=PAINTSIZEMODE_ZOOM;
- ((TMDIChild *)ActiveMDIChild)->ZoomImage(3,false);
- ((TMDIChild *)ActiveMDIChild)->ZoomSize=5;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::N141Click(TObject *Sender)
- {
- N141->Checked=true;
- ZoomIn1->Checked=false;
- ZoomOut1->Checked=true;
- ((TMDIChild *)ActiveMDIChild)->ZoomMode=PAINTSIZEMODE_ZOOM;
- ((TMDIChild *)ActiveMDIChild)->ZoomImage(4,false);
- ((TMDIChild *)ActiveMDIChild)->ZoomSize=6;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Flip1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Flipping Image");
- if(((TMDIChild *)ActiveMDIChild)->Lead1->HasRgn)
- ((TMDIChild *)ActiveMDIChild)->ProcessRegion("Flip");
- else
- ((TMDIChild *)ActiveMDIChild)->Lead1->Flip();
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Reverse1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Reversing Image");
- if(((TMDIChild *)ActiveMDIChild)->Lead1->HasRgn)
- ((TMDIChild *)ActiveMDIChild)->ProcessRegion("Reverse");
- else
- ((TMDIChild *)ActiveMDIChild)->Lead1->Reverse();
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Rotate1Click(TObject *Sender)
- {
- String instring;
- int degrees;
-
- if(InputQuery("Rotate Image", "Enter Degrees (-360...360)", instring))
- {
- degrees = instring.ToInt();
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Rotating Image");
- if(((TMDIChild *)ActiveMDIChild)->Lead1->HasRgn)
- {
- ((TMDIChild *)ActiveMDIChild)->rValue = degrees;
- ((TMDIChild *)ActiveMDIChild)->ProcessRegion("Rotate");
- }
- else
- ((TMDIChild *)ActiveMDIChild)->Lead1->Rotate(degrees*100,true,clBlack);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Shear1Click(TObject *Sender)
- {
- String instring;
- int angle;
-
- if(InputQuery("Shear", "Clockwise angle in degrees (-45...45)", instring))
- {
- angle = instring.ToInt();
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Shearing Image");
- if(((TMDIChild *)ActiveMDIChild)->Lead1->HasRgn)
- {
- ((TMDIChild *)ActiveMDIChild)->rValue = angle;
- ((TMDIChild *)ActiveMDIChild)->ProcessRegion("Shear");
- }
- else
- ((TMDIChild *)ActiveMDIChild)->Lead1->Shear(angle*100,true,clBlack);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Resize1Click(TObject *Sender)
- {
- String instring(((TMDIChild *)ActiveMDIChild)->Lead1->BitmapWidth);
- int w,h;
-
- //instring;
- if(InputQuery("New Image Width", "Enter Width", instring))
- {
- w = instring.ToInt();
- if(w > 0)
- {
- String in(((TMDIChild *)ActiveMDIChild)->Lead1->BitmapHeight);
- if(InputQuery("New Image Height", "Enter Height", in))
- {
- h=in.ToInt();
- if(h > 0)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Resizing Image");
- if(((TMDIChild *)ActiveMDIChild)->Lead1->HasRgn)
- {
- ((TMDIChild *)ActiveMDIChild)->rValue = w;
- ((TMDIChild *)ActiveMDIChild)->sValue = h;
- ((TMDIChild *)ActiveMDIChild)->ProcessRegion("Resize");
- }
- else
- ((TMDIChild *)ActiveMDIChild)->Lead1->Size(w,h,RESIZE_NORMAL);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Resample1Click(TObject *Sender)
- {
- String instring(((TMDIChild *)ActiveMDIChild)->Lead1->BitmapWidth);
- int w,h;
-
- if(InputQuery("New Image Width", "Enter Width", instring))
- {
- w = instring.ToInt();
- if(w > 0)
- {
- String in(((TMDIChild *)ActiveMDIChild)->Lead1->BitmapHeight);
- if(InputQuery("New Image Height", "Enter Height", in))
- {
- h=in.ToInt();
- if(h > 0)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Resampling Image");
- if(((TMDIChild *)ActiveMDIChild)->Lead1->HasRgn)
- {
- ((TMDIChild *)ActiveMDIChild)->rValue = w;
- ((TMDIChild *)ActiveMDIChild)->sValue = h;
- ((TMDIChild *)ActiveMDIChild)->ProcessRegion("Resample");
- }
- else
- ((TMDIChild *)ActiveMDIChild)->Lead1->Size(w,h,RESIZE_RESAMPLE);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Posterize1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "2";
- if(InputQuery("Posterize", "Levels per color (2..64)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<2 || nVal>64)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Posterizing Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Posterize(nVal);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Mosaic1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "2";
- if(InputQuery("Mosaic", "Tile size (2..64)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<2 || nVal>64)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Mosaic");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Mosaic(nVal);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Average1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "3";
- if(InputQuery("Average Filter", "Sample Size (3..11)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<3 || nVal>11)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Averaging Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Average(nVal);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Median1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "3";
- if(InputQuery("Median Filter", "Sample Size (3..11)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<3 || nVal>11)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Median Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Median(nVal);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Sharpen1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "0";
- if(InputQuery("Sharpen", "Percentage (-100..100)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<-100 || nVal>100)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Sharpening Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Sharpen(nVal*10);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::AddNoise1Click(TObject *Sender)
- {
- String instring;
- int nVal,nChannel;
-
- instring = "0";
- if(InputQuery("Add Noise", "Level (0..100)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<0 || nVal>100)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- nChannel = CHANNEL_MASTER;
- if(!GetListIndex("Add noise", "Channel", aChannelList,&nChannel))
- return;
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Adding Noise");
- ((TMDIChild *)ActiveMDIChild)->Lead1->AddNoise(nVal*10,nChannel);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Emboss1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Emboss Spatial Filter","Direction",aGradientList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Embossing Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->SpatialFilter(nFlt+FLT_EMBOSS_N);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Despeckle1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Despeckling Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Despeckle();
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Halftone1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Halftoning Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Halftone(HALFTONE_VIEW,0);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Grayscale1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Graying Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Grayscale(8);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Invert1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Inverting Image");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Invert();
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Brightness1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "0";
- if(InputQuery("Change brightness", "Percentage (-100..100)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<-100 || nVal>100)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Changing Brightness");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Intensity(nVal*10);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Contrast1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "0";
- if(InputQuery("Change Contrast", "Percentage (-100..100)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<-100 || nVal>100)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Changing Contrast");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Contrast(nVal*10);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Hue1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "0";
- if(InputQuery("Change Hue", "Angle in degrees (0..360)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<0 || nVal>360)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Changing Hue");
- ((TMDIChild *)ActiveMDIChild)->Lead1->Contrast(nVal);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::HistogramEqualize1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Histogram Equalize");
- ((TMDIChild *)ActiveMDIChild)->Lead1->HistoEqualize();
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::StretchIntensity1Click(TObject *Sender)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Stretch Intensity");
- ((TMDIChild *)ActiveMDIChild)->Lead1->StretchIntensity();
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::GammaCorrect1Click(TObject *Sender)
- {
- String instring;
- int nVal;
-
- instring = "50";
- if(InputQuery("Gamma correct", "Value (0..500)", instring))
- {
- nVal = instring.ToInt();
- if(nVal<0 || nVal>500)
- Application->MessageBox("Invalid Value","Error",MB_ICONINFORMATION);
- else
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Gamma Correcting");
- ((TMDIChild *)ActiveMDIChild)->Lead1->GammaCorrect(nVal);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::IntensityDetect1Click(TObject *Sender)
- {
- String instring;
- int l,h;
-
- instring="0";
- if(InputQuery("Intensity Detect", "min (0..255)", instring))
- {
- l = instring.ToInt();
- if(l>= 0 && l<=255)
- {
- instring="0";
- if(InputQuery("Intensity Detect", "max (0..255)", instring))
- {
- h=instring.ToInt();
- if(h >= 0 && h<=255)
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Intensity Detect");
- ((TMDIChild *)ActiveMDIChild)->Lead1->IntensityDetect(l,h);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- }
- }
- //---------------------------------------------------------------------------
-
- bool TMainForm::GetListIndex(String Title,String LabelTitle,String strings[],int *index)
- {
- int i;
-
- ListDlg->Caption=Title;
- ListDlg->GroupBox1->Caption=LabelTitle;
- ListDlg->ListBox1->Clear();
- for(i=0;i<MAX_STRING_LIST;i++)
- if(strings[i]!="")
- ListDlg->ListBox1->Items->Add(strings[i]);
- else
- break;
- ListDlg->ListBox1->ItemIndex=0;
- ListDlg->ShowModal();
- *index=ListDlg->ListBox1->ItemIndex;
- return(ListDlg->ModalResult==mrOk);
- }
-
- void __fastcall TMainForm::Gradient1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Gradient Spatial Filter","Direction",aGradientList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Gradient Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->SpatialFilter(nFlt+FLT_GRADIENT_N);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
-
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Laplacian1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Laplacian Spatial Filter","Type",aLaplacianList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Laplacian Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->SpatialFilter(nFlt+FLT_LAPLACE_1);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
-
- bool TMainForm::GetPaintEffect(int *index)
- {
- int i;
-
- ListDlg->Caption="Paint Effect";
- ListDlg->GroupBox1->Caption="Select Effect";
- ListDlg->ListBox1->Clear();
- for(i=0;i<sizeof(aEffectList)/sizeof(aEffectList[0]);i++)
- ListDlg->ListBox1->Items->Add(aEffectList[i]);
- ListDlg->ListBox1->ItemIndex=0;
- ListDlg->ShowModal();
- *index=ListDlg->ListBox1->ItemIndex+2000;
- return(ListDlg->ModalResult==mrOk);
- }
-
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Sobel1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Sobel Spatial Filter","Direction",aHorzVertList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Spatial Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->SpatialFilter(nFlt+FLT_SOBEL_HORZ);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Prewitt1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Prewitt Spatial Filter","Direction",aHorzVertList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Prewitt Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->SpatialFilter(nFlt+FLT_PREWITT_HORZ);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::ShiftandDifference1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Shift & Difference Spatial Filter","Direction",aShiftDiffList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Shift & Difference");
- ((TMDIChild *)ActiveMDIChild)->Lead1->SpatialFilter(nFlt+FLT_SHIFTDIFF_DIAG);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::LineSegment1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Line Segment Spatial Filter","Filter Type",aLineSegmentList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Line Segment Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->SpatialFilter(nFlt+FLT_LINESEG_HORZ);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Erosion1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Erosion Binary Filter","Direction",aBinaryFilterList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Erosion Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->BinaryFilter(nFlt+BFLT_EROSION_OMNI);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Dilation1Click(TObject *Sender)
- {
- int nFlt;
-
- if(GetListIndex("Dialation Binary Filter","Direction",aBinaryFilterList,&nFlt))
- {
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Applying Dialation Filter");
- ((TMDIChild *)ActiveMDIChild)->Lead1->BinaryFilter(nFlt+BFLT_DILATION_OMNI);
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Auto1Click(TObject *Sender)
- {
- Auto1->Checked=true;
- Fixed1->Checked=false;
- HiddenLead->PaintPalette=PAINTPALETTE_AUTO;
- for(int i=0;i<MDIChildCount-1;i++)
- ((TMDIChild *)MDIChildren[i])->Lead1->PaintPalette=HiddenLead->PaintPalette;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Fixed1Click(TObject *Sender)
- {
- Fixed1->Checked=true;
- Auto1->Checked=false;
- HiddenLead->PaintPalette=PAINTPALETTE_FIXED;
- for(int i=0;i<MDIChildCount-1;i++)
- ((TMDIChild *)MDIChildren[i])->Lead1->PaintPalette=HiddenLead->PaintPalette;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Ordered1Click(TObject *Sender)
- {
- Ordered1->Checked=true;
- ErrorDiffusion1->Checked=false;
- HiddenLead->PaintDither=PAINTDITHER_ORDERED;
- for(int i=0;i<MDIChildCount-1;i++)
- ((TMDIChild *)MDIChildren[i])->Lead1->PaintDither=HiddenLead->PaintDither;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::ErrorDiffusion1Click(TObject *Sender)
- {
- ErrorDiffusion1->Checked=true;
- Ordered1->Checked=false;
- HiddenLead->PaintDither=PAINTDITHER_DIFFUSION;
- for(int i=0;i<MDIChildCount-1;i++)
- ((TMDIChild *)MDIChildren[i])->Lead1->PaintDither=HiddenLead->PaintDither;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Normal2Click(TObject *Sender)
- {
- Normal2->Checked=true;
- FavorBlack1->Checked=false;
- ScaleToGray1->Checked=false;
- HiddenLead->BitonalScaling=BITONALSCALING_NORMAL;
- for(int i=0;i<MDIChildCount-1;i++)
- ((TMDIChild *)MDIChildren[i])->Lead1->BitonalScaling=HiddenLead->BitonalScaling;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::FavorBlack1Click(TObject *Sender)
- {
- FavorBlack1->Checked=true;
- Normal2->Checked=false;
- ScaleToGray1->Checked=false;
- HiddenLead->BitonalScaling=BITONALSCALING_FAVORBLACK;
- for(int i=0;i<MDIChildCount-1;i++)
- ((TMDIChild *)MDIChildren[i])->Lead1->BitonalScaling=HiddenLead->BitonalScaling;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::ScaleToGray1Click(TObject *Sender)
- {
- ScaleToGray1->Checked=true;
- Normal2->Checked=false;
- FavorBlack1->Checked=false;
- HiddenLead->BitonalScaling=BITONALSCALING_SCALETOGRAY;
- for(int i=0;i<MDIChildCount-1;i++)
- ((TMDIChild *)MDIChildren[i])->Lead1->BitonalScaling=HiddenLead->BitonalScaling;
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::CaptureScreen1Click(TObject *Sender)
- {
- HDC screenDC;
- int nRet;
- TMDIChild *Child;
-
- Visible=false;
- #ifdef WIN32
- Sleep(1000);
- #else
- Yield();
- #endif
- screenDC = GetDC(0);
- nRet = HiddenLead->Capture((int)screenDC,0,0,GetDeviceCaps(screenDC,HORZRES),
- GetDeviceCaps(screenDC,VERTRES));
- ReleaseDC(0,screenDC);
- Visible=true;
- if(nRet==0)
- {
- Child = new TMDIChild(Application);
- Child->Caption="Screen Capture";
- Child->Lead1->Bitmap=HiddenLead->Bitmap;
- Child->Lead1->AutoAnimate=true;
- Child->Lead1->AutoRepaint=false;
- Child->Lead1->PaintPalette=HiddenLead->PaintPalette;
- Child->Lead1->PaintDither=HiddenLead->PaintDither;
- Child->Lead1->BitonalScaling=HiddenLead->BitonalScaling;
- Child->Lead1->EnableProgressEvent=HiddenLead->EnableProgressEvent;
- Child->Lead1->AutoRepaint=true;
- Child->ZoomMode=PAINTSIZEMODE_NORMAL;
- Child->ZoomSize=100;
- Child->RegionTool=RGNMARK_NONE;
- HiddenLead->Bitmap=0;
- }
- else
- {
- Application->MessageBox("Error capturing the screen","ERROR",MB_ICONINFORMATION);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::ColorResolution1Click(TObject *Sender)
- {
- int nRet,nBits;
- long uDither,uPalette,uFlags;
-
- ColorResDlg->ShowModal();
- if(ColorResDlg->ModalResult==mrOk)
- {
- switch(ColorResDlg->BPP->ItemIndex)
- {
- case 0: nBits=1; break;
- case 1: nBits=2; break;
- case 2: nBits=3; break;
- case 3: nBits=4; break;
- case 4: nBits=5; break;
- case 5: nBits=6; break;
- case 6: nBits=7; break;
- case 7: nBits=8; break;
- case 8: nBits=16; break;
- case 9: nBits=24; break;
- case 10: nBits=32; break;
- }
- switch(ColorResDlg->DitherMethod->ItemIndex)
- {
- case 0: uDither=CRD_NODITHERING; break;
- case 1: uDither=CRD_FLOYDSTEINDITHERING; break;
- case 2: uDither=CRD_BURKESDITHERING; break;
- case 3: uDither=CRD_STUCKIDITHERING; break;
- case 4: uDither=CRD_SIERRADITHERING; break;
- case 5: uDither=CRD_STEVENSONARCEDITHERING; break;
- case 6: uDither=CRD_JARVISDITHERING; break;
- }
- if(ColorResDlg->PaletteOption->ItemIndex==0)
- uPalette=CRP_OPTIMIZEDPALETTE;
- else
- uPalette=CRP_FIXEDPALETTE;
- if(nBits>8)
- {
- if(ColorResDlg->ColorOrder->ItemIndex==0)
- uPalette=CRP_BYTEORDERBGR;
- else
- uPalette=CRP_BYTEORDERRGB;
- }
- ((TMDIChild *)ActiveMDIChild)->InitStatusProcess("Doing ColorRes");
- try
- {
- ((TMDIChild *)ActiveMDIChild)->Lead1->ColorRes(nBits,uPalette,uDither,0);
- }
- catch(...)
- {
- ((TMDIChild *)ActiveMDIChild)->ResetStatusProcess();
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::ImageInfo1Click(TObject *Sender)
- {
- int nRet;
- char s[10];
-
- OpenDialog->Filter=szLoadFilter;
- if(OpenDialog->Execute())
- {
- nRet=HiddenLead->GetFileInfo(OpenDialog->FileName,0);
- if(nRet==0)
- {
- InfoBox->FName->Caption=OpenDialog->FileName;
- itoa(HiddenLead->InfoFormat,s,10);
- InfoBox->FFormat->Caption=s;
- itoa(HiddenLead->InfoWidth,s,10);
- InfoBox->FWidth->Caption=s;
- itoa(HiddenLead->InfoHeight,s,10);
- InfoBox->FHeight->Caption=s;
- itoa(HiddenLead->InfoBits,s,10);
- InfoBox->FBits->Caption=s;
- itoa(HiddenLead->InfoSizeDisk,s,10);
- InfoBox->FDisk->Caption=s;
- itoa(HiddenLead->InfoSizeMem,s,10);
- InfoBox->FMem->Caption=s;
- InfoBox->FComp->Caption=HiddenLead->InfoCompress;
- InfoBox->ShowModal();
- }
- else
- {
- Application->MessageBox("Error Getting Info","Error",MB_ICONEXCLAMATION);
- }
- }
- }
- //---------------------------------------------------------------------------
-
-
- void __fastcall TMainForm::HelpAboutItemClick(TObject *Sender)
- {
- AboutBox->ShowModal();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::TwainSelect1Click(TObject *Sender)
- {
- HiddenLead->TwainSelect((int)Handle);
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::TwainAcquire1Click(TObject *Sender)
- {
- int nRet;
- TMDIChild *Child;
-
- nRet=HiddenLead->TwainAcquire((int)Handle);
- if(nRet==0)
- {
- Child = new TMDIChild(Application);
- Child->Caption = "Twain image";
- Child->Lead1->AutoAnimate=true;
- Child->Lead1->AutoRepaint=false;
- Child->Lead1->EnableProgressEvent=HiddenLead->EnableProgressEvent;
- Child->Lead1->PaintPalette=HiddenLead->PaintPalette;
- Child->Lead1->PaintDither=HiddenLead->PaintDither;
- Child->Lead1->BitonalScaling=HiddenLead->BitonalScaling;
- Child->Lead1->AutoRepaint=true;
- Child->ZoomMode=PAINTSIZEMODE_NORMAL;
- Child->ZoomSize=100;
- Child->RegionTool=RGNMARK_NONE;
- Child->Lead1->Bitmap=HiddenLead->Bitmap;
- HiddenLead->Bitmap=0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Effects1Click(TObject *Sender)
- {
- int nVal;
-
- if(Effects1->Checked)
- {
- Effects1->Checked = false;
- ((TMDIChild *)ActiveMDIChild)->Lead1->PaintEffect = EFX_EFFECT_NONE;
- }
- else
- {
- if(GetPaintEffect(&nVal))
- {
- Effects1->Checked = true;
- ((TMDIChild *)ActiveMDIChild)->Lead1->PaintEffect = nVal;
- }
- }
- }
- //---------------------------------------------------------------------------
-