//--------------------------------------------------------------------------- #include #pragma hdrstop #include "LogData.h" #include "Combo_F.h" #include "ComboForm.h" #include "FileManager_F.h" #include "Main.h" #include "MainImage.h" #include "Palette.h" #include "Undo.h" #include "CommonPrint.h" #include "UserColor_F.h" #include "FullView.h" #include "NewColorWay_F.h" #include "ComboPrint_F.h" #include "define.h" #include "MainMenu.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "Selector" #pragma link "RzEdit" #pragma link "RzSpnEdt" #pragma link "RzButton" #pragma link "RzBckgnd" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_COMBOMENU StringTable[0] #define IDS_CHANGECOLOR StringTable[1] #define IDS_HUELIGSAT StringTable[2] #define IDS_HUE StringTable[3] #define IDS_LIGHTNESS StringTable[4] #define IDS_SATURATION StringTable[5] #define IDS_COMBO1 StringTable[6] #define IDS_COMBO2 StringTable[7] #define IDS_MSGBOX1 StringTable[8] //You need to select any image which you want to print! //--------------------------------------------------------------------------- TComboMenu *ComboMenu; //--------------------------------------------------------------------------- __fastcall TComboMenu::TComboMenu(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *) Owner)->Handle; //====================================================== StringTable.Create(DirectoryItem, Language, "Combo"); SetSmallFont(Font); Caption = IDS_COMBOMENU; // sbChange->Caption = IDS_CHANGECOLOR; // sbFile->Caption = IDS_COMMON_FILE; // sbHue->Caption = IDS_HUELIGSAT; // sbPrint->Caption = IDS_COMMON_PRINT; sbChange->Hint = IDS_CHANGECOLOR; sbFile->Hint = IDS_COMMON_FILE; sbHue->Hint = IDS_HUELIGSAT; sbPrint->Hint = IDS_COMMON_PRINT; // Label1->Caption = IDS_HUE; // Label2->Caption = IDS_LIGHTNESS; // Label3->Caption = IDS_SATURATION; rzbitbtnRun->Caption = IDS_COMMON_RUN; rzbitbtnExit->Caption = IDS_COMMON_EXIT; sbComboNew->Hint = IDS_COMMON_NEW; sbComboAll->Hint = IDS_COMMON_ALL; sbComboDelete->Hint = IDS_COMMON_INSERTCOLOR; sbComboBlock->Hint = IDS_COMMON_BLOCKCOLOR; sbBefore->Hint = IDS_COMMON_BEFORECOLOR; rzbitbtnOld->Caption = IDS_COMBO1; rzbitbtnNew->Caption = IDS_COMBO2; //====================================================== isLoad= false; useCombo = false; useNewCombo = false; isprinting = false; CancelExit = false; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::sbComboNewClick(TObject *Sender) { BEGIN_LOG("Combo_F"); int i, m, k; TSpeedButton *s = (TSpeedButton *) Sender; if (SubForm) { if (s == sbComboNew) { Selector->Initial(); for (m=0; m<=3; m++) { for (k=0; k<36; k++) { if(SubForm->Selector[m]->ComboShape[k]->Selected) SubForm->Selector[m]->ShapeDown(k+1); } } } else if (s == sbComboAll) { TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; for (i=0; iSelector[SubForm->page]->ChoiceColor->Count; i++) { Selector->ChoiceColor->Add(SubForm->Selector[SubForm->page]->Palette, SubForm->Selector[SubForm->page]->ChoiceColor->Code[i]); } Selector->Invalid(); FromSelector2comboSelector(); Screen->Cursor = cursor; } SubForm->SetData(); } else { if (s == sbComboNew) { Selector->Initial(); NewColorWayForm->ChangeColorChipShapeBySeletor1(false); } else if (s == sbComboAll) { TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; Selector->SetPalette(NewColorWayForm->Palette); for (i=0; iChoiceColor->Count; i++) { Selector->ChoiceColor->Add(NewColorWayForm->Palette, NewColorWayForm->ChoiceColor->Code[i]); } Selector->Invalid(); NewColorWayForm->ChangeColorChipShapeBySeletor1(true); Screen->Cursor = cursor; } } if (s == sbComboBlock) { if (sbComboBlock->Down) sbComboBlock->Hint = IDS_COMMON_ONECOLOR; else sbComboBlock->Hint = IDS_COMMON_BLOCKCOLOR; } else if (s == sbComboDelete) { if (sbComboDelete->Down) sbComboDelete->Hint = IDS_COMMON_DELETECOLOR; else sbComboDelete->Hint = IDS_COMMON_INSERTCOLOR; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::FromSelector2comboSelector() { BEGIN_LOG("Combo_F"); int cnt = Selector->Count; if (cnt>12) cnt = 13; for (int i=0; iChoiceColor->Code[i] == SubForm->ChoiceColor->Code[j]) { if (!SubForm->Selector[0]->ComboShape[j]->Selected) { for (int k=0; k<=3; k++) SubForm->Selector[k]->ShapeDown(j+1); break; } } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::comboseHueChange(TObject *Sender) { BEGIN_LOG("Combo_F"); if (comboseHue->Text.Length()>0) { if (bHS) CDrawHSBar(Hue, Sat); if (bL) CDrawLBar(Lig); CDrawL(); Hue = comboseHue->Value; CDrawHSBar(Hue, Sat); bHS = true; CDrawLBar(Lig); bL = true; CRunHLS(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::comboseHueClick(TObject *Sender) { TRzSpinEdit *sedit = (TRzSpinEdit *)Sender; sedit->SelectAll(); sedit->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TComboMenu::comboseLigChange(TObject *Sender) { BEGIN_LOG("Combo_F"); if (comboseLig->Text.Length()>0) { if (bL) CDrawLBar(Lig); Lig = comboseLig->Value; CDrawLBar(Lig); bL = true; CRunHLS(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::comboseSatChange(TObject *Sender) { BEGIN_LOG("Combo_F"); if (comboseSat->Text.Length()>0) { if (bHS) CDrawHSBar(Hue, Sat); Sat = comboseSat->Value; CDrawHSBar(Hue, Sat); bHS = true; CRunHLS(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ComboImageHSMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { mouseSw = true; if (Shift.Contains(ssLeft)) CMoveHS(X, Y); } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ComboImageLMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { mouseSw = true; if (Shift.Contains(ssLeft)) CMoveL(Y); } //--------------------------------------------------------------------------- void __fastcall TComboMenu::sbHueClick(TObject *Sender) { BEGIN_LOG("Combo_F"); int i, j, k; TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (SubForm) { if (SubForm->step > 0){ SubForm->DrawRectangle(Sender, SubForm->Temp); SubForm->step = 0; SubForm->Repaint(); } for (i=0; i<4; i++) SubForm->rotate.fix[i] = 0; SubForm->SpeedButton1->Font->Color = clBlack; SubForm->SpeedButton1->Caption = String(SubForm->SpeedButton1->Tag + 1); SubForm->SpeedButton1->Down = false; SubForm->SpeedButton2->Font->Color = clBlack; SubForm->SpeedButton2->Caption = String(SubForm->SpeedButton2->Tag + 1); SubForm->SpeedButton2->Down = false; SubForm->SpeedButton3->Font->Color = clBlack; SubForm->SpeedButton3->Caption = String(SubForm->SpeedButton3->Tag + 1); SubForm->SpeedButton3->Down = false; SubForm->SpeedButton4->Font->Color = clBlack; SubForm->SpeedButton4->Caption = String(SubForm->SpeedButton4->Tag + 1); SubForm->SpeedButton4->Down = false; SubForm->rotate.fix_cnt = 0; Selector->Initial(); SubForm->SetData(); SubForm->CanVisible(0); for (i=0; iSelector[SubForm->page]->ChoiceColor->Count; i++) { Selector->ChoiceColor->Add(SubForm->Selector[SubForm->page]->Palette, SubForm->Selector[SubForm->page]->ChoiceColor->Code[i]); } for (j=0; j<36; j++) { if (SubForm->Selector[0]->ComboShape[j]->Selected) for (k=0; k<=3; k++) SubForm->Selector[k]->ShapeDown(j+1); } Selector->Invalid(); if (!SubForm->Visible) SubForm->Visible = true; } else { Selector->Initial(); Selector->SetPalette(NewColorWayForm->Palette); Selector->Invalid(); NewColorWayForm->ChangeColorChipShapeBySeletor1(false); // 05.08.17 /* for (i=0; iChoiceColor->Count; i++) { Selector->ChoiceColor->Add(NewColorWayForm->Palette, NewColorWayForm->ChoiceColor->Code[i]); } Selector->Invalid(); */ } rzbitbtnRun->Enabled = true; Screen->Cursor = cursor; //Shape1->Pen->Color = clBtnShadow; //if(Shape2->Pen->Color == clRed) Shape2->Pen->Color = clBtnShadow; //se if (Shape2->Pen->Color == clBtnShadow) Shape2->Pen->Color = clRed; //Shape1->Visible = false; //if(Shape2->Visible) Shape2->Visible = false; //else if (!Shape2->Visible) Shape2->Visible = true; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::sbChangeClick(TObject *Sender) { BEGIN_LOG("Combo_F"); if (SubForm && SubForm->step > 0){ SubForm->DrawRectangle(Sender, SubForm->Temp); SubForm->step = 0; SubForm->Repaint(); } ChangePanel->Visible = true; HuePanel->Visible = false; if(BasicPalette) { delete BasicPalette; BasicPalette = NULL;} Selector->Initial(); if (SubForm) { for (int j=0; j<36; j++) { if (SubForm->Selector[0]->ComboShape[j]->Selected) for (int k=0; k<=3; k++) SubForm->Selector[k]->ShapeDown(j+1); } } else { NewColorWayForm->ChangeColorChipShapeBySeletor1(false); // 05.08.17 } ClientHeight = 175; //Parent->Height = ParentHeight+ClientHeight; /* Shape1->Pen->Color = clRed; Shape2->Pen->Color = clBtnShadow; */ //Shape2->Pen->Color = clBtnShadow; //if(Shape1->Pen->Color == clRed) Shape1->Pen->Color = clBtnShadow; //else if (Shape1->Pen->Color == clBtnShadow) Shape1->Pen->Color = clRed; //Shape2->Visible = false; //if(Shape1->Visible) Shape1->Visible = false; //else if (!Shape1->Visible) Shape1->Visible = true; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::sbFileClick(TObject *Sender) { BEGIN_LOG("Combo_F"); //TFileManagerForm *Form = NULL; FileManagerForm = new TFileManagerForm(this); if (SubForm) { if (SubForm->step > 0){ SubForm->DrawRectangle(Sender, SubForm->Temp); SubForm->step = 0; SubForm->Repaint(); } } else { } if (FileManagerForm) { if (SubForm) { FileManagerForm->Extension = 0; //Combo¸¦ fileManager¿¡°Ô ¾Ë¸². FileManagerForm->FilterComboBox->Filter = "Texpro Combo File (*.cmb)|*.cmb"; } else { FileManagerForm->Extension = 6; //Combo¸¦ fileManager¿¡°Ô ¾Ë¸². FileManagerForm->FilterComboBox->Filter = "Texpro NewColrWay File (*.mcw)|*.mcw"; } FileManagerForm->OnRead = ComboRead; FileManagerForm->OnFileName = ComboFileName; FileManagerForm->OnSave = ComboSave; FileManagerForm->ShowModal(); delete FileManagerForm; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::sbPrintClick(TObject *Sender) { BEGIN_LOG("Combo_F"); TPException ec = EC_NONE; rzbitbtnExitClick(this); if (SubForm) { if (SubForm->step > 0){ SubForm->DrawRectangle(Sender, SubForm->Temp); SubForm->step = 0; SubForm->Repaint(); } TCommonPrintForm *Form = NULL; TTexpiaBitmap *Pattern = NULL; if ((Form = new TCommonPrintForm((TComponent *)NULL))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Form->ShowModal() == mrOk) { if ((Pattern = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!DrawPattern(Pattern)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!SendToPrinterTP(Pattern, MainImageForm->CanvasInfor.DotsPerInch, "Combo - " + MainImageForm->FileName, Form->PageEdit->Value, Form->cbMethod->ItemIndex)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus delete Pattern; sbChangeClick(sbChange); } delete Form; END_LOG; return; fail: if (Pattern) delete Pattern; if (Form) delete Form; EXCEPTION_MESSAGE_OK(ec); END_LOG; } else { NewColorWayPrint(); // sbChangeClick(sbChange); // NewColorWayForm->ChangeColorChipShapeBySeletor1(false); // 05.08.17 END_LOG; return; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::SetSelectorPalette() { BEGIN_LOG("Combo_F"); // HLS Áß 4°³ÀÇ À̹ÌÁö Áß Çϳª¸¦ ¼±ÅÃÇßÀ» ¶§ »ç¿ë... double h, l, s, a; BasicPalette->SetPalette(SubForm->Selector[SubForm->page]->Palette); Basic.Hue = 0; Basic.Lig = 0; Basic.Sat = 0; for (int j=0; jCount; j++) { BasicPalette->RGBToHLS(Selector->Code[j], h, l, s); if (h != UNDEFINED) { if (j > 0) { a = Basic.Hue / j; if (a < 180) { if (h >= a + 180) h = h - 360; } else { if (h <= a - 180) h = h + 360; } } Basic.Hue = Basic.Hue + h; Basic.Lig = Basic.Lig + l; Basic.Sat = Basic.Sat + s; } } Basic.Hue = Basic.Hue / Selector->Count; if (Basic.Hue < 0) Basic.Hue = Basic.Hue + 360; else if (Basic.Hue >= 360) Basic.Hue = Basic.Hue - 360; Basic.Lig = Basic.Lig / Selector->Count; Basic.Sat = Basic.Sat / Selector->Count; comboseHue->Value = Basic.Hue; comboseLig->Value = 100*Basic.Lig; comboseSat->Value = 100*Basic.Sat; END_LOG; } //----------------------------------------------------------------------------- void __fastcall TComboMenu::PlayBarPlay(TObject *Sender) { BEGIN_LOG("Combo_F"); runSw = true; PlaySW = true; if (SubForm) { SubForm->ComChange(Sender); if (Selector->Count>8) Progress->Position = (SubForm->rotate.page * Progress->Frequency) /1000; else Progress->Position = SubForm->rotate.page * Progress->Frequency; lPageTotal->Caption = Format("%d/%d", OPENARRAY (TVarRec, (SubForm->rotate.number, SubForm->rotate.total))); for (int i = 0; i < 4; i++) SubForm->PaletteColorChange(i); } else { if (NewColorWayForm->rotate.page < 0) NewColorWayForm->rotate.page = NewColorWayForm->rotate.total-1; else if (NewColorWayForm->rotate.page > NewColorWayForm->rotate.total) NewColorWayForm->rotate.page = 0; NewColorWayForm->ComChange(Sender); if (Selector->Count>8) Progress->Position = NewColorWayForm->rotate.page/1001; else Progress->Position = NewColorWayForm->rotate.page; lPageTotal->Caption = Format("%d/%d", OPENARRAY (TVarRec, (NewColorWayForm->rotate.number, NewColorWayForm->rotate.total))); } PaletteForm->DIB256Palette->Invalidate(); PlaySW = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ProgressChange(TObject *Sender) { BEGIN_LOG("Combo_F"); if (Selector->Count<=0) { END_LOG; return; } // added by maxleo21c (05.05.09) int max_num = 479001600; // 479001600 = 12! if(!PlaySW)PlayBar->SetInit(); //2001.7.12 lhskys C++Bilder 5->3 »ö»çÀü°³½Ã ÇѹøÇÏ°í ¸ØÃß´Â°Í ¼öÁ¤ runSw = true; if (Progress->Frequency) { if (SubForm) { //SubForm->rotate.page = Progress->Position / Progress->Frequency; if (Selector->Count>8) SubForm->rotate.page = (Progress->Position*1000 / Progress->Frequency); else SubForm->rotate.page = Progress->Position / Progress->Frequency; if(!PlaySW)SubForm->ComChange(Sender); //2001.7.12 lhskys C++Bilder 5->3 »ö»çÀü°³½Ã ÇѹøÇÏ°í ¸ØÃß´Â°Í ¼öÁ¤ lPageTotal->Caption = Format("%d/%d", OPENARRAY (TVarRec, (SubForm->rotate.number, SubForm->rotate.total))); for (int i = 0; i < 4; i++) SubForm->PaletteColorChange(i); PaletteForm->DIB256Palette->Invalidate(); } else { NewColorWayForm->rotate.page = Progress->Position; if(!PlaySW)NewColorWayForm->ComChange(Sender); lPageTotal->Caption = Format("%d/%d", OPENARRAY (TVarRec, (NewColorWayForm->rotate.number, NewColorWayForm->rotate.total))); PaletteForm->DIB256Palette->Invalidate(); } } END_LOG; } // by embakum(07.03.13) ±âÁ¸ÀÇ /1000, *1000 algorithmÀ» ¼öÁ¤. AutoBtnClickÂüÁ¶ //--------------------------------------------------------------------------- void __fastcall TComboMenu::InitForm(bool skip) { BEGIN_LOG("Combo_F"); // if (!skip) //ParentHeight = Parent->Height+20; ClientHeight = 34; //Parent->Height = ParentHeight+ClientHeight; END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TComboMenu::ExitForm(bool skip) { BEGIN_LOG("Combo_F"); Selector->SaveToFile(AppDataItem+"\\Combo.ini", "Color"); if (isprinting) { END_LOG; return false; } // ÇÁ¸°Æ® ÁßÀ̱⠶§¹®¿¡ if (skip) goto next; // ÁøÂ¥ ÀÌ·¸°Ô ¸¸µé¾î¾ß Çϳª? ¤Ð¤Ð Çѹø¸¸ ÀÌ¿ëÇÑ´Ù. È®ÀÎÇØº¼°Í~ bool check; if (rzbitbtnExit->Enabled) rzbitbtnExitClick(rzbitbtnExit); if (NewColorWayForm) { if (NewColorWayForm->Visible) NewColorWayForm->FormCloseQuery(NewColorWayForm, check); else check=true; if (check) { NewExitForm(); END_LOG; return true; } else { END_LOG; return false; } } if (SubForm && SubForm->Visible) { SubForm->FormCloseQuery(SubForm, check); if (check==false) { END_LOG; return false; } } next: if (!SubForm) { if (BasicPalette) {delete BasicPalette; BasicPalette = NULL;} if (PlayBar) {delete PlayBar; PlayBar=NULL;} END_LOG; return true; } Byte *src, *dst, uc; int x, y, i, sx, sy, max; TPItemImage *Image = MainImageForm->iMainImage; if (!error) { sx = SubForm->window.s.x; sy = SubForm->window.s.y; max = 0; if (!Image->uBitmap->StartScanLine()) goto fail; for (y=0; yuBitmap->Height; y++){ src = (Byte *) Image->uBitmap->GetScanLine(y); for (x=0; xuBitmap->Width; x++) { if (maxuBitmap->StopScanLine(); uc = max; if (uc*2>=252) { EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); } else { if(runSw == true){ for (i=uc+1; i<=uc*2; i++){ MainImageForm->Palette->ColorData[i] = SubForm->Selector[SubForm->page]->Palette->ColorData[i-uc]; if (!Image->uBitmap->StartScanLine()) goto fail; if (!SubForm->CImage[SubForm->page]->Bitmap->StartScanLine()) goto fail; for (y=0; ywindow.size.y; y++) { src = (Byte *) SubForm->CImage[SubForm->page]->Bitmap->GetScanLine(y); dst = (Byte *) Image->uBitmap->GetScanLine(y+sy); for (x=0; xwindow.size.x; x++) { dst[x+sx] = src[x]+uc; } Image->uBitmap->PutScanLine(y+sy); } SubForm->CImage[SubForm->page]->Bitmap->StopScanLine(); Image->uBitmap->StopScanLine(); } MainImageForm->Palette->UseColor = uc*2; PaletteForm->DIB256Palette->ChoiceIndex = 2; } } delete SubForm; SubForm = NULL; } if (BasicPalette) {delete BasicPalette; BasicPalette = NULL;} if (PlayBar) {delete PlayBar; PlayBar=NULL;} isLoad = true; // added by maxleo21c (05.05.09) - mainimage repaint°¡ µÇ¾î¾ß // Çϴµ¥ ¸®ÅÏÇÏ´Â ºÎºÐÀ» ¸¸µé¾ú±â ¶§¹®¿¡ ±×°ÍÀ» ÇÇÇϱ⠿ìÇØ¼­ Ãß°¡Çß´Ù. ::RepaintColor(); END_LOG; return true; fail: Image->uBitmap->StopScanLine(); SubForm->CImage[SubForm->page]->Bitmap->StopScanLine(); if (SubForm) delete SubForm; if (BasicPalette) {delete BasicPalette; BasicPalette = NULL;} if (PlayBar) {delete PlayBar; PlayBar=NULL;} END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::NewExitForm() { BEGIN_LOG("Combo_F"); if (BasicPalette) {delete BasicPalette; BasicPalette=NULL;} if (PlayBar) {delete PlayBar; PlayBar=NULL;} PaletteForm->InitForm(MainImageForm->Palette); NewColorWayForm->ExitForm(); delete NewColorWayForm; NewColorWayForm=NULL; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::CDrawHS() { BEGIN_LOG("Combo_F"); int x, y, v, xx; double h, l, s; Byte r, g, b; Byte *sl, *sh; l = 0.5; for (y=0; y<=31; y++) { sl = (Byte *) ComboImageHS->Picture->Bitmap->ScanLine[32-y]; sh = (Byte *) ComboImageHS->Picture->Bitmap->ScanLine[32+y]; v = sqrt(1024-y*y);//v = sqrt(1296-y*y); for (x=-v; x<=v; x++) { xx = 3*(32+x); s = sqrt(x*x + y*y)/32; if ((y==0) && (x==0)) h = 0; else h = atan2(y, x)*180/M_PI; HLS2RGB(h, l, s, r, g, b); *(sl+xx) = b; *(sl+xx+1) = g; *(sl+xx+2) = r; if ((y==0) && (x==0)) h = 180; else h = 180 + atan2(y, -x) * 180 / M_PI; HLS2RGB(h, l, s, r, g, b); *(sh+xx) = b; *(sh+xx+1) = g; *(sh+xx+2) = r; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::CDrawL() { BEGIN_LOG("Combo_F"); int x, y, v, xx; double h, l, s; Byte r, g, b; Byte *sl, *sh; h = comboseHue->Value; for (y=0; y<=32; y++) { sl = (Byte *) ComboImageL->Picture->Bitmap->ScanLine[32-y]; sh = (Byte *) ComboImageL->Picture->Bitmap->ScanLine[32+y]; v = 2*(32-y); for (x=0; x<=v; x++) { xx = 3*x; if (v==0) s = 0; else s = (double) x/v; l = 0.5+ y/64.0; HLS2RGB(h, l, s, r, g, b); *(sl+xx) = b; *(sl+xx+1) = g; *(sl+xx+2) = r; l = 0.5-y/64.0; HLS2RGB(h, l, s, r, g, b); *(sh+xx) = b; *(sh+xx+1) = g; *(sh+xx+2) = r; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::CDrawHSBar(int h, int s) { BEGIN_LOG("Combo_F"); double r, x, y; int cx, cy; r = h*M_PI/180; ComboImageHS->Canvas->MoveTo(32, 32); x = 32 * cos(r); y = 32 * sin(r); ComboImageHS->Canvas->LineTo(32+(int)x, 32-(int)y); cx = 32 + (x*s/100); cy = 32 - (y*s/100); ComboImageHS->Canvas->Rectangle(cx-2, cy-2, cx+2, cy+2); ComboImageHS->Update(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::CDrawLBar(int l) { BEGIN_LOG("Combo_F"); int y; y = 63-l*63 / 100; ComboImageL->Canvas->MoveTo(0, y); ComboImageL->Canvas->LineTo(64, y); ComboImageHS->Update(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::CMoveHS(int X, int Y) { int h, s; X = X-32; Y = Y-32; if (Y<0) h = atan2(-Y, X)*180/M_PI; else { if ((Y==0) && (X==0)) h = 180; else h = 180+atan2(Y, -X)*180/M_PI; } comboseHue->Value = h; s = 100*sqrt(X*X+Y*Y)/32; if (s>100) s = 100; comboseSat->Value = s; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::CMoveL(int Y) { int l; l = 100-100*Y / 63; if (l<0) l = 0; if (l>100) l =100; comboseLig->Value = l; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::CRunHLS() { BEGIN_LOG("Combo_F"); int i, n; double h, l, s, hc, lc, sc; RGBQUAD rgb[256]; hc = Hue-Basic.Hue; lc = Lig/100.0-Basic.Lig; sc = Sat/100.0-Basic.Sat; if (mouseSw == true) { if (chLig != Lig) runSw= true; if (chHue != Hue) runSw = true; } for (i=0; iCount; i++) { n = Selector->Code[i]; BasicPalette->RGBToHLS(n, h, l, s); h = h + hc; if (h<0) h = h+360; else if (h>=360) h = h-360; l = l+lc; if (l<0) l = 0; else if (l>1) l = 1; s = s+sc; if (s<0) s = 0; else if (s>1) s = 1; if (SubForm) SubForm->Selector[SubForm->page]->Palette->HLSToRGB(n, h, l, s); else NewColorWayForm->Palette->HLSToRGB(n, h, l, s); } if (SubForm) { SubForm->Selector[SubForm->page]->Palette->ToRGBQUAD(rgb, 256); SubForm->CImage[SubForm->page]->Bitmap->PutColors(0, 256, rgb); SubForm->CImage[SubForm->page]->Repaint(); SubForm->Selector[SubForm->page]->Invalidate(); SubForm->PaletteColorChange(SubForm->page); PaletteForm->DIB256Palette->Invalidate(); } else { NewColorWayForm->Palette->ToRGBQUAD(rgb, 256); NewColorWayForm->PLayerImage->uBitmap->PutColors(0, 256, rgb); NewColorWayForm->PLayerImage->ChangeRGBColors(rgb); NewColorWayForm->PLayerImage->Repaint(); NewColorWayForm->RepaintShape(); PaletteForm->DIB256Palette->Invalidate(); } END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TComboMenu::DrawPattern(TTexpiaBitmap *Bmp) { BEGIN_LOG("Combo_F"); int w, h, i, j, sw, k, l, m, tab, ww, hh, sx, sy, tw, size; double rx, ry; double dr = (double)MainImageForm->CanvasInfor.DotsPerInch/160.0; //dpi¿¡ µû¸¥ ºñÀ² 160dpi ±âÁØ TPoint sp, ep; TRect Src, Dst, BitRect, StrRect; RGBQUAD rgbcol[256]; String Name, c_page; TColorData *ColorMap; TCanvas *ca = NULL; HDC hDC = NULL; bool b_DB = false; //080405 Pantone color int gap_t0 = 70+3, gap_b0 = 50+3; //080405 int gap_t2 = 90+3, gap_b2 = 70+3; int gap = 40; w = GetDeviceCaps(Printer()->Handle, HORZRES)*MainImageForm->CanvasInfor.DotsPerInch /GetDeviceCaps(Printer()->Handle, LOGPIXELSX); h = GetDeviceCaps(Printer()->Handle, VERTRES)*MainImageForm->CanvasInfor.DotsPerInch /GetDeviceCaps(Printer()->Handle, LOGPIXELSY); MainImageForm->Palette->ToRGBQUAD(rgbcol, 256); Bmp->Create(w, h, 8, rgbcol); Bmp->FillRect(Rect(0, 0, Bmp->Width, Bmp->Height), clWhite); w = Bmp->Width / 2; h = Bmp->Height / 2; if ((ca = Bmp->CreateCanvas()) == NULL) goto fail; ca->Pen->Color = clBlack; ca->Pen->Width = 3*dr ; size = ca->Font->Size; ca->Font->Size = size * dr + 0.5; ca->MoveTo(20*dr, 20*dr); ca->LineTo(20*dr, Bmp->Height-20*dr); ca->LineTo(Bmp->Width-20*dr, Bmp->Height-20*dr); ca->LineTo(Bmp->Width-20*dr, 20*dr); ca->LineTo(20*dr, 20*dr); ca->MoveTo(w, 20*dr); ca->LineTo(w, Bmp->Height-20*dr); ca->MoveTo(20*dr, h); ca->LineTo(Bmp->Width-20*dr, h); ca->Pen->Width = 1*dr; ca->MoveTo(20*dr, h-100*dr); ca->LineTo(Bmp->Width-20*dr, h-100*dr); ca->MoveTo(20*dr, Bmp->Height-120*dr); ca->LineTo(Bmp->Width-20*dr, Bmp->Height-120*dr); Src = Rect(0, 0, SubForm->CImage[0]->Bitmap->Width, SubForm->CImage[0]->Bitmap->Height); sx = w-40*dr; sy = h-130*dr; ww = SubForm->CImage[0]->Bitmap->Width; hh = SubForm->CImage[0]->Bitmap->Height; rx = (double) sx/ww; ry = (double) sy/hh; if (rx>ry) { sx = ww*ry; sy = hh*ry; } else { sx = ww*rx; sy = hh*rx; } for (m=0; m<=3; m++) { if ((hDC = SubForm->CImage[m]->Bitmap->CreateDC())==NULL) { END_LOG; return false; } switch (m) { case 0: Dst = Rect(30*dr, 30*dr, 30*dr+sx, 30*dr+sy); c_page = SubForm->Edit1->Text; StrRect = Rect(35*dr, 35*dr, 105*dr, 50*dr); break; case 1: Dst = Rect(w+10*dr, 30*dr, w+10*dr+sx, 30*dr+sy); c_page = SubForm->Edit2->Text; StrRect = Rect(w+15*dr, 35*dr, w+85*dr, 50*dr); break; case 2: Dst = Rect(30*dr, h+10*dr, 30*dr+sx, h+10*dr+sy); StrRect = Rect(35*dr, h+15*dr, 105*dr, h+30*dr); c_page = SubForm->Edit3->Text; break; case 3: Dst = Rect(w+10*dr, h+10*dr, w+10*dr+sx, h+10*dr+sy); StrRect = Rect(w+15*dr, h+15*dr, w+85*dr, h+30*dr); c_page = SubForm->Edit4->Text; break; } SetStretchBltMode(ca->Handle, COLORONCOLOR); StretchBlt(ca->Handle, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), hDC, Src.Left, Src.Top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); SubForm->CImage[m]->Bitmap->DeleteDC(hDC); hDC = NULL; if (SubForm->Edit1->Visible) { ca->Pen->Width = 2*dr; ca->MoveTo(StrRect.Right, StrRect.Top); ca->LineTo(StrRect.Left, StrRect.Top); ca->LineTo(StrRect.Left, StrRect.Bottom); ca->LineTo(StrRect.Right, StrRect.Bottom); ca->LineTo(StrRect.Right, StrRect.Top); ca->Pen->Width = 1*dr; tw = 65*dr-ca->TextWidth(c_page); ca->TextRect(StrRect, StrRect.Left+tw, StrRect.Top, c_page); } } gap_t0 = 90+3, gap_b0 = 70+3; //080405 gap_t2 = 110+3, gap_b2 = 90+3; for (m=0; m<=3; m++) { i = SubForm->Selector[m]->ChoiceColor->Count; sw = (w-50*dr) / 6; //chip's width gap = 40; //080405 b_DB = false; for (l = 0, k= 0, j = 0; j < i; j++, k++) { if (j > 11) break; //printingµÇ´Â color chip ¼ö¸¦ 12°³·Î Á¦ÇÑÇÑ´Ù.. if ((j % 6) == 0) { k = 0; l = j / 6; //if (j == 6 && b_DB) gap = 45; } ColorMap = SubForm->Selector[m]->Palette->ColorData[SubForm->Selector[m]-> ChoiceColor->Code[j]]; //if (ColorMap->Kind == 6) { b_DB = true;} if ((ColorMap->Kind & 0x0FFF) == 0x0006) { b_DB = true;} switch (m) { case 0: sp = Point(40*dr+sw*k, (h-gap_t0*dr)+gap*dr*l); ep = Point(40*dr+(sw-5*dr)+sw*k, (h-gap_b0*dr)+gap*dr*l); break; case 1: sp = Point((w+20*dr)+sw*k, (h-gap_t0*dr)+gap*dr*l); ep = Point((w+20*dr)+(sw-5*dr)+sw*k, (h-gap_b0*dr)+gap*dr*l); break; case 2: sp = Point(40*dr+sw*k, (Bmp->Height-gap_t2*dr)+gap*dr*l); ep = Point(40*dr+(sw-5*dr)+sw*k, (Bmp->Height-gap_b2*dr)+gap*dr*l); break; case 3: sp = Point((w+20*dr)+sw*k, (Bmp->Height-gap_t2*dr)+gap*dr*l); ep = Point((w+20*dr)+(sw-5*dr)+sw*k, (Bmp->Height-gap_b2*dr)+gap*dr*l); break; } PrintColorChip8(Bmp, Rect(sp.x, sp.y, ep.x, ep.y), ((252 - (4 * i)) + m * i) + j); } } gap_t0 = 70+3, gap_b0 = 50+3; //080405 gap_t2 = 90+3, gap_b2 = 70+3; gap = 40; for (m=0; m<=3; m++) { i = SubForm->Selector[m]->ChoiceColor->Count; sw = (w-50*dr) / 6; //chip's width gap = 40; //080405 b_DB = false; for (j = 0,l = 0, k = 0; j < i; j++, k++) { if (j > 11) break; //printingµÇ´Â color chip ¼ö¸¦ 12°³·Î Á¦ÇÑÇÑ´Ù.. if ((j % 6) == 0) { k = 0; l = j / 6; //if (j == 6 && b_DB) gap = 45; } switch (m) { case 0: // BitRect = Rect(40+sw*k, (h-90)+40*l, 40+(sw-5)+sw*k, (h-70)+40*l); StrRect = Rect(40*dr+sw*k, (h-gap_t0*dr)+gap*dr*l, 40*dr+(sw-5*dr)+sw*k, (h-gap_b0*dr)+gap*dr*l); break; case 1: // BitRect = Rect((w+20)+sw*k, (h-90)+40*l, (w+20)+(sw-5)+sw*k, (h-70)+40*l); StrRect = Rect((w+20*dr)+sw*k, (h-gap_t0*dr)+gap*dr*l, (w+20*dr)+(sw-5*dr)+sw*k, (h-gap_b0*dr)+gap*dr*l); break; case 2: // BitRect = Rect(40+sw*k, (Bmp->Height-110)+40*l, 40+(sw-5)+sw*k, (Bmp->Height-90)+40*l); StrRect = Rect(40*dr+sw*k, (Bmp->Height-gap_t2*dr)+gap*dr*l, 40*dr+(sw-5*dr)+sw*k, (Bmp->Height-gap_b2*dr)+gap*dr*l); break; case 3: // BitRect = Rect((w+20)+sw*k, (Bmp->Height-110)+40*l, (w+20)+(sw-5)+sw*k, (Bmp->Height-90)+40*l); StrRect = Rect((w+20*dr)+sw*k, (Bmp->Height-gap_t2*dr)+gap*dr*l, (w+20*dr)+(sw-5*dr)+sw*k, (Bmp->Height-gap_b2*dr)+gap*dr*l); break; } // ca->Brush->Color = SubForm->Selector[m]->Palette-> // ColorData[SubForm->Selector[m]->ChoiceColor->Code[j]]->Color; // ca->FillRect(BitRect); ca->Brush->Color = clWhite; ColorMap = SubForm->Selector[m]->Palette->ColorData[SubForm->Selector[m]-> ChoiceColor->Code[j]]; if ((ColorMap->Kind & 0x400F) >= 0x4000){ // user switch (ColorMap->Kind & 0x000F) { case 0: case 3: case 4: case 1: case 2: //¿ø·¡ Æ÷ÇԵǾî ÀÖÁö ¾Ê¾Ò´Ù. µðÀÚÀνÇ(³ª¸®)¿äûÀ¸·Î Ãß°¡ 080408 case 6: //080404 Name = ColorMap->ColorName; break; } } else { switch (ColorMap->Kind & 0x0FFF) { case 0: if (ColorMap->Page==0) Name = Format("%d-%d-%d", OPENARRAY (TVarRec, (255-ColorMap->RGB.rgbRed, 255-ColorMap->RGB.rgbGreen, 255-ColorMap->RGB.rgbBlue))); else Name = PrinterColor->PN2Code(ColorMap->Page, ColorMap->Number); break; case 3: Name = StandardColor->PN2Code(ColorMap->Page, ColorMap->Number); break; case 4: Name = TextileColor->PN2Code(ColorMap->Page, ColorMap->Number); break; case 6: //080404 Name = (char *)ColorMap->additionalColorData->GetData(TAG_PANTONE_COLOR);//ColorMap->PantoneColor; b_DB = true; break; } } tab = (sw-5*dr-ca->TextWidth(Name)) / 2; if (tab<0) tab = 0; //if (ColorMap->Kind == 6) { if ((ColorMap->Kind & 0x0FFF) == 0x0006) { PrintChipNameToMultiLine(ca, Name, StrRect);//080404 } else { switch (m) { case 0: ca->TextRect(StrRect, 40*dr+tab+sw*k, (h-65*dr)+40*dr*l, Name); break; case 1: ca->TextRect(StrRect, (w+20*dr)+tab+sw*k, (h-65*dr)+40*dr*l, Name); break; case 2: ca->TextRect(StrRect, 40*dr+tab+sw*k, (Bmp->Height-85*dr)+40*dr*l, Name); break; case 3: ca->TextRect(StrRect, (w+20*dr)+tab+sw*k, (Bmp->Height-85*dr)+40*dr*l, Name); break; } } } } Bmp->DeleteCanvas(ca); END_LOG; return true; fail: if (ca) Bmp->DeleteCanvas(ca); END_LOG; return false; } //--------------------------------------------------------------------------- // 080325 Pantoneó¸® void __fastcall TComboMenu::PrintChipNameToMultiLine(TCanvas* canvas, String full_name, TRect str_rect) { BEGIN_LOG("Combo_F"); int chip_width = str_rect.right - str_rect.left; int line_height = 15; int chip_name_margin = 3; int lastfontsize = canvas->Font->Size; canvas->Font->Size= 3; canvas->Font->Color = clBlack; int string_line_count = canvas->TextWidth(full_name) / chip_width + 1; if(string_line_count == 1) { int tab = (chip_width - canvas->TextWidth(full_name)) / 2; canvas->TextRect(str_rect, str_rect.left + tab, str_rect.top + chip_name_margin, full_name); } else { str_rect.top -= line_height * (string_line_count - 1) - chip_name_margin; str_rect.bottom -= line_height * (string_line_count - 1) - chip_name_margin; int Char_index, start_index = 0, start_line = 0; for(Char_index = 1 ; Char_index < full_name.Length() ; ++Char_index) { if(canvas->TextWidth(full_name.SubString(start_index, Char_index - start_index)) > chip_width) { canvas->TextRect(str_rect, str_rect.left, str_rect.top + chip_name_margin, full_name.SubString(start_index, Char_index - start_index - 1)); str_rect.bottom += line_height; str_rect.top += line_height; start_index = Char_index; ++start_line; } } canvas->TextRect(str_rect, str_rect.left, str_rect.top + 2, full_name.SubString(start_index, Char_index - start_index + 1)); } canvas->Font->Size= lastfontsize; END_LOG; } //--------------------------------------------------------------------------- //bool __fastcall TComboMenu::Load_File(String FileName, int Index, TUnionBitmap *pBitmap, // TPalette *pPalette, TPCanvasInfor &pi) bool __fastcall TComboMenu::Load_File(String FileName, int Index, TUnionBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &pi) { BEGIN_LOG("Combo_F"); TEXPIAFILEHEADER tpfh; int i, k, x, y; bool sw; Byte p, *sl; Byte c[225]; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; TPException ec = EC_NONE; int nColorDataVersion = 0; runSw = true; if (!FileExists(FileName)) { ec = EC_FILE_NOT_EXIST; SAVE_EXCEPTION(ec); goto fail; } if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, FindExtension(ExtractFileExt(FileName))))!=EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); pi = tpfh.CanvasInfor; if (tpfh.Version.Method == 'T') { if (tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } // 090527 upper version if (tpfh.Version.Number < 200) { sw = true; } else if (200 <= tpfh.Version.Number && tpfh.Version.Number < 210) { sw = false; nColorDataVersion = 0; } else if (210 <= tpfh.Version.Number && tpfh.Version.Number <= 301) { sw = false; nColorDataVersion = 1; } else if (302 <= tpfh.Version.Number) { sw = false; nColorDataVersion = 2; } } else { sw = true; } if (SubForm) { if (!ReadFile(hFile, &(SubForm->page), sizeof(Byte), &dwRead, NULL)){ ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && 302 <= tpfh.Version.Number) { if (!ReadFile(hFile, &(SubForm->color_count), sizeof(int), &dwRead, NULL)){ ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } else { if (!ReadFile(hFile, &(SubForm->color_count), sizeof(short), &dwRead, NULL)){ ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } if (sw) { SubForm->ChoiceColor->Initial(); SubForm->Selector[0]->Palette->SetPalette(pPalette); SubForm->Selector[1]->Palette->SetPalette(pPalette); SubForm->Selector[2]->Palette->SetPalette(pPalette); SubForm->Selector[3]->Palette->SetPalette(pPalette); if (!ReadFile(hFile, c, 225, &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!pBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yHeight; y++) { sl = (Byte *)pBitmap->GetScanLine(y); for (x=0; xWidth; x++) { p = *(sl+x); if (c[p-1]<225) { SubForm->ChoiceColor->Add(pPalette, p); k = c[p-1]+1; SubForm->Selector[0]->Palette->ColorData[p] = pPalette->ColorData[k]; k = k+SubForm->color_count; SubForm->Selector[1]->Palette->ColorData[p] = pPalette->ColorData[k]; k = k+SubForm->color_count; SubForm->Selector[2]->Palette->ColorData[p] = pPalette->ColorData[k]; k = k+SubForm->color_count; SubForm->Selector[3]->Palette->ColorData[p] = pPalette->ColorData[k]; c[p] = 255; } } pBitmap->PutScanLine(y); } pBitmap->StopScanLine(); } else { SubForm->ChoiceColor->LoadFromFile(hFile, nColorDataVersion); for (i=0; i<=3; i++) { SubForm->Selector[i]->Palette->LoadFromFileHandle(hFile, nColorDataVersion); } } CloseHandle(hFile); Selector->SetPalette(SubForm->Selector[SubForm->page]->Palette); SubForm->Visible = false; END_LOG; return true; } else { NewColorWayForm->Visible = false; NewColorWayForm->LoadFromFile(hFile, pBitmap, pPalette, nColorDataVersion); NewColorWayForm->pTitle = FileName; CloseHandle(hFile); Selector->SetPalette(NewColorWayForm->Palette); END_LOG; return true; } fail: pBitmap->StopScanLine(); if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ComboPaint(TObject *Sender) { SubForm->IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ComboSelectColor(int Value) { Selector->AddColor(Value); } //--------------------------------------------------------------------------- TPException __fastcall TComboMenu::ComboRead(TFMReadParameter rp, bool changeFileFormat) { BEGIN_LOG("Combo_F"); TRect r; RECT rc; int pw, ph, sw, sh; int zi, zo; // speed-test TPCanvasInfor pi; RGBQUAD rgb[256], mainRgb[256]; TUnionBitmap *TempBitmap = NULL; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; isLoad=true; MainImageForm->WorkAreaReset(true); MainForm->UpdateMenuItems(NULL); r = Rect(0, 0, Image->uBitmap->Width, Image->uBitmap->Height); MainImageForm->UndoSave(UK_ALL, r); Image->uBitmap->FillRect(r, PALETTEINDEX(BackgroundColor)); if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Load_File(FullPathName(rp.DirName, rp.FileName), rp.ExtIndex, TempBitmap, MainImageForm->Palette, pi)) goto fail; if ((TempBitmap->Width > Image->uBitmap->Width) || (TempBitmap->Height > Image->uBitmap->Height) || (MainImageForm->CanvasInfor.DotsPerInch != pi.DotsPerInch)) { MainImageForm->Undo->RemoveAll(); //may be bug don't ignore pi.SizeType = cstFree; pi.Width = TempBitmap->Width; pi.Height = TempBitmap->Height; MainImageForm->ResizePattern(pi, 8); FullViewForm->GetZoomRatio(MainImageForm->iMainImage, zi, zo); // speed-test MainImageForm->iMainImage->uBitmap->GetColors(0, 256, rgb); MainImageForm->iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test MainImageForm->iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } Image->uBitmap->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); ::RepaintColor(); rc = Rect(0, 0, TempBitmap->Width, TempBitmap->Height); Image->uBitmap->CopyToRect(rc.left, rc.top, TempBitmap, SRCCOPY); MainImageForm->WorkArea->SetRectangle(rc); MainImageForm->WorkAreaChange(); PaletteForm->DIB256Palette->ChoiceIndex = 2; sw = MainForm->ClientWidth-264; sh = MainForm->ClientHeight-MainForm->StatusBar->Height -GetSystemMetrics(SM_CYSMCAPTION)-GetSystemMetrics(SM_CYMENU)+3; pw = Image->uBitmap->Width + MainImageForm->PanelVert->Width; ph = Image->uBitmap->Height + MainImageForm->PanelHorz->Height; if (MainImageForm->sbRuler->Down) { pw += MainImageForm->Ruler->Thick; ph += MainImageForm->Ruler->Thick; } if (pwClientWidth = sw; MainImageForm->ClientHeight = sh; if (SubForm) { SubForm->SetComboImage(); SubForm->Visible = true; } else { isLoad=false; NewColorWayForm->Visible = true; PaletteForm->InitForm(NewColorWayForm->Palette); } sbChangeClick(sbChange); rzbitbtnExitClick(rzbitbtnExit); sbChange->Down = true; ::RepaintColor(); // FullView¿¡¼­ Èæ¹éÀ¸·Î ³ª¿À´Â ¹®Á¦¶§¹®¿¡ ¾î¿¼ö ¾øÀÌ ¸¸µé¾ú´Ù. ¸í½ÄÀÌ¿¡°Ô ¹®ÀÇ ÇÊ¿ä // added by maxleo21c (05.07.29) // MainImageForm->FullViewUpdate(); delete TempBitmap; isLoad=false; END_LOG; return EC_NONE; fail: if (TempBitmap) delete TempBitmap; if (ec == EC_NONE) ec = EC_FILE_NOT_READ; isLoad=false; END_LOG; return ec; } //--------------------------------------------------------------------------- //String __fastcall TComboMenu::ComboFileName(String FileName, // TGraphicFileFormat ExtIndex) String __fastcall TComboMenu::ComboFileName(String FileName, TGraphicFileFormat ExtIndex) { //PChar s; Char *s; int FileNameLength, last1, last2, last3, last4; //Char FileIndex1, FileIndex2, FileIndex3, FileIndex4; Char FileIndex1, FileIndex2, FileIndex3, FileIndex4; //=============================================================== FileNameLength = FileName.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; if (SubForm) { FileIndex1 = L'.'; FileIndex2 = L'c'; FileIndex3 = L'm'; FileIndex4 = L'b'; } else { FileIndex1 = L'.'; FileIndex2 = L'm'; FileIndex3 = L'c'; FileIndex4 = L'w'; } if((FileIndex1 == FileName[last1])&&(FileIndex2 == FileName[last2]) && (FileIndex3 == FileName[last3])&&(FileIndex4 == FileName[last4])){ s = L"PASS"; }else s=NULL; }else s=NULL; //=============================================================== // s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { //String fn; String fn; if (SubForm) fn = FileName + String(".cmb"); else fn = FileName + String(".mcw"); return fn; } else { return FileName; } } //--------------------------------------------------------------------------- //TPException __fastcall TComboMenu::ComboSave(String DirName, String FileName, // TGraphicFileFormat ExtIndex, TCompressMethod cm) TPException __fastcall TComboMenu::ComboSave(String DirName, String FileName, TGraphicFileFormat ExtIndex, TCompressMethod cm) { BEGIN_LOG("Combo_F"); int i, x, y, ww, hh, ec = EC_NONE; TEXPIAFILEHEADER tpfh; TRect src, dst; RGBQUAD rgb[256]; TTexpiaBitmap *tag = NULL; HDC dcSrc = NULL; TCanvas *cv = NULL; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwWrite; try { if ((hFile = CreateFile(FullPathName(DirName, FileName).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } tpfh.Version = TexVersion('P', 'T', TextileFileVersion); tpfh.CanvasInfor = MainImageForm->CanvasInfor; tpfh.BitsPerPixel = 8; tpfh.Compress = cm; if (MainImageForm->WorkArea->Mask) { src = MainImageForm->WorkArea->Range; tpfh.CanvasInfor.SizeType = cstFree; tpfh.CanvasInfor.DotsPerInch = tpfh.CanvasInfor.DotsPerInch; tpfh.CanvasInfor.Width = src.Right-src.Left; tpfh.CanvasInfor.Height = src.Bottom-src.Top; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (SubForm) { if (!tag->Create(80, 100, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cv = tag->CreateCanvas()) == NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } cv->Brush->Color = clWhite; cv->FillRect(Rect(0, 0, 80, 100)); ww = SubForm->CImage[0]->Bitmap->Width; hh = SubForm->CImage[0]->Bitmap->Height; for (i=0; i<4; i++) { x = i % 2; y = i / 2; if ((dcSrc = SubForm->CImage[i]->Bitmap->CreateDC()) == NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } SetStretchBltMode(cv->Handle, COLORONCOLOR); StretchBlt(cv->Handle, x*42, y*52, 38, 48, dcSrc, 0, 0, ww, hh, SRCCOPY); SubForm->CImage[i]->Bitmap->DeleteDC(dcSrc); dcSrc = NULL; } } else { if (!tag->Create(80, 100, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cv = tag->CreateCanvas()) == NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } cv->Brush->Color = clWhite; cv->FillRect(Rect(0, 0, 80, 100)); NewColorWayForm->MakeTag(cv); } tag->DeleteCanvas(cv); cv = NULL; if (SubForm) { if (MainImageForm->WorkArea && MainImageForm->WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, MainImageForm->Palette, tpfh, tag, MainImageForm->iMainImage->uBitmap, &MainImageForm->WorkArea->Range)) goto fail; // ÀÛ¾÷±¸¿ª ÀúÀå need-conversion } else { if (!SaveToTexpiaFile(hFile, MainImageForm->Palette, tpfh, tag, MainImageForm->iMainImage->uBitmap)) goto fail; } if (!WriteFile(hFile, &(SubForm->page), sizeof(Byte), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &(SubForm->color_count), sizeof(int), &dwWrite, NULL)) goto fail; SubForm->ChoiceColor->SaveToFile(hFile); for (i=0; i<=3; i++) { SubForm->Selector[i]->Palette->SaveToFileHandle(hFile, 2); } } else { if (MainImageForm->WorkArea && MainImageForm->WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, NewColorWayForm->OriginPalette, tpfh, tag, MainImageForm->iMainImage->uBitmap, &MainImageForm->WorkArea->Range)) goto fail; // ÀÛ¾÷±¸¿ª ÀúÀå need-conversion } else { if (!SaveToTexpiaFile(hFile, NewColorWayForm->OriginPalette, tpfh, tag, MainImageForm->iMainImage->uBitmap)) goto fail; } if (!NewColorWayForm->SaveToFile(hFile)) goto fail; NewColorWayForm->pTitle = FileName; } } catch(...){ SAVE_EXCEPTION(EC_NO_MESSAGE); goto fail; } delete tag; tag = NULL; CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; END_LOG; return EC_NONE; fail: if (tag) { if (cv) tag->DeleteCanvas(cv); delete tag; } if (hFile!=INVALID_HANDLE_VALUE){ CloseHandle(hFile); DeleteFile(FullPathName(DirName, FileName).c_str()); //shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; END_LOG; return ec; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::FGChange(int Index) { BEGIN_LOG("Combo_F"); int k, temp; if (sbChange->Down) { if (SubForm) { k = 252 - 4*SubForm->ChoiceColor->Count; if (Index < k) { if (Selector->Count < 12) { Selector->ChoiceColor->Add(MainImageForm->Palette, Index); Selector->SetPalette(MainImageForm->Palette);//090722 Selector->Invalid(); } else { // µðÀÚÀÎ½Ç ¸Þ½ÃÁö º¯°æ ¿äû : 256 Palette¿¡ ´õÀÌ»ó »öÀ» Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù. => 12»öº¸´Ù ¸¹½À´Ï´Ù. // by monkman (2009.12.31) //EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); EXCEPTION_MESSAGE_OK(EC_COLOR_OVER12); } } else ShowMessage(IDS_MESSAGE_COLORNUMBER + Format("%d.", OPENARRAY(TVarRec, (k-2)))); } else if (NewColorWayForm && !ComboMenu->rzbitbtnExit->Enabled) { if (Selector->Count < 250) { temp = Selector->ChoiceColor->Count; Selector->ChoiceColor->Add(NewColorWayForm->Palette, Index); Selector->Invalid(); if (temp < Selector->ChoiceColor->Count) NewColorWayForm->SelectShape(Index, false, true); // else if (temp == Selector->ChoiceColor->Count) // NewColorWayForm->SelectShape(Index, true, false); else NewColorWayForm->SelectShape(Index, true, false); /* if (temp != Selector->ChoiceColor->Count) NewColorWayForm->SelectShape(Index, true, true); else NewColorWayForm->SelectShape(Index, true, true); */ } else { EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::iMainImageKeyDown(WORD Key, TShiftState Shift) { if (rzbitbtnOld->Down || rzbitbtnNew->Down) { if (NewColorWayForm) NewColorWayForm->NewColorWayKeyDown(Key, Shift); if (Key == VK_RETURN && (sbChange->Down == true || sbHue->Down == true )) rzbitbtnRunClick(this); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ } } //--------------------------------------------------------------------------- void __fastcall TComboMenu::iMainImageKeyUp(WORD Key, TShiftState Shift) { if (NewColorWayForm) NewColorWayForm->NewColorWayKeyUp(Key, Shift); } //--------------------------------------------------------------------------- void __fastcall TComboMenu::SelectorMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG("Combo_F"); int Square; bool itexist=false; Square = Selector->PointToSquare(X, Y); if (SubForm) { for (int m=0; m<=3; m++) { for (int k=0; kChoiceColor->Count/*36*/; k++) { if(SubForm->ChoiceColor->Code[k] == Selector->ChoiceColor->Code[Square]) SubForm->Selector[m]->ShapeDown(k+1); } } } else { for (int k=0; kChoiceColor->Count; k++) { if(NewColorWayForm->ChoiceColor->Code[k] == Selector->ChoiceColor->Code[Square]) { TShape *colorShape; colorShape = (TShape *)NewColorWayForm->colorBGList->Items[k]; colorShape->Pen->Color = clWhite; itexist=true; break; } } if (itexist) NewColorWayForm->selectedChipCount--; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ComboFormColorChange() //090722 { //Selector´Â ÆÈ·¿Æ®ÀÇ »öÀÌ º¯°æµÇµµ º¯°æµÇÁö ¾Ê´Â ¹®Á¦°¡ ÀÖ¾ú´Ù. //¾Æ·¡¿Í °°ÀÌ Ã³¸®ÇÏ¿© ¼öÁ¤ //Selector->SetPalette(MainImageForm->Palette); //Selector->Invalidate(); SubForm->ComboColorChange(this); } //--------------------------------------------------------------------------- void __fastcall TComboMenu::NewColorWayColorChange() { BEGIN_LOG("Combo_F"); if (NewColorWayForm) { //Selector´Â ÆÈ·¿Æ®ÀÇ »öÀÌ º¯°æµÇµµ º¯°æµÇÁö ¾Ê´Â ¹®Á¦°¡ ÀÖ¾ú´Ù. //¾Æ·¡¿Í °°ÀÌ Ã³¸®ÇÏ¿© ¼öÁ¤ Selector->SetPalette(NewColorWayForm->Palette); Selector->Invalidate(); if (NewColorWayForm->itsStart) { NewColorWayForm->RepaintImage(); } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::NewColorWayPrint() { BEGIN_LOG("Combo_F"); TComboPrintForm *PrintForm = NULL; int WW, HH, Page, count=0; //DPI TSize r; bool FitSize, ChipCheck; double rx, ry, DPI; float WRatio = 0.0, HRatio = 0.0; TShape *tShape; TPException ec = EC_NONE; if ((PrintForm = new TComboPrintForm(this))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } PrintForm->InitComboPrint(); PrintForm->ShowModal(); if (PrintForm->Print_OKBtn) { for (int i=0; iSmallShapeList->Count; i++) { tShape=(TShape *)NewColorWayForm->SmallShapeList->Items[i]; if (tShape->Pen->Color != Graphics::clBlack) count++; } if (count==0) { Application->MessageBox(IDS_MSGBOX1.c_str(), L"Information", MB_OK); return; } isprinting = true; // ÇÁ¸°Æ® ½ÃÀÛÀ» È®ÀÎÇÏ´Â ºÎºÐ FitSize = PrintForm->FitInPaper->Checked; ChipCheck = PrintForm->WithChipCheckBox->Checked; Page = PrintForm->SpinEditPage->Value; WW = GetDeviceCaps(Printer()->Handle, HORZRES)*MainImageForm->CanvasInfor.DotsPerInch/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); HH = GetDeviceCaps(Printer()->Handle, VERTRES)*MainImageForm->CanvasInfor.DotsPerInch/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); if (PrintForm->OnlyColorchipPrint->Checked) { PrintOlnyColorChip(WW, HH, Page); } else if (PrintForm->AllInPaper->Checked) AllInOnePaperPrint(ChipCheck, count, WW, HH, Page); else { if (NewColorWayForm->Bitmap->Width >= WW || NewColorWayForm->Bitmap->Height >= HH) { TShape *tShape; for (int i=0; iSmallShapeList->Count; i++) { tShape=(TShape *)NewColorWayForm->SmallShapeList->Items[i]; if (tShape->Pen->Color == Graphics::clBlack) continue; OverSizePrint(FitSize, ChipCheck, WW, HH, Page, i); } } else { NomalSizePrint(FitSize, ChipCheck, WW, HH, Page); } } } delete PrintForm; isprinting = false; // ÇÁ¸°Æ® ³¡À» È®ÀÎÇÏ´Â ºÎºÐ END_LOG; return; fail: if (PrintForm) delete PrintForm; isprinting = false; // ÇÁ¸°Æ® ³¡À» È®ÀÎÇÏ´Â ºÎºÐ EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::OverSizePrint(bool FitSize, bool ChipCheck, int WW, int HH, int Page, int imageNum) { BEGIN_LOG("Combo_F"); TUnionBitmap *Pattern = NULL; //ColorChipµîÀ» ºÙ¿©ÁØ´Ù. TSize r; double rx, ry, DPI; float WRatio = 0.0, HRatio = 0.0; TPException ec = EC_NONE; if ((Pattern = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } DPI = MainImageForm->CanvasInfor.DotsPerInch; if (!ChipCheck) { ComboHeaderNoMethod(Pattern, imageNum); if (FitSize) { rx = (double)WW / Pattern->Width; ry = (double)HH / Pattern->Height; if (rx < ry) { if (rx < 1.0) DPI = DPI / rx; } else { if (ry < 1.0) DPI = DPI / ry; } } } else if (ChipCheck) { if (!ComboHeaderYesMethod(Pattern, imageNum)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (FitSize) { rx = (double)WW / Pattern->Width; ry = (double)HH / Pattern->Height; if (rx < ry) { if (rx < 1.0) DPI = DPI / rx; } else { if (ry < 1.0) DPI = DPI / ry; } } } else { TSize colorArera; MainImageForm->ComboHeaderUsedColorMethod(Pattern, false, 100, colorArera); if (colorArera.cy < 0) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (!SendToPrinter(Pattern, DPI, "Multi Color Way - "+NewColorWayForm->pTitle, Page, 0, r, 0, WRatio, HRatio, MainImageForm->Number)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } delete Pattern; END_LOG; return; fail: if (Pattern) delete Pattern; EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::NomalSizePrint(bool FitSize, bool ChipCheck, int WW, int HH, int Page) { BEGIN_LOG("Combo_F"); TUnionBitmap *Pattern = NULL; //ColorChipµîÀ» ºÙ¿©ÁØ´Ù. TCanvas *Canvas = NULL; TSize r; TShape *tShape; double rx, ry, DPI; float WRatio = 0.0, HRatio = 0.0; int printW, PrintH, top=30, count=0, rTop=30; int tWidth, tHeight; int logX, logY; TPrinter *print = Printer(); HDC hPrtdc = print->Handle; HDC hCanvasDC; if ((Pattern = new TUnionBitmap)==NULL) goto fail; DPI = MainImageForm->CanvasInfor.DotsPerInch; if (!ChipCheck) ComboHeaderNoMethod(Pattern, -1); else ComboHeaderYesMethod(Pattern, -1); if (FitSize) { rx = (double)WW / Pattern->Width; ry = (double)HH / Pattern->Height; if (rx < ry) { if (rx < 1.0) DPI = DPI / rx; } else { if (ry < 1.0) DPI = DPI / ry; } } logX = GetDeviceCaps(hPrtdc, LOGPIXELSX); logY = GetDeviceCaps(hPrtdc, LOGPIXELSY); printW = GetDeviceCaps(hPrtdc, HORZRES)*DPI/logX; PrintH = GetDeviceCaps(hPrtdc, VERTRES)*DPI/logY; if (PrintHHeight) { // color chipÀ¸·Î 1page¿¡ µé¾î°¡Áö ¾ÊÀ»¶§ ó¸® for (int i=0; iSmallShapeList->Count; i++) { tShape=(TShape *)NewColorWayForm->SmallShapeList->Items[i]; if (tShape->Pen->Color == Graphics::clBlack) continue; OverSizePrint(FitSize, ChipCheck, WW, HH, Page, i); } delete Pattern; Pattern=NULL; return; } delete Pattern; Pattern=NULL; print->Title = "Multi Color Way - " + NewColorWayForm->pTitle; print->Copies = Page; print->BeginDoc(); hCanvasDC = print->Canvas->Handle; for (int i=0; iSmallShapeList->Count; i++) { tShape=(TShape *)NewColorWayForm->SmallShapeList->Items[i]; if (tShape->Pen->Color == Graphics::clBlack) continue; if ((Pattern = new TUnionBitmap)==NULL) goto fail; if (!ChipCheck) ComboHeaderNoMethod(Pattern, i); else ComboHeaderYesMethod(Pattern, i); if (PrintHHeight) { print->NewPage(); top=30; rTop=30; } tWidth = Pattern->Width * logX / DPI; tHeight = Pattern->Height * logY / DPI; Pattern->UnionStretchBlt(hCanvasDC, 30, rTop, tWidth, tHeight, 0, 0, Pattern->Width, Pattern->Height, SRCCOPY); top=top+Pattern->Height+30; rTop=rTop+tHeight+30; delete Pattern; Pattern=NULL; } #ifdef TRIAL PaintWaterMark(hCanvasDC, 0, 0, WW, HH, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif print->EndDoc(); END_LOG; fail: if (Pattern) delete Pattern; Pattern=NULL; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::AllInOnePaperPrint(bool ChipCheck, int count, int WW, int HH, int Page) { BEGIN_LOG("Combo_F"); TUnionBitmap *Pattern = NULL; //ColorChipµîÀ» ºÙ¿©ÁØ´Ù. TCanvas *Canvas = NULL; TSize r; TShape *tShape; double rx, ry, DPI; float WRatio = 0.0, HRatio = 0.0; int printW, PrintH, top=0, left=0, line=1, num=0; int tWidth, tHeight, plus=0, minus=1, wCount, hCount; double scaleW=1.0, scaleH=1.0, Dimension, sDimension, tDimension; TPrinter *print = Printer(); HDC hPrtdc = print->Handle; HDC hCanvasDC; if ((Pattern = new TUnionBitmap)==NULL) goto fail; DPI = MainImageForm->CanvasInfor.DotsPerInch; if (!ChipCheck) ComboHeaderNoMethod(Pattern, -1); else ComboHeaderYesMethod(Pattern, -1); printW = GetDeviceCaps(hPrtdc, HORZRES)*DPI/GetDeviceCaps(hPrtdc, LOGPIXELSX); PrintH = GetDeviceCaps(hPrtdc, VERTRES)*DPI/GetDeviceCaps(hPrtdc, LOGPIXELSY); if (Pattern->Width >= Pattern->Height) scaleW = (double)Pattern->Width/Pattern->Height; else scaleH = (double)Pattern->Height/Pattern->Width; Dimension = printW*PrintH; sDimension = (double)Dimension/(count+1); while(1) { plus++; tDimension = (scaleW*plus)*(scaleH*plus); if (sDimension < tDimension) { tWidth=scaleW*(plus-1)+60; tHeight=scaleH*(plus-1)+60; break; } } delete Pattern; Pattern=NULL; wCount=printW/tWidth; hCount=PrintH/tHeight; if ((wCount*hCount)Title = "Multi Color Way - " + NewColorWayForm->pTitle; print->Copies = Page; print->BeginDoc(); hCanvasDC = print->Canvas->Handle; for (int i=0; iSmallShapeList->Count; i++) { tShape=(TShape *)NewColorWayForm->SmallShapeList->Items[i]; if (tShape->Pen->Color == Graphics::clBlack) continue; if ((Pattern = new TUnionBitmap)==NULL) goto fail; if (!ChipCheck) ComboHeaderNoMethod(Pattern, i); else ComboHeaderYesMethod(Pattern, i); if (num/(wCount*line)) { left=0; line++; top=top+tHeight+30; } Pattern->UnionStretchBlt(hCanvasDC, left, top, tWidth, tHeight, 0, 0, Pattern->Width, Pattern->Height, SRCCOPY); left=left+tWidth+30; delete Pattern; Pattern=NULL; num++; } #ifdef TRIAL PaintWaterMark(hCanvasDC, 0, 0, WW, HH, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif print->EndDoc(); END_LOG; fail: if (Pattern) delete Pattern; Pattern=NULL; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::PrintOlnyColorChip(int WW, int HH, int Page) { BEGIN_LOG("Combo_F"); String NumString; HDC hCanvasDC, UsedColDC; TShape *tShape = NULL; TUnionBitmap *UsedColBit = NULL; TImageData *ImageData = NULL; TPrinter *print = Printer(); int GTop=100, GLeft=100; int Top=100, Left=100, tx=0, ty=0, tWidth=0, tHeight=0; int DPI = MainImageForm->CanvasInfor.DotsPerInch; print->Title = "Multi Color Way - " + NewColorWayForm->pTitle; print->Copies = Page; print->BeginDoc(); hCanvasDC = print->Canvas->Handle; print->Canvas->Pen->Color = clBlack; print->Canvas->Brush->Color = clWhite; for (int i=0; iSmallShapeList->Count; i++) { tShape=(TShape *)NewColorWayForm->SmallShapeList->Items[i]; if (tShape->Pen->Color == Graphics::clBlack) continue; ImageData=(TImageData*)NewColorWayForm->ImageDataList->Items[i]; if ((UsedColBit = new TUnionBitmap)==NULL) goto fail; if (ComboHeaderUsedColorMethod(UsedColBit, true, i) < 0) goto fail; if (i==0) { if (WW-200 < UsedColBit->Width) tWidth = WW-200; else tWidth = UsedColBit->Width - 200; tHeight = UsedColBit->Height; tWidth = tWidth * GetDeviceCaps(hCanvasDC, LOGPIXELSX) / DPI; tHeight = tHeight * GetDeviceCaps(hCanvasDC, LOGPIXELSY) / DPI; } if (i !=0 && GTop+tHeight > (HH*GetDeviceCaps(hCanvasDC, LOGPIXELSY)/DPI)) { print->NewPage(); GLeft=100; GTop=100; } NumString = "Number : " + IntToStr(i+1); print->Canvas->TextOut(GLeft, GTop, NumString); GTop += 100; UsedColBit->UnionStretchBlt(hCanvasDC, GLeft, GTop, tWidth, tHeight, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); delete UsedColBit; UsedColBit=NULL; GTop += (tHeight+50); } #ifdef TRIAL PaintWaterMark(hCanvasDC, 0, 0, WW, HH, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif print->EndDoc(); END_LOG; return; fail: if (UsedColBit) delete UsedColBit; UsedColBit=NULL; END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ComboHeaderNoMethod(TUnionBitmap *Pattern, int imageNum) { BEGIN_LOG("Combo_F"); int width, height; RGBQUAD rgb[256]; TImageData *ImageData=NULL; width = NewColorWayForm->Bitmap->Width; height = NewColorWayForm->Bitmap->Height; NewColorWayForm->Palette->ToRGBQUAD(rgb, 256); Pattern->Create(width, height, 8, rgb); Pattern->FillRect(Rect(0, 0, width, height), clWhite); Pattern->Copy(NewColorWayForm->Bitmap, SRCCOPY); if (imageNum<0 || imageNum>NewColorWayForm->ImageDataList->Count) { } else { ImageData = (TImageData *)NewColorWayForm->ImageDataList->Items[imageNum]; ImageData->Palette->ToRGBQUAD(rgb, 256); Pattern->PutColors(0, 256, rgb); } END_LOG; } //---------------------------------------------------------------------------- // using by maxleo21c (convert by celberus in mainimage) bool __fastcall TComboMenu::ComboHeaderYesMethod(TUnionBitmap *Pattern, int imageNum) { BEGIN_LOG("Combo_F"); bool over; TRect Src, Dst, PDst; TUnionBitmap *UsedColBit = NULL; TUnionBitmap *tempBit = NULL; TImageData *ImageData = NULL; int w, h, temp, ht, width, height, cnt; if ((UsedColBit = new TUnionBitmap)==NULL) goto fail; if (ComboHeaderUsedColorMethod(UsedColBit, true, imageNum) < 0) goto fail; width = NewColorWayForm->Bitmap->Width;; height = NewColorWayForm->Bitmap->Height; w = UsedColBit->Width;//*CanvasInfor.DotsPerInch/160; h = UsedColBit->Height;//*CanvasInfor.DotsPerInch/160; // {µÎ°³ÀÇ BitmapÀ» ÇÕÄ£ PatternÀÇ »õ·Î¿î ³ôÀÌ¿Í ³ÐÀÌ} ht = GetDeviceCaps(Printer()->Handle, VERTRES)*MainImageForm->CanvasInfor.DotsPerInch/ //*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); temp = height; //================================================ if (w>width) width = w; cnt = temp/ht; if ((temp-ht*cnt+h) > ht) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ cnt++; over = true; height = cnt*ht + h; } else { over = false; height = temp + h; } //================================================ Pattern->Create(width, height, 24); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if ((tempBit = new TUnionBitmap)==NULL) goto fail; ComboHeaderNoMethod(tempBit, imageNum); Pattern->Copy(0, 0, tempBit->Width, tempBit->Height, tempBit, 0, 0, SRCCOPY); delete tempBit; tempBit=NULL; //============================================ if (over) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ PDst = Rect(0, cnt*ht, w, cnt*ht+h); } else { PDst = Rect(0, temp , w, temp+h); } //============================================ Src = Rect(0, 0, UsedColBit->Width, UsedColBit->Height); Pattern->UnionStretchBlt(PDst.Left, PDst.Top, PDst.Right - PDst.Left, PDst.Bottom - PDst.Top, UsedColBit, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); delete UsedColBit; UsedColBit=NULL; END_LOG; return true; fail: if (UsedColBit) delete UsedColBit; UsedColBit=NULL; if (tempBit) delete tempBit; tempBit=NULL; END_LOG; return false; } //---------------------------------------------------------------------------- int __fastcall TComboMenu::ComboHeaderUsedColorMethod(TUnionBitmap *Pattern, bool Yes, int imageNum)// using by maxleo21c (convert by celberus in mainimage) // modified by smallpotato 2007.05.02 // color name ´ÙÁß line Ãâ·Â °ü·ÃÀ¸·Î ¶Ç ¼öÁ¤ 2008.03.11 by smallpotato { BEGIN_LOG("Combo_F"); TChoiceColor *ChoiceColor = NULL; int i, row, column, width, height; short tab; TSize chip_size, chip_count, page_margin, chip_gap, chip_period, chip_name_area; String NameStr = "", Rgbvalue, strColorValue1 = "", strColorValue2 = "", strColorValue3 = "", delimiter = " "; RGBQUAD rgb[256]; TRect BitRect, StrRect; TCanvas *ca = NULL; TTexpiaBitmap *tempBitmap = NULL, *stretchBitmap = NULL; // by celberus TRect tempRect; // by celberus HDC tempDC, stretchDC; // by celberus bool RGBnum = false; TImageData *ImageData = NULL; if (imageNum<0 || imageNum>NewColorWayForm->ImageDataList->Count) { ChoiceColor = NewColorWayForm->ChoiceColor; } else { ImageData = (TImageData *)NewColorWayForm->ImageDataList->Items[imageNum]; ChoiceColor = ImageData->ChoiceColor; } width = GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); height = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); if (Yes) { // ComboBoxYesMethod¿¡¼­ »ç¿ë ÇÒ °ª chip_size.cx = 90; chip_size.cy = 50; } else { // UsedColorMethod¿¡¼­ »ç¿ë ÇÒ °ª chip_size.cx = 110; chip_size.cy = 100; } page_margin.cx = 44; page_margin.cy = 30; chip_name_area.cx = chip_size.cx; chip_name_area.cy = 20; chip_gap.cx = 10; chip_gap.cy = chip_name_area.cy; chip_period.cx = chip_size.cx + chip_gap.cx; chip_period.cy = chip_size.cy + chip_gap.cy; chip_count.cx = (width-page_margin.cx) / chip_period.cx ; // Pattern Height Á¤Çϱâ chip_count.cy = 1 + ChoiceColor->Count / chip_count.cx; height = chip_count.cy * chip_period.cy + page_margin.cy * 2; Pattern->Create(width * MainImageForm->CanvasInfor.DotsPerInch / 160, height * MainImageForm->CanvasInfor.DotsPerInch / 160, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); tempBitmap = new TTexpiaBitmap; // by celberus if(!tempBitmap) goto fail; tempBitmap->Create(500 , 200, 24); // by celberus ÀÓÀÇÀÇ °ª stretchBitmap = new TTexpiaBitmap; if(!stretchBitmap) goto fail; stretchBitmap->Create(500 * MainImageForm->CanvasInfor.DotsPerInch / 160, 200 * MainImageForm->CanvasInfor.DotsPerInch / 160, 24); tempBitmap->FillRect(Rect(0, 0, tempBitmap->Width, tempBitmap->Height), clWhite); ca = tempBitmap->CreateCanvas(); // by celberus ca->Font->Size = 10; stretchDC = stretchBitmap->CreateDC(); for (i=0, column = 0; iCount; i++, column++) { if (i%chip_count.cx == 0) { row = i / chip_count.cx; column = 0; } NameStr = ""; StrRect = Rect(page_margin.cx + column * chip_period.cx, page_margin.cy + chip_size.cy + row * chip_period.cy, page_margin.cx + column * chip_period.cx + chip_name_area.cx, page_margin.cy + chip_size.cy + row * chip_period.cy + chip_name_area.cy); tempRect.left = 0; tempRect.right = StrRect.right - StrRect.left; // tempRect.top = 0; tempRect.bottom = StrRect.bottom - StrRect.top; // ca->Brush->Color = clWhite; if (RGBnum == false) { if ((ChoiceColor->ColorMap[i]->Kind & 0x400F) >= 0x4000){ switch (ChoiceColor->ColorMap[i]->Kind & 0x000F){ case 0: case 3: case 4: case 1: case 2: //080408 (³ª¸®)¿äûÀ¸·Î Ãß°¡ case 6: //Pantone coloe 080324 NameStr = ChoiceColor->ColorMap[i]->ColorName; Rgbvalue = Format("%d - %d - %d", OPENARRAY(TVarRec, (ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue))); break; } } else { switch (ChoiceColor->ColorMap[i]->Kind & 0x0FFF) { case 0: if (ChoiceColor->ColorMap[i]->Page==0) NameStr = Format("%d - %d - %d", OPENARRAY(TVarRec, (255-ChoiceColor->ColorMap[i]->RGB.rgbRed, 255-ChoiceColor->ColorMap[i]->RGB.rgbGreen, 255-ChoiceColor->ColorMap[i]->RGB.rgbBlue))); else NameStr = PrinterColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; break; case 1: case 2: NameStr = "Special Color"; break; case 3: NameStr = StandardColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 4: NameStr = TextileColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 6: //NameStr = ChoiceColor->ColorMap[i]->PantoneColor; NameStr = (char *)ChoiceColor->ColorMap[i]->additionalColorData->GetData(TAG_PANTONE_COLOR); break; } } } else if (RGBnum == true) { NameStr = Format("%d - %d - %d", OPENARRAY(TVarRec,(ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue))); } if(NameStr != ""){ ca->Font->Color = clBlack; int string_line_count = ca->TextWidth(NameStr) / chip_name_area.cx + 1; if(string_line_count == 1) { tab = (chip_name_area.cx - ca->TextWidth(NameStr)) / 2; ca->TextRect(tempRect, tab, 2, NameStr); } else { chip_size.cy -= (chip_name_area.cy * (string_line_count - 1)); StrRect.top -= (chip_name_area.cy * (string_line_count - 1)); int Char_index, start_index = 0, start_line = 0; for(Char_index = 1 ; Char_index < NameStr.Length() ; ++Char_index) { if(ca->TextWidth(NameStr.SubString(start_index, Char_index - start_index)) > chip_name_area.cx) { ca->TextRect(tempRect, 0, start_line * chip_name_area.cy + 2, NameStr.SubString(start_index, Char_index - start_index - 1)); tempRect.bottom += chip_name_area.cy; tempRect.top += chip_name_area.cy; start_index = Char_index; ++start_line; } } ca->TextRect(tempRect, 0, start_line * chip_name_area.cy + 2, NameStr.SubString(start_index, Char_index - start_index + 1)); } } else{ tab = (chip_name_area.cx - ca->TextWidth(strColorValue1 + delimiter + strColorValue2 + delimiter + strColorValue3) ) / 2; // Adjust Center if (tab<0) tab = 0; // ¿©±â¼­ºÎÅÍ color code¸¦ ½á³Ö´Â ºÎºÐ ca->Font->Color = clRed; ca->TextRect(tempRect, tab, 2, strColorValue1); // by smallpotato 2007.05.02 tab += ca->TextWidth(strColorValue1 + delimiter); tempRect.Left = tab; ca->Font->Color = clGreen; ca->TextRect(tempRect, tab, 2, strColorValue2); // by smallpotato 2007.05.02 tab += ca->TextWidth(strColorValue2 + delimiter); tempRect.Left = tab; ca->Font->Color = clBlue; ca->TextRect(tempRect, tab, 2, strColorValue3); // by smallpotato 2007.05.02 } BitRect = Rect((page_margin.cx + column * chip_period.cx) * MainImageForm->CanvasInfor.DotsPerInch / 160, (page_margin.cy + row * chip_period.cy) * MainImageForm->CanvasInfor.DotsPerInch / 160, (page_margin.cx + column * chip_period.cx + chip_size.cx) * MainImageForm->CanvasInfor.DotsPerInch / 160, (page_margin.cy + row * chip_period.cy + chip_size.cy) * MainImageForm->CanvasInfor.DotsPerInch / 160); PrintColorChip24(Pattern, BitRect, ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue); chip_size.cy = chip_period.cy - chip_name_area.cy; SetStretchBltMode(stretchDC, COLORONCOLOR); StretchBlt(stretchDC, 0, 0, (StrRect.right - StrRect.left) * MainImageForm->CanvasInfor.DotsPerInch / 160, (StrRect.bottom - StrRect.top) * MainImageForm->CanvasInfor.DotsPerInch / 160, ca->Handle, 0, 0, StrRect.right - StrRect.left, StrRect.bottom - StrRect.top, SRCCOPY); Pattern->UnionBitBlt(stretchDC, StrRect.left * MainImageForm->CanvasInfor.DotsPerInch / 160, StrRect.top * MainImageForm->CanvasInfor.DotsPerInch / 160, (StrRect.right - StrRect.left) * MainImageForm->CanvasInfor.DotsPerInch / 160, (StrRect.bottom - StrRect.top) * MainImageForm->CanvasInfor.DotsPerInch / 160, 0, 0, SRCCOPY, true); // by celberus BitBlt(ca->Handle, 0, 0, tempRect.right, tempRect.bottom, NULL, 0, 0, WHITENESS); // ÇϳªÇϳª¾¿ Âï¾îÁÜ } tempBitmap->DeleteCanvas(ca); stretchBitmap->DeleteDC(stretchDC); delete tempBitmap; // by celberus delete stretchBitmap; END_LOG; return 0; fail: if(tempBitmap) delete tempBitmap; // by celberus if(stretchBitmap) delete stretchBitmap; END_LOG; return -1; } //---------------------------------------------------------------------------- void __fastcall TComboMenu::NewColorWayFormMouseWheel(TShiftState Shift, int WheelDelta) { if (NewColorWayForm) { if (NewColorWayForm->onImage) NewColorWayForm->PLayerImage->SetPosition(NewColorWayForm->PLayerImage->PositionX, NewColorWayForm->PLayerImage->PositionY-WheelDelta); else if (NewColorWayForm->onSImage) { if (WheelDelta<0) NewColorWayForm->ImageScrollBox->VertScrollBar->Position+=338; else NewColorWayForm->ImageScrollBox->VertScrollBar->Position-=338; } else if (NewColorWayForm->onChip) { if (WheelDelta<0) NewColorWayForm->UseColorScrollBox->VertScrollBar->Position+=120; else NewColorWayForm->UseColorScrollBox->VertScrollBar->Position-=120; } } } //--------------------------------------------------------------------------- // by embakum (07.03.09) //--------------------------------------------------------------------------- void __fastcall TComboMenu::EditorSelectAll(TObject *Sender) { SetFocusAndSelectAll(Sender); } //--------------------------------------------------------------------------- void __fastcall TComboMenu::ExecuteHotKey(String command) { if (rzbitbtnNew->Down == true) { if (NewColorWayForm != NULL) NewColorWayForm->ExecuteHotKey(command); } } //--------------------------------------------------------------------------- void __fastcall TComboMenu::rzbitBeforeClick(TObject *Sender) { BEGIN_LOG("Combo_F"); ChangePanel->Visible = true; HuePanel->Visible = false; if(BasicPalette) { delete BasicPalette; BasicPalette = NULL;} ClientHeight = 175; //Parent->Height = ParentHeight+ClientHeight; Selector->Invalid(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::rzbitbtnRunClick(TObject *Sender) { BEGIN_LOG("Combo_F"); int j; double h, l, s, a; if (SubForm && SubForm->step > 0){ SubForm->DrawRectangle(Sender, SubForm->Temp); SubForm->step = 0; SubForm->Repaint(); } if (sbChange->Down) { rzbitbtnRun->Enabled = false; rzbitbtnExit->Enabled = true; sbHue->Enabled = false; SelectorPanel->Visible = false; PlayPanel->Visible = true; if (SubForm) { SubForm->SetData(); SubForm->CanVisible(1); lPageTotal->Caption = Format("%d/%d", OPENARRAY (TVarRec, (SubForm->rotate.number, SubForm->rotate.total))); } else { NewColorWayForm->SetData(Selector->Count); Selector->SetPalette(NewColorWayForm->Palette); Selector->Invalid(); lPageTotal->Caption = Format("%d/%d", OPENARRAY (TVarRec, (NewColorWayForm->rotate.number, NewColorWayForm->rotate.total))); } } else if (sbHue->Down) { if (Selector->Count == 0) { MessageDlg(IDS_MESSAGE_CHOOSECOLOR, mtInformation, TMsgDlgButtons()<Visible = true; HuePanel->Visible = false; ClientHeight = 175; //Parent->Height = ParentHeight+ClientHeight; } else { HuePanel->Top = ChangePanel->Top + 3; ChangePanel->Visible = false; HuePanel->Visible = true; //ClientHeight = 203; //Parent->Height = ParentHeight + ClientHeight; if (SubForm) Selector->SetPalette(SubForm->Selector[SubForm->page]->Palette); else Selector->SetPalette(NewColorWayForm->Palette); BasicPalette = new TPalette; bOK = true; if (SubForm) BasicPalette->SetPalette(SubForm->Selector[SubForm->page]->Palette); else BasicPalette->SetPalette(NewColorWayForm->Palette); Basic.Hue = 0; Basic.Lig = 0; Basic.Sat = 0; for (j=0; jCount; j++) { BasicPalette->RGBToHLS(Selector->Code[j], h, l, s); if (h != UNDEFINED) { if (j > 0) { a = Basic.Hue / j; if (a < 180) { if (h >= a + 180) h = h - 360; } else { if (h <= a - 180) h = h + 360; } } Basic.Hue = Basic.Hue + h; Basic.Lig = Basic.Lig + l; Basic.Sat = Basic.Sat + s; } } Basic.Hue = Basic.Hue / Selector->Count; if (Basic.Hue < 0) Basic.Hue = Basic.Hue + 360; else if (Basic.Hue >= 360) Basic.Hue = Basic.Hue - 360; Basic.Lig = Basic.Lig / Selector->Count; Basic.Sat = Basic.Sat / Selector->Count; Hue = Basic.Hue; Lig = 100*Basic.Lig; Sat = 100*Basic.Sat; ComboImageHS->Picture->Bitmap->PixelFormat = pf24bit; ComboImageHS->Picture->Bitmap->Width = 65; ComboImageHS->Picture->Bitmap->Height = 65; ComboImageHS->Canvas->Brush->Color = clBtnFace; ComboImageHS->Canvas->FillRect(Rect(0, 0, ComboImageHS->Width, ComboImageHS->Height)); CDrawHS(); ComboImageHS->Canvas->Pen->Mode = pmXor; ComboImageHS->Canvas->Pen->Color = clWhite; CDrawHSBar(Hue, Sat); bHS = true; ComboImageL->Picture->Bitmap->PixelFormat = pf24bit; ComboImageL->Picture->Bitmap->Width = 65; ComboImageL->Picture->Bitmap->Height = 65; ComboImageL->Canvas->Brush->Color = clBtnFace; ComboImageL->Canvas->FillRect(Rect(0, 0, ComboImageL->Width, ComboImageL->Height)); CDrawL(); ComboImageL->Canvas->Pen->Mode = pmXor; ComboImageL->Canvas->Pen->Color = clWhite; CDrawLBar(Lig); bL = true; comboseHue->Value = Hue; chHue = Hue; comboseLig->Value = Lig; chLig = Lig; comboseSat->Value = Sat; bOK = false; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::rzbitbtnExitClick(TObject *Sender) { BEGIN_LOG("Combo_F"); rzbitbtnExit->Enabled = false; rzbitbtnRun->Enabled = true; sbHue->Enabled = true; if (PlayBar) PlayBar->SetInit(); PlayPanel->Visible = false; SelectorPanel->Visible = true; END_LOG; } //--------------------------------------------------------------------------- // by maxleo21c (06.09.27) // 080404 Á¾ÀÍÀ̰¡ ¸¸µç°Í ´Ù½Ã ¼öÁ¤ : ¹®Á¦Á¡Àº roatate.max¸¦ ÁöÁ¤ÇÏÁöµµ ¾Ê°í // max°¡ MAX_COMBO_NUMBER·Î ÁöÁ¤µÇ¸é new·Î »ý¼ºÇÏ´Â °Í¿¡¼­ over flow°¡ ¹ß»ýÇß´Ù. // ÇÊ¿äÇÑ ¸¸Å­(StyleNumEdit->Value)¸¸ New·Î »ý¼ºÇϰí randomÇÏ°Ô »ý¼ºµÇ´Â ¼ö¸¦ // È®ÀÎÇØ¼­ Áߺ¹µÇ´Â ¼ö°¡ ¾øµµ·Ï ó¸®Çß´Ù. // StyleNumEdit->MaxValue°¡ 20À̱⠶§¹®¿¡ ¹®Á¦°¡ ¹ß»ýÇÏÁö ¾ÊÀ¸¸®¶ó »ý°¢ÇÑ´Ù. void __fastcall TComboMenu::rzbitbtnAutoClick(TObject *Sender) { BEGIN_LOG("Combo_F"); int num = StyleNumEdit->Value; TPalette *nowPalette = NULL; int last, initnum, addition, k; if (sbChange->Down) { last = 0; nowPalette = new TPalette; nowPalette->SetPalette(NewColorWayForm->Palette); if (Selector->Count == 0) sbComboNewClick(sbComboAll); if (NewColorWayForm->ImageDataList->Count == 0) { NewColorWayForm->PopupSelectClick(NewColorWayForm->PopupSelect); last = 1; } rzbitbtnRunClick(rzbitbtnRun); //NewColorWayForm->rotate.totalÀÌ MAX_COMBO_NUMBER°¡ µÉ ¼ö Àֱ⠶§¹®¿¡ //Auto·Î ¸¸µé¾î ÁÙ¼ö ÀÖ´Â °Í¿¡ ÇѰ踦 ÁÖ¾ú´Ù. //Å©±â´Â 10000Á¤µµ·Î ÇÒ »ý°¢ÀÌ´Ù. //int* flag = new int[NewColorWayForm->rotate.total+1]; ///Áߺ¹À» ¹æÁöÇϱâÀ§ÇÑ ¹è¿­ //for(int j=1;jrotate.total+1;j++) { ///ÃʱâÈ­ // flag[j]=0; //} int MAX_AUTO = StyleNumEdit->Max; int* flag = new int[MAX_AUTO]; ///Áߺ¹À» ¹æÁöÇϱâÀ§ÇÑ ¹è¿­ for(int j=1;jNewColorWayForm->rotate.total) num=NewColorWayForm->rotate.total;///¸¸µé ¼ö ÀÖ´Â ÃÖ´ë À̹ÌÁö¼öÀÇ Á¦ÇÑ for (int i=last; irotate.total; }while(flag[k]!=0); ///¾ÆÁ÷ Imagelist¿¡ ¾È¿Ã·ÁÁø À̹ÌÁö¸¦ °ñ¶ó³¿ flag[k]=1; if(NewColorWayForm->rotate.total>40320) Progress->Position =k * ((NewColorWayForm->rotate.total)/RAND_MAX); //°æ¿ìÀÇ ¼ö°¡ ³Ê¹« ¸¹Àº °æ¿ìrand()ÀÇ ¹ß»ý ¹üÀ§¸¦ ¸ÂÃçÁÜ. else Progress->Position = k; NewColorWayForm->PopupSelectClick(NewColorWayForm->PopupSelect); }*/ if(num>MAX_AUTO) num=MAX_AUTO;///¸¸µé ¼ö ÀÖ´Â ÃÖ´ë À̹ÌÁö¼öÀÇ Á¦ÇÑ //Àüü °³¼öº¸´Ù ¸¸µé¾î¾ß ÇÒ °³¼ö°¡ ÀÛÀ¸¸é ¾Æ·¡ for¹®¿¡¼­ ¹«ÇÑ·çÇÁ¸¦ µ¹°Ô µÈ´Ù. by david 090907 if (num > NewColorWayForm->rotate.total) { if (nowPalette) { delete nowPalette; nowPalette = NULL; } delete[] flag; return; } for (int i=last; irotate.total; for (int j = 0; j < i; j++) { if (flag[j] == k) { k = rand()%NewColorWayForm->rotate.total; j = 0; } } flag[i] = k; if(NewColorWayForm->rotate.total>40320) Progress->Position = flag[i] * ((NewColorWayForm->rotate.total)/RAND_MAX); //°æ¿ìÀÇ ¼ö°¡ ³Ê¹« ¸¹Àº °æ¿ìrand()ÀÇ ¹ß»ý ¹üÀ§¸¦ ¸ÂÃçÁÜ. else Progress->Position = flag[i]; NewColorWayForm->PopupSelectClick(NewColorWayForm->PopupSelect); } delete[] flag; } else if (sbHue->Down) { nowPalette = new TPalette; last = 0; nowPalette->SetPalette(NewColorWayForm->Palette); if (Selector->Count == 0) sbComboNewClick(sbComboAll); if (NewColorWayForm->ImageDataList->Count == 0) { NewColorWayForm->PopupSelectClick(NewColorWayForm->PopupSelect); last = 1; } rzbitbtnRunClick(rzbitbtnRun); initnum = comboseHue->Value; for (int i=num; i>last; i--) { addition = 360/i; comboseHue->Value = (initnum + addition)%360; NewColorWayForm->PopupSelectClick(NewColorWayForm->PopupSelect); //NewColorWayForm->PopupReFreshClick(NewColorWayForm->PopupReFresh); Selector->SetPalette(nowPalette); rzbitbtnRunClick(rzbitbtnRun); } } if (nowPalette) { delete nowPalette; nowPalette = NULL; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::rzbitbtnOldClick(TObject *Sender) { BEGIN_LOG("Combo_F"); if (useCombo) return; if (NewColorWayForm) { if (!ExitForm()) { rzbitbtnNew->Down = true; END_LOG; return; } } if (SubForm) // ¸¸¾à subformÀÇ close¸¸ ½ÇÇàÇÑ »óŸé subformÀÌ ³²¾Æ Àֱ⠶§¹®¿¡ ExitForm(true); // ÀÌ °æ¿ì¿¡´Â ÀúÀå ¸Þ¼¼Áö ¹Ú½º¸¦ ½ÇÇàÇÒ Çʿ䰡 ¾ø´Ù. StyleNumEdit->Enabled = false; useCombo = true; useNewCombo = false; isLoad= false; PlayBar = new TPlayBar(PlayPanel); PlayBar->Parent = PlayPanel; PlayBar->Align = alTop; PlayBar->Margins->Left = 5; PlayBar->Margins->Right = 5; PlayBar->Margins->Top = 10; PlayBar->Margins->Bottom = 3; // PlayBar->Left = 4; // PlayBar->Top = 0; PlayBar->OnPlay = PlayBarPlay; PlayBar->SetBounds(4,4,204,30); RECT r = (MainImageForm->WorkArea->Mask) ? MainImageForm->WorkArea->Range : Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height) ; MainImageForm->UndoSave(UK_ALL, r); ClientHeight = 175; //Parent->Height = ParentHeight+ClientHeight; rzbitbtnAuto->Enabled = false;//by bomchun ÀÌ³Êºí ¹®Á¦ SubForm = new TComboForms(MainForm); SubForm->Parent = MainForm; if (SubForm->InitForm() == false) { delete SubForm; SubForm = NULL; error = true; } else error = false; sbChange->Down = true; ChangePanel->Visible = true; HuePanel->Visible = false; BasicPalette = NULL; Selector->SetPalette(MainImageForm->Palette); Selector->Initial(); Progress->Position = 0; if (rzbitbtnExit->Enabled) // added by maxleo21c (05.06.10) rzbitbtnExitClick(this); // ÀÌ»óÇϰԵµ progress bar »óÅ·Π½ÃÀÛÇÏ´Â °æ¿ì°¡ ÀÖ´Ù. if (error) PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); //Shape1->Pen->Color = clRed; //Shape2->Pen->Color = clBtnShadow; //Shape1->Visible = true; //Shape2->Visible = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::rzbitbtnNewClick(TObject *Sender) { BEGIN_LOG("Combo_F"); if (useNewCombo) { END_LOG; return; } if (SubForm) { if (!ExitForm()) { rzbitbtnOld->Down = true; END_LOG; return; } } if (NewColorWayForm) NewExitForm(); StyleNumEdit->Enabled = true; useNewCombo = true; useCombo = false; isLoad= false; PlayBar = new TPlayBar(PlayPanel); PlayBar->Parent = PlayPanel; PlayBar->Left = 4; PlayBar->Top = 4; PlayBar->OnPlay = PlayBarPlay; RECT r = (MainImageForm->WorkArea->Mask) ? MainImageForm->WorkArea->Range : Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height) ; MainImageForm->UndoSave(UK_ALL, r); ClientHeight = 175; //Parent->Height = ParentHeight+ClientHeight; NewColorWayForm = new TNewColorWayForm(MainForm); NewColorWayForm->Parent = MainForm; rzbitbtnAuto->Enabled = true; NewColorWayForm->pTitle = MainImageForm->FileName; NewColorWayForm->InitForm(); NewColorWayForm->Visible = true; sbChange->Down = true; ChangePanel->Visible = true; HuePanel->Visible = false; BasicPalette = NULL; Selector->SetPalette(MainImageForm->Palette); Selector->Initial(); Progress->Position = 0; if (rzbitbtnExit->Enabled) // added by maxleo21c (05.06.10) rzbitbtnExitClick(this); // ÀÌ»óÇϰԵµ progress bar »óÅ·Π½ÃÀÛÇÏ´Â °æ¿ì°¡ ÀÖ´Ù. if (error) PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); //Shape1->Pen->Color = clRed; //Shape2->Pen->Color = clBtnShadow; //Shape1->Visible = true; //Shape2->Visible = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::sbBeforeClick(TObject *Sender) { BEGIN_LOG(""); Selector->LoadFromFile(AppDataItem + "\\Combo.ini", "Color"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TComboMenu::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); // PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); if (MainMenuForm->ExitForm(1) == true) Action = true; else Action = false; END_LOG; } //---------------------------------------------------------------------------