// --------------------------------------------------------------------------- #include #include #pragma hdrstop #include "PenManager.h" #include "Define.h" #include "MainImage.h" #include "Palette.h" #include "Undo.h" #include "Draw_F.h" //lhskys pointlist ÀÌ¿ë... #include "Window.h" // GreenFish Filtering PenÀ¸·Î ÀÌ¿ë #include "Vector_F.h" #include "Kasuri_F.h" //kasuri #include "Main.h"//kasuri #include "LogData.h" #include "FullView.h" // --------------------------------------------------------------------------- // #include "PenAndNaviDock_F.h" #include "PenAndNaviTab_F.h" // --------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "Selector" #pragma link "TPStretchImage" #pragma link "TPImage" #pragma link "TPLayerImage" #pragma link "RzEdit" #pragma link "RzSpnEdt" #pragma link "TNumEdit" #pragma link "RzButton" #pragma link "RzTrkBar" #pragma link "RzRadChk" #pragma link "RzBckgnd" #pragma link "RzPanel" #pragma link "RzCmboBx" #pragma link "RzBckgnd" #pragma link "RzButton" #pragma link "RzPanel" #pragma link "RzRadChk" #pragma link "RzTrkBar" #pragma resource "*.dfm" // --------------------------------------------------------------------------- #define IDS_PEN StringTable[0] #define IDS_TOSQUARE StringTable[1] #define IDS_AIRBRUSH StringTable[2] #define IDS_CRAYON StringTable[3] #define IDS_WATERPEN StringTable[4] #define IDS_SCRAPEPEN StringTable[5] #define IDS_MASKPEN StringTable[6] #define IDS_PRESSURE StringTable[7] #define IDS_ANTIALISE StringTable[8] #define IDS_SINGLE StringTable[9] #define IDS_MULTI StringTable[10] #define IDS_PATTERN StringTable[11] #define IDS_DENSITY StringTable[12] #define IDS_NOZZLE StringTable[13] #define IDS_SPREAD StringTable[14] #define IDS_COLOR StringTable[15] #define IDS_BRISTLES StringTable[16] #define IDS_SCALE StringTable[17] #define IDS_SPREADGRADE StringTable[18] #define IDS_SELECTCOLOR StringTable[19] #define IDS_SELECT StringTable[20] #define IDS_SIMPLE StringTable[21] #define IDS_SPATTER StringTable[22] #define IDS_PURE StringTable[23] #define IDS_DIFFUSE StringTable[24] #define IDS_EFFECT StringTable[25] #define IDS_SHAPE StringTable[26] #define IDS_DRAWINGPEN StringTable[27] #define IDS_INSIDEDENSITY StringTable[28] #define IDS_OUTSIDEDENSITY StringTable[29] #define IDS_CLEAR StringTable[30] #define IDS_DELETE StringTable[31] #define IDS_FILL StringTable[32] #define IDS_TOCIRCLE StringTable[33] #define IDS_REVERSAL StringTable[34] #define IDS_BLUR StringTable[35] #define IDS_CONCENTRATION StringTable[36] #define IDS_IRREGULARITY StringTable[37] #define IDS_AIRBRUSH_DELETE StringTable[38] #define IDS_AIRBRUSH_DELALL StringTable[39] #define IDS_AIRBRUSH_RESET StringTable[40] #define IDS_KASURIPEN StringTable[41] #define IDS_KASURI StringTable[42] #define IDS_SCRATCH StringTable[43] #define IDS_PENTHICK StringTable[44] #define IDS_DRAW StringTable[45] #define MAX_PEN_HALF_WIDTH 25 // 7.42 ¹öÀü¿¡¼­ ÀÌ °ªÀº 14 (¹°·Ð 7.41ÀÌÀü¿¡ Á¤ÇØÁø °ªÀ̰ÚÁö¸¸..) #define MAX_PEN_LEFT_CENTER 25 // 7.42 ¹öÀü¿¡¼­ ÀÌ °ªÀº 13 (ÀÌ °ªÀÌ ¿¡·¯¸¦ À¯¹ßÇßÁö¸¸ ¾î¶² ¿ëµµ·Î »ç¿ëµÇ¾ú´ÂÁö ¸ô¶ó defineÀ» µû·Î Çß´Ù) by celberus // --------------------------------------------------------------------------- TPenManagerForm *PenManagerForm; // --------------------------------------------------------------------------- __fastcall TPenManagerForm::TPenManagerForm(TComponent* Owner) : TForm(Owner) // TPenAndNaviDockForm(Owner) { update = true; // =============================== 2001.5.3 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è StringTable.Create(DirectoryBin, Language, "PenManager"); SetFont(); Random = new TTexpiaRandom(360); Pen = new TPenObject(Tablet); if (Tablet) { // by david 090903 if (!Tablet->IsDevice()) Tablet->MaxNPressure = 1; if (!Tablet->MaxNPressure) Tablet->MaxNPressure = 1; } else { rzcbPressure->Enabled = false; } MenuSW = false; Type = PT_NORMAL; SingleColor.color = 1; // gabriel: init AirType = PAT_SINGLE; // gabriel: <- multi <- single AirBrushHighestColorIndex = 1; // gabriel: init BtnClick = false; ClientHeight = sbBtnUp->Top + sbBtnUp->Height; // rzSeparator2->Top;//ExitPanel->Top + ExitPanel->Height; FHeight = ClientHeight; EtcPanel->Left = 0; EtcPanel->Top = MainPanel->Height; // ClientHeight; WaterPanel->Left = 0; WaterPanel->Top = MainPanel->Height; // ClientHeight; AirBrushPanel->Left = 0; AirBrushPanel->Top = MainPanel->Height; // ClientHeight; MaskPanel->Left = 0; MaskPanel->Top = MainPanel->Height; // ClientHeight; Pen->BasicThick = 12; sbNormal->Down = true; // sbBtnUp->Visible = false; // spBtnDown->Visible = true; AirColorList = new TList; spread_pos = 0; spread_grade = 2; interval = 70; aspread = false; acolor = 0; Pen->Brush = 0; cr[PWT_SIMPLE] = 0.14; or[PWT_SIMPLE] = 0.90; cr[PWT_SPATTER] = 0.93; or[PWT_SPATTER] = 0.00; cr[PWT_PURE] = 0.66; or[PWT_PURE] = 0.93; cr[PWT_DIFFUSE] = 0.30; or[PWT_DIFFUSE] = 0.08; WaterType = PWT_SIMPLE; FPointPressurePen = point_pressure_pen; init_pressure_pen(); kasuriPointCount = 4; // shin 061024 kasuriBranchCount = 1; // shin 061024 // ======================================== Caption = IDS_PEN; PenWidthPanel->Hint = String(IDS_COMMON_CIRCLE) + " : " + String (IDS_TOSQUARE); sbNormal->Hint = IDS_COMMON_NORMAL; sbAirBrush->Hint = IDS_AIRBRUSH; sbCrayon->Hint = IDS_CRAYON; sbWater->Hint = IDS_WATERPEN; sbScratch->Hint = IDS_SCRAPEPEN; sbMask->Hint = IDS_MASKPEN; // rzcbPressure->Caption = IDS_PRESSURE; rzcbPressure->Hint = IDS_PRESSURE; imgPressure->Hint = IDS_PRESSURE; // rbSingle->Caption = IDS_SINGLE; // rbMulti->Caption = IDS_MULTI; // rbPattern->Caption = IDS_PATTERN; imgSingle->Hint = IDS_SINGLE; imgMulti->Hint = IDS_MULTI; imgPattern->Hint = IDS_PATTERN; // lbDensity2->Caption = IDS_DENSITY; // lbDropSize->Caption = IDS_NOZZLE; // lbConcentration->Caption = IDS_CONCENTRATION; // lbIrregularity->Caption = IDS_IRREGULARITY; imgDensity2->Hint = IDS_DENSITY; imgDropSize->Hint = IDS_NOZZLE; imgConcentration->Hint = IDS_CONCENTRATION; imgIrregularity->Hint = IDS_IRREGULARITY; tbSprayDensity->Hint = IDS_DENSITY; tbConcentration->Hint = IDS_CONCENTRATION; tbIrregularity->Hint = IDS_IRREGULARITY; tbDropSize->Hint = IDS_NOZZLE; // rzckColorSpread->Caption = String(IDS_SPREAD);// + " : " + String(IDS_COMMON_OFF); rzckColorSpread->Hint = IDS_SPREAD; imgSpread->Hint = IDS_SPREAD; rzckEtcDraw->Hint = IDS_DRAWINGPEN; imgEtcDraw->Hint = IDS_DRAWINGPEN; rzckColorSelect->Caption = String(IDS_COLOR); // + " : " + String(IDS_COMMON_BUTTONNO); lBristles->Caption = IDS_BRISTLES; lScale->Caption = IDS_SCALE; sbNew->Hint = IDS_COMMON_NEW; sbAll->Hint = IDS_COMMON_ALL; sbBlock->Hint = IDS_COMMON_BLOCKCOLOR; sbDelete->Hint = IDS_COMMON_INSERTCOLOR; sbBefore->Hint = IDS_COMMON_BEFORECOLOR; // spreadgrade->Caption = IDS_SPREADGRADE; // spreadgrade->Caption = String(IDS_SPREADGRADE) + "(2 - 70)"; sbWSimple->Hint = IDS_WATERPEN; sbWSpatter->Hint = IDS_SPATTER; rzbitbtnDelAll->Caption = IDS_CLEAR; sbWPure->Hint = IDS_PURE; sbWDiffuse->Hint = IDS_DIFFUSE; BtnAvg->Hint = IDS_BLUR; lbDensity->Caption = IDS_DENSITY; lbColor->Caption = IDS_COLOR; lbEffect->Caption = IDS_EFFECT; // lSelectDraw->Caption = IDS_SELECTCOLOR; lDensity->Caption = IDS_DENSITY; rzrbDraw->Caption = IDS_DRAW; rzrbFill->Caption = IDS_FILL; rzbitbtnReverse->Caption = IDS_REVERSAL; rzckDelete->Caption = IDS_DELETE; rzbitbtnDelAll->Caption = IDS_CLEAR; // ======================================== // gabriel Delete1->Caption = IDS_AIRBRUSH_DELETE; DeleteAll->Caption = IDS_AIRBRUSH_DELALL; Reset->Caption = IDS_AIRBRUSH_RESET; // ======================================== subScratchItem->Caption = IDS_SCRATCH; subKasuriItem->Caption = IDS_KASURI; lbDiameter->Caption = IDS_PENTHICK; penspread = 0; // lhskys pentaper = 0; // lhskys pointList = new TList; // =============================================== bMenuDown = false; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenShapeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { MainImageForm->iMainImageChange(); if (Pen->Shape == 1) { PenShape->Shape = stCircle; rzsePenSize->Value = Pen->BasicThick; Pen->Shape = 0; PenWidthPanel->Hint = String(IDS_COMMON_CIRCLE) + " : " + String (IDS_TOSQUARE); } else if (Pen->Shape == 0) { PenShape->Shape = stRectangle; rzsePenSize->Value = Pen->BasicThick; Pen->Shape = 1; PenWidthPanel->Hint = String(IDS_COMMON_SQUARE) + " : " + String (IDS_TOCIRCLE); } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenWidthPanelClick(TObject *Sender) { MainImageForm->iMainImageChange(); if (Pen->Shape == 1) { PenShape->Shape = stCircle; rzsePenSize->Value = Pen->BasicThick; Pen->Shape = 0; PenWidthPanel->Hint = String(IDS_COMMON_CIRCLE) + " : " + String (IDS_TOSQUARE); } else if (Pen->Shape == 0) { PenShape->Shape = stRectangle; rzsePenSize->Value = Pen->BasicThick; Pen->Shape = 1; PenWidthPanel->Hint = String(IDS_COMMON_SQUARE) + " : " + String (IDS_TOCIRCLE); } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzsePenSizeClick(TObject *Sender) { rzsePenSize->SetFocus(); rzsePenSize->SelectAll(); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenSelectClick(TObject *Sender) { BEGIN_LOG(""); TSpeedButton *s; TPenType bftype; bftype = Type; s = (TRzMenuToolbarButton*)Sender; if (s == sbNormal) Type = PT_NORMAL; else if (s == sbAirBrush) Type = PT_AIR; else if (s == sbCrayon) Type = PT_CRAYON; else if (s == sbWater) Type = PT_WATER; else if (s == sbScratch) Type = PT_SCRAPE; else if (s == sbMask) Type = PT_MASK; // else if (s == sbKasuri) Type = PT_KASURI; // else if (s == sbScratch_sub) Type = PT_SCRATCH; if (bftype != Type) MenuSW = true; InitType(Sender); if (DrawForm) { // ÀåÁø¸¸ : ±×¸®´Â µµÁß¿¡ Ææ ¹Ù²Ù¸é ¼± ²÷À½ if (DrawForm->Item == 0) DrawForm->FunctionClick((TObject*)DrawForm->sbLine); else if (DrawForm->Item == 5) DrawForm->FunctionClick((TObject*)DrawForm->sbCurve); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::sbNormalMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); #ifndef N_SCREENCAM String screencam, cam, camdir; TRegistry *Registry; SHELLEXECUTEINFO screeninfo; if (Button == mbRight && Shift.Contains(ssShift)) { Registry = new TRegistry; if (!Registry) { END_LOG; return; } Registry->RootKey = HKEY_LOCAL_MACHINE; Registry->OpenKey(RegFilename + "\\Directory", TRUE); // yw screencam = Registry->ReadString("screencam"); delete Registry; memset(&screeninfo, 0, sizeof(screeninfo)); screeninfo.cbSize = sizeof(screeninfo); screeninfo.lpVerb = L"open"; screeninfo.lpDirectory = screencam.c_str(); screeninfo.lpFile = L"scplayer.exe"; switch(dynamic_cast(Sender)->Tag) { case 0: cam = screencam + "\\TexStylist\\pen2.scm"; break; case 1: cam = screencam + "\\TexStylist\\pen2.scm"; break; case 2: cam = screencam + "\\TexStylist\\pen3.scm"; break; case 3: cam = screencam + "\\TexStylist\\pen3.scm"; break; case 4: cam = screencam + "\\TexStylist\\pen4.scm"; break; case 5: cam = screencam + "\\TexStylist\\pen5.scm"; break; } camdir = "\"" + cam + "\""; screeninfo.lpParameters = camdir.c_str(); screeninfo.fMask = SEE_MASK_NOCLOSEPROCESS; screeninfo.nShow = SW_SHOWDEFAULT; if (!ShellExecuteEx(&screeninfo)) { ShowMessage("can't play screencam movie."); END_LOG; return; } } #endif END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::MenuClick(TObject *Sender) { BEGIN_LOG(""); int h; TSpeedButton *s; s = (TSpeedButton*)Sender; if ((Type == PT_SCRATCH || Type == PT_KASURI) && s == sbBtnUp) { Type = PT_SCRAPE; // if(KasuriForm) KasuriForm->Visible = false; // if(KasuriSubForm) KasuriSubForm->Visible = false; if (KasuriForm) { delete KasuriForm; KasuriForm = NULL; } if (KasuriSubForm) { delete KasuriSubForm; KasuriSubForm = NULL; } } /* if(Type==PT_SCRAPE) {//re set etcpanel EtcPanel->Top = ExitPanel->Top + ExitPanel->Height + scratchPanel->Height; EtcSubPanel->Visible = false;//EtcSubPanel¾Èº¸ÀÌ°Ô ¼öÁ¤ by bomchun 2006.11.07 if(sbScratch_sub->Down)EtcSubPanel->Visible = true;//EtcSubPanel¾Èº¸ÀÌ°Ô ¼öÁ¤ by bomchun 2006.11.07 sbScratch_sub->Down=true; } else if(Type==PT_KASURI ) { EtcPanel->Top = ExitPanel->Top + ExitPanel->Height + scratchPanel->Height; EtcSubPanel->Visible = false;//EtcSubPanel¾Èº¸ÀÌ°Ô ¼öÁ¤ by bomchun 2006.11.07 END_LOG; return; } else if(Type==PT_SCRATCH) { EtcPanel->Top = ExitPanel->Top + ExitPanel->Height + scratchPanel->Height; EtcSubPanel->Visible = true;//EtcSubPanel¾Èº¸ÀÌ°Ô ¼öÁ¤ by bomchun 2006.11.07 END_LOG; return; }else{ EtcPanel->Top = ExitPanel->Top + ExitPanel->Height; EtcSubPanel->Visible = true;//EtcSubPanel¾Èº¸ÀÌ°Ô ¼öÁ¤ by bomchun 2006.11.07 } if (MenuSW == false) { Show(); MenuSW = true; switch (Type) { case PT_NORMAL : if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); EtcPanel->Visible = true; EtcPanel->BringToFront(); h = EtcSubPanel->Height; //=========================================== 2001.02.09 lhskys È®ÀÎ ¿ä¸Á if (SpreadPanel->Visible) { if (ColorPanel->Visible) { h += ColorPanel->Height; } SpreadPanel->Top = h; h += SpreadPanel->Height; aspread = true; } else { if (ColorPanel->Visible) { h += ColorPanel->Height; } } //=========================================== 2001.02.09 ¿ä±â±îÁö EtcPanel->Height = h; ClientHeight = EtcPanel->Top + h; break; case PT_AIR : if (MainImageForm->WorkArea->Mask) { rbPattern->Enabled = true; } else { //sbMulti->Down = true;//gabriel: org: sbSingle //AirFunctionClick(MultiPanel); //rbPattern->Enabled = false; SetWinControlEnabled(rbPattern, false); rbPattern->Checked = false; AirFunctionClick(MultiPanel); } AirPanel->Visible = true; AirPanel->BringToFront(); // if (AirType == PAT_SINGLE) { MultiPanel->Visible = true; AirPanel->Height = MultiPanel->Top + MultiPanel->Height; // } else if (AirType == PAT_MULTI) { // MultiPanel->Visible = true; // AirPanel->Height = MultiPanel->Top + MultiPanel->Height; // } else if (AirType == PAT_PATTERN) { // MultiPanel->Visible = true; //gabriel: <- false // AirPanel->Height = MultiPanel->Top + MultiPanel->Height; // } ClientHeight = AirPanel->Top + AirPanel->Height; break; case PT_WATER : WaterPanel->Visible = true; WaterPanel->BringToFront(); InitWaterPanel(WaterType); ClientHeight = WaterPanel->Top + WaterPanel->Height; break; case PT_MASK : MaskPanel->Height = 50; MaskPanel->Visible = true; MaskPanel->BringToFront(); ClientHeight = MaskPanel->Top + MaskPanel->Height; break; default : if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); EtcPanel->Visible = true; EtcPanel->BringToFront(); h = EtcSubPanel->Height; //============================================================ 2001.02.09 lhskys È®ÀÎ ¿ä¸Á if (SpreadPanel->Visible) { if (ScrapePanel->Visible || DensPanel->Visible || ColorPanel->Visible) { h += ColorPanel->Height; } SpreadPanel->Top = h; h += SpreadPanel->Height; aspread = true; } else { if (ScrapePanel->Visible || DensPanel->Visible || ColorPanel->Visible) { h += ColorPanel->Height; } } //============================================================= 2001.02.09 lhskys ¿ä±â±îÁö EtcPanel->Height = h; ClientHeight = EtcPanel->Top + h; } sbBtnUp->Visible = true; spBtnDown->Visible = false; } else if (MenuSW == true) { MenuSW = false; ClientHeight = FHeight; sbBtnUp->Visible = false; spBtnDown->Visible = true; switch (Type) { case PT_AIR : AirPanel->Visible = false; // by celberus clear whole ÇÒ ¶§ ¼­ºê¸Þ´º ³ª¿À´Â ¹®Á¦¶§¹®¿¡.. break; } //============================================================================lhskys if(SpreadPanel){ COLORREF c; //================================================== 2001.02.09 lhskys È®ÀÎ ¿ä¸Á // aspread = false; // lSpread->Caption = String(IDS_SPREAD) + " : " + String(IDS_COMMON_OFF); // spread_sw[4] = 0; // lSelectDraw->Caption = IDS_SELECTCOLOR; //===================================================2001.02.09 lhskys ¿ä±â±îÁö if(DrawForm){ DrawForm->PointList = new TList; //DrawForm->step = 0; DrawForm->undos = 0; if (DrawForm->xkey){ DrawForm->step = 0; DrawForm->InitPointList(); }else DrawForm->AddPointList(DrawForm->Lsx, DrawForm->Lsy, c); } } //============================================================================ } if(KasuriForm && Type==PT_SCRAPE)KasuriForm->Run(); */ END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ResetClientHeight() { // ClientHeight = FHeight; //by bomchun °¡½º¸® ¾ðµµ‹š Æû »çÀÌÁî ¿¡·¯³ª¼­ ¸·¾ÆµÒ (2006.10.30) } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::EditKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { TNumEdit *s; s = (TNumEdit*)Sender; if (Key == VK_RETURN) { if (s == numedEScale) { } else if (s == numedEGrade) { if (s->Value > 70) s->Value = 70; spread_grade = s->Value; } else { if (AirColorList->Count >= s->Tag + 1) { InputPercent(Sender); } } g_FocusControl->SetFocus(); } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::EditKeyPress(TObject *Sender, wchar_t &Key) { TNumEdit *s; s = (TNumEdit*)Sender; if (Key == 13) { if (s == numedEScale) { } else if (s == numedEGrade) { if (s->Value > 70) s->Value = 70; spread_grade = s->Value; } else { if (AirColorList->Count >= s->Tag + 1) { InputPercent(Sender); } } PenManagerForm->SetFocus(); // lhskys zŰ ½ÇÇàÀ» À§ÇØ } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::EditMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TNumEdit *s; s = (TNumEdit*)Sender; if (s == numedEGrade) { if (spread_sw[4] == 0) { s->SetFocus(); s->SelectAll(); } } else if (s == numedEScale) { s->SetFocus(); s->SelectAll(); } else { if (AirColorList->Count >= s->Tag + 1) { s->SetFocus(); s->SelectAll(); } } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::sbNewClick(TObject *Sender) { BEGIN_LOG(""); TSpeedButton *s; TCursor cursor; s = (TSpeedButton*)Sender; if (s == sbNew) { Selector->Initial(); } else if (s == sbAll) { cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->WorkArea->Mask) MainImageForm->SearchWorkAreaColor(Selector->ChoiceColor); else MainImageForm->SearchWholeColor(Selector->ChoiceColor); Selector->Invalid(); Screen->Cursor = cursor; } else if (s == sbBlock) { if (sbBlock->Down) sbBlock->Hint = IDS_COMMON_ONECOLOR; else sbBlock->Hint = IDS_COMMON_BLOCKCOLOR; } else if (s == sbDelete) { if (sbDelete->Down) sbDelete->Hint = IDS_COMMON_DELETECOLOR; else sbDelete->Hint = IDS_COMMON_INSERTCOLOR; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::sbBeforeClick(TObject *Sender) { BEGIN_LOG(""); Selector->LoadFromFile(AppDataItem + "\\Pen.ini", "Color"); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ShapeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TShape *s; s = (TShape*)Sender; if (s == shFirst) { shFirst->Pen->Color = clRed; shSecond->Pen->Color = clBlack; spread_pos = 0; } else if (s == shSecond) { shFirst->Pen->Color = clBlack; shSecond->Pen->Color = clRed; spread_pos = 1; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormClick(TObject *Sender) { Show(); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormClose(TObject *Sender, TCloseAction &Action) { Visible = false; if (FOnUpdateMenu) FOnUpdateMenu(Sender); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormCreate(TObject *Sender) { // LEADTOOLS V15 Migration ÁÖ¼®Ã³¸® - by monkman (2007.06.21) // =============================== 2001.5.3 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è // hLibrary = LoadLibrary("ltdlg13n.dll"); this->Width = 210; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormDestroy(TObject *Sender) { TColorList *pcolor; if (AirColorList) { while (AirColorList->Count > 0) { pcolor = (TColorList*)AirColorList->Last(); AirColorList->Remove(pcolor); delete pcolor; } delete AirColorList; } TPoint *pt; while (pointList->Count) { pt = (TPoint*)pointList->Last(); pointList->Remove(pt); delete pt; } delete pointList; if (Pen) delete Pen; if (Random) delete Random; if (lineItr) delete lineItr; if (KasuriForm) { delete KasuriForm; KasuriForm = NULL; } // LEADTOOLS V15 Migration ÁÖ¼®Ã³¸® - by monkman (2007.06.21) // FreeLibrary(hLibrary); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::WaterFuctionClick(TObject *Sender) { TSpeedButton *s = (TSpeedButton*)Sender; InitWaterPanel(s->Tag); } // --------------------------------------------------------------------------- // Private Function // --------------------------------------------------------------------------- /* void TPenManagerForm::WMEXITSIZEMOVE(TMessage &msg) { if ((Left <= MainForm->PenFormPos.x + 100) && (Left >= MainForm->PenFormPos.x - 100)) { if ((Top <= MainForm->PenFormPos.y + 100) && (Top >= MainForm->PenFormPos.y - 100)) { Top = MainForm->PenFormPos.y; Left = MainForm->PenFormPos.x; } } } */ // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::shAirColorMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); TShape *sh = (TShape*)Sender; if (AirColorList->Count >= sh->Tag + 1) { DeleteAirColorPalette(sh->Tag); ChangeAirColorPalette(sh->Tag, true); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::seDensityChange(TObject *Sender) { if (seDensity->Text.Length() > 0) { if (seDensity->Value > seDensity->Max) seDensity->Value = seDensity->Max; else if (seDensity->Value < seDensity->Min) seDensity->Value = seDensity->Min; else density = seDensity->Value; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::seSpraySizeChange(TObject *Sender) { // gabriel: Only for airbrush if (seSpraySize->Text.Length() > 0) { if (MainImageForm) MainImageForm->iMainImageChange(); try { seSpraySize->Text.ToInt(); if (seSpraySize->Value > seSpraySize->Max) seSpraySize->Value = seSpraySize->Max; if (seSpraySize->Value < seSpraySize->Min) seSpraySize->Value = seSpraySize->Min; if (DrawForm) if (DrawForm->StartSize->Visible == true) DrawForm->StartSize->Value = seSpraySize->Value; Pen->BasicThick = int(seSpraySize->Value); PenShape->Height = Pen->BasicThick; PenShape->Width = Pen->BasicThick; PenShape->Top = (PenWidthPanel->Height - Pen->BasicThick + 1) / 2.0; PenShape->Left = (PenWidthPanel->Width - Pen->BasicThick + 1) / 2.0; } catch(EConvertError&) { seSpraySize->Value = Pen->BasicThick; } } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::seSpraySizeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { seSpraySize->SetFocus(); seSpraySize->SelectAll(); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ChangeAirColorPalette(int index, bool del) { BEGIN_LOG(""); int i, count, cnt, modify, chcnt; TColorList *Temp, *Temp2; int TotalValue, DivValue; TShape *s; TEdit *e; TotalValue = 0; DivValue = 0; count = 0; modify = 0; for (i = 1; i <= AirColorList->Count; i++) { Temp = (TColorList*)(AirColorList->Items[i - 1]); if (Temp->modify) { TotalValue += Temp->percent; modify++; } else { count++; } } if (count) { DivValue = double(100 - TotalValue) / count; } else { if (modify > 1) { if (del) chcnt = modify; else chcnt = modify - 1; DivValue = (100 - TotalValue) / chcnt; } else DivValue = 100; } cnt = 0; for (i = 1; i <= 18; i++) { if (i <= AirColorList->Count) { Temp = (TColorList*)(AirColorList->Items[i - 1]); // s = (TShape *)(FindComponent("shAirColor" + String(i))); // s->Brush->Color = MainImageForm->Palette->Color[Temp->color]; if (AirColorList->Count == 1) { Temp->modify = false; Temp->percent = 100; } else { if (Temp->modify == false) { // °ªÀ» ¼öÁ¤ÇÏÁö ¾ÊÀº°Í cnt++; int remainder = 100 - DivValue * AirColorList->Count; // if (cnt == count) { // Temp->percent = abs(100 - (DivValue * (count - 1) + TotalValue)); // } // else { Temp->percent = DivValue; if (cnt > count - remainder ) { Temp->percent++; } // } } else if ((count == 0) && (modify > 1)) { // °ªÀ» ¼öÁ¤ÇÏÁö ¾ÊÀº °ÍÀÌ ¾ø°í cnt++; // °ªÀ» ¼öÁ¤ÇÑ °Í¸¸ ¿©·¯°³ ³²Àº °æ¿ì if (i - 1 != index) { Temp->percent += DivValue; } if (cnt == modify) { if (cnt - 1 == index) { Temp2 = (TColorList*)AirColorList->Items[index - 1]; Temp2->percent += abs(100 - (DivValue * chcnt + TotalValue)); e = (TEdit*)(FindComponent("Edit" + String(i - 1))); e->Text = Temp2->percent; } else { Temp->percent += abs(100 - (DivValue * chcnt + TotalValue)); } } } } e = (TEdit*)(FindComponent("Edit" + String(i))); e->Text = Temp->percent; } else { // s = (TShape *)(FindComponent("shAirColor" + String(i))); // s->Brush->Color = clWhite; // e = (TEdit *)(FindComponent("Edit" + String(i))); // e->Text = "0"; } } AirBrushPreview_Driver(); // gabriel ShowColorBar(); // gabriel END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::DeleteAirColorPalette(int index) { BEGIN_LOG(IntToStr(index)); // AirColorList->Delete(index); TColorList *pcolor = (TColorList*)AirColorList->Items[index]; AirColorList->Remove(pcolor); delete pcolor; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::InputPercent(TObject *Sender) { BEGIN_LOG(""); int i, TotalValue, Percent, Not; TNumEdit *s; TColorList *Temp; s = (TNumEdit*)Sender; TotalValue = 0; Not = 0; for (i = 0; i < AirColorList->Count; i++) { if (i != s->Tag) { Temp = (TColorList*)(AirColorList->Items[i]); if (Temp->modify == false) Not++; else TotalValue += Temp->percent; } } Percent = s->Value; if (Percent > 100 - TotalValue - Not) Percent = 100 - TotalValue - Not; Temp = (TColorList*)(AirColorList->Items[s->Tag]); Temp->percent = Percent; Temp->modify = true; ChangeAirColorPalette(s->Tag); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::drawFilledRectangle(TPItemImage *Image, int startX, int startY, int width, int height, COLORREF color) { BEGIN_LOG(""); lineItr->setBaseColor(color); for (int y = startY; y < startY + height; y++) { if (y >= 0 && y < Image->uBitmap->Height) { lineItr->getScanLine(y, startX, width); // for (int x = startX; x < startX + width; x++) { if (x >= 0 && x < Image->uBitmap->Width) { lineItr->putPixel(x); } } lineItr->putScanLine(y, startX, width); // } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::drawFilledCircle(TPItemImage *Image, int centeredX, int centeredY, int radius, COLORREF color) { // gabriel: DropSize > 5 BEGIN_LOG(""); int deltaX; lineItr->setBaseColor(color); for (int y = centeredY - radius; y < centeredY + radius; y++) { if (y >= 0 && y < Image->uBitmap->Height) { deltaX = sqrt(abs(radius * radius - (y - centeredY) * (y - centeredY))); lineItr->getScanLine(y, (0 > centeredX - deltaX) ? 0 : centeredX - deltaX, deltaX * 2); for (int x = centeredX - deltaX; x < centeredX + deltaX; x++) { if (x >= 0 && x < Image->uBitmap->Width) { lineItr->putPixel(x); } } lineItr->putScanLine(y, (0 > centeredX - deltaX) ? 0 : centeredX - deltaX, deltaX * 2); } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::drawFilledRectangle_pattern (TPItemImage *Image, int startX, int startY, int width, int height) { BEGIN_LOG(""); Byte *pPatternLine; int patternX, patternY; RECT rect = MainImageForm->WorkArea->Range; for (int y = startY; y < startY + height; y++) { patternY = getMappingPosition(y, rect.top, rect.bottom); if (y >= 0 && y < Image->uBitmap->Height) { lineItr->getScanLine(y, startX, width); // pPatternLine = Image1->Bitmap->GetScanLine(patternY); // for (int x = startX; x < startX + width; x++) { patternX = getMappingPosition(x, rect.left, rect.right); lineItr->setBaseColor(lineItr->pickColor(pPatternLine, patternX)); if (x >= 0 && x < Image->uBitmap->Width) { lineItr->putPixel(x); } } lineItr->putScanLine(y, startX, width); // } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::drawFilledCircle_pattern(TPItemImage *Image, int centeredX, int centeredY, int radius) { // gabriel: DropSize > 5 BEGIN_LOG(""); int deltaX; Byte *pPatternLine; int patternX, patternY; RECT rect = MainImageForm->WorkArea->Range; for (int y = centeredY - radius; y < centeredY + radius; y++) { patternY = getMappingPosition(y, rect.top, rect.bottom); if (y >= 0 && y < Image->uBitmap->Height) { deltaX = sqrt(abs(radius * radius - (y - centeredY) * (y - centeredY))); lineItr->getScanLine(y, (0 > centeredX - deltaX) ? 0 : centeredX - deltaX, deltaX * 2); pPatternLine = Image1->Bitmap->GetScanLine(patternY); for (int x = centeredX - deltaX; x < centeredX + deltaX; x++) { patternX = getMappingPosition(x, rect.left, rect.right); lineItr->setBaseColor(lineItr->pickColor(pPatternLine, patternX)); if (x >= 0 && x < Image->uBitmap->Width) { lineItr->putPixel(x); } } lineItr->putScanLine(y, (0 > centeredX - deltaX) ? 0 : centeredX - deltaX, deltaX * 2); } } END_LOG; } // --------------------------------------------------------------------------- int __fastcall TPenManagerForm::getMappingPosition(int value, int lowBound, int highBound) { if (value < lowBound) return highBound - (lowBound - value) % (highBound - lowBound) - lowBound - 1; else return(value - lowBound) % (highBound - lowBound); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::drawAirbrushImage(TPItemImage *Image, double drawDensity, int SpraySize, int DropSize, int Concentration, int Irregularity, COLORREF color) { BEGIN_LOG(""); int i, x, y, penWidth, randomNumber, toX, toY, IrrDropSize, var; penWidth = Pen->Thick / 2 + 1; i = 0; while (i < (drawDensity * SpraySize / 40 / DropSize)) { while (1) { toX = penWidth * RandGenerator() / (Concentration * 0.2 + 1); toY = penWidth * RandGenerator() / (Concentration * 0.2 + 1); if ((abs(toX) < penWidth) && (abs(toY) < penWidth) && (sqrt(abs(toX) * abs(toX) + abs(toY) * abs(toY)) < penWidth)) { break; } } x = Lsx + toX; y = Lsy + toY; // gabriel: Get Irregularity , put a point, evaluate IrrDropSize if (!Random->Get(2)) // +/- ? var = Random->Get(Irregularity + 1); else var = -Random->Get(Irregularity + 1); IrrDropSize = DropSize + var; if (IrrDropSize < 1) IrrDropSize = 1; // if (IrrDropSize > DropSize) IrrDropSize = DropSize;//max value is original DropSize if (IrrDropSize == 1) { // Old code: (size: 1 ~ 5) drawFilledRectangle(Image, x, y, 1, 1, color); } else if (IrrDropSize == 2) { if (x & 1) { // odd drawFilledRectangle(Image, x, y, 2, 1, color); } else { // even drawFilledRectangle(Image, x, y, 1, 2, color); } } else if (IrrDropSize == 3) { drawFilledRectangle(Image, x, y, 2, 2, color); } else if (IrrDropSize == 4) { if (x & 1) { // odd drawFilledRectangle(Image, x - 1, y, 3, 2, color); } else { // even drawFilledRectangle(Image, x, y - 1, 2, 3, color); } } else if (IrrDropSize == 5) { // DropSize == 5 drawFilledRectangle(Image, x - 1, y - 1, 3, 3, color); } else // IrrDropSize > 5 drawFilledCircle(Image, x, y, IrrDropSize - 3, color); // End of putting a point i++; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_airbrush_pen_single(TPItemImage *Image) { BEGIN_LOG(""); int j; TColorList *V; COLORREF color; double drawDensity; int denvalue = rzspedSprayDensity->Value; int DropSize = rzspedDropSize->Value; int SpraySize = seSpraySize->Value; int Concentration = rzspedConcentration->Value; int Irregularity = rzspedIrregularity->Value; drawDensity = denvalue; color = getListColor(&SingleColor, Image->uBitmap->BitsPerPixel); drawAirbrushImage(Image, drawDensity, SpraySize, DropSize, Concentration, Irregularity, color); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_airbrush_pen_multi(TPItemImage *Image) { BEGIN_LOG(""); int j; TColorList *V; COLORREF color; double drawDensity; int denvalue = rzspedSprayDensity->Value; int DropSize = rzspedDropSize->Value; int SpraySize = seSpraySize->Value; int Concentration = rzspedConcentration->Value; int Irregularity = rzspedIrregularity->Value; if (AirColorList->Count > 0) { for (j = 0; j < AirColorList->Count; j++) { V = (TColorList*)AirColorList->Items[j]; drawDensity = denvalue * V->percent / 100.0; color = getListColor(V, Image->uBitmap->BitsPerPixel); drawAirbrushImage(Image, drawDensity, SpraySize, DropSize, Concentration, Irregularity, color); } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_airbrush_pen_pattern(TPItemImage *Image) { BEGIN_LOG(""); int i, x, y, toX, toY, penWidth, var, IrrDropSize; double radius, angle, drawDensity; penWidth = Pen->Thick / 2 + 1; drawDensity = rzspedSprayDensity->Value; int DropSize = rzspedDropSize->Value; int Irregularity = rzspedIrregularity->Value; i = 0; while (i < (sqrt(drawDensity - 1) + .1) * 2 * penWidth / DropSize) { // gabriel while (1) { toX = penWidth * RandGenerator(); toY = penWidth * RandGenerator(); if ((abs(toX) < penWidth) && (abs(toY) < penWidth) && (sqrt(abs(toX) * abs(toX) + abs(toY) * abs(toY)) < penWidth)) { break; } } x = Lsx + toX; y = Lsy + toY; if (!Random->Get(2)) // +/- ? var = Random->Get(Irregularity + 1); else var = -Random->Get(Irregularity + 1); IrrDropSize = DropSize + var; if (IrrDropSize < 1) IrrDropSize = 1; if (IrrDropSize == 1) { drawFilledRectangle_pattern(Image, x, y, 1, 1); } else if (IrrDropSize == 2) { if (x & 1) { // odd drawFilledRectangle_pattern(Image, x, y, 2, 1); } else { // even drawFilledRectangle_pattern(Image, x, y, 1, 2); } } else if (IrrDropSize == 3) { drawFilledRectangle_pattern(Image, x, y, 2, 2); } else if (IrrDropSize == 4) { if (x & 1) { // odd drawFilledRectangle_pattern(Image, x - 1, y, 3, 2); } else { // even drawFilledRectangle_pattern(Image, x, y - 1, 2, 3); } } else if (IrrDropSize == 5) { drawFilledRectangle_pattern(Image, x - 1, y - 1, 3, 3); } else // > 5 drawFilledCircle_pattern(Image, x, y, IrrDropSize - 3); i++; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_airbrush_pen(void) { BEGIN_LOG(""); TPItemImage *Image = MainImageForm->iMainImage; if (AirType == PAT_SINGLE) { set_airbrush_pen_single(Image); } else if (AirType == PAT_MULTI) { set_airbrush_pen_multi(Image); } else if (AirType == PAT_PATTERN) { set_airbrush_pen_pattern(Image); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::line_airbrush_pen(void) { BEGIN_LOG(""); int sx, sy, ex, ey, i; double dx, dy; double slopex, slopey; TPItemImage *Image = MainImageForm->iMainImage; RECT rect; int ls, rs; TPException ec = EC_NONE; ls = Pen->Thick >> 1; rs = Pen->Thick - ls; if (lineItr) { delete lineItr; lineItr = NULL; } if (Image->LayerMask) { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Layer_Mask(Image); } else { lineItr = (LineItr*)new LineItr_Layer(Image); } } else { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Mask(Image); } else { lineItr = (LineItr*)new LineItr(Image); } } lineItr->setColorProtected(MainImageForm->Protect); if (lineItr->startScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (AirType == PAT_PATTERN) { if (Image1->Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } sx = Lsx; ex = Lex; sy = Lsy; ey = Ley; dx = ex - sx; dy = ey - sy; if (sx == ex) { if (sy == ey) { set_airbrush_pen(); } else { Lsx = sx; if (sy < ey) { for (i = sy; i <= ey; i += 3) { Lsy = i; set_airbrush_pen(); } } else { for (i = sy; i >= ey; i -= 3) { Lsy = i; set_airbrush_pen(); } } } } else { if (sy == ey) { Lsy = sy; if (sx < ex) { for (i = sx; i <= ex; i += 3) { Lsx = i; set_airbrush_pen(); } } else { for (i = sx; i >= ex; i -= 3) { Lsx = i; set_airbrush_pen(); } } } else { slopex = dy / dx; slopey = dx / dy; if (sx < ex) { if (sy < ey) { if (fabs(slopex) < 1.0) { for (i = sx; i <= ex; i += 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i <= ey; i += 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } else { if (fabs(slopex) < 1.0) { for (i = sx; i <= ex; i += 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i >= ey; i -= 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } } else { if (sy < ey) { if (fabs(slopex) < 1.0) { for (i = sx; i >= ex; i -= 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i <= ey; i += 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } else { if (fabs(slopex) < 1.0) { for (i = sx; i >= ex; i -= 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i >= ey; i -= 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } } } } if (AirType == PAT_PATTERN) { Image1->Bitmap->StopScanLine(); } lineItr->stopScanLine(); rect.left = min(sx, ex) - ls; rect.top = min(sy, ey) - ls; rect.right = max(sx, ex) + rs; rect.bottom = max(sy, ey) + rs; if (update) Image->RectPaint(rect); Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; END_LOG; return; fail: if (AirType == PAT_PATTERN) { Image1->Bitmap->StopScanLine(); } EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_brush_spread_pen(int lsx, int lsy, int size, COLORREF color) { BEGIN_LOG(""); int sx, sy, x, y, s, e, pw; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; static int cnt = 0; if (lineItr) { delete lineItr; lineItr = NULL; } if (Image->LayerMask) { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Layer_Mask(Image); } else { lineItr = (LineItr*)new LineItr_Layer(Image); } } else { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Mask(Image); } else { lineItr = (LineItr*)new LineItr(Image); } } lineItr->setColorProtected(MainImageForm->Protect); lineItr->setBaseColor(color); if (lineItr->startScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel == 8) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { lineItr->getScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (acolor != 2 || Selector->Number[lineItr->pickColor(sx + x)] < 255)) { // ¼±ÅÃÇÑ color¿¡¸¸ ±×¸®±â ¿É¼Ç lineItr->putPixel(sx + x); } } } lineItr->putScanLine(sy + y, sx + s, e - s + 1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { lineItr->getScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { lineItr->putPixel(sx + x); } } } lineItr->putScanLine(sy + y, sx + s, e - s + 1); // } } } lineItr->stopScanLine(); END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_crayon_brush_spread_pen(int lsx, int lsy, int size, COLORREF color) { BEGIN_LOG(""); int s, e, sx, sy, x, y, pw, p; int ran; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; if (lineItr) { delete lineItr; lineItr = NULL; } if (Image->LayerMask) { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Layer_Mask(Image); } else { lineItr = (LineItr*)new LineItr_Layer(Image); } } else { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Mask(Image); } else { lineItr = (LineItr*)new LineItr(Image); } } lineItr->setColorProtected(MainImageForm->Protect); lineItr->setBaseColor(color); pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (pw <= 0) p = 1; else p = pw; if (density == 1) { ran = 5000 / p; } else if (density == 2) { ran = 12000 / p; } else if (density == 3) { ran = 18000 / p; } else if (density == 4) { ran = 24000 / p; } else { ran = 30000 / p; } if (lineItr->startScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel == 8) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { lineItr->getScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (acolor != 2 || Selector->Number[lineItr->pickColor(sx + x)] < 255)) { lineItr->putPixel(sx + x); } } } lineItr->putScanLine(sy + y, sx + s, e - s + 1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { lineItr->getScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran)) { lineItr->putPixel(sx + x); } } } lineItr->putScanLine(sy + y, sx + s, e - s + 1); // } } } lineItr->stopScanLine(); END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_brush_mask_pen(int lsx, int lsy, int size) { BEGIN_LOG(""); int sx, sy, x, y, s, e, pw; Byte *P; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (Image->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel == 8) { if (rzckDelete->Checked) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { P = Image->Mask->GetScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[sx + x] = 0x00; } } } Image->Mask->PutScanLine(sy + y, sx + s, e - s + 1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { P = Image->Mask->GetScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[sx + x] = 0x0F; } } } Image->Mask->PutScanLine(sy + y, sx + s, e - s + 1); // } } } } else { if (rzckDelete->Checked) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { P = Image->Mask->GetScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[(sx + x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } } Image->Mask->PutScanLine(sy + y, sx + s, e - s + 1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->uBitmap->Height)) { P = Image->Mask->GetScanLine(sy + y, sx + s, e - s + 1); // for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->uBitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[(sx + x) >> 3] |= (0x80 >> ((sx + x) & 7)); } } } Image->Mask->PutScanLine(sy + y, sx + s, e - s + 1); // } } } } Image->Mask->StopScanLine(); END_LOG; return; fail: Image->Mask->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::init_pressure_pen() { int i, j, k, l, cx, cy, sx, sy, a, t; double r; for (i = 0; i <= 1; i++) { for (j = 0; j <= 49; j++) { for (k = 0; k <= 50; k++) { for (l = 0; l <= 50; l++) { pshape[i].size[j].dot[k][l] = 0; } } } } cx = MAX_PEN_HALF_WIDTH; cy = MAX_PEN_HALF_WIDTH; pshape[0].size[0].dot[cy][cx] = 1; for (j = 0; j <= 49; j++) { r = (j + 1.0) / 2.0; t = r; if (j & 1) { for (k = 0; k <= t - 1; k++) { l = sqrt(t * t - (k + 0.5) * (k + 0.5)) + 0.5; for (a = cx - l; a <= cx + l; a++) { pshape[0].size[j].dot[cy + k][a] = 1; pshape[0].size[j].dot[cy - k - 1][a] = 1; } } } else { for (k = 0; k <= t; k++) { l = sqrt(r * r - k * k); for (a = cx - l; a <= cx + l; a++) { pshape[0].size[j].dot[cy + k][a] = 1; pshape[0].size[j].dot[cy - k][a] = 1; } } } } pshape[1].size[0].dot[cy][cx] = 1; for (j = 1; j <= 49; j++) { sx = cx - (j + 1) / 2.0; sy = cy - (j + 1) / 2.0; for (k = sy; k <= sy + j; k++) { for (l = sx; l <= sx + j; l++) { pshape[1].size[j].dot[k][l] = 1; } } } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::point_pressure_pen(int x, int y, int size, COLORREF color) { BEGIN_LOG(""); TColor rgb; RGBQUAD m_rgb[3]; int lsx = x, lsy = y; if (MainImageForm->iMainImage->Reflection && MainImageForm->reflection){ POINT pt; pt = MainImageForm->reflection->FindOriginalPos(x, y); lsx = pt.x; lsy = pt.y; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (Type == PT_NORMAL) { set_brush_spread_pen(lsx, lsy, size, color); } else if (Type == PT_CRAYON) { set_crayon_brush_spread_pen(lsx, lsy, size, color); } else if (Type == PT_MASK) { set_brush_mask_pen(lsx, lsy, size); } } else { if (aspread) { m_rgb[0] = MainImageForm->Palette->ColorData[spread_start]->RGB; m_rgb[1] = MainImageForm->Palette->ColorData[spread_end]->RGB; if (Tablet) { if (m_rgb[1].rgbRed > m_rgb[0].rgbRed) m_rgb[2].rgbRed = m_rgb[0].rgbRed + color * (m_rgb[1].rgbRed - m_rgb[0].rgbRed) / Tablet->MaxNPressure; else m_rgb[2].rgbRed = m_rgb[1].rgbRed + (Tablet->MaxNPressure - color) * (m_rgb[0].rgbRed - m_rgb[1].rgbRed) / Tablet->MaxNPressure; if (m_rgb[1].rgbGreen > m_rgb[0].rgbGreen) m_rgb[2].rgbGreen = m_rgb[0].rgbGreen + color * (m_rgb[1].rgbGreen - m_rgb[0].rgbGreen) / Tablet->MaxNPressure; else m_rgb[2].rgbGreen = m_rgb[1].rgbGreen + (Tablet->MaxNPressure - color) * (m_rgb[0].rgbGreen - m_rgb[1].rgbGreen) / Tablet->MaxNPressure; if (m_rgb[1].rgbBlue > m_rgb[0].rgbBlue) m_rgb[2].rgbBlue = m_rgb[0].rgbBlue + color * (m_rgb[1].rgbBlue - m_rgb[0].rgbBlue) / Tablet->MaxNPressure; else m_rgb[2].rgbBlue = m_rgb[1].rgbBlue + (Tablet->MaxNPressure - color) * (m_rgb[0].rgbBlue - m_rgb[1].rgbBlue) / Tablet->MaxNPressure; } else { m_rgb[2] = m_rgb[0]; } rgb = RGBToTColor(m_rgb[2]); } else { rgb = MainImageForm->Palette->Color[color]; // color; } if (Type == PT_NORMAL) { set_brush_spread_pen(lsx, lsy, size, rgb); } else if (Type == PT_CRAYON) { set_crayon_brush_spread_pen(lsx, lsy, size, rgb); } else if (Type == PT_MASK) { set_brush_mask_pen(lsx, lsy, size); } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::line_pressure_pen(int pw, COLORREF spc) { BEGIN_LOG(""); int size, sx, sy, ex, ey, pwl, pcl; COLORREF color; double pwx, pwy, pcx, pcy; double dx, dy; double slopex, slopey; TPItemImage *Image = MainImageForm->iMainImage; RECT rect; int ls, rs; ls = pw >> 1; rs = pw - ls; sx = Lsx; ex = Lex; sy = Lsy; ey = Ley; dx = ex - sx; dy = ey - sy; pwl = pw - o_size; if (dx == 0) pwx = pwl; else pwx = pwl / fabs(dx); if (dy == 0) pwy = pwl; else pwy = pwl / fabs(dy); pcl = spc - o_color; if (dx == 0) pcx = pcl; else pcx = pcl / fabs(dx); if (dy == 0) pcy = pcl; else pcy = pcl / fabs(dy); if (sx == ex) { if (sy == ey) { if (o_size < pw) { FPointPressurePen(Lsx, Lsy, pw, spc); } } else { Lsx = sx; if (sy < ey) { for (Lsy = sy; Lsy <= ey; Lsy++) { size = o_size + (Lsy - sy) * pwy + 0.5; color = o_color + (Lsy - sy) * pcy + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy >= ey; Lsy--) { size = o_size + (sy - Lsy) * pwy + 0.5; color = o_color + (sy - Lsy) * pcy + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } } else { if (sy == ey) { Lsy = sy; if (sx < ex) { for (Lsx = sx; Lsx <= ex; Lsx++) { size = o_size + (Lsx - sx) * pwx + 0.5; color = o_color + (Lsx - sx) * pcx + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsx = sx; Lsx >= ex; Lsx--) { size = o_size + (sx - Lsx) * pwx + 0.5; color = o_color + (sx - Lsx) * pcx + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } else { slopex = dy / dx; slopey = dx / dy; if (sx < ex) { if (sy < ey) { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx <= ex; Lsx++) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (Lsx - sx) + 0.5; color = o_color + pcx * (Lsx - sx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy <= ey; Lsy++) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (Lsy - sy) + 0.5; color = o_color + pcy * (Lsy - sy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } else { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx <= ex; Lsx++) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (Lsx - sx) + 0.5; color = o_color + pcx * (Lsx - sx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy >= ey; Lsy--) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (sy - Lsy) + 0.5; color = o_color + pcy * (sy - Lsy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } } else { if (sy < ey) { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx >= ex; Lsx--) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (sx - Lsx) + 0.5; color = o_color + pcx * (sx - Lsx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy <= ey; Lsy++) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (Lsy - sy) + 0.5; color = o_color + pcy * (Lsy - sy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } else { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx >= ex; Lsx--) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (sx - Lsx) + 0.5; color = o_color + pcx * (sx - Lsx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy >= ey; Lsy--) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (sy - Lsy) + 0.5; color = o_color + pcy * (sy - Lsy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } } } } rect.left = min(sx, ex) - ls - 1; rect.top = min(sy, ey) - ls - 1; rect.right = max(sx, ex) + rs + 1; rect.bottom = max(sy, ey) + rs + 1; if (DrawForm) { if (DrawForm->btndelete != 1) if (update) Image->RectPaint(rect); Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; } else { if (update) Image->RectPaint(rect); Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_pen(int x, int y, int size, COLORREF color) { BEGIN_LOG(""); int xx; double x1, yy, r, r2; Byte *P, *MP, *LP, *BP; TPItemImage *Image = MainImageForm->iMainImage; lineItr->setBaseColor(color); if (Image->uBitmap->BitsPerPixel == 8) { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->uBitmap->Height)) { lineItr->getScanLine(y, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width) && (acolor != 2 || Selector->Number[lineItr->pickColor(x + xx)] < 255) ) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y, x - r, r + r + 1); // } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->uBitmap->Height)) { lineItr->getScanLine(y - yy, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width) && (acolor != 2 || Selector->Number[lineItr->pickColor(x + xx)] < 255)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y - yy, x - r, r + r + 1); // } if ((y + yy >= 0) && (y + yy < Image->uBitmap->Height)) { lineItr->getScanLine(y + yy, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width) && (acolor != 2 || Selector->Number[lineItr->pickColor(x + xx)] < 255)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y + yy, x - r, r + r + 1); // } } } else { // Pen->Shape != 1 r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->uBitmap->Height)) { lineItr->getScanLine(y, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width) && (acolor != 2 || Selector->Number[lineItr->pickColor(x + xx)] < 255) ) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y, x - r, r + r + 1); // } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->uBitmap->Height)) { lineItr->getScanLine(y - yy, x - x1, x1 + x1 + 1); // for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width) && (acolor != 2 || Selector->Number[lineItr->pickColor(x + xx)] < 255)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y - yy, x - x1, x1 + x1 + 1); // } if ((y + yy >= 0) && (y + yy < Image->uBitmap->Height)) { lineItr->getScanLine(y + yy, x - x1, x1 + x1 + 1); // for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width) && (acolor != 2 || Selector->Number[lineItr->pickColor(x + xx)] < 255)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y + yy, x - x1, x1 + x1 + 1); // } } } } else { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->uBitmap->Height)) { lineItr->getScanLine(y, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y, x - r, r + r + 1); // } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->uBitmap->Height)) { lineItr->getScanLine(y - yy, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y - yy, x - r, r + r + 1); // } if ((y + yy >= 0) && (y + yy < Image->uBitmap->Height)) { lineItr->getScanLine(y + yy, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y + yy, x - r, r + r + 1); // } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->uBitmap->Height)) { lineItr->getScanLine(y, x - r, r + r + 1); // for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y, x - r, r + r + 1); // } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->uBitmap->Height)) { lineItr->getScanLine(y - yy, x - x1, x1 + x1 + 1); // for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y - yy, x - x1, x1 + x1 + 1); // } if ((y + yy >= 0) && (y + yy < Image->uBitmap->Height)) { lineItr->getScanLine(y + yy, x - x1, x1 + x1 + 1); // for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->uBitmap->Width)) { lineItr->putPixel(x + xx); } } lineItr->putScanLine(y + yy, x - x1, x1 + x1 + 1); // } } } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::calc_scrape_position(int size, int i, int &sx, int &sy, int &ex, int &ey) { int lx, ly; double theta, st, ct; lx = Lex - Lsx; ly = Ley - Lsy; theta = M_PI / 2.0 - atan2((double)ly, (double)lx); if (theta == M_PI / 2.0) { st = (numedEScale->IntValue / 100.0) * size * i; sx = Lsx; sy = Lsy - st; ex = Lex; ey = Ley - st; } else if (theta == -M_PI / 2.0) { st = (numedEScale->IntValue / 100.0) * size * i; sx = Lsx; sy = Lsy + st; ex = Lex; ey = Ley + st; } else { ct = cos(theta) * (numedEScale->IntValue / 100.0) * size * i; st = sin(theta) * (numedEScale->IntValue / 100.0) * size * i; sx = Lsx + ct; sy = Lsy - st; ex = Lex + ct; ey = Ley - st; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::scrape_pen(int size, COLORREF color) { BEGIN_LOG(""); int px, py, i, radius, sx, sy, ex, ey, count, t; double s; TPItemImage *Image = MainImageForm->iMainImage; RECT rect; int ls, rs; TPException ec = EC_NONE; ls = size >> 1; rs = size - ls; t = (size + 8) / 8.0; radius = seBristles->Value / 2.0; if (((int)seBristles->Value % 2) == 1) count = radius + 1; else count = radius; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; if (lineItr) { delete lineItr; lineItr = NULL; } if (Image->LayerMask) { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Layer_Mask(Image); } else { lineItr = (LineItr*)new LineItr_Layer(Image); } } else { if (MainImageForm->MaskArea) { lineItr = (LineItr*)new LineItr_Mask(Image); } else { lineItr = (LineItr*)new LineItr(Image); } } lineItr->setColorProtected(MainImageForm->Protect); if (lineItr->startScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (i = -radius; i <= count - 1; i++) { calc_scrape_position(size, i, sx, sy, ex, ey); if (sx == ex) { if (sy < ey) { py = sy; while (py <= ey) { set_pen(sx, py, size, color); py = py + t; } } else { py = sy; while (py >= ey) { set_pen(sx, py, size, color); py = py - t; } } } else if (sy == ey) { if (sx < ex) { px = sx; while (px <= ex) { set_pen(px, sy, size, color); px = px + t; } } else { px = sx; while (px >= ex) { set_pen(px, sy, size, color); px = px - t; } } } else { s = double(ey - sy) / (ex - sx); if (fabs(s) > 1.0) { if (sy < ey) { py = sy; while (py <= ey) { px = sx + (py - sy) / s + 0.5; set_pen(px, py, size, color); py = py + t; } } else { py = sy; while (py >= ey) { px = sx + (py - sy) / s + 0.5; set_pen(px, py, size, color); py = py - t; } } } else { if (sx < ex) { px = sx; while (px <= ex) { py = sy + (px - sx) * s + 0.5; set_pen(px, py, size, color); px = px + t; } } else { px = sx; while (px >= ex) { py = sy + (px - sx) * s + 0.5; set_pen(px, py, size, color); px = px - t; } } } } rect.left = min(sx, ex) - ls; rect.top = min(sy, ey) - ls; rect.right = max(sx, ex) + rs; rect.bottom = max(sy, ey) + rs; // Image->uBitmap->StopScanLine(); // by celberus lineItr->stopScanLine(); if (update) Image->RectPaint(rect); lineItr->startScanLine(); // Image->uBitmap->StartScanLine(); // by celberus StartScanLine ÈÄ RectPaintÇÏ´Â ÀÌÀ¯´Â? } lineItr->stopScanLine(); /* if (MainImageForm->MaskArea) Image->Mask->StopScanLine(); if (Image->LayerMask) { if (MainImageForm->Protect || acolor == 2) Image->BackGround->StopScanLine(); Image->LayerMask->StopScanLine(); } Image->uBitmap->StopScanLine(); */ END_LOG; return; fail: /* if (Image->LayerMask) { if (MainImageForm->Protect || acolor == 2) Image->BackGround->StopScanLine(); Image->LayerMask->StopScanLine(); } if (Image->Mask) Image->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); */ EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::make_spread() { BEGIN_LOG(""); Byte s, e; Byte ColorIndex[2]; Byte ColorGap[1]; int i; if (MainImageForm->Palette->UseColor + spread_grade < 252) { ColorIndex[0] = spread_start; ColorIndex[1] = spread_end; spread_start = MainImageForm->Palette->UseColor + 1; ColorGap[0] = spread_grade - 1; MainImageForm->Palette->MakeSpread(1, ColorIndex, 2, ColorGap, 1); spread_end = MainImageForm->Palette->UseColor; s = spread_start; e = spread_end; ::RepaintColor(); } else if (MainImageForm->Palette->UseColor - 1 != 250) { // lhskys i = 251 - MainImageForm->Palette->UseColor; // »ö¼±ÅÃÀÌ numedEGrade->Text = i; // 252¸¦ spread_grade = i; // ³Ñ´Â ColorIndex[0] = spread_start; ColorIndex[1] = spread_end; // °ÍÀ» spread_start = MainImageForm->Palette->UseColor + 1; // ¸·À½. ColorGap[0] = spread_grade - 1; // MainImageForm->Palette->MakeSpread(1, ColorIndex, 2, ColorGap, 1); // spread_end = MainImageForm->Palette->UseColor; // s = spread_start; e = spread_end; // EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); // ::RepaintColor(); // /* numedEGrade->Text = "2"; spread_grade = 2; spread_start = s; spread_end = e; EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); */ } else { EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); // lhskys if (DrawForm) { // »ö¼±Åà if (DrawForm->isTaper) DrawForm->TaperLabelClick(this); // °ªÀÌ DrawForm->rzcbPressure->Enabled = false; // °°À¸¸é } // return } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::InitWaterPanel(int i) { trbColor->Enabled = true; // Average pen ¿¡´Â ½ºÅ©·Ñ¹Ù ÇÊ¿ä ¾ø´Ù trbEffect->Max = 100; trbEffect->Min = 0; lbColor->Visible = true; rznumedColor->Visible = true; rzmtbColor->Visible = true; switch(i) { case 0: WaterType = PWT_SIMPLE; lbColor->Caption = IDS_COLOR; lbEffect->Caption = IDS_EFFECT; trbColor->Visible = true; trbColor->Position = 100 * cr[PWT_SIMPLE]; trbEffect->Position = 100 * or[PWT_SIMPLE]; lbDensity->Visible = false; spEditDensity->Visible = false; break; case 1: WaterType = PWT_SPATTER; lbColor->Caption = IDS_INSIDEDENSITY; lbEffect->Caption = IDS_OUTSIDEDENSITY; trbColor->Visible = true; trbColor->Position = 100 * cr[PWT_SPATTER]; trbEffect->Position = 100 * or[PWT_SPATTER]; lbDensity->Visible = true; spEditDensity->Visible = true; break; case 2: WaterType = PWT_PURE; lbColor->Caption = IDS_COLOR; lbEffect->Caption = IDS_EFFECT; trbColor->Visible = true; trbColor->Position = 100 * cr[PWT_PURE]; trbEffect->Position = 100 * or[PWT_PURE]; lbDensity->Visible = false; spEditDensity->Visible = false; // PureShape->Pen->Color = clRed; break; case 3: WaterType = PWT_DIFFUSE; lbColor->Caption = IDS_COLOR; lbEffect->Caption = IDS_SHAPE; trbColor->Visible = true; trbColor->Position = 100 * cr[PWT_DIFFUSE]; trbEffect->Position = 100 * or[PWT_DIFFUSE]; lbDensity->Visible = false; spEditDensity->Visible = false; break; case 4: // By GreenFish AveragePen WaterType = PWT_AVERAGE; lbColor->Caption = ""; lbEffect->Caption = IDS_DENSITY; trbColor->Visible = false; trbEffect->Max = 5; trbEffect->Min = 1; trbEffect->Position = 3; lbColor->Visible = false; rznumedColor->Visible = false; rzmtbColor->Visible = false; lbDensity->Visible = false; spEditDensity->Visible = false; spEditDensity->Value = 3; break; } rznumedColor->Text = trbColor->Position; rznumedEffect->Text = trbEffect->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_water_func() { switch(WaterType) { case PWT_SIMPLE: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_simple_mask; else Pen->PenDrawFunc = set_simple_normal; break; case PWT_SPATTER: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_spatter_mask; else Pen->PenDrawFunc = set_spatter_normal; break; case PWT_PURE: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_pure_mask; else Pen->PenDrawFunc = set_pure_normal; break; case PWT_DIFFUSE: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_diffuse_mask; else Pen->PenDrawFunc = set_diffuse_normal; break; } } // --------------------------------------------------------------------------- /* #define GET_RGBCOLOR \ switch (draw.Image->IsBackGround()) { \ case 1: \ IP = draw.Image->LayerMask->GetScanLine(y, x, 1); \ if (IP[x >> 3] & (0x80 >> (x & 7))) { \ rgb = TColorToRGB((TColor)draw.Image->BackGround->GetPixelColor(x, y)); \ IP[x >> 3] &= ~(0x80 >> (x & 7)); \ draw.Image->LayerMask->PutScanLine(y, x, 1); \ } else { \ rgb = TColorToRGB((TColor)draw.Image->uBitmap->GetPixelColor(x, y)); \ } \ break; \ case 0: \ rgb = TColorToRGB((TColor)draw.Image->uBitmap->GetPixelColor(x, y)); \ break; \ } */ #define GET_RGBCOLOR \ switch (draw.Image->IsBackGround()) { \ case 1: \ if (draw.Image->LayerMask->GetPixelColor(x, y)) { \ rgb = TColorToRGB((TColor)draw.Image->BackGround->GetPixelColor(x, y)); \ draw.Image->LayerMask->PutPixelColor(x, y, 0); \ } else { \ rgb = TColorToRGB((TColor)draw.Image->uBitmap->GetPixelColor(x, y)); \ } \ break; \ case 0: \ rgb = TColorToRGB((TColor)draw.Image->uBitmap->GetPixelColor(x, y)); \ break; \ } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_simple_normal(sPenDraw &draw) { BEGIN_LOG(""); int x, y; RGBQUAD rgb; double v, r = cr[PWT_SIMPLE] * 0.2; Byte *IP; bool isNotInLMask; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { GET_RGBCOLOR; rgb.rgbRed = rgb.rgbRed + (rgbWater.rgbRed - rgb.rgbRed) * r; rgb.rgbGreen = rgb.rgbGreen + (rgbWater.rgbGreen - rgb.rgbGreen) * r; rgb.rgbBlue = rgb.rgbBlue + (rgbWater.rgbBlue - rgb.rgbBlue) * r; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_simple_mask(sPenDraw &draw) { BEGIN_LOG(""); Byte *mp, *IP; int x, y; RGBQUAD rgb; double r = cr[PWT_SIMPLE] * 0.2; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y, x, 1); // if (mp[x >> 3] & (0x80 >> (x & 7))) { END_LOG; return; } GET_RGBCOLOR; rgb.rgbRed = rgb.rgbRed + (rgbWater.rgbRed - rgb.rgbRed) * r; rgb.rgbGreen = rgb.rgbGreen + (rgbWater.rgbGreen - rgb.rgbGreen) * r; rgb.rgbBlue = rgb.rgbBlue + (rgbWater.rgbBlue - rgb.rgbBlue) * r; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::spatter(int X, int Y) { BEGIN_LOG(""); int size, width; double r, ran, temp; double interval[5] = { 1.0, 0.75, 0.5, 0.25, 0.1 }; Byte *IP; TPoint mp; width = Pen->BasicThick; size = Pen->Thick; r = (rand() % (size * 3)); ran = (rand() % 360) * (M_PI / 180.0); mp = Point(X + r * cos(ran), Y + r * sin(ran)); temp = interval[(int)spEditDensity->Value - 1] * size; if ((mp.x > X + temp || mp.x < X - temp) && (mp.y > Y + temp || mp.y < Y - temp)) { Pen->Thick = rand() % size + 1; Pen->SetPixels(pd, mp.x, mp.y); Pen->BasicThick = width; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_spatter_normal(sPenDraw &draw) { BEGIN_LOG(""); int x, y; RGBQUAD rgb; Byte *IP; double r; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { GET_RGBCOLOR; r = sqrt(draw.mq.x * draw.mq.x + draw.mq.y * draw.mq.y) / Pen->Thick * 2.0; if (r < 0.0) r = 0.0; else if (r > 1.0) r = 1.0; r = cr[PWT_SPATTER] - (cr[PWT_SPATTER] - or[PWT_SPATTER]) * r; rgb.rgbRed = rgb.rgbRed + (rgbWater.rgbRed - rgb.rgbRed) * r; rgb.rgbGreen = rgb.rgbGreen + (rgbWater.rgbGreen - rgb.rgbGreen) * r; rgb.rgbBlue = rgb.rgbBlue + (rgbWater.rgbBlue - rgb.rgbBlue) * r; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_spatter_mask(sPenDraw &draw) { BEGIN_LOG(""); Byte *mp, *IP; int x, y; RGBQUAD rgb; double r; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y, x, 1); // if (mp[x >> 3] & (0x80 >> (x & 7))) { END_LOG; return; } GET_RGBCOLOR; r = sqrt(draw.mq.x * draw.mq.x + draw.mq.y * draw.mq.y) / Pen->Thick * 2.0; if (r < 0.0) r = 0.0; else if (r > 1.0) r = 1.0; r = cr[PWT_SPATTER] - (cr[PWT_SPATTER] - or[PWT_SPATTER]) * r; rgb.rgbRed = rgb.rgbRed + (rgbWater.rgbRed - rgb.rgbRed) * r; rgb.rgbGreen = rgb.rgbGreen + (rgbWater.rgbGreen - rgb.rgbGreen) * r; rgb.rgbBlue = rgb.rgbBlue + (rgbWater.rgbBlue - rgb.rgbBlue) * r; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } END_LOG; } // --------------------------------------------------------------------------- static int sigma(int n) { int i, t; for (i = 1, t = 0; i <= n; i++) t += i; return t; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_pure_normal(sPenDraw &draw) { BEGIN_LOG(""); int x, y; COLORREF c1, c2; double rr, hls[2][3]; RGBQUAD rgb[3]; Byte *IP; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { switch(draw.Image->IsBackGround()) { case 1: IP = draw.Image->LayerMask->GetScanLine(y, x, 1); // if (IP[x >> 3] & (0x80 >> (x & 7))) { c1 = draw.Image->BackGround->GetPixelColor(draw.fp.x, draw.fp.y); c2 = draw.Image->BackGround->GetPixelColor(x, y); IP[x >> 3] &= ~(0x80 >> (x & 7)); draw.Image->LayerMask->PutScanLine(y, x, 1); // } else { c1 = draw.Image->uBitmap->GetPixelColor(draw.fp.x, draw.fp.y); c2 = draw.Image->uBitmap->GetPixelColor(x, y); } break; case 0: c1 = draw.Image->uBitmap->GetPixelColor(draw.fp.x, draw.fp.y); c2 = draw.Image->uBitmap->GetPixelColor(x, y); break; } rgb[1] = TColorToRGB((TColor)c1); TColor2HLS((TColor)c1, hls[1][0], hls[1][1], hls[1][2]); rgb[0] = TColorToRGB((TColor)c2); TColor2HLS((TColor)c2, hls[0][0], hls[0][1], hls[0][2]); if (hls[0][2] == 0.0 && hls[0][1] == 1.0) { rr = cr[PWT_PURE]; } else { rr = (1.0 - hls[0][1]) * cr[PWT_PURE]; } rgb[2].rgbRed = rgb[0].rgbRed + (rgb[1].rgbRed - rgb[0].rgbRed) * rr; rgb[2].rgbGreen = rgb[0].rgbGreen + (rgb[1].rgbGreen - rgb[0].rgbGreen) * rr; rgb[2].rgbBlue = rgb[0].rgbBlue + (rgb[1].rgbBlue - rgb[0].rgbBlue) * rr; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb[2])); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_pure_mask(sPenDraw &draw) { BEGIN_LOG(""); Byte *mp, *IP; int x, y; COLORREF c1, c2; double rr, hls[2][3]; RGBQUAD rgb[3]; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y, x, 1); // if (mp[x >> 3] & (0x80 >> (x & 7))) { END_LOG; return; } switch(draw.Image->IsBackGround()) { case 1: IP = draw.Image->LayerMask->GetScanLine(y, x, 1); // if (IP[x >> 3] & (0x80 >> (x & 7))) { c1 = draw.Image->BackGround->GetPixelColor(draw.fp.x, draw.fp.y); c2 = draw.Image->BackGround->GetPixelColor(x, y); IP[x >> 3] &= ~(0x80 >> (x & 7)); draw.Image->LayerMask->PutScanLine(y, x, 1); // } else { c1 = draw.Image->uBitmap->GetPixelColor(draw.fp.x, draw.fp.y); c2 = draw.Image->uBitmap->GetPixelColor(x, y); } break; case 0: c1 = draw.Image->uBitmap->GetPixelColor(draw.fp.x, draw.fp.y); c2 = draw.Image->uBitmap->GetPixelColor(x, y); break; } rgb[1] = TColorToRGB((TColor)c1); TColor2HLS((TColor)c1, hls[1][0], hls[1][1], hls[1][2]); rgb[0] = TColorToRGB((TColor)c2); TColor2HLS((TColor)c2, hls[0][0], hls[0][1], hls[0][2]); if (hls[0][2] == 0.0 && hls[0][1] == 1.0) { rr = cr[PWT_PURE]; } else { rr = (1.0 - hls[0][1]) * cr[PWT_PURE]; } rgb[2].rgbRed = rgb[0].rgbRed + (rgb[1].rgbRed - rgb[0].rgbRed) * rr; rgb[2].rgbGreen = rgb[0].rgbGreen + (rgb[1].rgbGreen - rgb[0].rgbGreen) * rr; rgb[2].rgbBlue = rgb[0].rgbBlue + (rgb[1].rgbBlue - rgb[0].rgbBlue) * rr; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb[2])); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_diffuse_normal(sPenDraw &draw) { BEGIN_LOG(""); RGBQUAD rgb; int x, y, temp; bool sw = false; double r, ratio, radius; Byte *IP; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { radius = Pen->Thick / 4.0; ratio = sqrt(draw.mq.x * draw.mq.x + draw.mq.y * draw.mq.y) / radius; if (ratio < 0.0) ratio = 0.0; else if (ratio > 2.0) ratio = 2.0; if (ratio > 1.75) { temp = rand() % 9; if (temp < 4) { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 1.5 && ratio <= 1.75) { temp = rand() % 8; if (temp < 3) { sw = true; r = ratio / 1.1 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 1.25 && ratio <= 1.5) { temp = rand() % 7; if (temp < 3) { sw = true; r = ratio / 1.2 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 1.0 && ratio <= 1.25) { temp = rand() % 6; if (temp < 3) { sw = true; r = ratio / 1.3 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 0.75 && ratio <= 1.0) { temp = rand() % 5; if (temp < 3) { sw = true; r = ratio / 1.4 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 0.5 && ratio <= 0.75) { temp = rand() % 4; if (temp < 2) { sw = true; r = ratio / 1.5 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 0.25 && ratio <= 0.5) { temp = rand() % 3; if (temp < 2) { sw = true; r = ratio / 1.6 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } if (sw) { GET_RGBCOLOR; if (r < 0.0) r = 0.0; else if (r > (1.5 + or[PWT_DIFFUSE]) * 0.5) r = 1.0; r = 0.2 * cr[PWT_DIFFUSE] * (2.0 - r); rgb.rgbRed = rgb.rgbRed + (rgbWater.rgbRed - rgb.rgbRed) * r; rgb.rgbGreen = rgb.rgbGreen + (rgbWater.rgbGreen - rgb.rgbGreen) * r; rgb.rgbBlue = rgb.rgbBlue + (rgbWater.rgbBlue - rgb.rgbBlue) * r; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_diffuse_mask(sPenDraw &draw) { BEGIN_LOG(""); Byte *mp, *IP; RGBQUAD rgb; int x, y, temp; bool sw = false; double r, ratio, radius; x = draw.cp.x + draw.mq.x; y = draw.cp.y + draw.mq.y; if (x >= 0 && x < draw.Image->uBitmap->Width && y >= 0 && y < draw.Image->uBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y, x, 1); // if (mp[x >> 3] & (0x80 >> (x & 7))) { END_LOG; return; } radius = Pen->Thick / 4.0; ratio = sqrt(draw.mq.x * draw.mq.x + draw.mq.y * draw.mq.y) / radius; if (ratio < 0.0) ratio = 0.0; else if (ratio > 2.0) ratio = 2.0; if (ratio > 1.75) { temp = rand() % 9; if (temp < 4) { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 1.5 && ratio <= 1.75) { temp = rand() % 8; if (temp < 3) { sw = true; r = ratio / 1.1 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 1.25 && ratio <= 1.5) { temp = rand() % 7; if (temp < 3) { sw = true; r = ratio / 1.2 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 1.0 && ratio <= 1.25) { temp = rand() % 6; if (temp < 3) { sw = true; r = ratio / 1.3 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 0.75 && ratio <= 1.0) { temp = rand() % 5; if (temp < 3) { sw = true; r = ratio / 1.4 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 0.5 && ratio <= 0.75) { temp = rand() % 4; if (temp < 2) { sw = true; r = ratio / 1.5 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else if (ratio > 0.25 && ratio <= 0.5) { temp = rand() % 3; if (temp < 2) { sw = true; r = ratio / 1.6 * or[PWT_DIFFUSE]; } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } } else { sw = true; r = ratio * or[PWT_DIFFUSE]; } if (sw) { GET_RGBCOLOR; if (r < 0.0) r = 0.0; else if (r > (1.5 + or[PWT_DIFFUSE]) * 0.5) r = 1.0; r = 0.2 * cr[PWT_DIFFUSE] * (2.0 - r); rgb.rgbRed = rgb.rgbRed + (rgbWater.rgbRed - rgb.rgbRed) * r; rgb.rgbGreen = rgb.rgbGreen + (rgbWater.rgbGreen - rgb.rgbGreen) * r; rgb.rgbBlue = rgb.rgbBlue + (rgbWater.rgbBlue - rgb.rgbBlue) * r; draw.Image->uBitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } END_LOG; } // --------------------------------------------------------------------------- // Public Function // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SetFont() { SetSmallFont(Font); /* SetSmallFont(lbDiameter->Font); SetSmallFont(lbPx->Font); SetSmallFont(rzcbPressure->Font); SetSmallFont(rzckColorSpread->Font); SetSmallFont(rzckColorSelect->Font); SetSmallFont(lGrade->Font); SetSmallFont(lDensity->Font); SetSmallFont(lScale->Font); SetSmallFont(lbColor->Font); SetSmallFont(lbEffect->Font); SetSmallFont(lbDensity->Font); SetSmallFont(rbSingle->Font); SetSmallFont(rbMulti->Font); SetSmallFont(rbPattern->Font); SetSmallFont(lbDensity2->Font); SetSmallFont(lbConcentration->Font); SetSmallFont(lbIrregularity->Font); SetSmallFont(lbDropSize->Font); */ } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::InitType(TObject *Sender, bool init3d) { BEGIN_LOG(""); /* if (s == sbNormal) Type = PT_NORMAL; else if (s == sbAirBrush) Type = PT_AIR; else if (s == sbCrayon) Type = PT_CRAYON; else if (s == sbWater) Type = PT_WATER; else if (s == sbScratch) Type = PT_SCRAPE; else if (s == sbMask) Type = PT_MASK; ¸ðµå ¼³Á¤ ÂüÁ¶ À§ÇØ ÁÖ¼®À¸·Î º¹»çÇØ¿È */ if (!PenAndNaviTabForm && MainMenuForm->Item != T_STYLECOMBO) this->BringToFront(); RGBQUAD rgb[256]; int Tx, Ty; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; Shape2->BringToFront(); Image1->BringToFront(); Image3->BringToFront(); if (Type == PT_AIR) { // ¿¡¾îºê·¯½Ã ÆæÀÌ¸é ¸î °³ÀÇ ÆÐ³ÎÀ» ¼û±è seSpraySizeChange(NULL); PenWidthPanel->Enabled = false; PenWidthPanel->ShowHint = false; PenWidthPanel->Visible = false; rzsePenSize->Enabled = false; // Shape1->Left = 1; Shape1->Top = 1; // Shape1->Width = 50; Shape1->Height = 50; if (MainImageForm->Palette->UseColor < AirBrushHighestColorIndex) MainImageForm->Palette->UseColor = AirBrushHighestColorIndex; // update UseColor, } else { // ¿¡¾îºê·¯½Ã ÆæÀÌ ¾Æ´Ï¸é ¼û°å´ø ÆÐ³ÎÀ» ´Ù½Ã º¸¿©ÁÜ rzsePenSizeChange(NULL); // is size valid? PenWidthPanel->Enabled = true; PenWidthPanel->ShowHint = true; PenWidthPanel->Visible = true; rzsePenSize->Enabled = true; // Shape1->Left = 0; Shape1->Top = 0; // Shape1->Width = 52; Shape1->Height = 52; } // EOM if (Type == PT_NORMAL) { // ÀÏ¹Ý ÆæÀ̸é sbNormal->Down = true; DensPanel->Visible = false; DensPanel->Visible = false; ScrapePanel->Visible = false; EtcPanel->BringToFront(); EtcPanel->Visible = true; if (bMenuDown) { ClientHeight = EtcPanel->Top + EtcPanel->Height - ScrapePanel->Height; // - 1; // ChangeBtnUpImage(1); } else { ClientHeight = sbBtnUp->Top + sbBtnUp->Height; } if (KasuriForm) { // shin 061024 delete KasuriForm; KasuriForm = NULL; rzcbPressure->Enabled = true; } if (KasuriSubForm) { // shin 061024 delete KasuriSubForm; KasuriSubForm = NULL; } if (MainImageForm) MainImageForm->SetMaskShow(false); } else if (Type == PT_AIR) { Image2->Visible = true; Image3->Visible = true; if (MainImageForm->WorkArea->Mask) { rbPattern->Enabled = true; } else { rbPattern->Enabled = false; rbSingle->Checked = true; } if (AirType == PAT_PATTERN) { Image3->Visible = false; if (MainImageForm->WorkArea->Mask) { Tx = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; Ty = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; if (Image->uBitmap->BitsPerPixel == 8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!(Image1->Bitmap->Create(Tx, Ty, 8, rgb))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!(Image1->Bitmap->Create(Tx, Ty, 24))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } Image->uBitmap->CopyToTexpia(Image1->Bitmap, 0, 0, Image1->Bitmap->Width, Image1->Bitmap->Height, MainImageForm->WorkArea->Range.left, MainImageForm->WorkArea->Range.top, SRCCOPY); // convert by celberus Image1->Repaint(); } } sbAirBrush->Down = true; AirBrushPreview_Driver(); ShowColorBar(); AirBrushPanel->BringToFront(); AirBrushPanel->Visible = true; if (bMenuDown) { ClientHeight = AirBrushPanel->Top + AirBrushPanel->Height - 1; // ChangeBtnUpImage(1); } if (KasuriForm) { delete KasuriForm; KasuriForm = NULL; rzcbPressure->Enabled = true; } if (KasuriSubForm) { delete KasuriSubForm; KasuriSubForm = NULL; } if (MainImageForm) MainImageForm->SetMaskShow(false); } else if (Type == PT_CRAYON) { sbCrayon->Down = true; DensPanel->BringToFront(); DensPanel->Visible = true; EtcPanel->BringToFront(); EtcPanel->Visible = true; if (bMenuDown) { ClientHeight = EtcPanel->Top + EtcPanel->Height - 1; // ChangeBtnUpImage(1); } // if (KasuriForm) { // KasuriForm->Visible = false; // rzcbPressure->Enabled = true; // } // if (KasuriSubForm) { // KasuriSubForm->Visible = false; // } if (KasuriForm) { // shin 061024 delete KasuriForm; KasuriForm = NULL; rzcbPressure->Enabled = true; } if (KasuriSubForm) { // shin 061024 delete KasuriSubForm; KasuriSubForm = NULL; } if (MainImageForm) MainImageForm->SetMaskShow(false); } else if (Type == PT_WATER) { sbWater->Down = true; WaterPanel->BringToFront(); WaterPanel->Visible = true; if (bMenuDown) { ClientHeight = WaterPanel->Top + WaterPanel->Height - 1; // ChangeBtnUpImage(1); } if (KasuriForm) { delete KasuriForm; KasuriForm = NULL; rzcbPressure->Enabled = true; } if (KasuriSubForm) { delete KasuriSubForm; KasuriSubForm = NULL; } if (MainImageForm) MainImageForm->SetMaskShow(false); pd.Image = MainImageForm->iMainImage; } else if (Type == PT_SCRAPE || Type == PT_SCRATCH || Type == PT_KASURI) { sbScratch->Down = true; DensPanel->Visible = false; EtcPanel->BringToFront(); EtcPanel->Visible = true; ScrapePanel->BringToFront(); ScrapePanel->Visible = true; if (MainImageForm) MainImageForm->SetMaskShow(false); if (KasuriForm == NULL && Type == PT_KASURI) { // by bomchun ±×¸®±â ÀÌ³Êºí ¹®Á¦·Î ¼öÁ¤ KasuriForm = new TKasuriForm(this); // 060914 shin kasuri KasuriForm->Parent = this; // MainForm; KasuriForm->InitForm(kasuriPointCount, kasuriBranchCount); ClientHeight = EtcPanel->Top + KasuriForm->Height; ChangeBtnUpImage(1); rzcbPressure->Checked = false; rzcbPressure->Enabled = false; KasuriForm->Top = EtcPanel->Top; KasuriForm->Left = 0; KasuriForm->Visible = true; KasuriForm->OnClose = KauriClose; KasuriForm->ClientWidth = 204; } else if (Type == PT_KASURI) { ClientHeight = EtcPanel->Top + KasuriForm->Height; ChangeBtnUpImage(1); rzcbPressure->Checked = false; rzcbPressure->Enabled = false; KasuriForm->Top = EtcPanel->Top; KasuriForm->Visible = true; KasuriForm->BringToFront(); } else if (Type != PT_KASURI) { // by bomchun ±×¸®±â ÀÌ³Êºí ¹®Á¦·Î ¼öÁ¤ if (KasuriForm) { delete KasuriForm; KasuriForm = NULL; rzcbPressure->Checked = true; } if (KasuriSubForm) { delete KasuriSubForm; KasuriSubForm = NULL; } if (bMenuDown) { ClientHeight = EtcPanel->Top + EtcPanel->Height; // ChangeBtnUpImage(1); } TSpeedButton *s = (TSpeedButton*)Sender; // by bomchun ±×¸®±â ÀÌ³Êºí ¹®Á¦·Î ¼öÁ¤ } } else if (Type == PT_MASK) { sbMask->Down = true; rzckDelete->Checked = false; MaskPanel->BringToFront(); MaskPanel->Visible = true; if (bMenuDown) { ClientHeight = MaskPanel->Top + MaskPanel->Height - 1; // ChangeBtnUpImage(1); } if (KasuriForm) { delete KasuriForm; KasuriForm = NULL; } if (KasuriSubForm) { delete KasuriSubForm; KasuriSubForm = NULL; } TPItemImage *Image = MainImageForm->iMainImage; RECT r; if (Image->Mask == NULL) { if (Image->uBitmap->Width <= 0 || Image->uBitmap->Height <= 0) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Image->Mask = new TUnionBitmap; // convert by celberus if (Image->Mask == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel == 8) { if (Image->Mask->Create(Image->uBitmap->Width, Image->uBitmap->Height, 8) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Image->Mask->Create(Image->uBitmap->Width, Image->uBitmap->Height, 1) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } for (int i = 0; i < Image->uBitmap->CountX * Image->uBitmap->CountY; i++) { Image->uBitmap->PartialUndo->UndoCheckLoad(i); } SetRect(&r, 0, 0, Image->uBitmap->Width, Image->uBitmap->Height); Image->Mask->FillRect(r, 0); } MainImageForm->MaskArea = true; if (MainImageForm) MainImageForm->SetMaskShow(true); } if (init3d) MenuSW = true; // if 3d Menu click, prevent to show normal pen form MenuClick(NULL); MainImageForm->PenChange(); if (Type == PT_WATER) { MainImageForm->iMainImage->InitBackGround(0x04); } else { MainImageForm->iMainImage->ExitBackGround(0x04); } ::RepaintImage(); if (PenAndNaviTabForm && bMenuDown) PenAndNaviTabForm->FormResizeForPen(ClientHeight); // Spread On: ¾Æ·¡ ±â´ÉÀ» »ç¿ëÇϰí MenuDownÀÏ °æ¿ì¿¡´Â ÀÚµ¿À¸·Î On ÇÑ´Ù. // Spread Off: ¾Æ·¡ ±â´É »ç¿ëÁß MenuDownÀÌ False(Up) µÇ¸é Off ÇÑ´Ù. if (bMenuDown && (Type == PT_NORMAL || Type == PT_CRAYON || Type == PT_SCRAPE || Type == PT_SCRATCH)) { rzckColorSpread->Checked = true; aspread = true; if (rzckColorSelect->Checked) acolor = 2; // Yes else acolor = 0; // No // IDS_COMMON_BUTTONNO } END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SelectColor(Byte Color) { BEGIN_LOG(""); this->PenShape->Pen->Color = MainImageForm->Palette->Color[Color]; // shin 061024 ¸Ç¾Æ·¡¼­ À§·Î ¿Ã¸² this->PenShape->Brush->Color = MainImageForm->Palette->Color[Color]; this->PenWidthPanel->Color = MainImageForm->Palette->Color[BackgroundIndex]; switch(Type) { case PT_AIR: AddAirBrushColor(Color); break; case PT_KASURI: ChangeKasuriPenColor(); break; // shin 061024 default: if (spread_sw[4] == 0) { if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); if (aspread) { if (spread_pos == 0) { spread_pos = 1; spread_start = Color; shFirst->Brush->Color = MainImageForm->Palette->Color[spread_start]; shFirst->Pen->Color = clBlack; shSecond->Pen->Color = clRed; } else if (spread_pos == 1) { spread_pos = 0; spread_end = Color; shSecond->Brush->Color = MainImageForm->Palette->Color[spread_end]; shFirst->Pen->Color = clRed; shSecond->Pen->Color = clBlack; } } } else { if (acolor == 1) { Selector->AddColor(Color); } } } PenShape->Pen->Color = MainImageForm->Palette->Color[Color]; PenShape->Brush->Color = MainImageForm->Palette->Color[Color]; PenWidthPanel->Color = MainImageForm->Palette->Color[BackgroundIndex]; END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_read_8(Byte *p, int x) { return p[x] == 0x00; } // ---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_save_8(Byte *p, int x) { p[x] = 0x0F; } // --------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_read_24(Byte *p, int x) { return(p[x >> 3] & (0x80 >> (x & 7))) == 0; } // ---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_save_24(Byte *p, int x) { p[x >> 3] |= 0x80 >> (x & 7); } // --------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_delete_read_8(Byte *p, int x) { return p[x] == 0x0F; } // ---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_delete_save_8(Byte *p, int x) { p[x] = 0x00; } // --------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_delete_read_24(Byte *p, int x) { return p[x >> 3] & (0x80 >> (x & 7)); } // ---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_delete_save_24(Byte *p, int x) { p[x >> 3] &= ~(0x80 >> (x & 7)); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); COLORREF spc, lc; int pw, ww, hh; RECT r, art; int ix, iy; TPItemImage *Image = MainImageForm->iMainImage; if (!PenManagerForm->Visible) { ShowMessage(IDS_MESSAGE_PENMENU_OFF); END_LOG; return; } if (Image->Reflection && MainImageForm->reflection){ POINT reflectionPos; reflectionPos = MainImageForm->reflection->FindOriginalPos(X, Y); if (reflectionPos.x < MainImageForm->reflection->BitmapRange.left || reflectionPos.y < MainImageForm->reflection->BitmapRange.top || reflectionPos.x > MainImageForm->reflection->BitmapRange.right || reflectionPos.y > MainImageForm->reflection->BitmapRange.bottom){ END_LOG; return; } } // access°¡ ¹ß»ýÇØ¼­ ÁÖ¼®Ã³¸® by david 090914 // ¿¹¸¦ µé¾î ÆÈ·¹Æ®ÀÇ ÇÁ¸°ÅÍ Ä®¶ó -> °Ë»ö -> ÄÚµå °ª¿¡ Æ÷Ä¿½º°¡ ÀÖ´Â »óÅ¿¡¼­ a/s۸¦ ´©¸£´Ù°¡ // ÆæÀ¸·Î ĵ¹ö½º¸¦ Ŭ¸¯ÇÏ¸é Æ÷Ä¿½º ¹Ì½Ì ¿¡·¯°¡ ¹ß»ýÇÑ´Ù. // PenManagerForm->SetFocus(); if (Tablet) { if (Tablet->prsNew > Tablet->MaxNPressure) Tablet->prsNew = Tablet->MaxNPressure; } if (Button == mbMiddle || (Shift.Contains(ssShift) && Button == mbLeft)) { // »ö¼±ÅÃÀº Middle¹öư°ú shift+left ¹öư¸¸ »ç¿ëÇϱ⠶§¹®¿¡ // Mousemove¿¡¼­´Â ¹öưÀÇ Á¾·ù¸¦ È®ÀÎÇÒ ¼ö ¾ø´Ù. µû¶ó¼­ ¾Æ·¡¿Í °°ÀÌ // acolor = 1·Î È®ÀÎ Çϵµ·Ï º¯°æ ÇÔ. acolor = 1; Selector->Invalid(); //if (acolor == 1) { if (rzckColorSelect->Checked) { if (sbBlock->Down) { if (Image->LayerMask) { lc = Image->LayerMask->GetPixelColor(X, Y); if (sbDelete->Down) { if (lc == 0) Selector->DeleteColor(Image->uBitmap->GetPixelColor(X, Y)); } else { if (lc == 0) Selector->AddColor(Image->uBitmap->GetPixelColor(X, Y)); } } else { if (sbDelete->Down) { Selector->DeleteColor(Image->uBitmap->GetPixelColor(X, Y)); } else { Selector->AddColor(Image->uBitmap->GetPixelColor(X, Y)); } } } else { if (step == 0) { Temp.left = X; Temp.top = Y; Temp.bottom = Temp.top; Temp.right = Temp.left; MainImageForm->DrawRectangleLocate(Temp); IsDraw = true; step = 1; } else if (step == 1) { Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); if (Temp.left > Temp.right) { r.left = Temp.right; r.right = Temp.left; } else { r.left = Temp.left; r.right = Temp.right; } if (Temp.top > Temp.bottom) { r.top = Temp.bottom; r.bottom = Temp.top; } else { r.top = Temp.top; r.bottom = Temp.bottom; } if (sbDelete->Down) { if (Image->LayerMask) { for (iy = r.top; iy < r.bottom; iy++) { for (ix = r.left; ix < r.right; ix++) { lc = Image->LayerMask->GetPixelColor(ix, iy); if (lc == 0) Selector->DeleteColor(Image->uBitmap->GetPixelColor(ix, iy)); } } } else { for (iy = r.top; iy < r.bottom; iy++) { for (ix = r.left; ix < r.right; ix++) { Selector->DeleteColor(Image->uBitmap->GetPixelColor(ix, iy)); } } } } else { if (Image->LayerMask) { for (iy = r.top; iy < r.bottom; iy++) { for (ix = r.left; ix < r.right; ix++) { lc = Image->LayerMask->GetPixelColor(ix, iy); if (lc == 0) Selector->AddColor(Image->uBitmap->GetPixelColor(ix, iy)); } } } else { for (iy = r.top; iy < r.bottom; iy++) { for (ix = r.left; ix < r.right; ix++) { Selector->AddColor(Image->uBitmap->GetPixelColor(ix, iy)); } } } } IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL; /////////////////by jeegeo step = 0; } } } //} } else if (Button == mbLeft) { if (acolor != 1) { int ZoomIn = Image->ZoomIn; int ZoomOut = Image->ZoomOut; int PenSize = PenManagerForm->Pen->Thick; r.left = Image->PositionX - (PenSize + 30); // 30 is Caption Height if (r.left < 0) r.left = 0; r.top = Image->PositionY - (PenSize + 30); if (r.top < 0) r.top = 0; r.right = r.left + Image->Width * ZoomOut / ZoomIn + PenSize + 60; if (r.right > Image->uBitmap->Width) r.right = Image->uBitmap->Width; r.bottom = r.top + Image->Height * ZoomOut / ZoomIn + PenSize + 60; if (r.bottom > Image->uBitmap->Height) r.bottom = Image->uBitmap->Height; art = r; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) art = MainImageForm->AutoRep_UndoRect(r); switch(Type) { case PT_NORMAL: // MainImageForm->UndoSave(UK_PATTERN, art, false); // RECT TempRect=RECT{0,0,0,0}; MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, 0, 0)); // by linxujun Undo_Method BtnClick = true; Lsx = X; Lsy = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) { spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = spread_start +double(spread_grade - 1) + 0.5; } } else { if (Tablet) { spc = Tablet->prsNew; } else { spc = 1; } } FPointPressurePen(Lsx, Lsy, Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; if (update){ if (Image->Reflection){ RECT rt; if (MainImageForm->reflection->ChangeRectPaintRange(r, rt)){ MainImageForm->iMainImage->RectPaint(rt); } } else { MainImageForm->iMainImage->RectPaint(r); } } } } else { Lex = Lsx; Ley = Lsy; #ifdef FASTPEN // --------------------------------- TPoint *pt; while (pointList->Count) { pt = (TPoint*)pointList->Last(); pointList->Remove(pt); delete pt; } pt = new TPoint; pt->x = X; pt->y = Y; pointList->Add(pt); MainImageForm->Templine_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF (MainImageForm->iMainImage->uBitmap->BitsPerPixel), &r); if (update) MainImageForm->iMainImage->RectScreenPaint(r); // --------------------------------- #else MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF (Image->uBitmap->BitsPerPixel), &r); if (update){ if (Image->Reflection){ RECT rt; if (MainImageForm->reflection->ChangeRectPaintRange(r, rt)){ MainImageForm->iMainImage->RectPaint(rt); } } else { MainImageForm->iMainImage->RectPaint(r); } } #endif } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) { spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = spread_start +double(spread_grade - 1) + 0.5; } } else { if (Tablet) spc = Tablet->prsNew; else spc = 1; } if (Tablet) { pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; } else { pw = double(Pen->Thick - 1) + 1.0; } FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; if (Tablet) { pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; } else { pw = double(Pen->Thick - 1) + 1.0; } FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } break; case PT_AIR: // MainImageForm->UndoSave(UK_PATTERN, art, false); // MainImageForm->UndoSave(UK_PATTERN, art); //by linuxjun For Undo_Method MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, 0, 0)); // by linxujun Undo_Method BtnClick = true; Lsx = X; Lsy = Y; Lex = Lsx; Ley = Lsy; line_airbrush_pen(); break; case PT_CRAYON: // MainImageForm->UndoSave(UK_PATTERN, art, false); // MainImageForm->UndoSave(UK_PATTERN, art); //by linuxjun For Undo_Method MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, 0, 0)); // by linxujun Undo_Method BtnClick = true; Lsx = X; Lsy = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) { spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = spread_start +double(spread_grade - 1) + 0.5; } } else { if (Tablet) spc = Tablet->prsNew; else spc = 1; } FPointPressurePen(Lsx, Lsy, Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; FPointPressurePen(Lsx, Lsy, Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) { spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = spread_start +double(spread_grade - 1) + 0.5; } } else { if (Tablet) spc = Tablet->prsNew; else spc = 1; } if (Tablet) { pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; } else { pw = double(Pen->Thick - 1) + 1.0; } FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; if (Tablet) { pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; } else { pw = double(Pen->Thick - 1) + 1.0; } FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } break; case PT_WATER: // MainImageForm->UndoSave(UK_PATTERN, art, false); // MainImageForm->UndoSave(UK_PATTERN, art); //by linuxjun For Undo_Method if (X > Lex) { r.left = Lex - (Pen->Thick) / 2; r.right = X + (Pen->Thick + 1) / 2 + 1; } else { r.left = X - (Pen->Thick) / 2; r.right = Lex + (Pen->Thick + 1) / 2 + 1; } if (Y > Ley) { r.top = Ley - (Pen->Thick) / 2; r.bottom = Y + (Pen->Thick + 1) / 2 + 1; } else { r.top = Y - (Pen->Thick) / 2; r.bottom = Ley + (Pen->Thick + 1) / 2 + 1; } // MainImageForm->UndoSave(UK_PATTERN, Rect(0,0,0,0)); //by linuxjun For Undo_Method MainImageForm->UndoSave(UK_PATTERN, r); // by linuxjun For Undo_Method set_water_func(); if (MainImageForm->iMainImage->LayerMask) MainImageForm->iMainImage->LayerMask->StartScanLine(); if (MainImageForm->MaskArea) MainImageForm->iMainImage->Mask->StartScanLine(); if (WaterType == PWT_AVERAGE) { // By GreenFish Average Pen±â´É /* pBITMAPHANDLE bh = MainImageForm->iMainImage->uBitmap->Handle; RGNXFORM XForm; RECT rc; HRGN rgnSrc, rgnDst; XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; */ // MainImageForm->iMainImage->uBitmap->PartialUndo->RectSaveUndo(r); Lex = AvgStartPt.x = X; Ley = AvgStartPt.y = Y; // ÇöÀç ÁÂÇ¥ ±â¾ï AvgPtCount = 1; /* rc.left = X - (Pen->Thick)/2; rc.right = X + (Pen->Thick+1)/2 +1; rc.top = Y - (Pen->Thick)/2; rc.bottom = Y + (Pen->Thick+1)/2 +1; L_SetBitmapRgnEllipse(bh, &XForm, &rc, L_RGN_SET); */ /* L_GetBitmapRgnHandle(bh, &XForm, &rgnDst); MainImageForm->WorkArea->SetMask(rgnDst); DeleteObject(rgnDst); */ /* L_INT nChange = 3; L_UINT32 uProcess; HINSTANCE hLibrary = LoadLibrary("ltdlg13n.dll"); if (hLibrary) { // TDlgGetChange DlgGetChange = (TDlgGetChange)GetProcAddress(hLibrary, "L_DlgGetChange"); if (nChange) { L_AverageFilterBitmap(bh, nChange); WindowForm->sbOffClick(this); // ÀÛ¾÷±¸¿ª ÇØÁ¦ } FreeLibrary(hLibrary); } */ } if (WaterType == PWT_SPATTER) { rgbWater = PaletteForm->DIB256Palette->ForegroundRgb; spatter(X, Y); } else { if (WaterType != PWT_PURE) { rgbWater = PaletteForm->DIB256Palette->ForegroundRgb; } Pen->MoveRatio = WaterType == PWT_SIMPLE || WaterType == PWT_PURE ? 3 + or[WaterType] * 7 : 8; if (WaterType == PWT_DIFFUSE) Pen->ThickRatio = 1.0 + or[PWT_DIFFUSE]; Pen->MoveTo(pd, X, Y); } BtnClick = true; break; case PT_SCRAPE: case PT_SCRATCH: // MainImageForm->UndoSave(UK_PATTERN, art, false); // MainImageForm->UndoSave(UK_PATTERN, art); //by linuxjun For Undo_Method MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, 0, 0)); // by linxujun Undo_Method BtnClick = true; Lsx = X; Lsy = Y; Lex = Lsx; Ley = Lsy; break; case PT_MASK: if (rzrbFill->Checked) { POINT p = Point(X, Y); RECT rect; BYTE *WP = NULL, *MP = NULL; int nWidth, nRPBytesPos, nColumnIndex = 0; HRGN hRgn=NULL; // MainImageForm->UndoSave(UK_MASK, false); // MainImageForm->UndoSave(UK_MASK); //by linxujun for Undo_Method MainImageForm->UndoSave(UK_MASK, Rect(0, 0, 0, 0)); // ÀÛ¾÷±¸¿ª º¸È£ÆæÀ¸·Î ä¿ì±â/Áö¿ì±â - by monkman (2010.10.01) // L_IsPtInBitmapRgn(Image->uBitmap->RgnBitmap->Handle, X, Y) ¸¦ »ç¿ëÇϸé Á¦´ë·Î µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.. hRgn = Image->uBitmap->RgnBitmap->GetRegion(false); // ÀÎÀÚ·Î false¸¦ ÁÖ¾î Á¦°ÅÇÏÁö ¾Ê´Â´Ù if (MainImageForm->WorkArea->Mask && PtInRegion(hRgn, X, Y)) { MainImageForm->WorkArea->Mask->StartScanLine(); nWidth = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; if (Image->Mask->StartScanLine()) { for (int y = MainImageForm->WorkArea->Range.top; y < MainImageForm->WorkArea->Range.bottom; y++) { // MainImageForm->WorkArea->MaskÀº RegionµéÀÇ ÇÕÁýÇÕ µÑ·¹¸¦ Å©±â·Î °®´Â ºñÆ®¸ÊÀÌ´Ù. WP = MainImageForm->WorkArea->Mask->GetScanLine(y-MainImageForm->WorkArea->Range.top); MP = Image->Mask->GetScanLine(y); nColumnIndex = 0; for (int x = 0; x < nWidth; x++) { // MaskÀÇ BitsPerPixel == 8 if (Image->uBitmap->BitsPerPixel == 8) { nRPBytesPos = x+MainImageForm->WorkArea->Range.left; if (*(WP+x)) { if (rzckDelete->Checked) { *(MP+nRPBytesPos) = 0x00; } else { *(MP+nRPBytesPos) = 0x0F; } } } else { // MaskÀÇ BitsPerPixel == 1 nRPBytesPos = nColumnIndex+MainImageForm->WorkArea->Range.left; if ((*(WP+(nColumnIndex>>3))) & (0x80>>(nColumnIndex&7))) { if (rzckDelete->Checked) { *(MP+(nRPBytesPos>>3)) &= ~(0x80>>(nRPBytesPos&7)); } else { *(MP+(nRPBytesPos>>3)) |= (0x80>>(nRPBytesPos&7)); } } } nColumnIndex++; } Image->Mask->PutScanLine(y); } Image->Mask->StopScanLine(); } if (hRgn) { DeleteObject(hRgn); // ¹Ýµå½Ã Áö¿öÁØ´Ù } MainImageForm->WorkArea->Mask->StopScanLine(); } else { // by linxujun for Undo_Method if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (rzckDelete->Checked) { Image->Mask->FloodFill((TPoint)p, mask_fill_delete_read_8, mask_fill_delete_save_8, (TRect)rect); } else { Image->Mask->FloodFill((TPoint)p, mask_fill_read_8, mask_fill_save_8, (TRect)rect); } } else { if (rzckDelete->Checked) { Image->Mask->FloodFill((TPoint)p, mask_fill_delete_read_24, mask_fill_delete_save_24, (TRect)rect); } else { Image->Mask->FloodFill((TPoint)p, mask_fill_read_24, mask_fill_save_24, (TRect)rect); } } } Image->Repaint(); } else { // MainImageForm->UndoSave(UK_MASK, art, false); // MainImageForm->UndoSave(UK_MASK, art); //by linuxjun for Undo_Method MainImageForm->UndoSave(UK_MASK, Rect(0, 0, 0, 0)); // by linxujun for Undo_Method BtnClick = true; Lsx = X; Lsy = Y; if (Pen->Brush == 0) { Lex = Lsx; Ley = Lsy; MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF (Image->uBitmap->BitsPerPixel), &r); if (update){ if (Image->Reflection){ RECT rt; if (MainImageForm->reflection->ChangeRectPaintRange(r, rt)){ MainImageForm->iMainImage->RectPaint(rt); } } else { MainImageForm->iMainImage->RectPaint(r); } } } else if (Pen->Brush == 1) { spc = PaletteForm->DIB256Palette->ChoiceIndex; if (Tablet) { pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; } else { pw = double(Pen->Thick - 1) + 1.0; } FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } break; case PT_KASURI: // kasuri if (KasuriForm) { MainImageForm->iMainImage->Cursor = crDefault; int ZoomIn = MainImageForm->iMainImage->ZoomIn; int ZoomOut = MainImageForm->iMainImage->ZoomOut; if (KasuriForm->bPathDrawEnd) { if (KasuriForm->hasKasuri && (KasuriForm->bKasuriEditMode == true)) { KasuriForm->bKasuriPointMoveMode = true; } else { KasuriForm->bKasuriPointMoveMode = false; } } else { if (KasuriForm->hasKasuri && KasuriForm->bPathDrawingMode) { KasuriForm->PathDrawMouseDownSet(X, Y, MainImageForm->iMainImage->PositionX, MainImageForm->iMainImage->PositionY, ZoomIn, ZoomOut); } } } break; } } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialMouseMove(TShiftState Shift, int X, int Y) { BEGIN_LOG(""); COLORREF spc; int pw; RGBQUAD m_rgb[3]; TPItemImage *Image = MainImageForm->iMainImage; RECT r; if (Image->Reflection && MainImageForm->reflection){ POINT reflectionPos; reflectionPos = MainImageForm->reflection->FindOriginalPos(X, Y); if (reflectionPos.x < MainImageForm->reflection->BitmapRange.left || reflectionPos.y < MainImageForm->reflection->BitmapRange.top || reflectionPos.x > MainImageForm->reflection->BitmapRange.right || reflectionPos.y > MainImageForm->reflection->BitmapRange.bottom){ BtnClick = false; END_LOG; return; } } if (Tablet) { if (Tablet->prsNew > Tablet->MaxNPressure) Tablet->prsNew = Tablet->MaxNPressure; } if (acolor != 1) { switch(Type) { case PT_NORMAL: if (BtnClick) { Lex = X; Ley = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) { spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = spread_start +double(spread_grade - 1) + 0.5; } } else { if (Tablet) { spc = Tablet->prsNew; } else spc = 1; } line_pressure_pen(Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else { #ifdef FASTPEN // ------------------------- TPoint *pt = new TPoint; pt->x = X; pt->y = Y; pointList->Add(pt); MainImageForm->Templine_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF (MainImageForm->iMainImage->uBitmap->BitsPerPixel), &r); if (update) MainImageForm->iMainImage->RectScreenPaint(r); // ------------------------- #else MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF (Image->uBitmap->BitsPerPixel), &r); if (update){ if (Image->Reflection){ RECT rt; if (MainImageForm->reflection->ChangeRectPaintRange(r, rt)){ MainImageForm->iMainImage->RectPaint(rt); } } else { MainImageForm->iMainImage->RectPaint(r); } } #endif } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) { spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = spread_start +double(spread_grade - 1) + 0.5; } } else { if (Tablet) spc = Tablet->prsNew; else spc = 1; } if (Tablet) pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; else pw = double(Pen->Thick - 1) + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; if (Tablet) pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; else pw = double(Pen->Thick - 1) + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } Lsx = Lex; Lsy = Ley; } break; case PT_AIR: if (BtnClick) { Lex = X; Ley = Y; line_airbrush_pen(); Lsx = Lex; Lsy = Ley; } break; case PT_CRAYON: if (BtnClick) { Lex = X; Ley = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; else spc = spread_start +double(spread_grade - 1) + 0.5; } else { if (Tablet) spc = Tablet->prsNew; else spc = 1; } line_pressure_pen(Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; line_pressure_pen(Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; else spc = spread_start +double(spread_grade - 1) + 0.5; } else { if (Tablet) spc = Tablet->prsNew; else spc = 1; } if (Tablet) pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; else pw = double(Pen->Thick - 1) + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; if (Tablet) pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; else pw = double(Pen->Thick - 1) + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } Lsx = Lex; Lsy = Ley; } break; case PT_WATER: if (BtnClick) { if (abs(X - pd.fp.x) > Pen->BasicThick || abs(Y - pd.fp.y) > Pen->BasicThick) { if (WaterType == PWT_AVERAGE) { // By GreenFish Average Pen±â´É /* pBITMAPHANDLE bh = MainImageForm->iMainImage->uBitmap->Handle; RGNXFORM XForm; RECT rc; HRGN rgnSrc, rgnDst; XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; */ if (AvgPtCount >= 200) { END_LOG; return; } POINT PolyPt[4]; POINT *pPolyPt = PolyPt; int dx, dy, k; float sin, cos, dl; dx = X - Lex; dy = Y - Ley; dl = sqrt(dx * dx + dy * dy); k = (Pen->Thick + 1) / 2; if (dl == 0) break; sin = dy / dl * k; cos = dx / dl * k; pPolyPt[0].x = Lex + sin; pPolyPt[0].y = Ley - cos; pPolyPt[1].x = X + sin; pPolyPt[1].y = Y - cos; pPolyPt[2].x = X - sin; pPolyPt[2].y = Y + cos; pPolyPt[3].x = Lex - sin; pPolyPt[3].y = Ley + cos; if (AvgPtCount == 1) { AvgUpperPt[0] = pPolyPt[3]; AvgLowerPt[0] = pPolyPt[0]; } AvgUpperPt[AvgPtCount] = pPolyPt[2]; AvgLowerPt[AvgPtCount] = pPolyPt[1]; AvgPtCount++; if (WaterType == PWT_AVERAGE) { // By GreenFish Average Pen±â´É if (X > Lex) { r.left = Lex - (Pen->Thick) / 2; r.right = X + (Pen->Thick + 1) / 2 + 1; } else { r.left = X - (Pen->Thick) / 2; r.right = Lex + (Pen->Thick + 1) / 2 + 1; } if (Y > Ley) { r.top = Ley - (Pen->Thick) / 2; r.bottom = Y + (Pen->Thick + 1) / 2 + 1; } else { r.top = Y - (Pen->Thick) / 2; r.bottom = Ley + (Pen->Thick + 1) / 2 + 1; } MainImageForm->iMainImage->uBitmap->PartialUndo->RectSaveUndo(r); } Lex = X; Ley = Y; break; /* L_SetBitmapRgnPolygon(bh, &XForm, pPolyPt, 4, L_POLY_WINDING, L_RGN_SET); L_INT nChange = 3; L_UINT32 uProcess; HINSTANCE hLibrary = LoadLibrary("ltdlg13n.dll"); if (hLibrary) { L_AverageFilterBitmap(bh, nChange); WindowForm->sbOffClick(this); // ÀÛ¾÷±¸¿ª ÇØÁ¦ } FreeLibrary(hLibrary); Lex = X; Ley = Y; break; */ } if (WaterType == PWT_SPATTER) { spatter(X, Y); } else { Pen->LineTo(pd, X, Y); } } } break; case PT_SCRAPE: case PT_SCRATCH: if (BtnClick) { Lex = X; Ley = Y; if ((Lsx - 5 > Lex) || (Lsx + 5 < Lex) || (Lsy - 5 > Ley) || (Lsy + 5 < Ley)) { if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Tablet) pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; else pw = double(Pen->Thick - 1) + 1.0; if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; else spc = spread_start +double(spread_grade - 1) + 0.5; } else { m_rgb[0] = MainImageForm->Palette->ColorData[spread_start] ->RGB; m_rgb[1] = MainImageForm->Palette->ColorData[spread_end]->RGB; if (Tablet) { m_rgb[2].rgbRed = m_rgb[0].rgbRed + Tablet->prsNew * (m_rgb[1].rgbRed - m_rgb[0].rgbRed) / Tablet->MaxNPressure; m_rgb[2].rgbGreen = m_rgb[0].rgbGreen + Tablet->prsNew * (m_rgb[1].rgbGreen - m_rgb[0].rgbGreen) / Tablet->MaxNPressure; m_rgb[2].rgbBlue = m_rgb[0].rgbBlue + Tablet->prsNew * (m_rgb[1].rgbBlue - m_rgb[0].rgbBlue) / Tablet->MaxNPressure; } else { m_rgb[2] = m_rgb[0]; } spc = RGBToTColor(m_rgb[2]); } scrape_pen(pw, spc); } } else { if (Tablet) pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; else pw = double(Pen->Thick - 1) + 1.0; scrape_pen(pw, PaletteForm->DIB256Palette->GetFGCOLORREF (Image->uBitmap->BitsPerPixel)); } } else if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->uBitmap->BitsPerPixel == 8) { if (Tablet) spc = spread_start +double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; else spc = spread_start +double(spread_grade - 1) + 0.5; } else { m_rgb[0] = MainImageForm->Palette->ColorData[spread_start] ->RGB; m_rgb[1] = MainImageForm->Palette->ColorData[spread_end]->RGB; if (Tablet) { m_rgb[2].rgbRed = m_rgb[0].rgbRed + Tablet->prsNew * (m_rgb[1].rgbRed - m_rgb[0].rgbRed) / Tablet->MaxNPressure; m_rgb[2].rgbGreen = m_rgb[0].rgbGreen + Tablet->prsNew * (m_rgb[1].rgbGreen - m_rgb[0].rgbGreen) / Tablet->MaxNPressure; m_rgb[2].rgbBlue = m_rgb[0].rgbBlue + Tablet->prsNew * (m_rgb[1].rgbBlue - m_rgb[0].rgbBlue) / Tablet->MaxNPressure; } else { m_rgb[2] = m_rgb[0]; } spc = RGBToTColor(m_rgb[2]); } scrape_pen(Pen->Thick, spc); } } else { scrape_pen(Pen->Thick, PaletteForm->DIB256Palette->GetFGCOLORREF (Image->uBitmap->BitsPerPixel)); } } Lsx = Lex; Lsy = Ley; } } break; case PT_MASK: if (BtnClick) { Lex = X; Ley = Y; if (Pen->Brush == 0) { MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF (Image->uBitmap->BitsPerPixel), &r); if (update){ if (Image->Reflection){ RECT rt; if (MainImageForm->reflection->ChangeRectPaintRange(r, rt)){ MainImageForm->iMainImage->RectPaint(rt); } } else { MainImageForm->iMainImage->RectPaint(r); } } } else if (Pen->Brush == 1) { spc = PaletteForm->DIB256Palette->ChoiceIndex; if (Tablet) pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; else pw = double(Pen->Thick - 1) + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } Lsx = Lex; Lsy = Ley; } break; case PT_KASURI: // kasuri MainImageForm->iMainImage->Cursor = crDefault; if (KasuriForm && KasuriForm->hasKasuri) { MainImageForm->iMainImage->Cursor = crDefault; if (KasuriForm->bPathDrawEnd) { if (KasuriForm->isPointEnd()) { if (KasuriForm->bKasuriPointMoveMode) { KasuriForm->MovePoint(X, Y); } else { KasuriForm->FindPoint(X, Y); if (KasuriForm->bKasuriEditMode) { KasuriForm->bKasuriPointMoveMode = true; KasuriForm->MovePoint(X, Y); } } } } else { if (KasuriForm->bPathDrawMovingMode) { KasuriForm->PathDrawMouseMoveSet(X, Y, MainImageForm->iMainImage->PositionX, MainImageForm->iMainImage->PositionY, MainImageForm->iMainImage->ZoomIn, MainImageForm->iMainImage->ZoomOut); } } } break; } } else if (acolor == 1) { if (step == 1) { if (IsDraw) MainImageForm->DrawRectangleLocate(Temp); Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); IsDraw = true; } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialMouseUp(TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); if (MainImageForm->iMainImage->Reflection && MainImageForm->reflection){ POINT reflectionPos; reflectionPos = MainImageForm->reflection->FindOriginalPos(X, Y); if (reflectionPos.x < MainImageForm->reflection->BitmapRange.left || reflectionPos.y < MainImageForm->reflection->BitmapRange.top || reflectionPos.x > MainImageForm->reflection->BitmapRange.right || reflectionPos.y > MainImageForm->reflection->BitmapRange.bottom){ MainImageForm->iMainImage->Repaint(); END_LOG; return; } } if (acolor == 1) { if (rzckColorSelect->Checked) acolor = 2; // Yes else acolor = 0; // No } switch(Type) { case PT_NORMAL: case PT_AIR: case PT_CRAYON: case PT_SCRAPE: case PT_WATER: case PT_MASK: case PT_KASURI: BtnClick = false; } #ifdef FASTPEN // ---------------- if (Type == PT_NORMAL) { RECT r; bool first = true; TPoint sp, ep; TPoint *pt; while (pointList->Count) { Screen->Cursor = crHourGlass; pt = (TPoint*)pointList->First(); if (first) { sp = *pt; first = false; } ep = *pt; MainImageForm->line_pen(sp.x, sp.y, ep.x, ep.y, PaletteForm->DIB256Palette->GetFGCOLORREF (MainImageForm->iMainImage->uBitmap->BitsPerPixel), &r); sp = *pt; pointList->Remove(pt); delete pt; } MainImageForm->iMainImage->Repaint(); } // ----------------- #endif if (Type == PT_WATER) { if (WaterType == PWT_AVERAGE) { // By GreenFish Average Pen±â´É AvgDestPt.x = X; AvgDestPt.y = Y; // pBITMAPHANDLE bh = MainImageForm->iMainImage->uBitmap->Handle; TCursor OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; RGNXFORM XForm; RECT rc; HRGN rgnSrc, rgnDst; XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; L_INT nChange = spEditDensity->Value + 1; rc.left = AvgStartPt.x - (Pen->Thick) / 2; rc.right = AvgStartPt.x + (Pen->Thick + 1) / 2 + 1; rc.top = AvgStartPt.y - (Pen->Thick) / 2; rc.bottom = AvgStartPt.y + (Pen->Thick + 1) / 2 + 1; // ==============================¼öÁ¤Áß(¼Óµµ°³¼±) GreenFish TTexpiaBitmap *BtTemp; // ºñÆ®¸Ê Àӽà ÀúÀå RGBQUAD Btrgb[256]; TPException ec = EC_NONE; int TempWidth = rc.right - rc.left, TempHeight = rc.bottom - rc.top; RECT Temprc; if ((BtTemp = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->iMainImage->uBitmap->GetColors(0, 256, Btrgb); if (!BtTemp->Create(TempWidth, TempHeight, MainImageForm->iMainImage->uBitmap->BitsPerPixel, Btrgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } /* BtTemp->Copy(0, 0, TempWidth, TempHeight, MainImageForm->iMainImage->uBitmap, rc.left, rc.top, SRCCOPY); // BtTemp Á¶°¢(¿µ¿ª¸¸) º¸°ü */ MainImageForm->iMainImage->uBitmap->CopyToTexpia(BtTemp, 0, 0, TempWidth, TempHeight, rc.left, rc.top, SRCCOPY); // convert by celberus Temprc.left = 0; Temprc.right = TempWidth; Temprc.top = 0; Temprc.bottom = TempHeight; L_SetBitmapRgnEllipse(BtTemp->Handle, &XForm, &Temprc, L_RGN_SET); if (nChange) { L_AverageFilterBitmap(BtTemp->Handle, nChange); // ½ÃÀÛÁ¡ ºÎºÐ (¿ø) if (WindowForm) WindowForm->workAreaMenu->sbOffClick(this); // WindowForm ÀÌ NULL ÀÏ ¶§ ¿¡·¯ ¹ß»ýÇØ¼­ if¹® Ãß°¡ by celberus } MainImageForm->iMainImage->uBitmap->Copy(rc.left, rc.top, TempWidth, TempHeight, BtTemp, 0, 0, SRCCOPY); // BtTemp Á¶°¢(¿µ¿ª¸¸) º¸°ü delete BtTemp; // ======================================= /* ¿ø·¡ ÇÔ¼ö (¼öÁ¤Áß À§) L_SetBitmapRgnEllipse(bh, &XForm, &rc, L_RGN_SET); if (nChange) { L_AverageFilterBitmap(bh, nChange); // ½ÃÀÛÁ¡ ºÎºÐ (¿ø) WindowForm->sbOffClick(this); // ÀÛ¾÷±¸¿ª ÇØÁ¦ } */ if (AvgPtCount > 1) { /* rc.left = AvgDestPt.x - (Pen->Thick)/2; rc.right = AvgDestPt.x + (Pen->Thick+1)/2 +1; rc.top = AvgDestPt.y - (Pen->Thick)/2; rc.bottom = AvgDestPt.y + (Pen->Thick+1)/2 +1; L_SetBitmapRgnEllipse(bh, &XForm, &rc, L_RGN_SET); if (nChange) { L_AverageFilterBitmap(bh, nChange); // Á¾ÂøÁ¡ ºÎºÐ (¿ø) WindowForm->sbOffClick(this); // ÀÛ¾÷±¸¿ª ÇØÁ¦ } */ POINT AvgPt[400]; POINT *pAvgPt = AvgPt; // =============================================== ÀÛ¾÷Áß ¾Æ·¡(GreenFish) for (int i = 0; i < AvgPtCount; i++) { pAvgPt[i] = AvgLowerPt[i]; pAvgPt[AvgPtCount * 2 - i - 1] = AvgUpperPt[i]; rc.right = rc.right < AvgLowerPt[i].x + (Pen->Thick) / 2 ? AvgLowerPt[i].x + (Pen->Thick) / 2 : rc.right; rc.left = rc.left > AvgLowerPt[i].x - (Pen->Thick) / 2 ? AvgLowerPt[i].x - (Pen->Thick) / 2 : rc.left; rc.top = rc.top > AvgLowerPt[i].y - (Pen->Thick) / 2 ? AvgLowerPt[i].y - (Pen->Thick) / 2 : rc.top; rc.bottom = rc.bottom < AvgLowerPt[i].y + (Pen->Thick) / 2 ? AvgLowerPt[i].y + (Pen->Thick) / 2 : rc.bottom; rc.right = rc.right < AvgUpperPt[i].x + (Pen->Thick) / 2 ? AvgUpperPt[i].x + (Pen->Thick) / 2 : rc.right; rc.left = rc.left > AvgUpperPt[i].x - (Pen->Thick) / 2 ? AvgUpperPt[i].x - (Pen->Thick) / 2 : rc.left; rc.top = rc.top > AvgUpperPt[i].y - (Pen->Thick) / 2 ? AvgUpperPt[i].y - (Pen->Thick) / 2 : rc.top; rc.bottom = rc.bottom < AvgUpperPt[i].y + (Pen->Thick) / 2 ? AvgUpperPt[i].y + (Pen->Thick) / 2 : rc.bottom; } TempWidth = rc.right - rc.left; TempHeight = rc.bottom - rc.top; if ((BtTemp = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->iMainImage->uBitmap->GetColors(0, 256, Btrgb); if (!BtTemp->Create(TempWidth, TempHeight, MainImageForm->iMainImage->uBitmap->BitsPerPixel, Btrgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } /* BtTemp->Copy(0, 0, TempWidth, TempHeight, MainImageForm->iMainImage->uBitmap, rc.left, rc.top, SRCCOPY); // BtTemp Á¶°¢(¿µ¿ª¸¸) º¸°ü */ MainImageForm->iMainImage->uBitmap->CopyToTexpia(BtTemp, 0, 0, TempWidth, TempHeight, rc.left, rc.top, SRCCOPY); // convert by celberus for (int i = 0; i < AvgPtCount * 2; i++) { pAvgPt[i].x -= rc.left; pAvgPt[i].y -= rc.top; } L_SetBitmapRgnPolygon(BtTemp->Handle, &XForm, pAvgPt, AvgPtCount * 2, L_POLY_WINDING, L_RGN_SET); L_AverageFilterBitmap(BtTemp->Handle, nChange); // ´Ù°¢Çü ºÎºÐ if (WindowForm) WindowForm->workAreaMenu->sbOffClick(this); // WindowForm ÀÌ NULL ÀÏ ¶§ ¿¡·¯ ¹ß»ýÇØ¼­ if¹® Ãß°¡ by celberus MainImageForm->iMainImage->uBitmap->Copy(rc.left, rc.top, TempWidth, TempHeight, BtTemp, 0, 0, SRCCOPY); // BtTemp Á¶°¢(¿µ¿ª¸¸) º¸°ü delete BtTemp; // ===========================================ÀÛ¾÷Áß À§ /* L_SetBitmapRgnPolygon(bh, &XForm, pAvgPt, AvgPtCount*2, L_POLY_WINDING, L_RGN_SET); L_AverageFilterBitmap(bh, nChange); // ´Ù°¢Çü ºÎºÐ WindowForm->sbOffClick(this); // ÀÛ¾÷±¸¿ª ÇØÁ¦ */ } Screen->Cursor = OldCursor; MainImageForm->iMainImage->Repaint(); fail: } if (MainImageForm->MaskArea) MainImageForm->iMainImage->Mask->StopScanLine(); if (MainImageForm->iMainImage->LayerMask) MainImageForm->iMainImage->LayerMask->StopScanLine(); } if (Type == PT_KASURI) { // kasuri if (KasuriForm) { MainImageForm->iMainImage->Cursor = crDefault; if (KasuriForm->hasKasuri && KasuriForm->bPathDrawEnd) { if (KasuriForm->bKasuriPointMoveMode) { // °¡¾²¸® ¼± ¿¡µðÆ® by bomchun (06/08/03) KasuriForm->MovePoint(X, Y, true); // shin 061024 KasuriForm->bKasuriPointMoveMode = false; KasuriForm->bKasuriEditMode = false; } } else { if (KasuriForm->bPathDrawMovingMode) { // °¡½º¸® ÆÐ½º µå·ÎÀ× KasuriForm->PathDrawMouseUpSet(X, Y, MainImageForm->iMainImage->PositionX, MainImageForm->iMainImage->PositionY, MainImageForm->iMainImage->ZoomIn, MainImageForm->iMainImage->ZoomOut); } } } } MainImageForm->iMainImage->Repaint(); // gabriel: for airbrush // MouseUpÀÌ ÀϾÀ»¶§ FullView À̹ÌÁö¸¦ ¾÷µ¥ÀÌÆ®->¹Ý¿µ ÇØÁØ´Ù. FullViewForm->Image->Repaint(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialMouseLeave(TObject *Sender) { BEGIN_LOG(""); #ifdef FASTPEN // ---------------- if (Type == PT_NORMAL) { TCursor oldCursor = Screen->Cursor; RECT r; bool first = true; TPoint sp, ep; TPoint *pt; while (pointList->Count) { Screen->Cursor = crHourGlass; pt = (TPoint*)pointList->First(); if (first) { sp = *pt; first = false; } ep = *pt; MainImageForm->line_pen(sp.x, sp.y, ep.x, ep.y, PaletteForm->DIB256Palette->GetFGCOLORREF (MainImageForm->iMainImage->uBitmap->BitsPerPixel), &r); sp = *pt; pointList->Remove(pt); delete pt; } Screen->Cursor = oldCursor; MainImageForm->iMainImage->Repaint(); } else if (Type == PT_KASURI) { // kasuri MainImageForm->iMainImage->Cursor = crDefault; if (KasuriForm) KasuriForm->iMainImageMouseLeave(Sender); } // ----------------- #endif END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialPaint() { IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL; /////////////////by jeegeo } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::AddAirBrushColor(Byte SetColor) { BEGIN_LOG(""); TColorList *pcolor, *p; if (AirBrushHighestColorIndex < SetColor) AirBrushHighestColorIndex = SetColor; // gabriel: µµ¼ö ÀúÀå if (AirType == PAT_MULTI) { if (AirColorList->Count < 18) { pcolor = new TColorList; pcolor->color = SetColor; pcolor->modify = false; for (int i = 0; i < AirColorList->Count; i++) { p = (TColorList*)AirColorList->Items[i]; if (p->color == pcolor->color) { delete pcolor; END_LOG; return; } } AirColorList->Add(pcolor); ChangeAirColorPalette(AirColorList->Count - 1); } } else if (AirType == PAT_SINGLE) { SingleColor.color = SetColor; AirBrushPreview_Driver(); ShowColorBar(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::WorkAreaChange() { BEGIN_LOG(""); RGBQUAD rgb[256]; int Tx, Ty; TPItemImage *Image = MainImageForm->iMainImage; TPException ec; if (Type == PT_AIR) { if (AirType == PAT_PATTERN) { if (MainImageForm->WorkArea->Mask) { rbPattern->Enabled = true; Tx = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; Ty = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; if (Image->uBitmap->BitsPerPixel == 8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!(Image1->Bitmap->Create(Tx, Ty, 8, rgb))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!(Image1->Bitmap->Create(Tx, Ty, 24))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } Image->uBitmap->CopyToTexpia(Image1->Bitmap, 0, 0, Image1->Bitmap->Width, Image1->Bitmap->Height, MainImageForm->WorkArea->Range.left, MainImageForm->WorkArea->Range.top, SRCCOPY); // convert by celberus Image1->Repaint(); } else { AirType = PAT_MULTI; rbSingle->Checked = true; rbPattern->Enabled = false; } } else { if (MainImageForm->WorkArea->Mask) { rbPattern->Enabled = true; } else { rbSingleClick(this); rbPattern->Enabled = false; } } } END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::iMainImageChange() { if (IsDraw) { IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL; /////////////////by jeegeo } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SetColor(TPalette *Palette) { Selector->SetPalette(Palette); Selector->Invalid(); shFirst->Update(); shSecond->Update(); PenShape->Pen->Color = Palette->Color [PaletteForm->DIB256Palette->ChoiceIndex]; PenShape->Brush->Color = Palette->Color [PaletteForm->DIB256Palette->ChoiceIndex]; PenWidthPanel->Color = Palette->Color[BackgroundIndex]; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpreadChange(TPalette *Palette) { BEGIN_LOG(""); //¿©·¯ ĵ¹ö½º À̵¿½Ã¿¡ ¼±ÅõǾî ÀÖ´Â color¹øÈ£ÀÇ »ö°ú SelectColor¿¡¼­ ¼±ÅõǾî //¸¸µé¾îÁø spread color¿Í ´Ù¸¥ ¹®Á¦°¡ ÀÖ´Ù. ¶ÇÇÑ ±âÁ¸¿¡ ÀÌ ÇÔ¼ö¿¡¼­ ó¸®ÇÏ´Â °ÍÀÌ //shapeÀÇ brush color¸¸À» ¼¼ÆÃÇÏ´Â °ÍÀ̱⠶§¹®¿¡ choiceindex°¡ ¾Æ´Ñ Ç×»ó °°Àº °ªÀ» //³ÖÀº °ÍÀÌ ¹Ù¶÷Á÷ÇÒ °Í °°¾Æ¼­ 0À¸·Î ¼¼ÆÃÇß´Ù. by david 100928 Byte ChoiceIndex = 0;//PaletteForm->DIB256Palette->ChoiceIndex; TColor ChoiceColor = Palette->Color[ChoiceIndex]; Selector->Initial(); Selector->SetPalette(Palette); spread_grade = 2; numedEGrade->Text = "2"; if (252 - Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); spread_start = ChoiceIndex; shFirst->Brush->Color = ChoiceColor; spread_end = ChoiceIndex; shSecond->Brush->Color = ChoiceColor; // lSelectDraw->Caption = IDS_SELECTCOLOR; spread_sw[4] = 0; spread_pos = 0; shFirst->Pen->Color = clRed; shSecond->Pen->Color = clBlack; PenShape->Pen->Color = ChoiceColor; PenShape->Brush->Color = ChoiceColor; PenWidthPanel->Color = Palette->Color[BackgroundIndex]; // AirSelectColor->Brush->Color = ChoiceColor; gabriel /* TShape *s = 0; TColorList *Temp = 0; for (int i = 1; i <= AirColorList->Count; i++) { Temp = (TColorList *)(AirColorList->Items[i - 1]); s = (TShape *)(FindComponent("shAirColor" + String(i))); s->Brush->Color = Palette->Color[Temp->color]; } */ END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenShapeChange(int value) { PenShape->Pen->Color = PaletteForm->DIB256Palette->Palette->Color[value]; PenShape->Brush->Color = PaletteForm->DIB256Palette->Palette->Color[value]; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormChange(TPalette *Palette) { BEGIN_LOG(""); TPException ec = EC_NONE; MainImageForm->PenChange(); if (Type == PT_NORMAL || Type == PT_CRAYON || Type == PT_SCRAPE) { EtcPanel->BringToFront(); EtcPanel->Visible = true; ClientHeight = EtcPanel->Top + EtcPanel->Height - 1; } else if (Type == PT_AIR) { if (MainImageForm->WorkArea->Mask) { rbPattern->Enabled = true; } else { rbSingleClick(this); rbPattern->Enabled = true; } AirBrushPanel->BringToFront(); AirBrushPanel->Visible = true; ClientHeight = AirBrushPanel->Top + AirBrushPanel->Height - 1; MenuSW = true; } else if (Type == PT_MASK) { MaskPanel->BringToFront(); MaskPanel->Visible = true; ClientHeight = MaskPanel->Top + MaskPanel->Height - 1; TPItemImage *Image = MainImageForm->iMainImage; // ti -> Image ·Î À̸§º¯°æ by celberus RECT r; if (Image->Mask == NULL) { if (Image->uBitmap->Width <= 0 || Image->uBitmap->Height <= 0) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Image->Mask = new TUnionBitmap; // convert by celberus if (Image->Mask == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel == 8) { if (Image->Mask->Create(Image->uBitmap->Width, Image->uBitmap->Height, 8) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Image->Mask->Create(Image->uBitmap->Width, Image->uBitmap->Height, 1) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } SetRect(&r, 0, 0, Image->uBitmap->Width, Image->uBitmap->Height); Image->Mask->FillRect(r, 0); } } WorkAreaChange(); END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::InitPenForm() { BEGIN_LOG(""); Type = PT_NORMAL; InitType(NULL); sbNormal->Down = true; ClientHeight = FHeight; // ChangeBtnUpImage(0); CloseMenuBtnClick(this, true); MenuSW = false; if (VectorForm == NULL) SpreadChange(MainImageForm->Palette); if (acolor != 0) InitColorPen(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::InitColorPen() { BEGIN_LOG(""); acolor = 0; rzckColorSelect->Caption = String(IDS_COLOR); // + " : " + String(IDS_COMMON_BUTTONNO); ColorPanel->Visible = false; Selector->SaveToFile(AppDataItem + "\\Pen.Ini", "Color"); MainImageForm->PenChange(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::DrawTaperLine(int lsx, int lsy, int lex, int ley, int s_size, int e_size, double s_rate, double e_rate, COLORREF color) { BEGIN_LOG(""); int pw; COLORREF spc; if (aspread) { Lsx = lsx; Lsy = lsy; Lex = lex; Ley = ley; o_size = s_size + (e_size - s_size) * s_rate; pw = s_size + (e_size - s_size) * e_rate; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { o_color = spread_start + (spread_end - spread_start) * s_rate + 0.5; spc = spread_start + (spread_end - spread_start) * e_rate + 0.5; } else { if (Tablet) { o_color = Tablet->MaxNPressure * s_rate; spc = Tablet->MaxNPressure * e_rate; } else { o_color = color; spc = color; } } line_pressure_pen(pw, spc); } else { Lsx = lsx; Lsy = lsy; Lex = lex; Ley = ley; o_size = s_size + (e_size - s_size) * s_rate; pw = s_size + (e_size - s_size) * e_rate; o_color = color; spc = color; line_pressure_pen(pw, spc); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::BtnAvgClick(TObject *Sender) { TSpeedButton *s = (TSpeedButton*)Sender; InitWaterPanel(s->Tag); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::spEditDensityChange(TObject *Sender) { if (WaterType == PWT_AVERAGE) { trbEffect->Position = spEditDensity->Value; rznumedEffect->Text = IntToStr((int)spEditDensity->Value); return; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::EditKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { TEdit *s; s = (TEdit*)Sender; if (AirColorList->Count >= s->Tag + 1) { InputPercent(Sender); } } // --------------------------------------------------------------------------- COLORREF __fastcall TPenManagerForm::getListColor(TColorList *colorList, int bitsPerPixel) // by celberus { if (bitsPerPixel == 8) return colorList->color; else return MainImageForm->Palette->Color[colorList->color]; } // --------------------------------------------------------------------------- COLORREF __fastcall TPenManagerForm::getSelectedPaletteColor(int bitsPerPixel) { return PaletteForm->DIB256Palette->GetFGCOLORREF(bitsPerPixel); } // --------------------------------------------------------------------------- void __fastcall DrawingPen::setDrawingLine(Byte *pLine) { drawingLine = pLine; } // --------------------------------------------------------------------------- void __fastcall DrawingPen::setColor(COLORREF color) { _color = color; } // --------------------------------------------------------------------------- void __fastcall DrawingPen_8::setColorProtected(bool value) { _colorProtected = value; } // --------------------------------------------------------------------------- void __fastcall DrawingPen_8::setProtectCheckLine(Byte *pLine) { protectCheckLine = pLine; } // --------------------------------------------------------------------------- void __fastcall DrawingPen_8::putPixel(int x) { if (!_colorProtected || MainImageForm->Palette->ColorData[protectCheckLine[x]] ->Protect == 0) { drawingLine[x] = _color; } } // --------------------------------------------------------------------------- void __fastcall DrawingPen_8::copyPixel(int x, Byte *pixel) { if (!_colorProtected || MainImageForm->Palette->ColorData[protectCheckLine[x]] ->Protect == 0) { drawingLine[x] = *pixel; } } // --------------------------------------------------------------------------- void __fastcall DrawingPen_8::putPixel(int x, Byte *pMaskLine) { if (pMaskLine[x] == 0) putPixel(x); } // --------------------------------------------------------------------------- void __fastcall DrawingPen_8::copyPixel(int x, Byte *pMaskLine, Byte *pixel) { if (pMaskLine[x] == 0) copyPixel(x, pixel); } // --------------------------------------------------------------------------- COLORREF __fastcall DrawingPen_8::pickColor(Byte *pSourceLine, int x) { return pSourceLine[x]; } // --------------------------------------------------------------------------- bool __fastcall DrawingPen_8::isProtected(int x) { return _colorProtected && MainImageForm->Palette->ColorData [protectCheckLine[x]]->Protect != 0; } // --------------------------------------------------------------------------- bool __fastcall DrawingPen_8::isProtected(int x, Byte *pMaskLine) { return(_colorProtected && MainImageForm->Palette->ColorData [protectCheckLine[x]]->Protect != 0) || pMaskLine[x] != 0; } // --------------------------------------------------------------------------- void __fastcall DrawingPen_24::putPixel(int x) { setPixel(drawingLine + 3 * x, _color); } // --------------------------------------------------------------------------- void __fastcall DrawingPen_24::copyPixel(int x, Byte *pixel) { copyPixel(drawingLine + 3 * x, pixel); } // --------------------------------------------------------------------------- void __fastcall DrawingPen_24::putPixel(int x, Byte *pMaskLine) { if ((pMaskLine[x >> 3] & (0x80 >> (x & 7))) == 0) putPixel(x); } // --------------------------------------------------------------------------- void __fastcall DrawingPen_24::copyPixel(int x, Byte *pMaskLine, Byte *pixel) { if ((pMaskLine[x >> 3] & (0x80 >> (x & 7))) == 0) copyPixel(x, pixel); } // --------------------------------------------------------------------------- void __fastcall DrawingPen_24::setPixel(Byte *pLine, COLORREF color) { SetPixel24(pLine, color); } // --------------------------------------------------------------------------- void __fastcall DrawingPen_24::copyPixel(Byte *pLine, Byte *pixel) { CopyPixel24(pLine, pixel); } // --------------------------------------------------------------------------- COLORREF __fastcall DrawingPen_24::pickColor(Byte *pSourceLine, int x) { COLORREF result; // GetPixel24(pSourceLine, result); result = (pSourceLine[3 * x] << 16) + (pSourceLine[3 * x + 1] << 8) + pSourceLine[3 * x + 2]; return result; } // --------------------------------------------------------------------------- bool __fastcall DrawingPen_24::isProtected(int x) { return false; } // --------------------------------------------------------------------------- bool __fastcall DrawingPen_24::isProtected(int x, Byte *pMaskLine) { return(pMaskLine[x >> 3] & (0x80 >> (x & 7))) != 0; } // --------------------------------------------------------------------------- void __fastcall DrawingPen_1::putPixel(int x) { drawingLine[x >> 3] &= ~(0x80 >> (x & 7)); } // --------------------------------------------------------------------------- void __fastcall DrawingPen_1::putPixel(int x, Byte *pMaskLine) { if ((pMaskLine[x >> 3] & (0x80 >> (x & 7))) == 0) putPixel(x); } // --------------------------------------------------------------------------- __fastcall LineItr::LineItr(TPItemImage *theImage) { Image = theImage; if (Image->uBitmap->BitsPerPixel == 8) { basePen = (DrawingPen*)new DrawingPen_8; maskPen = (DrawingPen*)new DrawingPen_8; maskPen->setColor(0); } else if (Image->uBitmap->BitsPerPixel == 24) { basePen = (DrawingPen*)new DrawingPen_24; maskPen = (DrawingPen*)new DrawingPen_1; maskPen->setColor(0); } } // --------------------------------------------------------------------------- __fastcall LineItr::~LineItr() { delete basePen; delete maskPen; } // --------------------------------------------------------------------------- void __fastcall LineItr::setBaseColor(COLORREF color) { basePen->setColor(color); } // --------------------------------------------------------------------------- COLORREF __fastcall LineItr::pickColor(int x) { return basePen->pickColor(protectCheckLine, x); } // --------------------------------------------------------------------------- COLORREF __fastcall LineItr::pickColor(Byte *pSourceLine, int x) { return basePen->pickColor(pSourceLine, x); } // --------------------------------------------------------------------------- void __fastcall LineItr::setColorProtected(bool value) { _colorProtected = value; basePen->setColorProtected(value); } // --------------------------------------------------------------------------- bool __fastcall LineItr::startScanLine() { if (Image->uBitmap->StartScanLine() == false) goto fail; return true; fail: stopScanLine(); return false; } // --------------------------------------------------------------------------- void __fastcall LineItr::stopScanLine() { Image->uBitmap->StopScanLine(); } // --------------------------------------------------------------------------- void __fastcall LineItr::getScanLine(int y, int startX, int length) { baseLine = Image->uBitmap->GetScanLine(y, startX, length); // basePen->setDrawingLine(baseLine); protectCheckLine = baseLine; basePen->setProtectCheckLine(baseLine); } // --------------------------------------------------------------------------- void __fastcall LineItr::putScanLine(int y, int startX, int length) { Image->uBitmap->PutScanLine(y, startX, length); // } // --------------------------------------------------------------------------- void __fastcall LineItr::putPixel(int x) { basePen->putPixel(x); } // --------------------------------------------------------------------------- void __fastcall LineItr::copyPixel(int x, Byte *pixel) { basePen->copyPixel(x, pixel); } // --------------------------------------------------------------------------- bool __fastcall LineItr::isProtected(int x) { return basePen->isProtected(x); } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer::setColorProtected(bool value) { _colorProtected = value; basePen->setColorProtected(value); maskPen->setColorProtected(value); } // --------------------------------------------------------------------------- bool __fastcall LineItr_Layer::startScanLine() { if (Image->uBitmap->StartScanLine() == false) goto fail; if (Image->LayerMask->StartScanLine() == false) goto fail; if (_colorProtected) { if (Image->BackGround->StartScanLine() == false) goto fail; } return true; fail: stopScanLine(); return false; } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer::stopScanLine() { Image->uBitmap->StopScanLine(); Image->LayerMask->StopScanLine(); } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer::getScanLine(int y, int startX, int length) { baseLine = Image->uBitmap->GetScanLine(y, startX, length); // basePen->setDrawingLine(baseLine); layerMaskLine = Image->LayerMask->GetScanLine(y, startX, length); maskPen->setDrawingLine(layerMaskLine); // ·¹À̾î ÀÖ´Â °æ¿ì »öº¸È£°¡ ±×¸°ÈÄ ¼³Á¤Çß´ø °Í¸¸ »öº¸È£ µÇ´ø °ÍÀ» ÀÌÈÄ¿¡µµ ±× »öÀ» »ç¿ëÇßÀ» ¶§ »öº¸È£ µÇµµ·Ï ¼öÁ¤ // 080408 by david with hoochu protectCheckLine = baseLine; basePen->setProtectCheckLine(baseLine); maskPen->setProtectCheckLine(baseLine); /* if (_colorProtected) { backgroundLine = Image->BackGround->GetScanLine(y, startX, length); protectCheckLine = backgroundLine; basePen->setProtectCheckLine(backgroundLine); maskPen->setProtectCheckLine(backgroundLine); } else { protectCheckLine = baseLine; basePen->setProtectCheckLine(baseLine); maskPen->setProtectCheckLine(baseLine); } */ } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer::putScanLine(int y, int startX, int length) { Image->uBitmap->PutScanLine(y, startX, length); // Image->LayerMask->PutScanLine(y, startX, length); // } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer::putPixel(int x) { // basePen->putPixel(x); // maskPen->putPixel(x); maskPen->putPixel(x); // Image->uBitmap¿¡ ±×·ÁÁø ³»¿ëÀ¸·Î º¸È£»öÀ» ÆÇº°Çϱ⠶§¹®¿¡ maskPenÀ» basePenº¸´Ù ¸ÕÀú ±×·ÁÁØ´Ù. basePen->putPixel(x); // 080408 by david with hoochu } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer::copyPixel(int x, Byte *pixel) { // basePen->copyPixel(x, pixel); // maskPen->putPixel(x); maskPen->putPixel(x); // 080408 by david with hoochu basePen->copyPixel(x, pixel); } // --------------------------------------------------------------------------- bool __fastcall LineItr_Layer::isProtected(int x) { return basePen->isProtected(x); } // --------------------------------------------------------------------------- bool __fastcall LineItr_Mask::startScanLine() { if (Image->uBitmap->StartScanLine() == false) goto fail; if (Image->Mask->StartScanLine() == false) goto fail; return true; fail: stopScanLine(); return false; } // --------------------------------------------------------------------------- void __fastcall LineItr_Mask::stopScanLine() { Image->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); } // --------------------------------------------------------------------------- void __fastcall LineItr_Mask::getScanLine(int y, int startX, int length) { baseLine = Image->uBitmap->GetScanLine(y, startX, length); // basePen->setDrawingLine(baseLine); maskLine = Image->Mask->GetScanLine(y, startX, length); protectCheckLine = baseLine; basePen->setProtectCheckLine(baseLine); } // --------------------------------------------------------------------------- void __fastcall LineItr_Mask::putScanLine(int y, int startX, int length) { Image->uBitmap->PutScanLine(y, startX, length); // } // --------------------------------------------------------------------------- void __fastcall LineItr_Mask::putPixel(int x) { basePen->putPixel(x, maskLine); } // --------------------------------------------------------------------------- void __fastcall LineItr_Mask::copyPixel(int x, Byte *pixel) { basePen->copyPixel(x, pixel); } // --------------------------------------------------------------------------- bool __fastcall LineItr_Mask::isProtected(int x) { return basePen->isProtected(x, maskLine); } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer_Mask::setColorProtected(bool value) { _colorProtected = value; basePen->setColorProtected(value); maskPen->setColorProtected(value); } // --------------------------------------------------------------------------- bool __fastcall LineItr_Layer_Mask::startScanLine() { if (Image->uBitmap->StartScanLine() == false) goto fail; if (Image->LayerMask->StartScanLine() == false) goto fail; if (_colorProtected) { if (Image->BackGround->StartScanLine() == false) goto fail; } if (Image->Mask->StartScanLine() == false) goto fail; return true; fail: stopScanLine(); return false; } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer_Mask::stopScanLine() { Image->Mask->StopScanLine(); if (_colorProtected) Image->BackGround->StopScanLine(); Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer_Mask::getScanLine(int y, int startX, int length) { baseLine = Image->uBitmap->GetScanLine(y, startX, length); // basePen->setDrawingLine(baseLine); layerMaskLine = Image->LayerMask->GetScanLine(y, startX, length); maskPen->setDrawingLine(layerMaskLine); // ·¹À̾î ÀÖ´Â °æ¿ì »öº¸È£°¡ ±×¸°ÈÄ ¼³Á¤Çß´ø °Í¸¸ »öº¸È£ µÇ´ø °ÍÀ» ÀÌÈÄ¿¡µµ ±× »öÀ» »ç¿ëÇßÀ» ¶§ »öº¸È£ µÇµµ·Ï ¼öÁ¤ protectCheckLine = baseLine; basePen->setProtectCheckLine(baseLine); maskPen->setProtectCheckLine(baseLine); /* if (_colorProtected) { backgroundLine = Image->BackGround->GetScanLine(y); protectCheckLine = backgroundLine; basePen->setProtectCheckLine(backgroundLine); maskPen->setProtectCheckLine(backgroundLine); } else { protectCheckLine = baseLine; basePen->setProtectCheckLine(baseLine); maskPen->setProtectCheckLine(baseLine); } */ maskLine = Image->Mask->GetScanLine(y, startX, length); } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer_Mask::putScanLine(int y, int startX, int length) { Image->uBitmap->PutScanLine(y, startX, length); // Image->LayerMask->PutScanLine(y, startX, length); // } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer_Mask::putPixel(int x) { // basePen->putPixel(x, maskLine); // maskPen->putPixel(x, maskLine); maskPen->putPixel(x, maskLine); // Image->uBitmap¿¡ ±×·ÁÁø ³»¿ëÀ¸·Î º¸È£»öÀ» ÆÇº°Çϱ⠶§¹®¿¡ maskPenÀ» basePenº¸´Ù ¸ÕÀú ±×·ÁÁØ´Ù. basePen->putPixel(x, maskLine); } // --------------------------------------------------------------------------- void __fastcall LineItr_Layer_Mask::copyPixel(int x, Byte *pixel) { // basePen->copyPixel(x, pixel); // maskPen->putPixel(x); maskPen->putPixel(x); basePen->copyPixel(x, pixel); } // --------------------------------------------------------------------------- bool __fastcall LineItr_Layer_Mask::isProtected(int x) { return basePen->isProtected(x, maskLine); } // --------------------------------------------------------------------------- // ------------------- gabriel: AirBrush Part ---------------------------- double __fastcall TPenManagerForm::RandGenerator() // gabriel: random number generator { static double V1, V2, S; static int phase = 0; double X; if (phase == 0) { do { double U1 = (double)rand() / RAND_MAX; double U2 = (double)rand() / RAND_MAX; V1 = 2 * U1 - 1; V2 = 2 * U2 - 1; S = V1 * V1 + V2 * V2; } while (S >= 1 || S == 0); X = V1 * sqrt(-2 * log(S) / S); } else X = V2 * sqrt(-2 * log(S) / S); phase = 1 - phase; return X; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::AirBrushPreview_Driver(void) { // gabriel: used in ChangeAirColorPalette & value change functions, // see set_airbrush_pen_multi BEGIN_LOG(""); int i, j; TColorList *V; COLORREF color; double drawDensity; int denvalue = rzspedSprayDensity->Value; int DropSize = rzspedDropSize->Value; int Concentration = rzspedConcentration->Value; int Irregularity = rzspedIrregularity->Value; TPItemImage *Image = MainImageForm->iMainImage; Image3->Canvas->Pen->Color = clBlack; Image3->Canvas->Brush->Color = clWhite; Image3->Canvas->Rectangle(0, 0, Image3->Width, Image3->Height); if (AirType == PAT_SINGLE) { drawDensity = denvalue; color = getListColor(&SingleColor, Image->uBitmap->BitsPerPixel); AirBrushPreview(drawDensity, DropSize, Concentration, Irregularity, color); } else { if (AirColorList->Count > 0) { for (i = 0; i < 5; i++) { // not dummy ! for (j = 0; j < AirColorList->Count; j++) { V = (TColorList*)AirColorList->Items[j]; drawDensity = denvalue * V->percent / 100.0; color = getListColor(V, Image->uBitmap->BitsPerPixel); AirBrushPreview(drawDensity, DropSize, Concentration, Irregularity, color); } } } } Image3->Canvas->Pen->Color = clBlack; Image3->Canvas->Brush->Style = bsClear; Image3->Canvas->Rectangle(0, 0, Image3->Width, Image3->Height); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::AirBrushPreview(double drawDensity, int DropSize, int Concentration, int Irregularity, COLORREF color) { // gabriel: see drawAirbrushImage , ÀϺδ °æÇèÀûÀ¸·Î ±¸Çö BEGIN_LOG(""); TColor color_conv; int centerx, centery; centerx = Image3->Width / 2; centery = Image3->Height / 2; int SpraySize = 150; int i, x, y, penWidth, randomNumber, toX, toY, IrrDropSize, var; penWidth = SpraySize / 3.4 + 1; i = 0; while (i < (sqrt(drawDensity) * SpraySize / (DropSize * DropSize))) { while (1) { toX = penWidth * RandGenerator() / (Concentration * 0.4 + 1); toY = penWidth * RandGenerator() / (Concentration * 0.4 + 1); if ((abs(toX) < penWidth) && (abs(toY) < penWidth) && (sqrt(abs(toX) * abs(toX) + abs(toY) * abs(toY)) < penWidth)) { break; } } x = centerx + toX; y = centery + toY; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) color_conv = MainImageForm->Palette->ColorData[color]->Color; else color_conv = (TColor)color; Image3->Canvas->Pen->Color = color_conv; Image3->Canvas->Brush->Color = color_conv; Image3->Canvas->Brush->Style = bsSolid; if (!Random->Get(2)) // +/- ? var = Random->Get(Irregularity + 1); else var = -Random->Get(Irregularity + 1); IrrDropSize = DropSize + var; if (IrrDropSize < 1) IrrDropSize = 1; if (IrrDropSize == 1) { // size: 1 ~ 5 Image3->Canvas->Ellipse(x, y, x + 1, y + 1); } else if (IrrDropSize == 2) { if (x & 1) { // odd Image3->Canvas->Ellipse(x - 1, y, x + 1, y + 1); } else { // even Image3->Canvas->Ellipse(x, y - 1, x + 1, y + 1); } } else if (IrrDropSize == 3) { Image3->Canvas->Ellipse(x - 1, y - 1, x + 1, y + 1); } else if (IrrDropSize == 4) { if (x & 1) { // odd Image3->Canvas->Ellipse(x - 1, y - 2, x + 2, y + 1); } else { // even Image3->Canvas->Ellipse(x - 2, y - 1, x + 1, y + 2); } } else if (IrrDropSize == 5) { // DropSize == 5 Image3->Canvas->Ellipse(x - 2, y - 2, x + 2, y + 2); } else // IrrDropSize > 5 Image3->Canvas->Ellipse(x - (IrrDropSize - 3), y - (IrrDropSize - 3), x + (IrrDropSize - 3), y + (IrrDropSize - 3)); i++; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ShowColorBar(void) { // gabriel: update image2 BEGIN_LOG(""); int i, j; TColorList *V; COLORREF color; TColor color_conv; double drawDensity; TPItemImage *Image = MainImageForm->iMainImage; int wid = Image2->Width; int pos1 = 0, pos2 = 0; Image2->Canvas->Pen->Color = clWhite; Image2->Canvas->Brush->Color = clWhite; Image2->Canvas->Rectangle(0, 0, Image2->Width, Image2->Height); if (AirType == PAT_MULTI) { for (i = 0; i < 19; i++) AirColorPosition[i] = 0; if (AirColorList->Count > 0) { for (j = 0; j < AirColorList->Count; j++) { V = (TColorList*)AirColorList->Items[j]; pos2 = pos1 + wid * (V->percent / 100.0); color = getListColor(V, Image->uBitmap->BitsPerPixel); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) color_conv = MainImageForm->Palette->ColorData[color]->Color; else color_conv = (TColor)color; if (pos2 > Image2->Width) pos2 = Image2->Width; AirColorPosition[j + 1] = pos2; // saving positions Image2->Canvas->Pen->Color = color_conv; Image2->Canvas->Brush->Color = color_conv; Image2->Canvas->Rectangle(pos1, 0, pos2, Image2->Height); pos1 = pos2; } // fill up the rest part // tbColorBar->Width = pos2;// + 18; Image2->Canvas->Pen->Color = clBtnFace; Image2->Canvas->Brush->Color = clBtnFace; Image2->Canvas->Rectangle(pos2, 0, Image2->Width, Image2->Height); ShowSelectedBar(); } // tbColorBar->Position = 0; // } else if (AirType == PAT_SINGLE) { // single color = getListColor(&SingleColor, Image->uBitmap->BitsPerPixel); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) color_conv = MainImageForm->Palette->ColorData[color]->Color; else color_conv = (TColor)color; pos2 = Image2->Width; Image2->Canvas->Pen->Color = color_conv; Image2->Canvas->Brush->Color = color_conv; Image2->Canvas->Rectangle(pos1, 0, pos2, Image2->Height); } else { // pattern } Image2->Canvas->Pen->Color = clBlack; Image2->Canvas->Brush->Style = bsClear; if (pos2) Image2->Canvas->Rectangle(0, 0, pos2, Image2->Height); else Image2->Canvas->Rectangle(0, 0, Image2->Width, Image2->Height); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::Image2MouseDown(TObject *Sender, // gabriel TMouseButton Button, TShiftState Shift, int X, int Y) { // set trackbar position or delete colors BEGIN_LOG(""); TColorList *V; int i, j, wid, left, right; int AirColorIndex; if ((X < 0) || (X > Image2->Width)) { END_LOG; return; } if (!AirColorList->Count) { END_LOG; return; } AirColorIndex = getAirColorIndex(X); AirColor_X = X; if (Button == mbRight) { // delete /* to popupmenu DeleteAirColorPalette(AirColorIndex); ChangeAirColorPalette(AirColorIndex, true); CurrentAirColorIndex = 0; CurrentAirColorPosition = 0; tbColorBar->Position = 0; */ } else if (Button == mbLeft) { // set the position left = AirColorPosition[AirColorIndex]; right = AirColorPosition[AirColorIndex + 1]; wid = right - left; for (i = 0, j = 0; i < AirColorIndex; i++) { V = (TColorList*)AirColorList->Items[i]; j += V->percent; } V = (TColorList*)AirColorList->Items[AirColorIndex]; CurrentAirColorPosition = (((X - left) / (float)wid > .5) ? j + V->percent : j); tbColorBar->Position = CurrentAirColorPosition; CurrentAirColorIndex = ((X - left) / (float)wid < .5) ? AirColorIndex : AirColorIndex + 1; // ShowSelectedBar(); -> ShowColorBar() ShowColorBar(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ShowSelectedBar() { // gabriel: show the check mark at the selected bar of ColorBar(image2) BEGIN_LOG(""); int i, j; TColorList *V; COLORREF color; TColor color_conv; if (AirType != PAT_MULTI) { END_LOG; return; } if (CurrentAirColorIndex <= 0 || CurrentAirColorIndex >= AirColorList->Count) { END_LOG; return; } // left side V = (TColorList*)AirColorList->Items[CurrentAirColorIndex - 1]; color = getListColor(V, MainImageForm->iMainImage->uBitmap->BitsPerPixel); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) color_conv = MainImageForm->Palette->ColorData[color]->Color; else color_conv = (TColor)color; Image2->Canvas->Pen->Color = color_conv; Image2->Canvas->Pen->Mode = pmNotCopy; Image2->Canvas->Pen->Width = 1; Image2->Canvas->Rectangle(AirColorPosition[CurrentAirColorIndex] - 1, 0, AirColorPosition[CurrentAirColorIndex], 40); Image2->Canvas->Pen->Mode = pmCopy; Image2->Canvas->Pen->Width = 1; // right side V = (TColorList*)AirColorList->Items[CurrentAirColorIndex]; color = getListColor(V, MainImageForm->iMainImage->uBitmap->BitsPerPixel); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) color_conv = MainImageForm->Palette->ColorData[color]->Color; else color_conv = (TColor)color; Image2->Canvas->Pen->Color = color_conv; Image2->Canvas->Pen->Mode = pmNotCopy; Image2->Canvas->Pen->Width = 1; Image2->Canvas->Rectangle(AirColorPosition[CurrentAirColorIndex] + 1, 0, AirColorPosition[CurrentAirColorIndex] + 2, 40); Image2->Canvas->Pen->Mode = pmCopy; Image2->Canvas->Pen->Width = 1; END_LOG; } // --------------------------------------------------------------------------- int __fastcall TPenManagerForm::getAirColorIndex(int pos) { // gabriel: get index of list of color[pos] // int i; // for (i=1; i<19;i++) { // if (!AirColorPosition[i]) // break; // if ((AirColorPosition[i-1] <= pos) && (AirColorPosition[i] > pos)) // return (i-1>0)? i-1:0; // } // return (i-2>0)? i-2:0; int i = 0; for (i = 0; i < AirColorList->Count - 1; i++) { if (pos >= AirColorPosition[i] && pos < AirColorPosition[i + 1]) break; } return i; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::Image2MouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { // gabriel: show the percent on the position if (!AirColorList->Count) return; TColorList *V; V = (TColorList*)AirColorList->Items[getAirColorIndex(X)]; Image2->Hint = String(V->percent) + "%"; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::Delete1Click(TObject *Sender) { // gabriel: delete at popup BEGIN_LOG(""); int AirColorIndex; if ((AirColor_X < 0) || (AirColor_X > Image2->Width)) { END_LOG; return; } if (!AirColorList->Count) { END_LOG; return; } AirColorIndex = getAirColorIndex(AirColor_X); DeleteAirColorPalette(AirColorIndex); ChangeAirColorPalette(AirColorIndex, true); CurrentAirColorIndex = 0; CurrentAirColorPosition = 0; tbColorBar->Position = 0; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::DeleteAllClick(TObject *Sender) { // gabriel: delete all at popup BEGIN_LOG(""); int temp_X = AirColor_X; AirColor_X = 1; while (AirColorList->Count) Delete1Click(Sender); AirColor_X = temp_X; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ResetClick(TObject *Sender) { // gabriel: init. color percent at popup BEGIN_LOG(""); int i, j; TColorList *tempcolor; if (!AirColorList->Count) { END_LOG; return; } j = AirColorList->Count; TList *templist = new TList; for (i = 0; i < j; i++) { tempcolor = new TColorList; *tempcolor = *((TColorList*)AirColorList->Items[i]); templist->Add(tempcolor); } DeleteAllClick(Sender); for (i = 0; i < j; i++) { tempcolor = (TColorList*)templist->Items[i]; AddAirBrushColor(tempcolor->color); } for (i = 0; i < j; i++) { tempcolor = (TColorList*)templist->Items[0]; delete tempcolor; templist->Delete(0); } delete templist; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::iMainImageKeyDown(WORD Key, TShiftState Shift) { // 060914 shin kasuri BEGIN_LOG(String(Key)); if (Type == PT_KASURI) { if (KasuriForm) KasuriForm->iMainImageKeyDown(Key, Shift); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::KauriClose(TObject *Sender, TCloseAction &Action) { if (KasuriForm) { KasuriForm->OnClose = NULL; delete KasuriForm; KasuriForm = NULL; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ChangeKasuriPenColor() // shin 061024 { if (KasuriForm) { KasuriForm->SetPenColor(); MainImageForm->iMainImage->Repaint(); } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::EditorSelectAll(TObject *Sender) { SetFocusAndSelectAll(Sender); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::AddPenSpreadColorForUndo (Byte historySpreadStIdx, Byte historySpreadEndIdx, Byte prevUseColorCnt) { BEGIN_LOG(""); spread_start = historySpreadStIdx; spread_end = historySpreadEndIdx; TColor spreadStClr = shFirst->Brush->Color; TColor spreadEndClr = shSecond->Brush->Color; if (spreadStClr != MainImageForm->Palette->Color[spread_start] || spreadEndClr != MainImageForm->Palette->Color[spread_end]) { spread_start = 0; spread_end = 0; for (int i = 0; i < prevUseColorCnt + 1; i++) { if (MainImageForm->Palette->Color[i] == spreadStClr) spread_start = i; if (MainImageForm->Palette->Color[i] == spreadEndClr) spread_end = i; } if (spread_start == 0) { spread_start = MainImageForm->Palette->UseColor + 1; MainImageForm->Palette->SetNormal(MainImageForm->Palette->UseColor + 1, spreadStClr & 0x0000FF, (spreadStClr >> 8) & 0x0000FF, (spreadStClr >> 16) & 0x0000FF); MainImageForm->Palette->UseColor++; } else { if (spread_start > MainImageForm->Palette->UseColor) MainImageForm->Palette->UseColor = spread_start; } if (spread_end == 0) { spread_end = MainImageForm->Palette->UseColor + 1; MainImageForm->Palette->SetNormal(MainImageForm->Palette->UseColor + 1, spreadEndClr & 0x0000FF, (spreadEndClr >> 8) & 0x0000FF, (spreadEndClr >> 16) & 0x0000FF); MainImageForm->Palette->UseColor++; } else { if (spread_end > MainImageForm->Palette->UseColor) MainImageForm->Palette->UseColor = spread_end; } make_spread(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::sbScratchClick(TObject *Sender) { // Ŭ¸¯ÇßÀ» °æ¿ì ¸¶Áö¸· ¼±ÅÃÇß´ø ÆæÀÌ ¼±Åõǵµ·Ï ÇÑ´Ù // °°Àº À̺¥Æ®°¡ Áߺ¹ È£ÃâµÉ ¼öµµ ÀÖ´Ù - by monkman (2010.08.27) if (PopupPen->Tag == subScratchItem->Tag) subScratchItemClick(subScratchItem); else if (PopupPen->Tag == subKasuriItem->Tag) subKasuriItemClick(subKasuriItem); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::subScratchItemClick(TObject *Sender) { // PopupMenu Áß ¾î¶² ÆæÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) PopupPen->Tag = subScratchItem->Tag; ChangePenMenuIcon(0); Type = PT_SCRATCH; InitType(Sender); if (DrawForm) { // ÀåÁø¸¸ : ±×¸®´Â µµÁß¿¡ Ææ ¹Ù²Ù¸é ¼± ²÷À½ if (DrawForm->Item == 0) DrawForm->FunctionClick((TObject*)DrawForm->sbLine); else if (DrawForm->Item == 5) DrawForm->FunctionClick((TObject*)DrawForm->sbCurve); } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::subKasuriItemClick(TObject *Sender) { // PopupMenu Áß ¾î¶² ÆæÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) PopupPen->Tag = subKasuriItem->Tag; ChangePenMenuIcon(1); Type = PT_KASURI; InitType(Sender); if (DrawForm) { // ÀåÁø¸¸ : ±×¸®´Â µµÁß¿¡ Ææ ¹Ù²Ù¸é ¼± ²÷À½ if (DrawForm->Item == 0) DrawForm->FunctionClick((TObject*)DrawForm->sbLine); else if (DrawForm->Item == 5) DrawForm->FunctionClick((TObject*)DrawForm->sbCurve); } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzcbPressureClick(TObject *Sender) { Pen->Brush = rzcbPressure->Checked; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzsePenSizeChange(TObject *Sender) { // gabriel: With airbrush, we don't use this... // see seSpraySizeChange() TSpeedButton *s; s = (TSpeedButton*)Sender; if (s == sbAirBrush) return; // EOM if (rzsePenSize->Text.Length() > 0) { if (MainImageForm) MainImageForm->iMainImageChange(); try { rzsePenSize->Text.ToInt(); if (rzsePenSize->Value > 50) rzsePenSize->Value = 50; if (rzsePenSize->Value < 1) rzsePenSize->Value = 1; if (DrawForm) if (DrawForm->StartSize->Visible == true) DrawForm->StartSize->Value = rzsePenSize->Value; Pen->BasicThick = int(rzsePenSize->Value); PenShape->Height = Pen->BasicThick; PenShape->Width = Pen->BasicThick; PenShape->Top = (PenWidthPanel->Height - Pen->BasicThick + 1) / 2.0; PenShape->Left = (PenWidthPanel->Width - Pen->BasicThick + 1) / 2.0; } catch(EConvertError&) { rzsePenSize->Value = Pen->BasicThick; } tbDiameter->Position = rzsePenSize->Value; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzmtbColorClick(TObject *Sender) { if (!rzpnColor->Visible) { rzpnColor->Left = rznumedColor->Left; rzpnColor->Top = rznumedColor->Top + rznumedColor->Height + 1; rzpnColor->BringToFront(); rzpnColor->Visible = true; rzpnEffect->Visible = false; } else { rzpnColor->Visible = false; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzmtbEffectClick(TObject *Sender) { if (!rzpnEffect->Visible) { rzpnEffect->Left = rznumedEffect->Left + rznumedEffect->Width - rzpnEffect->Width; rzpnEffect->Top = rznumedEffect->Top + rznumedEffect->Height + 1; rzpnEffect->BringToFront(); rzpnEffect->Visible = true; rzpnColor->Visible = false; } else { rzpnEffect->Visible = false; } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::sbBtnUpClick(TObject *Sender) { CloseMenuBtnClick(Sender, bMenuDown); } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::CloseMenuBtnClick(TObject *Sender, bool bClose) { if (!bClose) { // -------------Size º¯°æ -------------------- if (Type == PT_NORMAL) { // ÀÏ¹Ý ÆæÀ̸é ClientHeight = EtcPanel->Top + EtcPanel->Height - ScrapePanel->Height; // - 1; } else if (Type == PT_AIR) { ClientHeight = AirBrushPanel->Top + AirBrushPanel->Height - 1; } else if (Type == PT_CRAYON) { ClientHeight = EtcPanel->Top + EtcPanel->Height - 1; } else if (Type == PT_WATER) { ClientHeight = WaterPanel->Top + WaterPanel->Height - 1; } else if (Type == PT_SCRAPE || Type == PT_SCRATCH || Type == PT_KASURI) { if (Type == PT_KASURI) { if (KasuriForm == NULL) InitType(NULL); else ClientHeight = EtcPanel->Top + KasuriForm->Height; } else if (Type != PT_KASURI) { // by bomchun ±×¸®±â ÀÌ³Êºí ¹®Á¦·Î ¼öÁ¤ ClientHeight = EtcPanel->Top + EtcPanel->Height; } } else if (Type == PT_MASK) { ClientHeight = MaskPanel->Top + MaskPanel->Height - 1; } // --------------------------------------------- ChangeBtnUpImage(1); if (MainImageForm) InitType(Sender); } else { ChangeBtnUpImage(0); if (Type == PT_KASURI) { if (KasuriForm != NULL) { delete KasuriForm; KasuriForm = NULL; } if (KasuriSubForm != NULL) { delete KasuriSubForm; KasuriSubForm = NULL; } // KasuriForm->Visible = false; // KasuriForm->SendToBack(); } else if (Type == PT_NORMAL || Type == PT_CRAYON || Type == PT_SCRATCH) { rzckColorSpread->Checked = false; rzckColorSelect->Checked = false; //rzckEtcDraw->Checked = false; aspread = false; acolor = 0; if (MainImageForm) MainImageForm->PenChange(); } ClientHeight = sbBtnUp->Top + sbBtnUp->Height; if (PenAndNaviTabForm && PenAndNaviTabForm->Visible) { PenAndNaviTabForm->FormResizeForPen(ClientHeight); } } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rbSingleClick(TObject *Sender) { BEGIN_LOG(""); TSpeedButton *s; RGBQUAD rgb[256]; int Tx, Ty; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; // gabriel: trackbar init /* tbSpraySize->Max = seSpraySize->Max; tbSpraySize->Min = seSpraySize->Min; tbSprayDensity->Max = seSprayDensity->Max; tbSprayDensity->Min = seSprayDensity->Min; tbConcentration->Max = seConcentration->Max; tbConcentration->Min = seConcentration->Min; tbIrregularity->Max = seIrregularity->Max; tbIrregularity->Min = seIrregularity->Min; tbDropSize->Max = seDropSize->Max; tbDropSize->Min = seDropSize->Min; */ ClientHeight = AirBrushPanel->Top + AirBrushPanel->Height; Shape2->BringToFront(); Image1->BringToFront(); Image3->BringToFront(); if (rbSingle->Checked) { AirType = PAT_SINGLE; Image2->Visible = true; Image3->Visible = true; tbColorBar->Enabled = false; } else if (rbMulti->Checked) { AirType = PAT_MULTI; Image2->Visible = true; Image3->Visible = true; tbColorBar->Enabled = true; } else if (rbPattern->Checked) { // gabriel: show pattern preview at pattern case AirType = PAT_PATTERN; Image2->Visible = true; Image3->Visible = false; tbColorBar->Enabled = false; if (MainImageForm->WorkArea) { Tx = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; Ty = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; if (Tx && Ty) { Screen->Cursor = crHourGlass; if (Image->uBitmap->BitsPerPixel == 8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!(Image1->Bitmap->Create(Tx, Ty, 8, rgb))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!(Image1->Bitmap->Create(Tx, Ty, 24))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } Image->uBitmap->CopyToTexpia(Image1->Bitmap, 0, 0, Image1->Bitmap->Width, Image1->Bitmap->Height, MainImageForm->WorkArea->Range.left, MainImageForm->WorkArea->Range.top, SRCCOPY); // convert by celberus Screen->Cursor = crDefault; } } } AirBrushPreview_Driver(); ShowColorBar(); END_LOG; return; fail: Screen->Cursor = crNone; EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzbitbtnReverseClick(TObject *Sender) { BEGIN_LOG(""); int x, y, w, h; Byte *bp = NULL, m; TPException ec = EC_NONE; MainImageForm->ReverseMask = !MainImageForm->ReverseMask; w = MainImageForm->iMainImage->Mask->Width; h = MainImageForm->iMainImage->Mask->Height; // ¹ÝÀüÇÒ¶§¸¶´Ù Mask°¡ º¯°æµÇ¹Ç·Î UndoSave MainImageForm->UndoSave(UK_MASK, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height)); // by linxujun for Undo_Method if ((MainImageForm->iMainImage->Mask->StartScanLine()) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { for (y = 0; y < h; y++) { bp = MainImageForm->iMainImage->Mask->GetScanLine(y); // for (x = 0; x < w; x++) bp[x] ^= 0x0F; MainImageForm->iMainImage->Mask->PutScanLine(y, 0, w); // } } else { for (y = 0; y < h; y++) { bp = MainImageForm->iMainImage->Mask->GetScanLine(y); // /* m = 0x80; for (x = 0; x < w; x++) { if (*bp & m) *bp &= ~m; else *bp |= m; if (m == 1) { m = 0x80; bp++; } else m >>= 1; } */ for (x = 0; x < w; x++) { bp[x >> 3] ^= (0x80 >> (x & 7)); } MainImageForm->iMainImage->Mask->PutScanLine(y, 0, w); // } } MainImageForm->iMainImage->Mask->StopScanLine(); MainImageForm->iMainImage->Repaint(); END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzbitbtnDelAllClick(TObject *Sender) { BEGIN_LOG(""); RECT r; SetRect(&r, 0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); // MainImageForm->UndoSave(UK_MASK, r, true); // MainImageForm->UndoSave(UK_MASK,Rect(0,0,0,0)); //by linxujun for Undo_Method MainImageForm->UndoSave(UK_MASK, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height)); // by linxujun for Undo_Method MainImageForm->iMainImage->Mask->FillRect(r, 0x00); ::RepaintImage(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzckDeleteClick(TObject *Sender) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { MainImageForm->OnSetHLine = MainImageForm->SetHLineMask8; if (rzckDelete->Checked) { MainImageForm->MaskPixel = 0x00; } else { MainImageForm->MaskPixel = 0x0F; } } else { if (rzckDelete->Checked) { MainImageForm->OnSetHLine = MainImageForm->SetHLineMaskDelete24; MainImageForm->MaskPixel = 0x00; } else { MainImageForm->OnSetHLine = MainImageForm->SetHLineMask24; MainImageForm->MaskPixel = 0x80; } } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzspedSprayDensityChange(TObject *Sender) { BEGIN_LOG(""); int Max = 20, Min = 1; if (rzspedSprayDensity->Text.Length() > 0) { if (rzspedSprayDensity->Value > Max) rzspedSprayDensity->Value = Max; else if (rzspedSprayDensity->Value < Min) rzspedSprayDensity->Value = Min; tbSprayDensity->Position = rzspedSprayDensity->Value; AirBrushPreview_Driver(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzspedConcentrationChange(TObject *Sender) { BEGIN_LOG(""); int Max = 9, Min = 0; if (rzspedConcentration->Text.Length() > 0) { if (rzspedConcentration->Value > Max) rzspedConcentration->Value = Max; else if (rzspedConcentration->Value < Min) rzspedConcentration->Value = Min; tbConcentration->Position = rzspedConcentration->Value; AirBrushPreview_Driver(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzspedIrregularityChange(TObject *Sender) { BEGIN_LOG(""); int Max = 20, Min = 0; if (rzspedIrregularity->Text.Length() > 0) { if (rzspedIrregularity->Value > Max) rzspedIrregularity->Value = Max; else if (rzspedIrregularity->Value < Min) rzspedIrregularity->Value = Min; tbIrregularity->Position = rzspedIrregularity->Value; AirBrushPreview_Driver(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzspedDropSizeChange(TObject *Sender) { BEGIN_LOG(""); int Max = 20, Min = 1; if (rzspedDropSize->Text.Length() > 0) { if (rzspedDropSize->Value > Max) rzspedDropSize->Value = Max; else if (rzspedDropSize->Value < Min) rzspedDropSize->Value = Min; tbDropSize->Position = rzspedDropSize->Value; AirBrushPreview_Driver(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::tbDiameterChange(TObject *Sender) { if (tbDiameter->Position == rzsePenSize->Value) return; rzsePenSize->Text = tbDiameter->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::trbEffectChange(TObject *Sender) { if (WaterType == PWT_AVERAGE) { spEditDensity->Value = trbEffect->Position; rznumedEffect->Text = trbEffect->Position; return; } or[WaterType] = trbEffect->Position / 100.0; rznumedEffect->Text = trbEffect->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::trbEffectExit(TObject *Sender) { rzpnEffect->Visible = false; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::trbColorChange(TObject *Sender) { cr[WaterType] = trbColor->Position / 100.0; rznumedColor->Text = trbColor->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::trbColorExit(TObject *Sender) { rzpnColor->Visible = false; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::tbColorBarChange(TObject *Sender) { static bool isInProcess = false; if (isInProcess == true) return; // gabriel: change percent BEGIN_LOG(""); isInProcess = true; TColorList *V; int i; if (CurrentAirColorIndex < 1 || CurrentAirColorIndex >= AirColorList->Count) { isInProcess = false; END_LOG; return; } if (tbColorBar->Position < CurrentAirColorPosition) { // <--- for (i = 0; i < AirColorList->Count; i++) { V = (TColorList*)AirColorList->Items[i]; V->modify = true; } V = (TColorList*)AirColorList->Items[CurrentAirColorIndex]; V->modify = false; V = (TColorList*)AirColorList->Items[CurrentAirColorIndex - 1]; V->percent -= (CurrentAirColorPosition - tbColorBar->Position); if (V->percent <= 0) { tbColorBar->Position -= V->percent; V->percent = 0; ChangeAirColorPalette(CurrentAirColorIndex - 1); } else { ChangeAirColorPalette(CurrentAirColorIndex - 1); } } else if (tbColorBar->Position > CurrentAirColorPosition) { // ---> for (i = 0; i < AirColorList->Count; i++) { V = (TColorList*)AirColorList->Items[i]; V->modify = true; } V = (TColorList*)AirColorList->Items[CurrentAirColorIndex - 1]; V->modify = false; V = (TColorList*)AirColorList->Items[CurrentAirColorIndex]; V->percent += (CurrentAirColorPosition - tbColorBar->Position); if (V->percent <= 0) { tbColorBar->Position += V->percent; V->percent = 0; ChangeAirColorPalette(CurrentAirColorIndex); } else { ChangeAirColorPalette(CurrentAirColorIndex); } } else { isInProcess = false; END_LOG; return; } CurrentAirColorPosition = tbColorBar->Position; // update ShowColorBar(); isInProcess = false; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::tbSprayDensityChange(TObject *Sender) { rzspedSprayDensity->Value = tbSprayDensity->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::tbConcentrationChange(TObject *Sender) { rzspedConcentration->Value = tbConcentration->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::tbIrregularityChange(TObject *Sender) { rzspedIrregularity->Value = tbIrregularity->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::tbDropSizeChange(TObject *Sender) { rzspedDropSize->Value = tbDropSize->Position; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::WaterPanelClick(TObject *Sender) { rzpnColor->Visible = false; rzpnEffect->Visible = false; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ChangePenMenuIcon(int kind) { Graphics::TBitmap *bitmap = new Graphics::TBitmap; ImageList->GetBitmap(kind, bitmap); sbScratch->Glyph->Assign(bitmap); delete bitmap; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::ChangeBtnUpImage(int kind) { Graphics::TBitmap *bitmap = new Graphics::TBitmap; imglistBtnUpDown->GetBitmap(kind, bitmap); sbBtnUp->Glyph->Assign(bitmap); delete bitmap; if (kind) bMenuDown = true; else bMenuDown = false; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::numedEGradeChange(TObject *Sender) { spread_grade = numedEGrade->Value; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzckColorSpreadClick(TObject *Sender) { if (rzckColorSpread->Checked) { // select spread color Word key; key = VK_RETURN; if (numedEGrade->Visible) EditKeyDown(numedEGrade, key, TShiftState()); else if (numedEScale->Visible) EditKeyDown(numedEScale, key, TShiftState()); spread_sw[4] = 0; // IDS_SELECTCOLOR if (rzckEtcDraw->Checked) rzckEtcDraw->Checked = false; } else { // Draw //¿äû¿¡ ÀÇÇØ¼­ ¼±ÅÃÇÑ »öÀÌ ´Ù¸¦ °æ¿ì¿¡´Â ´Ù´Ü°è »öÀ» ¸¸µéµµ·Ï ó¸®ÇÔ. //MenuDownÀÌ false µÇ¸é ¹«Á¶°Ç ´Ù´Ü°è »öÀ» ¸¸µéÁö ¾Ê°í ¸®ÅÏÇÑ´Ù. //´Ù´Ü°è »öÀÌ ¸¸µé¾îÁö¸é ÆÈ·¹Æ®¿¡ »öÀÌ Ãß°¡µÈ´Ù. if (bMenuDown && (shFirst->Brush->Color != shSecond->Brush->Color)) { } else { rzckColorSpread->Checked = true; return; } aspread = true; spread_sw[4] = 1; make_spread(); Selector->Invalid(); if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); // ===============================================================lhskys if (DrawForm) { if (DrawForm->Lsx != NULL && DrawForm->Lsy != NULL) { int stx, sty; COLORREF c; if (penspread == 0) { if (spread_sw[4] == 1) { penspread = 1; stx = DrawForm->Lsx, sty = DrawForm->Lsy; DrawForm->iMainImageChange(); if (DrawForm->Line_type == 1 || DrawForm->Curve_type == 1) { DrawForm->PointList = new TList; /* DrawForm->step = 0; */ DrawForm->undos = 0; pentaper = 0; DrawForm->Lsx = stx, DrawForm->Lsy = sty; if (DrawForm->xkey) { DrawForm->step = 0; DrawForm->InitPointList(); } else DrawForm->AddPointList(DrawForm->Lsx, DrawForm->Lsy, c); } } } else if (pentaper == 0) { if (spread_sw[4] == 0 && DrawForm->isTaper) { pentaper = 1; stx = DrawForm->Lsx, sty = DrawForm->Lsy; DrawForm->iMainImageChange(); if (DrawForm->Line_type == 1 || DrawForm->Curve_type == 1) { DrawForm->PointList = new TList; /* DrawForm->step = 0; */ DrawForm->undos = 0; penspread = 0; DrawForm->Lsx = stx, DrawForm->Lsy = sty; if (DrawForm->xkey) { DrawForm->step = 0; DrawForm->InitPointList(); } else DrawForm->AddPointList(DrawForm->Lsx, DrawForm->Lsy, c); } } } } } // ====================================================================== } } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzckEtcDrawClick(TObject *Sender) { if (rzckEtcDraw->Checked) { // Drarw if (rzckColorSpread->Checked) { rzckColorSpread->Checked = false; } else { aspread = true; spread_sw[4] = 1; // Draw // IDS_DRAWINGPEN if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); } } else { if (rzckColorSelect->Checked) { // ColorSelect¿¡¼­ Draw¸¦ falseÇÒ °æ¿ì¿¡´Â Spread¸¦ checked ÇÏÁö ¾Ê´Â´Ù. // ClorSelect ÇÑ »óÅ¿¡¼­ Draw¸¦ ´­·¯¾ß Yes »óŰ¡ µÇ±â ¶§¹®ÀÌ´Ù. return; } if (!rzckColorSpread->Checked) rzckColorSpread->Checked = true; } // ===============================================================lhskys if (DrawForm) { if (DrawForm->Lsx != NULL && DrawForm->Lsy != NULL) { int stx, sty; COLORREF c; if (penspread == 0) { if (spread_sw[4] == 1) { penspread = 1; stx = DrawForm->Lsx, sty = DrawForm->Lsy; DrawForm->iMainImageChange(); if (DrawForm->Line_type == 1 || DrawForm->Curve_type == 1) { DrawForm->PointList = new TList; /* DrawForm->step = 0; */ DrawForm->undos = 0; pentaper = 0; DrawForm->Lsx = stx, DrawForm->Lsy = sty; if (DrawForm->xkey) { DrawForm->step = 0; DrawForm->InitPointList(); } else DrawForm->AddPointList(DrawForm->Lsx, DrawForm->Lsy, c); } } } else if (pentaper == 0) { if (spread_sw[4] == 0 && DrawForm->isTaper) { pentaper = 1; stx = DrawForm->Lsx, sty = DrawForm->Lsy; DrawForm->iMainImageChange(); if (DrawForm->Line_type == 1 || DrawForm->Curve_type == 1) { DrawForm->PointList = new TList; /* DrawForm->step = 0; */ DrawForm->undos = 0; penspread = 0; DrawForm->Lsx = stx, DrawForm->Lsy = sty; if (DrawForm->xkey) { DrawForm->step = 0; DrawForm->InitPointList(); } else DrawForm->AddPointList(DrawForm->Lsx, DrawForm->Lsy, c); } } } } } // ====================================================================== } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::rzckColorSelectClick(TObject *Sender) { if (rzckColorSelect->Checked) { // Yes acolor = 2; if (rzckColorSpread->Checked) rzckColorSpread->Checked = false; //if (!rzckEtcDraw->Checked) aspread = false; } else { // No // MainImageForm->iMainImage->ExitBackGround(0x20); acolor = 0; Selector->SaveToFile(AppDataItem + "\\Pen.Ini", "Color"); } MainImageForm->PenChange(); } // --------------------------------------------------------------------------- int __fastcall TPenManagerForm::GetPenSize() { if (Type == PT_AIR) return seSpraySize->Value; else return rzsePenSize->Value; } // --------------------------------------------------------------------------- void __fastcall TPenManagerForm::SetPenSize(int nAPenSize) { if (Type == PT_AIR) seSpraySize->Value = nAPenSize; else rzsePenSize->Value = nAPenSize; } // ---------------------------------------------------------------------------