//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "TPrint_F.h" #include "MainImage.h" #include "MainMenu.h" #include "VecDraw.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPStretchImage" #pragma link "RzEdit" #pragma link "RzSpnEdt" #pragma link "TNumEdit" #pragma link "RzButton" #pragma link "RzCmboBx" #pragma link "RzRadChk" #pragma link "RzPanel" #pragma link "RzLabel" #pragma link "RzTrkBar" #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] #define IDS_LeftTop StringTable[17] #define IDS_MiddleTop StringTable[18] #define IDS_RightTop StringTable[19] #define IDS_LeftCenter StringTable[20] #define IDS_MiddleCenter StringTable[21] #define IDS_RightCenter StringTable[22] #define IDS_LeftBottom StringTable[23] #define IDS_MiddleBottom StringTable[24] #define IDS_RightBottom StringTable[25] #define IDS_CurrentPage StringTable[26] //--------------------------------------------------------------------------- __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 + " - " + String(i+1);//2001.7.20 lhskys 5 ¿¡¼­ ÇÁ¸°Æ® ½ÇÇàÀÌ ¾ÈµÇ´Â°ÍÀ» cbMethod->Items->Add(IDS_COMMON_PRINTMETHOD + " - " + String(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 = String(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); LT->Caption = IDS_LeftTop; MT->Caption = IDS_MiddleTop; RT->Caption = IDS_RightTop; LM->Caption = IDS_LeftCenter; MM->Caption = IDS_MiddleCenter; RM->Caption = IDS_RightCenter; LB->Caption = IDS_LeftBottom; MB->Caption = IDS_MiddleBottom; RB->Caption = IDS_RightBottom; cbCurrentPage->Caption = IDS_CurrentPage; //================================================================ cbMethod->ItemIndex = 0; TIniFile *IniFile = new TIniFile(AppDataItem + "\\status.ini"); if (IniFile) { cbMethod->ItemIndex = IniFile->ReadInteger("Printer", "Method", 0); delete IniFile; IniFile = NULL; } 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; Label9->Enabled = false; EditRepeat->Enabled = false; this->DoubleBuffered = true; PBitmap = new TUnionBitmap; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::FormClose(TObject *Sender, TCloseAction &Action) { if (PBitmap) delete PBitmap; PBitmap = NULL; TIniFile *IniFile = new TIniFile(AppDataItem+"\\TextilePrint.ini"); if (IniFile) { IniFile->WriteInteger("Form", "Left", Left); IniFile->WriteInteger("Form", "Top", Top); delete IniFile; IniFile = NULL; } IniFile = new TIniFile(AppDataItem + "\\status.ini"); if (IniFile) { IniFile->WriteInteger("Printer", "Method", cbMethod->ItemIndex); delete IniFile; IniFile = NULL; } if (MainMenuForm) MainMenuForm->ExitFileManager(); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::FormCreate(TObject *Sender) { PrinterSetupDialog->OnShow = OnPrintSetupDlgShow; } //-------------------------------------------------------------------------- void __fastcall TTPrintForm::OnPrintSetupDlgShow(TObject *Sender) { SetWindowPos(PrinterSetupDialog->Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ButtonSetupClick(TObject *Sender) { if (!PrinterAvailable()) { Application->MessageBox(IDS_MESSAGE_NO_PRINTER.c_str(), L"Warning", MB_OK); return; } try { PrinterSetupDialog->Execute(); lbPrinter->Caption = IDS_COMMON_PRINTER + " : " + Printer()->Printers->Strings[Printer()->PrinterIndex]; SWView(); } catch (EPrinter&) // EPrinterError { Application->MessageBox(IDS_COMMON_PRINTSPOOLING.c_str(), L"Information", MB_OK); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ComboBoxRepeatCloseUp(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->Value = v; SWView(); if (!View->Checked) return; if (UpDown1->Max == 1 && FPrintHeader != phYes) { CBHeaderNoMethod(); } else { Preview(); } } //--------------------------------------------------------------------------- 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; } } PanelColorZoom->Visible = false; switch (FPrintHeader) { case phNo: NoPanel->Enabled = true; NoPanel->Visible = true; //Label9->Enabled = false; //EditRepeat->Enabled = false; OkLabel->Font->Color = clBlue; //clGreen; OkLabel->Caption = IDS_COMMON_BUTTONOK; InitFunc(0); MosaicPanel->Enabled = false; MosaicPanel->Visible = false; cbFitSize->Enabled = true; GridCheck->Enabled = true; GridCheck->OnClick(Sender); //GridCheckÀÇ »óÅ¿¡ µû¸¥ °¢ Ç׸ñÀÇ enabled¸¦ À¯ÁöÇϱâÀ§ÇØ GridCheck->OnClick(Sender); //¿¬´Þ¾Æ 2¹ø Ŭ¸¯ÇÔ(Æí¹ýÀÌÁö¸¸;;) by siuaa View->Enabled = true; CheckRGB->Enabled = false; break; case phYes: NoPanel->Enabled = true; NoPanel->Visible = true; Label9->Enabled = false; EditRepeat->Enabled = false; OkLabel->Font->Color = clRed; OkLabel->Caption = IDS_DISABLED; PanelColorZoom->BringToFront(); PanelColorZoom->Visible = true; InitFunc(1); MosaicPanel->Enabled = false; MosaicPanel->Visible = false; cbFitSize->Enabled = true; GridCheck->Enabled = true; View->Enabled = true; CheckRGB->Enabled = true; break; case phUsedColor: NoPanel->Enabled = true; NoPanel->Visible = true; Label9->Enabled = false; EditRepeat->Enabled = false; 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; Label9->Enabled = false; EditRepeat->Enabled = 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() { TPLayerImage *Image = MainImageForm->iMainImage; if (Image->uBitmap->BitsPerPixel==8) { ComboBoxHeader->Items->Clear(); ComboBoxHeader->Items->Add(IDS_IMAGE); ComboBoxHeader->Items->Add(IDS_IMAGECOLORCHIP); ComboBoxHeader->Items->Add(IDS_HEADER_USED); ComboBoxHeader->Items->Add(IDS_HEADER_MOSAIC); } else { ComboBoxHeader->Items->Clear(); ComboBoxHeader->Items->Add(IDS_IMAGE); ComboBoxHeader->Items->Add(IDS_HEADER_MOSAIC); } ComboBoxHeader->ItemIndex = 0; FPrintHeader = phNo; #if defined(TEXSTYLIST) // if (!View->Checked) Width = 357; if (!View->Checked) ClientWidth = rzpnlMain->Width; SWView(); //if (UpDown1->Max != 1) MakeViewImage(PBitmap); #endif } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::MosaicEditChange(TObject *Sender) { TRzSpinEdit *s = (TRzSpinEdit *) 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->Min) SpinEditPage->Value = SpinEditPage->Min; else if (SpinEditPage->Value > SpinEditPage->Max) SpinEditPage->Value = SpinEditPage->Max; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::SpinEditRepeatXChange(TObject *Sender) { if(SpinEditRepeatX->Text.Length() == 0) return; if (SpinEditRepeatX->Text.Length() > 0) { if (SpinEditRepeatX->Value < SpinEditRepeatX->Min) SpinEditRepeatX->Value = SpinEditRepeatX->Min; else if (SpinEditRepeatX->Value > SpinEditRepeatX->Max) SpinEditRepeatX->Value = SpinEditRepeatX->Max; } Panel1->Visible = false; SWView(); if (!View->Checked) return; if (UpDown1->Max == 1 && FPrintHeader != phYes) { UpDown1->Position = 1; CBHeaderNoMethod(); } else { if (UpDown1->Position > UpDown1->Max) UpDown1->Position = UpDown1->Max; Preview(); } RPageNUM->Text = Format("%d/%d", OPENARRAY(TVarRec, ((int)UpDown1->Position, UpDown1->Max))); UpDown1->Update(); Panel1->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::SpinEditRepeatYChange(TObject *Sender) { if(SpinEditRepeatY->Text.Length() == 0)return; if (SpinEditRepeatY->Text.Length() > 0) { if (SpinEditRepeatY->Value < SpinEditRepeatY->Min) SpinEditRepeatY->Value = SpinEditRepeatY->Min; else if (SpinEditRepeatY->Value > SpinEditRepeatY->Max) SpinEditRepeatY->Value = SpinEditRepeatY->Max; } Panel1->Visible = false; SWView(); if (!View->Checked) return; if (UpDown1->Max == 1 && FPrintHeader != phYes) { UpDown1->Position = 1; CBHeaderNoMethod(); } else { if (UpDown1->Position > UpDown1->Max) UpDown1->Position = UpDown1->Max; Preview(); } RPageNUM->Text = Format("%d/%d", OPENARRAY(TVarRec, ((int)UpDown1->Position, UpDown1->Max))); UpDown1->Update(); Panel1->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::GridCheckClick(TObject *Sender) { GridCheck->Checked != GridCheck->Checked; if (GridCheck->Checked) InitFunc(1); else if(this->PrintHeader == phYes) InitFunc(1); //°¢ Ç׸ñÀÇ enabled°¡ À߸ø º¯ÇÏ´Â °ÍÀ» ¸·±â À§ÇØ Ãß°¡ by siuaa else InitFunc(0); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::PRPositionClick(TObject *Sender) { if (UpDown1->Max == 1 && FPrintHeader != phYes) { 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; } else { Preview(); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::ViewClick(TObject *Sender) { if (!View->Checked) { ViewImage->Picture = NULL; this->ClientWidth = rzpnlMain->Width; rzpnlPreview->Visible = false; return; } switch (PrintHeader) { case phYes: case phNo: SWView(); UpDown1->Position = 1; if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { if(cbFitSize->Checked){ UpDown1->Enabled=false; RPageNUM->Text = 1; } else { UpDown1->Enabled=true; RPageNUM->Text = PageNUM->Text + "/" + IntToStr(UpDown1->Max); } //Allpart = false; PageNUM->Text = 1; HeightNUM = 0; WidthNUM = 0; ViewImage->Top = 0; ViewImage->Left = 0; LT->Checked = true; CBHeaderNoMethod(); } else { Preview(); } rzpnlPreview->Visible = true; break; } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::MakeViewImage(TUnionBitmap *Pattern) { if(FPrintHeader == phYes) { MakeColorChipPreview(PBitmap); } else { MakeRepeatImage(PBitmap, ComboBoxRepeat->ItemIndex); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::Preview() { if (View->Checked) { this->ClientWidth = rzpnlMain->Width + rzpnlPreview->Width; ViewImage->Picture = NULL; ViewImage->Invalidate(); InitVariables(PBitmap); MakeViewImage(PBitmap); //PBitmap->SaveToFile(L"C:\\Users\\david\\Documents\\Test_Image\\test.bmp", FILE_BMP); PutViewImage(PBitmap, ViewImage->Canvas); ViewImage->Repaint(); if (Allpart || cbFitSize->Checked) { cbCurrentPage->Enabled = false; UpDown1->Enabled = false; RPageNUM->Enabled = false; RPageNUM->Text = "All"; } else { cbCurrentPage->Enabled = true; UpDown1->Enabled = true; RPageNUM->Enabled = true; UpDown1->Max = PageNum.cx*PageNum.cy; RPageNUM->Text = Format("%d/%d", OPENARRAY(TVarRec, ((int)UpDown1->Position, (int)((PageNum.cx)*(PageNum.cy))))); } UpDown1->Update(); } } //--------------------------------------------------------------------------- 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->Value> 0)dpi = dpi * 100 / EditZoom->IntValue; 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; Panel->Left = (Panel1->Width - Panel->Width) / 2; Panel->Top = (Panel1->Height - Panel->Height) / 2; WidthSize = 305; HeightSize = 214; } else if(Area.cx < Area.cy){ Panel->Height = 305; Panel->Width =214; Panel->Left = (Panel1->Width - Panel->Width) / 2; Panel->Top = (Panel1->Height - Panel->Height) / 2; 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) { realWid = Panel->Width * s.cx / Area.cx + 2; realHei = Panel->Height * s.cy / Area.cy + 2; ViewImage->Width = realWid; ViewImage->Height = realHei; if(!Repeat(ComboBoxRepeat->ItemIndex, Area, s)) goto fail; if (cbFitSize->Checked) { ViewImage->Width = RrealWid; ViewImage->Height = RrealHei; r = Rect(0,0,ViewImage->Width,ViewImage->Height); eBox(r); } else { //r = Rect(0,0,ViewImage->ClientWidth,ViewImage->ClientHeight); r = Rect(0,0,ViewImage->Width,ViewImage->Height); 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(); this->ClientWidth = rzpnlMain->Width + rzpnlPreview->Width; } else { ViewImage->Picture = NULL; ViewImage->Invalidate(); this->ClientWidth = rzpnlMain->Width; } 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 || FPrintHeader == phYes) 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 || FPrintHeader == phYes)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); } } //--------------------------------------------------------------------------- bool __fastcall TTPrintForm::SWView() { // convert by celberus HDC hPrintDC; int WidthRes, HeightRes, width, height; TSize Area, s, r, colorChipArea;; TRect Src; double dpi; ViewImage->Picture = NULL; ViewImage->Invalidate(); colorChipArea.cx = 0; colorChipArea.cy = 0; dpi = MainImageForm->CanvasInfor.DotsPerInch; if(EditZoom->Value > 0)dpi = dpi * 100 / EditZoom->IntValue; 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(FPrintHeader == phYes) { r.cx = 1; r.cy = 1; } 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 { int colorChipW; if(FPrintHeader == phYes) { if (MainImageForm->ComboHeaderUsedColorMethod(NULL, true, NumEdColorZoom->Value, colorChipArea) < 0) return false; } colorChipW = width > colorChipArea.cx ? width : colorChipArea.cx; s.cx = ((colorChipW - 1) / Area.cx) + 1; s.cy = ((height + colorChipArea.cy - 1) / Area.cy) + 1; } WidthPage = s.cx; HeightPage = s.cy; UpDown1->Max = s.cx * s.cy; if (UpDown1->Max == 1) Allpart = 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; } } if (View->Checked) { this->ClientWidth = rzpnlMain->Width + rzpnlPreview->Width; if (UpDown1->Max > 1) { Panel->Left = 4; Panel->Top = 3; Panel->Width = 307; Panel->Height = 302; } s.cx = width; s.cy = height; 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; ViewImage->Left = 0; ViewImage->Top = 0; ViewImage->Width = Panel->Width * s.cx / Area.cx + 2; ViewImage->Height = Panel->Height * s.cy / Area.cy + 2; } return true; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::eBox(TRect r) { TPenMode pm; TColor cl; TBrushStyle bs; 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) { // Blankµµ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ - by monkman (2010.07.20) //if(EditZoom->Value <= 0)return; if(EditZoom->Value < 10)return; SWView(); if (!View->Checked) return; if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { CBHeaderNoMethod(); } else { Preview(); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::EditZoomExit(TObject *Sender) { // Blankµµ ÀÔ·Â °¡´ÉÇϳª, Edit¸¦ ¹þ¾î³¯ ¶§ 0ÀÌÇÏÀÏ °æ¿ì BlankValue·Î ÀÔ·Â - by monkman (2010.07.20) if (EditZoom->Value <= 0) EditZoom->Value = EditZoom->BlankValue; EditZoom->Text = IntToStr(EditZoom->IntValue); } //--------------------------------------------------------------------------- bool __fastcall TTPrintForm::Repeat(int item, TSize Area, TSize s) { // convet by celberus int width, height; TSize r; RECT Src; RGBQUAD rgb[256]; 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); } //Ä÷¯Ä¨ ÇÁ¸°Æ®´Â MakeViewImage() ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ó¸®ÇÑ´Ù. //±×·¯³ª Fit Print´Â ¾Æ·¡ ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù. Zoom µî ±âŸ ó¸® if(FPrintHeader == phYes) { if (!ColorChipPreview(Src, EditRepeat->IntValue, item, Area, s)) goto fail; } else { if (!Repeat_Method(r, Src, EditRepeat->IntValue, item, Area, s)) goto fail; } return true; fail: 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; // by embakum º¤ÅÍÇÁ¸°Æ® ¹Ì¸®º¸±â¿ë 080331 TUnionBitmap *SrcPAT1 = NULL; HDC dcDst; int countX, countY; if ((SrcPAT1 = new TUnionBitmap)==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; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->ExactCopy(MainImageForm->iMainImage->uBitmap); } } else { if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); if((tempBitmap = MainImageForm->iMainImage->Composition()) == NULL) goto fail; SrcPAT1->ExactCopy(tempBitmap); if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } } } countX = SrcPAT1->CountX; countY = SrcPAT1->CountY; if (MainImageForm->WorkArea->Mask) { for (int n = 0; n < countX * countY; n++) { dcDst = SrcPAT1->CreateDC(n); // VecDraw->ConvertRectToBitmap(dcDst, Src.left + SrcPAT1->uRect[0][n].left, Src.top + SrcPAT1->uRect[0][n].top , Src.left + SrcPAT1->uRect[0][n].right, Src.top + SrcPAT1->uRect[0][n].bottom); // SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } else { for( int n = 0; n < countX * countY; n ++) { dcDst = SrcPAT1->CreateDC(n); VecDraw->ConvertToBitmap(this, dcDst, false, SrcPAT1->uRect[0][n].left, SrcPAT1->uRect[0][n].top, n==countX*countY-1); SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } sx.cx = SrcPAT1->Width; sx.cy = SrcPAT1->Height; realWid = Panel->Width * sx.cx / Area.cx; realHei = Panel->Height * sx.cy / Area.cy; if ((Preview = new TTexpiaBitmap)==NULL) goto fail; if(cbFitSize->Checked){ Preview->Create(realWid*r.cx, realHei*r.cy, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); 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, Image->uBitmap->RGB); 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){ ViewImage->Width = realWid*r.cx*xxx/1000; ViewImage->Height = realHei*r.cy*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){ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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){ ViewImage->Width = realWid*r.cx*yyy/1000; ViewImage->Height = realHei*r.cy*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){ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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){ ViewImage->Width = WidthSize*WidthPage/PartNum; ViewImage->Height = HeightSize*HeightPage/PartNum; 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{ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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), Src.left, Src.top, (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); SrcPAT1->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){ ViewImage->Width = realWid*r.cx*xxx/1000; ViewImage->Height = realHei*r.cy*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){ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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){ ViewImage->Width = realWid*r.cx*yyy/1000; ViewImage->Height = realHei*r.cy*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){ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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){ ViewImage->Width = WidthSize*WidthPage/PartNum; ViewImage->Height = HeightSize*HeightPage/PartNum; 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{ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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), Src.left, Src.top,(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); SrcPAT1->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){ ViewImage->Width = realWid*r.cx*xxx/1000; ViewImage->Height = realHei*r.cy*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){ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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){ ViewImage->Width = realWid*r.cx*yyy/1000; ViewImage->Height = realHei*r.cy*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){ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; 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){ ViewImage->Width = WidthSize*WidthPage/PartNum; ViewImage->Height = HeightSize*HeightPage/PartNum; 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{ ViewImage->Width = realWid*r.cx; ViewImage->Height = realHei*r.cy; BitBlt(ViewImage->Canvas->Handle, 0, 0, realWid*r.cx, realHei*r.cy, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); } } ViewImage->Invalidate(); break; } if (SrcPAT) { delete SrcPAT; SrcPAT = NULL; } if (PreDC) Preview->DeleteDC(PreDC); if (Preview) { delete Preview; Preview = NULL; } // by embakum º¤ÅÍ ¹Ì¸®º¸±â 080331 if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = NULL; } return true; fail: if (SrcPAT) { delete SrcPAT; SrcPAT = NULL; } if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } if (PreDC) Preview->DeleteDC(PreDC); if (Preview) { delete Preview; Preview = NULL; } // by embakum º¤ÅÍ ¹Ì¸®º¸±â 080331 if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = 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); 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); 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(); } return; fail: MainImageForm->WorkArea->Mask->StopScanLine(); SrcPAT->StopScanLine(); } //---------------------------------------------------------------------------- bool __fastcall TTPrintForm::ColorChipPreview(TRect Src, int len, int item, TSize Area, TSize s) { int P, Dis; TRect Source, Dst, Srce; TSize sx, colorChipArea; int x, y, width, height, realWid, realHei, lenth; int realColorWid, realColorHei; HDC PreDC = NULL; TUnionBitmap *SrcPAT = NULL; TUnionBitmap *tempBitmap = NULL; TTexpiaBitmap *Preview = NULL; TPItemImage *Image = MainImageForm->iMainImage; TUnionBitmap *UsedColBit = NULL; // by embakum º¤ÅÍÇÁ¸°Æ® ¹Ì¸®º¸±â¿ë 080331 TUnionBitmap *SrcPAT1 = NULL; HDC dcDst; int countX, countY; int previewW, previewH; double Zoom = (double)EditZoom->IntValue / 100; if ((SrcPAT1 = new TUnionBitmap)==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; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->ExactCopy(MainImageForm->iMainImage->uBitmap); } } else { if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); if((tempBitmap = MainImageForm->iMainImage->Composition()) == NULL) goto fail; SrcPAT1->ExactCopy(tempBitmap); if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } } } countX = SrcPAT1->CountX; countY = SrcPAT1->CountY; if (MainImageForm->WorkArea->Mask) { for (int n = 0; n < countX * countY; n++) { dcDst = SrcPAT1->CreateDC(n); // VecDraw->ConvertRectToBitmap(dcDst, Src.left + SrcPAT1->uRect[0][n].left, Src.top + SrcPAT1->uRect[0][n].top , Src.left + SrcPAT1->uRect[0][n].right, Src.top + SrcPAT1->uRect[0][n].bottom); // SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } else { for( int n = 0; n < countX * countY; n ++) { dcDst = SrcPAT1->CreateDC(n); VecDraw->ConvertToBitmap(this, dcDst,false, SrcPAT1->uRect[0][n].left, SrcPAT1->uRect[0][n].top, n==countX*countY-1); SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } sx.cx = SrcPAT1->Width * Zoom; sx.cy = SrcPAT1->Height * Zoom; //PanelÅ©±â¿¡ »ó´ëÀûÀÎ À̹ÌÁö Å©±â ----------- realWid = (Panel->Width - 1) * sx.cx / Area.cx; realHei = (Panel->Height - 1) * sx.cy / Area.cy; //--------------------------------------------- if ((UsedColBit = new TUnionBitmap)==NULL) goto fail; MainImageForm->ComboHeaderUsedColorMethod(UsedColBit, true, NumEdColorZoom->Value, colorChipArea); if (colorChipArea.cy < 0) goto fail; //UsedColBit->Width´Â Print Page, dpi¿Í MainImage dpi¿Í °è»êµÈ »ó´ëÀûÀÎ °ªÀ¸·Î //print°¡ a4·Î ¼¼ÆÃµÇ¾î ÀÖÀ¸¸é a4 size¿¡ ¸Â°Ô °è»êµÈ´Ù. //PanelÅ©±â¿¡ »ó´ëÀûÀÎ Ä÷¯Ä¨ Å©±â ----------- realColorWid = (Panel->Width - 1) * UsedColBit->Width / Area.cx; realColorHei = (Panel->Height - 1) * UsedColBit->Height / Area.cx; //--------------------------------------------- if ((Preview = new TTexpiaBitmap)==NULL) goto fail; if (realWid < realColorWid) previewW = realColorWid; else previewW = realWid; previewH = realHei + realColorHei; if (UpDown1->Max == 1 && previewH > Panel->Height) { realColorHei = (Panel->Height - 1) - realHei; previewH = realHei + realColorHei; } Preview->Create(previewW, previewH, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); if ((PreDC = Preview->CreateDC()) == NULL) goto fail; Preview->FillRect(Rect(0,0,previewW, previewH), clWhite); SetStretchBltMode(PreDC,HALFTONE); //À̹ÌÁö Dst.Top = 0; Dst.Bottom = Dst.Top+realHei; Dst.Left = 0; Dst.Right = Dst.Left+realWid; SrcPAT1->UnionStretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top),0,0,width,height,SRCCOPY); //Ä÷¯Ä¨ Dst.Top = realHei; Dst.Bottom = Dst.Top+realColorHei; Dst.Left = 0; Dst.Right = Dst.Left+realColorWid; UsedColBit->UnionStretchBlt(PreDC, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top),0,0,UsedColBit->Width,UsedColBit->Height,SRCCOPY); if(cbFitSize->Checked){ int xxx = WidthSize*1000 / previewW; int yyy = HeightSize*1000 / previewH; if (xxx < yyy) { if (xxx < 1000){ ViewImage->Width = previewW * xxx / 1000; ViewImage->Height = previewH * xxx / 1000; SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, previewW*xxx/1000, previewH*xxx/1000, PreDC,0,0,previewW ,previewH ,SRCCOPY); RrealWid = previewW * xxx / 1000; RrealHei = previewH * xxx / 1000; }else if(xxx >= 1000){ ViewImage->Width = previewW; ViewImage->Height = previewH; BitBlt(ViewImage->Canvas->Handle, 0, 0, previewW, previewH, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); RrealWid = previewW; RrealHei = previewH; } } else { if (yyy < 1000){ ViewImage->Width = previewW * yyy / 1000; ViewImage->Height = previewH * yyy / 1000; SetStretchBltMode(ViewImage->Canvas->Handle,COLORONCOLOR); StretchBlt(ViewImage->Canvas->Handle, 0, 0, previewW*yyy/1000, previewH*yyy/1000, PreDC,0,0,previewW ,previewH ,SRCCOPY); RrealWid = previewW*yyy/1000; RrealHei = previewH*yyy/1000; }else if(yyy >= 1000){ ViewImage->Width = previewW; ViewImage->Height = previewH; BitBlt(ViewImage->Canvas->Handle, 0, 0, previewW, previewH, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); RrealWid = previewW; RrealHei = previewH; } } } else { if(Allpart){ ViewImage->Width = WidthSize*WidthPage/PartNum; ViewImage->Height = HeightSize*HeightPage/PartNum; 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{ ViewImage->Width = previewW; ViewImage->Height = previewH; BitBlt(ViewImage->Canvas->Handle, 0, 0, previewW, previewH, PreDC, WidthNUM*WidthSize, HeightNUM*HeightSize, SRCCOPY); } } ViewImage->Invalidate(); if (UsedColBit) { delete UsedColBit; UsedColBit = NULL; } if (SrcPAT) { delete SrcPAT; SrcPAT = NULL; } if (PreDC) Preview->DeleteDC(PreDC); if (Preview) { delete Preview; Preview = NULL; } // by embakum º¤ÅÍ ¹Ì¸®º¸±â 080331 if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = NULL; } return true; fail: if (UsedColBit) { delete UsedColBit; UsedColBit = NULL; } if (SrcPAT) { delete SrcPAT; SrcPAT = NULL; } if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } if (PreDC) Preview->DeleteDC(PreDC); if (Preview) { delete Preview; Preview = NULL; } // by embakum º¤ÅÍ ¹Ì¸®º¸±â 080331 if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = NULL; } return false; } //---------------------------------------------------------------------------- void __fastcall TTPrintForm::UpDown1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (UpDown1->Max == 1) return; int NUM, total; ViewImage->Picture = NULL; ViewImage->Invalidate(); NUM = StrToInt(PageNUM->Text); /* if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { total = HeightPage * WidthPage; RPageNUM->Text = PageNUM->Text + "/" + IntToStr(total); HeightNUM=-1; WidthNUM=-1; for(int i=0; i < HeightPage;i++){ HeightNUM += 1; WidthNUM=-1; for(int j=0; j < WidthPage;j++){ WidthNUM += 1; NUM -=1; if(NUM == 0){ CBHeaderNoMethod(); return; } } } } else {*/ total = PageNum.cx * PageNum.cy; RPageNUM->Text = PageNUM->Text + "/" + IntToStr(total); Preview(); //} } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::AllpartsClick(TObject *Sender) { if (!Allpart && UpDown1->Max == 1) return; Allpart = !Allpart; Graphics::TBitmap *bitmap = new Graphics::TBitmap; if(Allpart){ ImageList->GetBitmap(0, bitmap); } else { ImageList->GetBitmap(1, bitmap); } Allparts->Glyph->Assign(bitmap); delete bitmap; if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { if(Allpart){ cbCurrentPage->Enabled = false; ViewImage->Top = 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 { cbCurrentPage->Enabled = true; UpDown1->Enabled=true; HeightNUM = backupWid; WidthNUM = backupHei; } ViewImage->Picture = NULL; ViewImage->Invalidate(); CBHeaderNoMethod(); } else { Preview(); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (UpDown1->Max == 1) return; int NUM, total; if(Key == VK_PRIOR){ //PageUp ViewImage->Picture = NULL; ViewImage->Invalidate(); NUM = StrToInt(PageNUM->Text)+1; UpDown1->Position = NUM; total = PageNum.cx * PageNum.cy; RPageNUM->Text = IntToStr(NUM) + "/" + IntToStr(total); Preview(); } else if(Key == VK_NEXT){ //PageDown ViewImage->Picture = NULL; ViewImage->Invalidate(); NUM = StrToInt(PageNUM->Text)-1; UpDown1->Position = NUM; total = PageNum.cx * PageNum.cy; RPageNUM->Text = IntToStr(NUM) + "/" + IntToStr(total); Preview(); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::cbFitSizeClick(TObject *Sender) { SWView(); if (!View->Checked) return; if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { CBHeaderNoMethod(); } else { Preview(); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::CheckRGBClick(TObject *Sender) { if(CheckRGB->Checked == true)MainImageForm->RGBnum = true; else MainImageForm->RGBnum = false; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::EditorSelectAll(TObject *Sender) { SetFocusAndSelectAll(Sender); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::NumEdColorZoomChange(TObject *Sender) { if (NumEdColorZoom->Value == tbColorZoom->Position) return; if(NumEdColorZoom->Value < 10)return; // Blankµµ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ - by monkman (2010.07.20) // if(NumEdColorZoom->Value < 0)return; if (!SWView()) { NumEdColorZoom->Value = 100; } tbColorZoom->Position = NumEdColorZoom->Value; if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { CBHeaderNoMethod(); } else { Preview(); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::NumEdColorZoomExit(TObject *Sender) { // Blankµµ ÀÔ·Â °¡´ÉÇϳª, Edit¸¦ ¹þ¾î³¯ ¶§ 0ÀÌÇÏÀÏ °æ¿ì BlankValue·Î ÀÔ·Â - by monkman (2010.07.20) if (NumEdColorZoom->Value <= 0) NumEdColorZoom->Value = NumEdColorZoom->BlankValue; NumEdColorZoom->Text = IntToStr(NumEdColorZoom->IntValue); } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::tbColorZoomMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (NumEdColorZoom->Value == tbColorZoom->Position) return; NumEdColorZoom->Value = tbColorZoom->Position; //bool bView = View->Checked; // Blankµµ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ - by monkman (2010.07.20) if(NumEdColorZoom->Value < 0)return; SWView(); if (!View->Checked) return; if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { RPageNUM->Text = Format("%d/%d", OPENARRAY(TVarRec, (1, 1))); CBHeaderNoMethod(); } else { Preview(); } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::NumEdColorZoomKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_RETURN) { //bool bView = View->Checked; // Blankµµ ÀÔ·ÂÇÒ ¼ö ÀÖµµ·Ï º¯°æ - by monkman (2010.07.20) if(NumEdColorZoom->Value < 0)return; if (!SWView()) { NumEdColorZoom->Value = 100; } if (!View->Checked) return; if (UpDown1->Max == 1) {// && FPrintHeader != phYes) { CBHeaderNoMethod(); } else { Preview(); } } } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::InitVariables(TUnionBitmap *Pattern) { HDC hPrintDC, PreDC; int w, h, Gap = 3; TRect Src, Dst; TSize repeat, colorChipArea; int width, height; int RealPatternW, RealPatternH; TPItemImage *Image = MainImageForm->iMainImage; double Zoom = (double)EditZoom->IntValue / 100; int DPI = MainImageForm->CanvasInfor.DotsPerInch; hPrintDC = Printer()->Handle; PaperSize.cx = GetDeviceCaps(hPrintDC, PHYSICALWIDTH) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSX); PaperSize.cy = GetDeviceCaps(hPrintDC, PHYSICALHEIGHT) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSY); PrintableSize.cx = GetDeviceCaps(hPrintDC, HORZRES) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSX); PrintableSize.cy = GetDeviceCaps(hPrintDC, VERTRES) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSY); OffSet.cx = GetDeviceCaps(hPrintDC, PHYSICALOFFSETX) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSX); OffSet.cy = GetDeviceCaps(hPrintDC, PHYSICALOFFSETY) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSY); ///////////////////////////////////////////////////////////// repeat.cx = StrToInt(SpinEditRepeatX->Text); repeat.cy = StrToInt(SpinEditRepeatY->Text); if (MainImageForm->iMainImage->LayerList->Count <= 1) { 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; } } else { 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; } } RealPatternW = width * Zoom * repeat.cx; RealPatternH = height * Zoom * repeat.cy; ///////////////////////////////////////////////////////////// //Color chip size Æ÷ÇÔÇØ¼­ °è»êµÇ´Â ºÎºÐ if(FPrintHeader == phYes) { colorChipArea.cx = 0; colorChipArea.cy = 0; MainImageForm->ComboHeaderUsedColorMethod(NULL, true, NumEdColorZoom->Value, colorChipArea); if (colorChipArea.cy > 0) { //UsedColBit->Width´Â Print Page, dpi¿Í MainImage dpi¿Í °è»êµÈ »ó´ëÀûÀÎ °ªÀ¸·Î //print°¡ a4·Î ¼¼ÆÃµÇ¾î ÀÖÀ¸¸é a4 size¿¡ ¸Â°Ô °è»êµÈ´Ù. if (RealPatternW < colorChipArea.cx) RealPatternW = colorChipArea.cx; RealPatternH = RealPatternH + colorChipArea.cy; } } ///////////////////////////////////////////////////////////// PageNum.cx = ((RealPatternW - 1) / PrintableSize.cx) + 1; PageNum.cy = ((RealPatternH - 1) / PrintableSize.cy) + 1; if(cbFitSize->Checked){ PageNum.cx = 1; PageNum.cy = 1; } w = (Panel->ClientWidth - 3*Gap) / PageNum.cx - Gap; h = (Panel->ClientHeight - 3*Gap) / PageNum.cy - Gap; if ((double)w/PaperSize.cx > (double)h/PaperSize.cy) ZoomRatio_All = (double)h/PaperSize.cy; else ZoomRatio_All = (double)w/PaperSize.cx; w = (Panel->ClientWidth - 3*Gap) - Gap; h = (Panel->ClientHeight - 3*Gap) - Gap; if ((double)w/PaperSize.cx > (double)h/PaperSize.cy) ZoomRatio_1 = (double)h/PaperSize.cy; else ZoomRatio_1 = (double)w/PaperSize.cx; if (Allpart) { ViewImage->Width = Gap + PageNum.cx*(ZoomRatio_All*PaperSize.cx + Gap) + 1; ViewImage->Height = Gap + PageNum.cy*(ZoomRatio_All*PaperSize.cy + Gap) + 1; ViewImage->Left = (Panel->ClientWidth - ViewImage->Width)/2; ViewImage->Top = (Panel->ClientHeight - ViewImage->Height)/2; } else { ViewImage->Width = Gap + (ZoomRatio_1*PaperSize.cx + Gap) + 1; ViewImage->Height = Gap + (ZoomRatio_1*PaperSize.cy + Gap) + 1; ViewImage->Left = (Panel->ClientWidth - ViewImage->Width)/2; ViewImage->Top = (Panel->ClientHeight - ViewImage->Height)/2; } return; } //--------------------------------------------------------------------------- void __fastcall TTPrintForm::PutViewImage(TUnionBitmap *Pattern, TCanvas *DstCanvas) { int x, y, w, h, Gap = 3, updown = UpDown1->Position; TRect Src, Dst; RGBQUAD Btrgb[256]; ViewImage->Canvas->Brush->Color = clBtnFace;//clWhite; ViewImage->Canvas->FillRect(TRect(0,0,ViewImage->Width,ViewImage->Height)); if (Allpart) { ViewImage->Width = Gap + PageNum.cx*(ZoomRatio_All*PaperSize.cx + Gap) + 1; ViewImage->Height = Gap + PageNum.cy*(ZoomRatio_All*PaperSize.cy + Gap) + 1; ViewImage->Left = (Panel->ClientWidth - ViewImage->Width)/2; ViewImage->Top = (Panel->ClientHeight - ViewImage->Height)/2; SetStretchBltMode(ViewImage->Canvas->Handle,HALFTONE); for (x = 0; x < PageNum.cx; x++) { for (y = 0; y< PageNum.cy; y++) { Src.Left = x * PrintableSize.cx * ZoomRatio_All; Src.Right = Src.Left + PrintableSize.cx * ZoomRatio_All; Src.Top = y * PrintableSize.cy * ZoomRatio_All; Src.Bottom = Src.Top + PrintableSize.cy * ZoomRatio_All; Dst.Left = Gap*(1+x) + ZoomRatio_All * (x*PaperSize.cx + OffSet.cx); Dst.Right = Gap*(1+x) + ZoomRatio_All * ((x+1)*PaperSize.cx - OffSet.cx); Dst.Top = Gap*(1+y) + ZoomRatio_All * (y*PaperSize.cy + OffSet.cy); Dst.Bottom = Gap*(1+y) + ZoomRatio_All * ((y+1)*PaperSize.cy - OffSet.cy); if (Src.Right>Pattern->Width) { Src.Right = Pattern->Width; //Dst.Right = Gap*(1+x) + ZoomRatio_All * ((2*x+1)*OffSet.cx + Src.Right); Dst.Right = Gap*(1+x) + ZoomRatio_All * ((2*x+1)*OffSet.cx) + Src.Right; } if (Src.Bottom>Pattern->Height) { Src.Bottom = Pattern->Height; //Dst.Bottom = Gap*(1+y) + ZoomRatio_All * ((2*y+1)*OffSet.cy + Src.Bottom); Dst.Bottom = Gap*(1+y) + ZoomRatio_All * ((2*y+1)*OffSet.cy) + Src.Bottom; } Pattern->UnionStretchBlt(ViewImage->Canvas->Handle, Dst.Left, Dst.Top, Dst.Width(), Dst.Height(), Src.Left,Src.Top,Src.Width(),Src.Height(), SRCCOPY); Dst.Left = Gap*(1+x) + ZoomRatio_All * (x*PaperSize.cx); Dst.Right = Gap*(1+x) + ZoomRatio_All * ((x+1)*PaperSize.cx); Dst.Top = Gap*(1+y) + ZoomRatio_All * (y*PaperSize.cy); Dst.Bottom = Gap*(1+y) + ZoomRatio_All * ((y+1)*PaperSize.cy); eBox(Dst); } } } else { ViewImage->Width = Gap + (ZoomRatio_1*PaperSize.cx + Gap) + 1; ViewImage->Height = Gap + (ZoomRatio_1*PaperSize.cy + Gap) + 1; ViewImage->Left = (Panel->ClientWidth - ViewImage->Width)/2; ViewImage->Top = (Panel->ClientHeight - ViewImage->Height)/2; SetStretchBltMode(ViewImage->Canvas->Handle,HALFTONE); x = (updown-1) % PageNum.cx; y = (updown-1) / PageNum.cx; Src.Left = x * PrintableSize.cx * ZoomRatio_1; Src.Right = Src.Left + PrintableSize.cx * ZoomRatio_1; Src.Top = y * PrintableSize.cy * ZoomRatio_1; Src.Bottom = Src.Top + PrintableSize.cy * ZoomRatio_1; Dst.Left = Gap + ZoomRatio_1 * (OffSet.cx); Dst.Right = Gap + ZoomRatio_1 * (PaperSize.cx - OffSet.cx); Dst.Top = Gap + ZoomRatio_1 * (OffSet.cy); Dst.Bottom = Gap + ZoomRatio_1 * (PaperSize.cy - OffSet.cy); if (Src.Right>Pattern->Width) { Src.Right = Pattern->Width; //Dst.Right = Gap + ZoomRatio_1 * (OffSet.cx + Pattern->Width - Src.Left); Dst.Right = Gap + ZoomRatio_1 * OffSet.cx + Pattern->Width - Src.Left; } if (Src.Bottom>Pattern->Height) { Src.Bottom = Pattern->Height; //Dst.Bottom = Gap + ZoomRatio_1 * (OffSet.cy + Pattern->Height - Src.Top); Dst.Bottom = Gap + ZoomRatio_1 * OffSet.cy + Pattern->Height - Src.Top; } Pattern->UnionStretchBlt(ViewImage->Canvas->Handle, Dst.Left, Dst.Top, Dst.Width(), Dst.Height(), Src.Left,Src.Top,Src.Width(),Src.Height(), SRCCOPY); Dst.Left = Gap; Dst.Right = Gap + ZoomRatio_1 * (PaperSize.cx); Dst.Top = Gap; Dst.Bottom = Gap + ZoomRatio_1 * (PaperSize.cy); eBox(Dst); } return; } //--------------------------------------------------------------------------- bool __fastcall TTPrintForm::MakeRepeatImage(TUnionBitmap *Pattern, int item) { HDC dcDst; TSize repeat; int countX, countY; int x, y, width, height; int P, Dis, RepeatPoz; TRect Src, Dst; int ZoomedW, ZoomedH, ZoomedDis; TUnionBitmap *tempBitmap = NULL; // convert by celberus TPItemImage *Image = MainImageForm->iMainImage; TUnionBitmap *SrcPAT1 = NULL; repeat.cx = StrToInt(SpinEditRepeatX->Text); repeat.cy = StrToInt(SpinEditRepeatY->Text); RepeatPoz = EditRepeat->IntValue; double Zoom = (double)EditZoom->IntValue / 100; if ((SrcPAT1 = new TUnionBitmap)==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; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->ExactCopy(MainImageForm->iMainImage->uBitmap); } } else { if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = Src.Right - Src.Left; height = Src.Bottom - Src.Top; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); if((tempBitmap = MainImageForm->iMainImage->Composition()) == NULL) goto fail; SrcPAT1->ExactCopy(tempBitmap); if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } } } countX = SrcPAT1->CountX; countY = SrcPAT1->CountY; if (MainImageForm->WorkArea->Mask) { for (int n = 0; n < countX * countY; n++) { dcDst = SrcPAT1->CreateDC(n); VecDraw->ConvertRectToBitmap(dcDst, Src.left + SrcPAT1->uRect[0][n].left, Src.top + SrcPAT1->uRect[0][n].top , Src.left + SrcPAT1->uRect[0][n].right, Src.top + SrcPAT1->uRect[0][n].bottom); // SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } else { for( int n = 0; n < countX * countY; n ++) { dcDst = SrcPAT1->CreateDC(n); VecDraw->ConvertToBitmap(this, dcDst,false, SrcPAT1->uRect[0][n].left, SrcPAT1->uRect[0][n].top, n==countX*countY-1); SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } if (Allpart) { ZoomedW = width * Zoom * ZoomRatio_All; ZoomedH = height * Zoom * ZoomRatio_All; } else { ZoomedW = width * Zoom * ZoomRatio_1; ZoomedH = height * Zoom * ZoomRatio_1; } Pattern->Create(ZoomedW * repeat.cx, ZoomedH * repeat.cy, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB);//24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); switch (item) {// 0: Normal, 1: Half Drop Horizontal, 2: Half Drop Vertical case 0: for (y = 0; y < repeat.cy; y++) { Dst.Top = y * ZoomedH; Dst.Bottom = Dst.Top + ZoomedH; for (x = 0; x < repeat.cx; x++) { Dst.Left = x * ZoomedW; Dst.Right = Dst.Left + ZoomedW; Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), SrcPAT1, 0, 0, width, height, SRCCOPY); } } break; case 1: for (y=0; y < repeat.cy; y++) { Dst.Top = y * ZoomedH; Dst.Bottom = Dst.Top + ZoomedH; for (x=0; x < repeat.cx; x++) { Src.Left = 0; Src.Top =0; Src.Right = width; Src.Bottom = height; if (x==0){ Dst.Left = 0; if (y==0) Dst.Right = ZoomedW; else { Dis = (y * RepeatPoz)%width; if (Allpart) ZoomedDis = Dis * ZoomRatio_All; else ZoomedDis = Dis * ZoomRatio_1; if(Dis!=0){ Dst.Right = (ZoomedW*ZoomedDis)/ZoomedW; Src.Left = width - Dis; P = Src.Left; } else Dst.Right = ZoomedW; Src.Right = width; } } else { Dst.Left = Dst.Right; Dst.Right = Dst.Left + ZoomedW; } Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), SrcPAT1, Src.left, Src.top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); } if (Dst.Right < ZoomedW * repeat.cx) { Dst.Left = Dst.Right; Dst.Right = ZoomedW * repeat.cx; Src.Left = 0; Src.Right = P; Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), SrcPAT1, Src.left, Src.top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); } } break; case 2: for (x=0; x < repeat.cx; x++) { Dst.Left = x * ZoomedW; Dst.Right = Dst.Left + ZoomedW; for (y=0; y < repeat.cy; y++) { Src.Left = 0; Src.Top =0; Src.Right = width; Src.Bottom = height; if (y==0){ Dst.Top = 0; if (x==0) Dst.Bottom = ZoomedH; else { Dis = (x * RepeatPoz)%height; if (Allpart) ZoomedDis = Dis * ZoomRatio_All; else ZoomedDis = Dis * ZoomRatio_1; if(Dis!=0){ Dst.Bottom = (ZoomedH*ZoomedDis)/ZoomedH; Src.Top = height - Dis; P = Src.Top; } else Dst.Bottom = ZoomedH; Src.Bottom = height; } } else { Dst.Top = Dst.Bottom; Dst.Bottom = Dst.Top+ZoomedH; } Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), SrcPAT1, Src.left, Src.top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); } if (Dst.Bottom < ZoomedH * repeat.cy) { Dst.Top = Dst.Bottom; Dst.Bottom = ZoomedH * repeat.cy; Src.Top = 0; Src.Bottom = P; Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), SrcPAT1, Src.left, Src.top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); } } break; } // by embakum º¤ÅÍ ¹Ì¸®º¸±â 080331 if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = NULL; } return true; fail: if (tempBitmap) { delete tempBitmap; tempBitmap = NULL; } // by embakum º¤ÅÍ ¹Ì¸®º¸±â 080331 if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = NULL; } return false; } //---------------------------------------------------------------------------- bool __fastcall TTPrintForm::MakeColorChipPreview(TUnionBitmap *Pattern) { TRect Src, Dst; int x, y, width, height, lenth; int realColorWid, realColorHei; TUnionBitmap *tempBitmap = NULL; TPItemImage *Image = MainImageForm->iMainImage; TUnionBitmap *UsedColBit = NULL; // by embakum º¤ÅÍÇÁ¸°Æ® ¹Ì¸®º¸±â¿ë 080331 TUnionBitmap *SrcPAT1 = NULL; HDC dcDst; int countX, countY, ColorChipW, ColorChipH; int previewW, previewH, tempH; int ZoomedW, ZoomedH; HDC hPrintDC = Printer()->Handle; double Zoom = (double)EditZoom->IntValue / 100; TSize colorChipArea; int DPI = MainImageForm->CanvasInfor.DotsPerInch; if ((SrcPAT1 = new TUnionBitmap)==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; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->ExactCopy(MainImageForm->iMainImage->uBitmap); } } else { if (MainImageForm->WorkArea->Mask) { Src = MainImageForm->WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); SrcPAT1->Copy(0, 0, Src.Right - Src.Left, Src.Bottom - Src.Top, MainImageForm->iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // by celberus AreaIrregularrect(SrcPAT1); } else { width = MainImageForm->iMainImage->uBitmap->Width; height = MainImageForm->iMainImage->uBitmap->Height; SrcPAT1->Create(width, height, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB); if((tempBitmap = MainImageForm->iMainImage->Composition()) == NULL) goto fail; SrcPAT1->ExactCopy(tempBitmap); if(tempBitmap) { delete tempBitmap; tempBitmap = NULL; } } } countX = SrcPAT1->CountX; countY = SrcPAT1->CountY; if (MainImageForm->WorkArea->Mask) { for (int n = 0; n < countX * countY; n++) { dcDst = SrcPAT1->CreateDC(n); // VecDraw->ConvertRectToBitmap(dcDst, Src.left + SrcPAT1->uRect[0][n].left, Src.top + SrcPAT1->uRect[0][n].top , Src.left + SrcPAT1->uRect[0][n].right, Src.top + SrcPAT1->uRect[0][n].bottom); // SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } else { for( int n = 0; n < countX * countY; n ++) { dcDst = SrcPAT1->CreateDC(n); VecDraw->ConvertToBitmap(this, dcDst, false, SrcPAT1->uRect[0][n].left, SrcPAT1->uRect[0][n].top, n==countX*countY-1); SrcPAT1->Table[0][n].modify = true; SrcPAT1->Table[0][n].isZoomUpdated = false; SrcPAT1->Table[0][n].blank = false; SrcPAT1->DeleteDC(dcDst, n); dcDst = NULL; } } if ((UsedColBit = new TUnionBitmap)==NULL) goto fail; MainImageForm->ComboHeaderUsedColorMethod(UsedColBit, true, NumEdColorZoom->Value, colorChipArea); if (colorChipArea.cy < 0) goto fail; //UsedColBit->Width´Â Print Page, dpi¿Í MainImage dpi¿Í °è»êµÈ »ó´ëÀûÀÎ °ªÀ¸·Î //print°¡ a4·Î ¼¼ÆÃµÇ¾î ÀÖÀ¸¸é a4 size¿¡ ¸Â°Ô °è»êµÈ´Ù. PaperSize.cx = GetDeviceCaps(hPrintDC, PHYSICALWIDTH) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSX); PaperSize.cy = GetDeviceCaps(hPrintDC, PHYSICALHEIGHT) * DPI / GetDeviceCaps(hPrintDC, LOGPIXELSY); ColorChipW = UsedColBit->Width; ColorChipH = UsedColBit->Height; ZoomedW = SrcPAT1->Width * Zoom; ZoomedH = SrcPAT1->Height * Zoom; //tempH = PaperSize.cy * ((SrcPAT1->Height / PaperSize.cy) + 1); //if (SrcPAT1->Height < tempH * 0.8) tempH = SrcPAT1->Height; if (ZoomedW < ColorChipW) previewW = ColorChipW; else previewW = ZoomedW; previewH = ZoomedH + ColorChipH; if (Allpart) { previewW = previewW * ZoomRatio_All; previewH = previewH * ZoomRatio_All; ZoomedW *= ZoomRatio_All; ZoomedH *= ZoomRatio_All; ColorChipW *= ZoomRatio_All; ColorChipH *= ZoomRatio_All; } else { previewW = previewW * ZoomRatio_1; previewH = previewH * ZoomRatio_1; ZoomedW *= ZoomRatio_1; ZoomedH *= ZoomRatio_1; ColorChipW *= ZoomRatio_1; ColorChipH *= ZoomRatio_1; } Pattern->Create(previewW, previewH, Image->uBitmap->BitsPerPixel, Image->uBitmap->RGB);//24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); Pattern->UnionStretchBlt(0, 0, ZoomedW, ZoomedH, SrcPAT1, 0, 0, SrcPAT1->Width, SrcPAT1->Height, SRCCOPY); Pattern->UnionStretchBlt(0, ZoomedH , ColorChipW, ColorChipH, UsedColBit, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); if (UsedColBit) { delete UsedColBit; UsedColBit = NULL; } if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = NULL; } return true; fail: if (UsedColBit) { delete UsedColBit; UsedColBit = NULL; } if (SrcPAT1) { delete SrcPAT1; SrcPAT1 = NULL; } return false; } //----------------------------------------------------------------------------