//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "TPrint_F.h" #include "MainImage.h" #include "MainMenu.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPSpin" #pragma link "TPStretchImage" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_HEADER StringTable[0] #define IDS_HEADER_USED StringTable[1] #define IDS_HEADER_MOSAIC StringTable[2] #define IDS_COUNT StringTable[3] #define IDS_METHOD_HDVER StringTable[4] #define IDS_METHOD_HDHOR StringTable[5] #define IDS_MOSAICOPTION StringTable[6] #define IDS_XAXIS StringTable[7] #define IDS_YAXIS StringTable[8] #define IDS_DISABLED StringTable[9] #define IDS_FCAPTION StringTable[10] #define IDS_FITSIZE StringTable[11] #define IDS_PRINTMETHOD StringTable[12] #define IDS_PRINTGRID StringTable[13] #define IDS_VIEW StringTable[14] #define IDS_IMAGE StringTable[15] #define IDS_IMAGECOLORCHIP StringTable[16] //--------------------------------------------------------------------------- __fastcall TTPrintForm::TTPrintForm(TComponent* Owner) : TForm(Owner) { //====================================================== StringTable.Create(DirectoryItem, Language, "TPrint"); SetSmallFont(Font); SetSmallFont(OkLabel->Font); SetSmallFont(Label2->Font); SetSmallFont(Label8->Font); Caption = IDS_FCAPTION; lbPrinter->Caption = IDS_COMMON_PRINTER + " : " + Printer()->Printers->Strings[Printer()->PrinterIndex]; for (int i = 0; i < 3; i++) { // cbMethod->Items->Strings[i] = IDS_COMMON_PRINTMETHOD + " - " + AnsiString(i+1);//2001.7.20 lhskys 5 ¿¡¼­ ÇÁ¸°Æ® ½ÇÇàÀÌ ¾ÈµÇ´Â°ÍÀ» cbMethod->Items->Add(IDS_COMMON_PRINTMETHOD + " - " + AnsiString(i+1)); //Add ·Î ¹Ù²Ù¾î °¡´É ÇÏ°Ô ÇÏ¿´´Ù. } LabelPage->Caption = IDS_COMMON_PAGE; LabelHeader->Caption = IDS_HEADER; Label10->Caption = IDS_COMMON_REPEAT; Label11->Caption = IDS_PRINTMETHOD; OkLabel->Caption = IDS_COMMON_BUTTONOK; LabelZoom->Caption = IDS_COMMON_ZOOM; Label6->Caption = IDS_COMMON_METHOD; Label7->Caption = IDS_COUNT; Label9->Caption = IDS_COMMON_POSITION; ButtonSetup->Caption = AnsiString(IDS_COMMON_SETUP) + "..."; CancelBtn->Caption = IDS_COMMON_BUTTONCANCEL; OKBtn->Caption = IDS_COMMON_BUTTONOK; Label1->Caption = IDS_MOSAICOPTION; Label3->Caption = IDS_XAXIS; Label4->Caption = IDS_YAXIS; Label5->Caption = IDS_COMMON_MAX; cbFitSize->Caption = IDS_FITSIZE; GridCheck->Caption = IDS_PRINTGRID; View->Caption = IDS_VIEW; ComboBoxHeader->Items->Clear(); ComboBoxHeader->Items->Add(IDS_IMAGE); ComboBoxHeader->Items->Add(IDS_IMAGECOLORCHIP); ComboBoxHeader->Items->Add(IDS_HEADER_USED); #ifndef ACADMEY ComboBoxHeader->Items->Add(IDS_HEADER_MOSAIC); #endif ComboBoxRepeat->Items->Clear(); ComboBoxRepeat->Items->Add(IDS_COMMON_NORMAL); ComboBoxRepeat->Items->Add(IDS_COMMON_HDHOR); ComboBoxRepeat->Items->Add(IDS_COMMON_HDVER); //================================================================ TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { cbMethod->ItemIndex = IniFile->ReadInteger("Printer", "Method", 0); delete IniFile; } ComboBoxHeader->ItemIndex = 0; ComboBoxRepeat->ItemIndex = 0; NoPanel->Enabled = true; NoPanel->Visible = true; cbFitSize->Enabled = true; MosaicPanel->Enabled = false; MosaicPanel->Visible = false; mmFocus = false; freeposition = false; Allpart = false; MainImageForm->RGBnum = false; #ifdef ACADEMY OkLabel->Font->Color = clRed; OkLabel->Caption = IDS_DISABLED; InitFunc(2); #endif } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\TextilePrint.ini"); if (IniFile) { IniFile->WriteInteger("Form", "Left", Left); IniFile->WriteInteger("Form", "Top", Top); delete IniFile; } IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { IniFile->WriteInteger("Printer", "Method", cbMethod->ItemIndex); delete IniFile; } MainMenuForm->ExitFileManeger(); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::FormCreate(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ButtonSetupClick(TObject *Sender) { PrinterSetupDialog->Execute(); lbPrinter->Caption = IDS_COMMON_PRINTER + " : " + Printer()->Printers->Strings[Printer()->PrinterIndex]; SWView(); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ComboBoxRepeatChange(TObject *Sender) { int v; if(ComboBoxRepeat->Text == "")return; switch (ComboBoxRepeat->ItemIndex) { case 0: v = 0; Label9->Enabled = false; EditRepeat->Enabled = false; break; case 1: if (MainImageForm->WorkArea->Mask) v = (MainImageForm->WorkArea->Range.right -MainImageForm->WorkArea->Range.left) / 2; else v = MainImageForm->iMainImage->uBitmap->Width / 2; Label9->Enabled = true; EditRepeat->Enabled = true; break; case 2: if (MainImageForm->WorkArea->Mask) v = (MainImageForm->WorkArea->Range.bottom -MainImageForm->WorkArea->Range.top) / 2; else v = MainImageForm->iMainImage->uBitmap->Height / 2; Label9->Enabled = true; EditRepeat->Enabled = true; break; } EditRepeat->Text = v; SWView(); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ComboBoxHeaderChange(TObject *Sender) { int w, h; if(View->Checked)View->Checked=false; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { switch (ComboBoxHeader->ItemIndex) { case 0: FPrintHeader = phNo; break; case 1: FPrintHeader = phYes; break; case 2: FPrintHeader = phUsedColor; break; case 3: FPrintHeader = phMosaic; break; } } else { switch (ComboBoxHeader->ItemIndex) { case 0: FPrintHeader = phNo; break; case 1: FPrintHeader = phMosaic; break; } } switch (FPrintHeader) { case phNo: NoPanel->Enabled = true; NoPanel->Visible = true; #ifndef ACADEMY OkLabel->Font->Color = clBlue; //clGreen; OkLabel->Caption = IDS_COMMON_BUTTONOK; InitFunc(0); #else OkLabel->Font->Color = clRed; OkLabel->Caption = IDS_DISABLED; InitFunc(2); #endif MosaicPanel->Enabled = false; MosaicPanel->Visible = false; cbFitSize->Enabled = true; GridCheck->Enabled = true; View->Enabled = true; CheckRGB->Enabled = false; break; case phYes: NoPanel->Enabled = true; NoPanel->Visible = true; OkLabel->Font->Color = clRed; OkLabel->Caption = IDS_DISABLED; InitFunc(1); MosaicPanel->Enabled = false; MosaicPanel->Visible = false; cbFitSize->Enabled = true; GridCheck->Enabled = true; View->Enabled = false; CheckRGB->Enabled = true; break; case phUsedColor: NoPanel->Enabled = true; NoPanel->Visible = true; InitFunc(1); OkLabel->Font->Color = clRed; OkLabel->Caption = IDS_DISABLED; MosaicPanel->Enabled = false; MosaicPanel->Visible = false; cbFitSize->Enabled = false; GridCheck->Enabled = false; View->Enabled = false; CheckRGB->Enabled = true; break; case phMosaic: NoPanel->Enabled = false; NoPanel->Visible = false; InitFunc(0); MosaicPanel->Enabled = true; MosaicPanel->Visible = true; cbFitSize->Enabled = false; GridCheck->Enabled = false; View->Enabled = false; if (MainImageForm->WorkArea->Mask) { w = MainImageForm->WorkArea->Range.right-MainImageForm->WorkArea->Range.left; h = MainImageForm->WorkArea->Range.bottom-MainImageForm->WorkArea->Range.top; msax = w/ 10; msay = h/ 10; } else { msax = MainImageForm->iMainImage->uBitmap->Width /10; msay = MainImageForm->iMainImage->uBitmap->Height /10; } MaxLabel->Caption = Format("%d X %d", OPENARRAY (TVarRec, (msax, msay))); // MosaicXEdit->MaxValue = msax; // MosaicYEdit->MaxValue = msay; CheckRGB->Enabled = false; break; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm ::InitFunc(int i) { switch (i) { case 0: EditZoom->Enabled = true; ComboBoxRepeat->Enabled = true; SpinEditRepeatX->Enabled = true; SpinEditRepeatY->Enabled = true; EditRepeat->Enabled = true; break; case 1: EditZoom->Enabled = false; ComboBoxRepeat->Enabled = false; SpinEditRepeatX->Enabled = false; SpinEditRepeatY->Enabled = false; EditRepeat->Enabled = false; break; case 2: EditZoom->Enabled = true; ComboBoxRepeat->Enabled = false; SpinEditRepeatX->Enabled = false; SpinEditRepeatY->Enabled = false; EditRepeat->Enabled = false; break; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm ::InitForm() { #ifdef CARPET TPTextileImage *Image = MainImageForm->iMainImage; #else TPLayerImage *Image = MainImageForm->iMainImage; #endif if (Image->uBitmap->BitsPerPixel==8) { ComboBoxHeader->Items->Clear(); ComboBoxHeader->Items->Add(IDS_IMAGE); ComboBoxHeader->Items->Add(IDS_IMAGECOLORCHIP); ComboBoxHeader->Items->Add(IDS_HEADER_USED); #ifndef ACADEMY ComboBoxHeader->Items->Add(IDS_HEADER_MOSAIC); #endif } else { ComboBoxHeader->Items->Clear(); ComboBoxHeader->Items->Add(IDS_IMAGE); ComboBoxHeader->Items->Add(IDS_HEADER_MOSAIC); } FPrintHeader = phNo; #if defined(TEXTILE) Width = 357; SWView(); #endif } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::MosaicEditChange(TObject *Sender) { TPSpinEdit *s = (TPSpinEdit *) Sender; if (s->Text.Length()>0) { if (s->Tag) { MosaicYEdit->SetFocus(); if (s->Value > msay) s->Value = msay; } else { MosaicXEdit->SetFocus(); if (s->Value > msax) s->Value = msax; } } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::SpinEditPageChange(TObject *Sender) { if (SpinEditPage->Text.Length() > 0) { if (SpinEditPage->Value < SpinEditPage->MinValue) SpinEditPage->Value = SpinEditPage->MinValue; else if (SpinEditPage->Value > SpinEditPage->MaxValue) SpinEditPage->Value = SpinEditPage->MaxValue; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::SpinEditRepeatXChange(TObject *Sender) { if(SpinEditRepeatX->Text.Length() == 0)return; if (SpinEditRepeatX->Text.Length() > 0) { if (SpinEditRepeatX->Value < SpinEditRepeatX->MinValue) SpinEditRepeatX->Value = SpinEditRepeatX->MinValue; else if (SpinEditRepeatX->Value > SpinEditRepeatX->MaxValue) SpinEditRepeatX->Value = SpinEditRepeatX->MaxValue; } SWView(); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::SpinEditRepeatYChange(TObject *Sender) { if(SpinEditRepeatY->Text.Length() == 0)return; if (SpinEditRepeatY->Text.Length() > 0) { if (SpinEditRepeatY->Value < SpinEditRepeatY->MinValue) SpinEditRepeatY->Value = SpinEditRepeatY->MinValue; else if (SpinEditRepeatY->Value > SpinEditRepeatY->MaxValue) SpinEditRepeatY->Value = SpinEditRepeatY->MaxValue; } SWView(); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::GridCheckClick(TObject *Sender) { GridCheck->Checked != GridCheck->Checked; if (GridCheck->Checked) InitFunc(1); else InitFunc(0); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::PRPositionClick(TObject *Sender) { int BitWid, BitHei; int PanWid, PanHei; BitWid = ViewImage->Width; BitHei = ViewImage->Height; PanWid = Panel->Width; PanHei = Panel->Height; if(LT->Checked){ ViewImage->Top = 0; ViewImage->Left = 0; }else if(MT->Checked){ ViewImage->Top = 0; ViewImage->Left = (PanWid-BitWid)/2; }else if(RT->Checked){ ViewImage->Top = 0; ViewImage->Left = PanWid - BitWid; }else if(LM->Checked){ ViewImage->Top = (PanHei-BitHei)/2; ViewImage->Left = 0; }else if(MM->Checked){ ViewImage->Top = (PanHei-BitHei)/2; ViewImage->Left = (PanWid-BitWid)/2; }else if(RM->Checked){ ViewImage->Top = (PanHei-BitHei)/2; ViewImage->Left = PanWid - BitWid; }else if(LB->Checked){ ViewImage->Top = PanHei - BitHei; ViewImage->Left = 0; }else if(MB->Checked){ ViewImage->Top = PanHei - BitHei; ViewImage->Left = (PanWid-BitWid)/2; }else if(RB->Checked){ ViewImage->Top = PanHei - BitHei; ViewImage->Left = PanWid - BitWid; } freeposition = false; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ViewClick(TObject *Sender) { int total; switch (PrintHeader) { case phNo: if(cbFitSize->Checked){ UpDown1->Enabled=false; RPageNUM->Text = 1; }else { UpDown1->Enabled=true; total = HeightPage * WidthPage; RPageNUM->Text = PageNUM->Text + "/" + IntToStr(total); } Allpart = false; PageNUM->Text = 1; HeightNUM = 0; WidthNUM = 0; ViewImage->Top = 0; ViewImage->Left = 0; LT->Checked = true; CBHeaderNoMethod(); break; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::CBHeaderNoMethod() { // convert by celberus HDC hPrintDC/*, phDC = NULL*/; int WidthRes, HeightRes, width, height, realWid, realHei; TSize Area, s, rx; TRect Src, r; double dpi; TEXPIAFILEHEADER tpfh; tpfh.CanvasInfor = MainImageForm->CanvasInfor; RGBQUAD Btrgb[256]; dpi = MainImageForm->CanvasInfor.DotsPerInch; if(EditZoom->Text != NULL)dpi = dpi * 100 / StrToInt(EditZoom->Text); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; if(Area.cx > Area.cy){ Panel->Height = 214; Panel->Width = 305; Panel1->Height = 220; Panel1->Width = 311; Panel1->Left = 352; Panel1->Top = 135; WidthSize = 305; HeightSize = 214; }else if(Area.cx < Area.cy){ Panel->Height = 305; Panel->Width =214; Panel1->Height = 311; Panel1->Width = 220; Panel1->Left = 400; Panel1->Top = 90; WidthSize = 214; HeightSize = 305; } if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; } rx.cx = StrToInt(SpinEditRepeatX->Text); rx.cy = StrToInt(SpinEditRepeatY->Text); s.cx = width*rx.cx; s.cy = height*rx.cy; s.cx -= WidthNUM*Area.cx; s.cy -= HeightNUM*Area.cy; if(s.cx > Area.cx)s.cx = Area.cx; if(s.cy > Area.cy)s.cy = Area.cy; if(View->Checked){ Width = 677; realWid = Panel->Width * s.cx / Area.cx; realHei = Panel->Height * s.cy / Area.cy; ViewImage->Width = realWid; ViewImage->Height = realHei; if(!Repeat(ComboBoxRepeat->ItemIndex, Area, s)) goto fail; r = Rect(0,0,realWid,realHei); if(cbFitSize->Checked){ r = Rect(0,0,RrealWid,RrealHei); ViewImage->Width = RrealWid; ViewImage->Height = RrealHei; eBox(r); } if(Allpart){ for(int i=0;iCanvas->MoveTo(AllView.Left*i/PartNum, AllView.Top*j/PartNum); ViewImage->Canvas->LineTo(AllView.Left*i/PartNum, AllView.Bottom*(j+1)/PartNum); ViewImage->Canvas->MoveTo(AllView.Left*i/PartNum, AllView.Bottom*(j+1)/PartNum); ViewImage->Canvas->LineTo(AllView.Right*(i+1)/PartNum, AllView.Bottom*(j+1)/PartNum); ViewImage->Canvas->MoveTo(AllView.Right*(i+1)/PartNum, AllView.Bottom*(j+1)/PartNum); ViewImage->Canvas->LineTo(AllView.Right*(i+1)/PartNum, AllView.Top*j/PartNum); ViewImage->Canvas->MoveTo(AllView.Right*(i+1)/PartNum, AllView.Top*j/PartNum); ViewImage->Canvas->LineTo(AllView.Left*i/PartNum, AllView.Top*j/PartNum); } } }else eBox(r); ViewImage->Invalidate(); }else { Width = 357; ViewImage->Picture = NULL; ViewImage->Invalidate(); } return; fail: ShowMessage("Fail to creat pattern."); if(View->Checked)View->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::mmFocusPosition(int X, int Y) { X = X - ViewImage->Width/2.0; Y = Y - ViewImage->Height/2.0; if(X<0 && Y<0){ X = 0; Y = 0; }else if(X < 0 && Y + ViewImage->Height > Panel->Height){ X = 0; Y = Panel->Height - ViewImage->Height; }else if(X + ViewImage->Width > Panel->Width && Y<0){ X = Panel->Width - ViewImage->Width; Y = 0; }else if(X + ViewImage->Width > Panel->Width && Y + ViewImage->Height > Panel->Height){ X = Panel->Width - ViewImage->Width; Y = Panel->Height - ViewImage->Height; }else if(X<0){ X = 0; }else if(X + ViewImage->Width > Panel->Width){ X = Panel->Width - ViewImage->Width; }else if(Y<0){ Y = 0; }else if(Y + ViewImage->Height > Panel->Height){ Y = Panel->Height - ViewImage->Height; } ViewImage->Top = Y; ViewImage->Left = X; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::PanelMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if(UpDown1->Max != 1 || cbFitSize->Checked)return; if (Button==mbLeft) { LT->Checked = false; MT->Checked = false; RT->Checked = false; LM->Checked = false; MM->Checked = false; RM->Checked = false; LB->Checked = false; MB->Checked = false; RB->Checked = false; freeposition = true; mmFocusPosition(X, Y); mmFocus = true; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::PanelMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if(mmFocus){ mmFocusPosition(X, Y); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::PanelMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if(mmFocus){ mmFocus = false; mmFocusPosition(X, Y); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ViewImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if(UpDown1->Max != 1 || cbFitSize->Checked)return; if (Button==mbLeft) { LT->Checked = false; MT->Checked = false; RT->Checked = false; LM->Checked = false; MM->Checked = false; RM->Checked = false; LB->Checked = false; MB->Checked = false; RB->Checked = false; freeposition = true; X = X + ViewImage->Left; Y = Y + ViewImage->Top; mmFocusPosition(X, Y); mmFocus = true; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ViewImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if(mmFocus){ X = X + ViewImage->Left; Y = Y + ViewImage->Top; mmFocusPosition(X, Y); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ViewImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if(mmFocus){ mmFocus = false; X = X + ViewImage->Left; Y = Y + ViewImage->Top; mmFocusPosition(X, Y); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::SWView() { // convert by celberus HDC hPrintDC; int WidthRes, HeightRes, width, height; TSize Area, s, r; TRect Src; double dpi; dpi = MainImageForm->CanvasInfor.DotsPerInch; if(EditZoom->Text != NULL)dpi = dpi * 100 / StrToInt(EditZoom->Text); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; r.cx = StrToInt(SpinEditRepeatX->Text); r.cy = StrToInt(SpinEditRepeatY->Text); if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = (Src.Right-Src.Left)*r.cx; height = (Src.Bottom-Src.Top)*r.cy; } else { width = MainImageForm->iMainImage->uBitmap->Width * r.cx; height = MainImageForm->iMainImage->uBitmap->Height * r.cy; } if(cbFitSize->Checked){ s.cx = 1; s.cy = 1; }else { s.cx = ((width - 1) / Area.cx) + 1; s.cy = ((height - 1) / Area.cy) + 1; } WidthPage = s.cx; HeightPage = s.cy; UpDown1->Max = s.cx * s.cy; if(View->Checked)View->Checked = false; if(cbFitSize->Checked){ LT->Enabled = false; MT->Enabled = false; RT->Enabled = false; LM->Enabled = false; MM->Enabled = false; RM->Enabled = false; LB->Enabled = false; MB->Enabled = false; RB->Enabled = false; Allparts->Enabled = false; }else { if(s.cx > 1 || s.cy > 1){ LT->Enabled = false; MT->Enabled = false; RT->Enabled = false; LM->Enabled = false; MM->Enabled = false; RM->Enabled = false; LB->Enabled = false; MB->Enabled = false; RB->Enabled = false; Allparts->Enabled = true; }else { LT->Enabled = true; MT->Enabled = true; RT->Enabled = true; LM->Enabled = true; MM->Enabled = true; RM->Enabled = true; LB->Enabled = true; MB->Enabled = true; RB->Enabled = true; Allparts->Enabled = false; } } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::eBox(TRect r) { TPenMode pm; TColor cl; TBrushStyle bs; TSize p; if (r.Right-r.Left<=0 || r.Bottom-r.Top<=0) return; pm = ViewImage->Canvas->Pen->Mode; cl = ViewImage->Canvas->Pen->Color; bs = ViewImage->Canvas->Brush->Style; ViewImage->Canvas->Pen->Mode = pmXor; ViewImage->Canvas->Pen->Color = clWhite; ViewImage->Canvas->Brush->Style = bsClear; ViewImage->Canvas->Rectangle(r.Left, r.Top, r.Right, r.Bottom); ViewImage->Canvas->Pen->Mode = pm; ViewImage->Canvas->Pen->Color = cl; ViewImage->Canvas->Brush->Style = bs; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::EditZoomChange(TObject *Sender) { if(EditZoom->Text == "")return; SWView(); } //--------------------------------------------------------------------------- bool __fastcall TTPrintForm::Repeat(int item, TSize Area, TSize s) { // convet by celberus int width, height; TSize r; RECT Src; RGBQUAD rgb[256]; TUnionBitmap *Bitmap = NULL; r.cx = StrToInt(SpinEditRepeatX->Text); r.cy = StrToInt(SpinEditRepeatY->Text); if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; } else { Src = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); } // if (MainImageForm->iMainImage->LayerList->Count > 1) { // if ((Bitmap = MainImageForm->iMainImage->Composition()) == NULL) goto fail; if (!Repeat_Method(r, Src, StrToInt(EditRepeat->Text), item, Area, s)) goto fail; // delete Bitmap; Bitmap = NULL; // } else { // if (!Repeat_Method(r, Src, StrToInt(EditRepeat->Text), item, Area, s)) goto fail; // } return true; fail: if (Bitmap) delete Bitmap; return false; } //--------------------------------------------------------------------------- bool __fastcall TTPrintForm::Repeat_Method(TSize r, TRect Src, int len, int item, TSize Area, TSize s) { // convert by celberus int P, Dis; TRect Source, Dst, Srce; TSize sx; int x, y, width, height, realWid, realHei, lenth; HDC /*phDC = NULL,*/ PreDC = NULL; // convert by celberus TUnionBitmap *SrcPAT = NULL; // by celberus TUnionBitmap *tempBitmap = NULL; // convert by celberus TTexpiaBitmap *Preview = NULL; TPItemImage *Image = MainImageForm->iMainImage; if ((SrcPAT = new TUnionBitmap)==NULL) goto fail; // by celberus if ((Preview = new TTexpiaBitmap)==NULL) goto fail; if (MainImageForm->iMainImage->LayerList->Count <= 1) { if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; SrcPAT->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT->ExactCopy(MainImageForm->iMainImage->uBitmap); // by celberus } } else { if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; if((tempBitmap = MainImageForm->iMainImage->Composition(Src)) == NULL) goto fail; SrcPAT->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT->ExactCopy(tempBitmap); AreaIrregularrect(SrcPAT); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; if((tempBitmap = MainImageForm->iMainImage->Composition()) == NULL) goto fail; SrcPAT->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT->ExactCopy(tempBitmap); // by celberus } if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } } // if ((phDC = SrcPAT->CreateDC()) == NULL) goto fail; convert by celberus sx.cx = SrcPAT->Width; sx.cy = SrcPAT->Height; realWid = Panel->Width * sx.cx / Area.cx; realHei = Panel->Height * sx.cy / Area.cy; if(cbFitSize->Checked){ Preview->Create(realWid*r.cx, realHei*r.cy, Image->uBitmap->BitsPerPixel); if ((PreDC = Preview->CreateDC()) == NULL) goto fail; Preview->FillRect(Rect(0,0,realWid*r.cx,realHei*r.cy), clWhite); }else { Preview->Create(WidthPage*WidthSize, HeightPage*HeightSize, Image->uBitmap->BitsPerPixel); if ((PreDC = Preview->CreateDC()) == NULL) goto fail; Preview->FillRect(Rect(0,0,WidthPage*WidthSize,HeightPage*HeightSize), clWhite); } switch (item) { // 0: Normal, 1: Half Drop Horizontal, 2: Half Drop Vertical case 0: for (y=0; yUnionStretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top),0,0,width,height,SRCCOPY); // convert by celberus } } if(cbFitSize->Checked){ int xxx = WidthSize*1000 / (realWid*r.cx); int yyy = HeightSize*1000 / (realHei*r.cy); if (xxx < yyy) { if (xxx < 1000){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx*xxx/1000, realHei*r.cy*xxx/1000, PreDC,0,0,realWid*r.cx,realHei*r.cy,SRCCOPY); RrealWid = realWid*r.cx*xxx/1000; RrealHei = realHei*r.cy*xxx/1000; }else if(xxx >= 1000){ BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); RrealWid = realWid*r.cx; RrealHei = realHei*r.cy; } }else { if (yyy < 1000){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx*yyy/1000, realHei*r.cy*yyy/1000, PreDC,0,0,realWid*r.cx,realHei*r.cy,SRCCOPY); RrealWid = realWid*r.cx*yyy/1000; RrealHei = realHei*r.cy*yyy/1000; }else if(yyy >= 1000){ BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); RrealWid = realWid*r.cx; RrealHei = realHei*r.cy; } } }else { if(Allpart){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, WidthSize*WidthPage/PartNum, HeightSize*HeightPage/PartNum, PreDC,0,0,WidthPage*WidthSize,HeightPage*HeightSize, SRCCOPY); }else{ BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); } } ViewImage->Invalidate(); break; case 1: for (y=0; yUnionStretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top),0,0,(Src.Right-Src.Left),(Src.Bottom-Src.Top),SRCCOPY); // convert by celberus } if (Dst.Right < realWid*r.cx) { Dst.Left = Dst.Right; Dst.Right = realWid*r.cx; Src.Left = 0; Src.Right = P; SetStretchBltMode(PreDC,COLORONCOLOR); // StretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), // (Dst.Bottom-Dst.Top),phDC,0,0,(Src.Right-Src.Left),(Src.Bottom-Src.Top),SRCCOPY); SrcPAT->UnionStretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top),0,0,(Src.Right-Src.Left),(Src.Bottom-Src.Top),SRCCOPY); // convert by celberus } } if(cbFitSize->Checked){ int xxx = WidthSize*1000 / (realWid*r.cx); int yyy = HeightSize*1000 / (realHei*r.cy); if (xxx < yyy) { if (xxx < 1000){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx*xxx/1000, realHei*r.cy*xxx/1000, PreDC,0,0,realWid*r.cx,realHei*r.cy,SRCCOPY); }else if(xxx >= 1000) BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); }else { if (yyy < 1000){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx*yyy/1000, realHei*r.cy*yyy/1000, PreDC,0,0,realWid*r.cx,realHei*r.cy,SRCCOPY); }else if(yyy >= 1000) BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); } }else { if(Allpart){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, WidthSize*WidthPage/PartNum, HeightSize*HeightPage/PartNum, PreDC,0,0,WidthPage*WidthSize,HeightPage*HeightSize,SRCCOPY); }else{ BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); } } ViewImage->Invalidate(); break; case 2: for (x=0; xUnionStretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top),0,0,(Src.Right-Src.Left),(Src.Bottom-Src.Top),SRCCOPY); // convert by celberus } if (Dst.Bottom < realHei*r.cy) { Dst.Top = Dst.Bottom; Dst.Bottom = realHei*r.cy; Src.Top = 0; Src.Bottom = P; SetStretchBltMode(PreDC,COLORONCOLOR); // StretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), // (Dst.Bottom-Dst.Top),phDC,0,0,(Src.Right-Src.Left),(Src.Bottom-Src.Top),SRCCOPY); SrcPAT->UnionStretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top),0,0,(Src.Right-Src.Left),(Src.Bottom-Src.Top),SRCCOPY); // convert by celberus } } if(cbFitSize->Checked){ int xxx = WidthSize*1000 / (realWid*r.cx); int yyy = HeightSize*1000 / (realHei*r.cy); if (xxx < yyy) { if (xxx < 1000){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx*xxx/1000, realHei*r.cy*xxx/1000, PreDC,0,0,realWid*r.cx,realHei*r.cy,SRCCOPY); }else if(xxx >= 1000) BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); }else { if (yyy < 1000){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx*yyy/1000, realHei*r.cy*yyy/1000, PreDC,0,0,realWid*r.cx,realHei*r.cy,SRCCOPY); }else if(yyy >= 1000) BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); } }else { if(Allpart){ SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, WidthSize*WidthPage/PartNum, HeightSize*HeightPage/PartNum, PreDC,0,0,WidthPage*WidthSize,HeightPage*HeightSize, SRCCOPY); }else{ BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); } } ViewImage->Invalidate(); break; } // if (phDC) SrcPAT->DeleteDC(phDC); convert by celberus if (SrcPAT) { delete SrcPAT; SrcPAT = NULL; } if (PreDC) Preview->DeleteDC(PreDC); if (Preview) { delete Preview; Preview = NULL; } return true; fail: // if (phDC) SrcPAT->DeleteDC(phDC); convert by celberus if (SrcPAT) { delete SrcPAT; SrcPAT = NULL; } if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } if (PreDC) Preview->DeleteDC(PreDC); if (Preview) { delete Preview; Preview = NULL; } return false; } //---------------------------------------------------------------------------- void __fastcall TTPrintForm::AreaIrregularrect(TUnionBitmap *SrcPAT) { // convert by celberus TRect Src; TUnionBitmap *BtTemp;// ºñÆ®¸Ê Àӽà ÀúÀå BtTemp RGBQUAD Btrgb[256]; // HDC patternDC; // by celberus Src = MainImageForm->WorkArea->Range; /* if ((BtTemp = new TUnionBitmap)==NULL) goto fail; MainImageForm->iMainImage->uBitmap->GetColors(0, 256, Btrgb); if (!BtTemp->Create(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, MainImageForm->iMainImage->uBitmap->BitsPerPixel, Btrgb)) goto fail; BtTemp->ExactCopy(MainImageForm->iMainImage->uBitmap); // by celberus */ Byte *mp, *bp; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (!SrcPAT->StartScanLine()) goto fail; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { for (int y = Src.top ,z = 0 ; y < Src.bottom; y++, z++) { bp = SrcPAT->GetScanLine(z); mp = MainImageForm->WorkArea->Mask->GetScanLine(z); // bp += Src.left; for (int x = 0 ; x < Src.right-Src.left ; x++, mp++) { if (*mp) { }else { *(bp+x) = 1; } } SrcPAT->PutScanLine(z); } MainImageForm->WorkArea->Mask->StopScanLine(); SrcPAT->StopScanLine(); }else { // Full Color TColor TempC = clWhite; for (int y = Src.top ,z = 0 ; y < Src.bottom; y++, z++) { bp = SrcPAT->GetScanLine(z); mp = MainImageForm->WorkArea->Mask->GetScanLine(z); // bp += Src.left*3; for (int x = 0; x < Src.right-Src.left; x++, bp+=3) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { *(bp+2) = TempC & 0xFF ; *(bp+1) = (TempC>>8) & 0xFF; *bp = (TempC>>16) & 0xFF; } } SrcPAT->PutScanLine(z); } MainImageForm->WorkArea->Mask->StopScanLine(); SrcPAT->StopScanLine(); } // patternDC = SrcPAT->CreateDC(); // by celberus // SrcPAT->Copy(0, 0, SrcPAT->Width, SrcPAT->Height, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus // MainImageForm->iMainImage->uBitmap->ExactCopy(BtTemp); // by celberus // delete BtTemp; BtTemp = NULL; fail: MainImageForm->WorkArea->Mask->StopScanLine(); SrcPAT->StopScanLine(); // if (BtTemp) { // delete BtTemp; BtTemp = NULL; // } } //---------------------------------------------------------------------------- void __fastcall TTPrintForm::UpDown1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int NUM, total; ViewImage->Picture = NULL; ViewImage->Invalidate(); NUM = StrToInt(PageNUM->Text); total = HeightPage * WidthPage; RPageNUM->Text = PageNUM->Text + "/" + IntToStr(total); HeightNUM=-1; WidthNUM=-1; for(int i=0;iTop = 0; ViewImage->Left = 0; UpDown1->Enabled=false; backupWid = HeightNUM; backupHei = WidthNUM; HeightNUM=0; WidthNUM=0; if(WidthPage > HeightPage){ PartNum = WidthPage; }else if(WidthPage < HeightPage){ PartNum = HeightPage; }else if(WidthPage == HeightPage){ PartNum = WidthPage; } AllView = Rect(0,0,WidthSize,HeightSize); } else { UpDown1->Enabled=true; HeightNUM = backupWid; WidthNUM = backupHei; } ViewImage->Picture = NULL; ViewImage->Invalidate(); CBHeaderNoMethod(); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { int NUM, total; if(Key == 33){ //PageUp ViewImage->Picture = NULL; ViewImage->Invalidate(); NUM = StrToInt(PageNUM->Text)+1; UpDown1->Position = NUM; total = HeightPage * WidthPage; RPageNUM->Text = IntToStr(NUM) + "/" + IntToStr(total); HeightNUM=-1; WidthNUM=-1; for(int i=0;iPicture = NULL; ViewImage->Invalidate(); NUM = StrToInt(PageNUM->Text)-1; UpDown1->Position = NUM; total = HeightPage * WidthPage; RPageNUM->Text = IntToStr(NUM) + "/" + IntToStr(total); HeightNUM=-1; WidthNUM=-1; for(int i=0;iChecked == true)MainImageForm->RGBnum = true; else MainImageForm->RGBnum = false; } //---------------------------------------------------------------------------