//--------------------------------------------------------------------------- // << Include >> #pragma hdrstop #include "WorkAreaMenu.h" #include "MainImage.h" #include "FullView.h" #include "Window.h" #include "LogData.h" #pragma package(smart_init) //--------------------------------------------------------------------------- __fastcall TWorkAreaMenu::TWorkAreaMenu() { pressZ = 0; //lhskys zŰ Á÷°¢Ç¥½Ã ÃʱâÈ­(=0) maneupdate = true; //================================================== } //--------------------------------------------------------------------------- __fastcall TWorkAreaMenu::~TWorkAreaMenu() { } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::Init() { } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::Exit() { } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::Create() { //--------------------------------------------------------- //¸Þ´º À̺¥Æ®µé ¿¬°á //--------------------------------------------------------- if (WindowForm){ WindowForm->rzmtbtShape->OnClick = sbShapeClick; WindowForm->miShapeSquare->OnClick = sbShapeSquareClick; WindowForm->miShapeRectangle->OnClick = sbShapeRectangleClick; WindowForm->miShapeCircle->OnClick = sbShapeCircleClick; WindowForm->miShapeEllipse->OnClick = sbShapeEllipseClick; WindowForm->rzmtbtIrregular->OnClick = sbIrregularClick; WindowForm->rzmtbtOutline->OnClick = sbOutlineClick; WindowForm->rbSet->OnClick = ShapeSetRadioGroupClick; WindowForm->rbAddition->OnClick = ShapeSetRadioGroupClick; WindowForm->rbSubtraction->OnClick = ShapeSetRadioGroupClick; WindowForm->rzmtbtUndo->OnClick = sbUndoClick; WindowForm->rzbitbtnRunUndo->OnClick = RunUndoClick; WindowForm->tbMagic->OnChange = tbMagicChange; WindowForm->seMagic->OnChange = seMagicChange; WindowForm->bnRun->OnClick = bnRunClick; WindowForm->rzmtbtOff->OnClick = sbOffClick; WindowForm->rzmtbtFull->OnClick = sbFullClick; WindowForm->sbIrreDelete->OnClick = sbIrreDeleteClick; WindowForm->sbIrreClose->OnClick = sbIrreCloseClick; WindowForm->miOutlineSurfaceMulti->OnClick = sbOutlineSurfaceMultiClick; WindowForm->miOutlineBorder->OnClick = sbOutlineBorderClick; WindowForm->miOutlineSurfaceSingle->OnClick = sbOutlineSurfaceSingleClick; WindowForm->cbSurfaceMulti->OnClick = cbOutlinePositionClick; WindowForm->sbSurfaceMultiNew->OnClick = sbOutlineNewClick; WindowForm->sbSurfaceMultiAll->OnClick = sbOutlineAllClick; WindowForm->sbSurfaceMultiOne->OnClick = sbOutlineOneClick; WindowForm->sbSurfaceMultiDelete->OnClick = sbOutlineDeleteClick; WindowForm->sbSurfaceMultiBefore->OnClick = sbOutlineBeforeClick; //------------------------------------------------------------- //========== [ Popup Click Event ] ========================================== // ------------------ by monkman (2006.08.24) WindowForm->Rectangle1->OnClick = Rectangle1Click; WindowForm->Square1->OnClick = Rectangle1Click; WindowForm->Circle1->OnClick = Rectangle1Click; WindowForm->Ellipse1->OnClick = Rectangle1Click; WindowForm->IrregularPopup->OnClick = IrregularPopupClick; WindowForm->SurfaceMulti1->OnClick = SurfaceMultiPopup; WindowForm->SurfaceSingle1->OnClick = SurfaceSinglePopup; WindowForm->Border1->OnClick = BorderPopup; WindowForm->InvertRegionPopup->OnClick = InvertRegionPopupClick; WindowForm->TransformRegionPopup->OnClick = TransformRegionPopupClick; WindowForm->FullPopup->OnClick = sbFullClick; WindowForm->OffPopup->OnClick = sbOffClick; } //------------------------------------------------------------------ bDeleteLastPoint = false; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::Close(TObject *Sender) { BEGIN_LOG(""); ExitMenu(); Destroy(); //MainForm->MainMenuMan->Item = TSM_NONE; // this°¡ Áö¿öÁöÁö ¾Ê°Ô º¸È£ //MainForm->MainMenuMan->ExitMenu(); //MainForm->MainMenuMan->Item = TSM_CLOSE; // ³ªÁß¿¡ ExitMenu() È£Ã⠽à this°¡ Áö¿öÁöµµ·Ï ´Ù½Ã ¼ÂÆÃ //MainForm->rztbWorkArea->Down = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::Destroy() { //--------------------------------------------------------- //¸Þ´º À̺¥Æ®µé ¿¬°á //--------------------------------------------------------- if (WindowForm){ WindowForm->rzmtbtShape->OnClick = NULL; WindowForm->miShapeSquare->OnClick = NULL; WindowForm->miShapeRectangle->OnClick = NULL; WindowForm->miShapeCircle->OnClick = NULL; WindowForm->miShapeEllipse->OnClick = NULL; WindowForm->rzmtbtIrregular->OnClick = NULL; WindowForm->rzmtbtOutline->OnClick = NULL; WindowForm->rbSet->OnClick = NULL; WindowForm->rbAddition->OnClick = NULL; WindowForm->rbSubtraction->OnClick = NULL; WindowForm->rzmtbtUndo->OnClick = NULL; WindowForm->rzbitbtnRunUndo->OnClick = NULL; WindowForm->tbMagic->OnChange = NULL; WindowForm->seMagic->OnChange = NULL; WindowForm->bnRun->OnClick = NULL; WindowForm->rzmtbtFull->OnClick = NULL; WindowForm->rzmtbtOff->OnClick = NULL; WindowForm->sbIrreDelete->OnClick = NULL; WindowForm->sbIrreClose->OnClick = NULL; WindowForm->miOutlineSurfaceMulti->OnClick = NULL; WindowForm->miOutlineBorder->OnClick = NULL; WindowForm->miOutlineSurfaceSingle->OnClick = NULL; WindowForm->cbSurfaceMulti->OnClick = NULL; WindowForm->sbSurfaceMultiNew->OnClick = NULL; WindowForm->sbSurfaceMultiAll->OnClick = NULL; WindowForm->sbSurfaceMultiOne->OnClick = NULL; WindowForm->sbSurfaceMultiDelete->OnClick = NULL; WindowForm->sbSurfaceMultiBefore->OnClick = NULL; //========== [ Popup Click Event ] ========================================== // ------------------ by monkman (2006.08.24) WindowForm->Rectangle1->OnClick = NULL; WindowForm->Square1->OnClick = NULL; WindowForm->Circle1->OnClick = NULL; WindowForm->Ellipse1->OnClick = NULL; WindowForm->IrregularPopup->OnClick = NULL; WindowForm->SurfaceMulti1->OnClick = NULL; WindowForm->SurfaceSingle1->OnClick = NULL; WindowForm->Border1->OnClick = NULL; WindowForm->InvertRegionPopup->OnClick = NULL; WindowForm->TransformRegionPopup->OnClick = NULL; WindowForm->FullPopup->OnClick = NULL; WindowForm->OffPopup->OnClick = NULL; } //MainForm->SubMenuForm = NULL; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::InitMenu() { BEGIN_LOG(""); PointList = new TList; TIniFile* WinIni = new TIniFile(AppDataItem+"\\window.ini"); Number = WinIni->ReadInteger("Window", "Number", 0); delete WinIni; Step = 0; Item = WI_SHAPE; if (WindowForm){ WindowForm->rzmtbtShape->Down = true; WindowForm->popupShape->Tag = WindowForm->miShapeRectangle->Tag; sbShapeRectangleClick(WindowForm->miShapeRectangle); } ShowWorkAreaSize(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::UpdateMenu() { } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::ExitMenu() { BEGIN_LOG(""); #ifdef TEXSTYLIST if(MainForm->WReopenMove){ TCursor OldCursor; MainImageForm->iMainImage->SubVisible = false; if(MainImageForm->WorkArea->StatusUndo()) RunUndoClick((TObject *)this);//sbUndoClick((TObject *)this); else{ ResetBitmapRegion(); Step = 0; MainImageForm->iMainImage->Repaint(); } MainForm->WReopenMove = false; Screen->Cursor = OldCursor; } #endif if (Step>0) { if (Step==11) { MainImageForm->TempLabel->Visible = false; MainImageForm->WorkAreaChange(); } if(WindowForm && WindowForm->rbAddition->Checked || WindowForm && WindowForm->rbSubtraction->Checked); else ResetBitmapRegion(); MainImageForm->iMainImage->OnPaintLocate = NULL; Step = 0; MainImageForm->iMainImage->Repaint(); } ExitItem(); TIniFile* WinIni = new TIniFile(AppDataItem+"\\window.ini"); WinIni->WriteInteger("Window", "Number", Number); delete WinIni; if (WindowForm) WindowForm->csSurfaceMulti->SaveToFile(AppDataItem + "\\Window.Ini", "ColorSelector(Outline)"); ResetPointList(); delete PointList; END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::iMainImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); switch (Item) { case WI_SHAPE: RectangleMouseDown(Button, X, Y); break; case WI_IRREGULAR: IrregularMouseDown(Button, X, Y); break; case WI_OUTLINE: OutlineMouseDown(Button, Shift, X, Y); break; } END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::iMainImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); //if(Shift.Contains(ssShift) && SubItem == WSI_RECTANGLE) SubItem = WSI_SQUARE; //by bomchun ½ÃÇÁÆ® ۸¦ ÀÌ¿ëÇÑ Á÷»ç°¢Çü->Á¤»ç°¢Çü //if(Shift.Contains(ssShift) && SubItem == WSI_ELLIPSE) SubItem = WSI_CIRCLE; switch (Item) { case WI_SHAPE: RectangleMouseMove(X, Y); break; case WI_IRREGULAR: IrregularMouseMove(Shift, X, Y); break; case WI_OUTLINE: OutlineMouseMove(Shift, X, Y); break; } //if(!Shift.Contains(ssShift) && SubItem == WSI_SQUARE) SubItem = WSI_RECTANGLE; //if(!Shift.Contains(ssShift) && SubItem == WSI_CIRCLE) SubItem = WSI_ELLIPSE; END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::iMainImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); switch (Item) { case WI_IRREGULAR: IrregularMouseUp(Shift, X, Y); break; } END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::iMainImageMouseLeave(TObject *Sender) { } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::iMainImageMouseEnter(TObject *Sender) { } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::iMainImagePaint(TObject *Sender) { isDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo return false; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::iMainImageChange(TObject *Sender) { return false; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::iMainImagePositionChange(TObject *Sender) { return false; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::iMainImageKeyDown(TObject *Sender, WORD Key, TShiftState Shift) { BEGIN_LOG(""); if (Key == VK_SHIFT && Shift.Contains(ssShift) && WindowForm && !WindowForm->rbSet->Checked) WindowForm->rbSet->Checked = true; if (Key == 'X'){ // 120: x 88: X down , 122 : z 90: Z down if(Item==WI_IRREGULAR) if (PointList->Count>2)sbIrreCloseClick(Sender); } else if (Key == 'Z' && Shift.Contains(ssShift) && WindowForm && WindowForm->sbIrreDelete->Enabled) { sbIrreDeleteClick(Sender); } else if (Key == 'Z') { if(Item==WI_IRREGULAR) if (WindowForm && WindowForm->cbIrreCurve->Checked==false) First=Second; pressZ=1; } else if (Key == VK_SHIFT && Shift.Contains(ssCtrl) && WindowForm && !WindowForm->rbAddition->Checked) { WindowForm->rbAddition->Checked = true; } else if (Key == VK_MENU && Shift.Contains(ssCtrl) && WindowForm && !WindowForm->rbSubtraction->Checked) { WindowForm->rbSubtraction->Checked = true; } else if (Key == '1') { if (WindowForm){ sbShapeClick(WindowForm->rzmtbtShape); //WindowForm->sbShape->Down = true; WindowForm->rzmtbtShape->Down = true; } } else if (Key == '2') { if (WindowForm){ //sbIrregularClick(WindowForm->sbIrregular); sbIrregularClick(WindowForm->rzmtbtIrregular); WindowForm->rzmtbtIrregular->Down = true; } } else if (Key == '3') { if (WindowForm){ //WindowForm->workAreaMenu->sbOutlineClick(WindowForm->sbOutline); WindowForm->workAreaMenu->sbOutlineClick(WindowForm->rzmtbtOutline); WindowForm->rzmtbtOutline->Down = true; } } else if (Key == VK_NUMPAD4/*left*/) { MoveWorkArea(3); } else if (Key == VK_NUMPAD8/*up*/) { MoveWorkArea(0); } else if (Key == VK_NUMPAD6/*right*/) { MoveWorkArea(1); } else if (Key == VK_NUMPAD2/*down*/) { MoveWorkArea(2); } /* // ¾Æ·¡ ´ÜÃàŰ(Àç¼³Á¤)´Â ¾ø¾îµµ Å©°Ô ¹®Á¦°¡ µÉ °Í °°Áö ¾Ê¾Æ¼­ ÁÖ¼®Ã³¸® - by monkman (2006.11.15) if (Shift.Contains(ssShift) && MainForm->rzrgShapeSet->ItemIndex != 0) MainForm->rzrgShapeSet->ItemIndex = 0; if (Key == 'X'){ // 120: x 88: X down , 122 : z 90: Z down if(Item==WI_IRREGULAR) if (PointList->Count>2)sbIrreCloseClick((TObject *)this); } else if (Key == 'Z' && Shift.Contains(ssShift) && bDeleteLastPoint) { DeleteLastPoint(); } else if (Key == 'Z') { if(Item==WI_IRREGULAR) if (MainForm->rzchbWACurve->Checked==false) First=Second; pressZ=1; } else if (Shift.Contains(ssShift) && Shift.Contains(ssCtrl) && MainForm->rzrgShapeSet->ItemIndex != 1) { MainForm->rzrgShapeSet->ItemIndex = 1; } else if (Shift.Contains(ssAlt) && Shift.Contains(ssCtrl) && MainForm->rzrgShapeSet->ItemIndex != 2) { MainForm->rzrgShapeSet->ItemIndex = 2; } else if (Key == VK_BACK && bDeleteLastPoint) { DeleteLastPoint(); } else if (Key == '1') { sbShapeRectangleClick(MainForm->rztbWARect); MainForm->rztbWARect->Down = true; } else if (Key == '2') { sbShapeRectangleClick(MainForm->rztbWAEllipse); MainForm->rztbWAEllipse->Down = true; }else if (Key == '3') { sbIrregularClick(MainForm->rztbWAIrregular); MainForm->rztbWAIrregular->Down = true; } else if (Key == '4') { sbOutlineClick(MainForm->rztbWAOutLine); MainForm->rztbWAOutLine->Down = true; } else if (Key == VK_NUMPAD4){ MoveWorkArea(3); } else if (Key == VK_NUMPAD8){ MoveWorkArea(0); } else if (Key == VK_NUMPAD6){ MoveWorkArea(1); } else if (Key == VK_NUMPAD2){ MoveWorkArea(2); } */ END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::iMainImageKeyUp(TObject *Sender, WORD Key) { if (Key == 'Z') { if (Item==WI_IRREGULAR) { pressZ = 0; } } } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::ShapeSetRadioGroupClick(TObject *Sender) { BEGIN_LOG(""); //üũ µÇ¾îÀÖ´ÀÁö È®Àθ¸ ÇØ¼­ À̺¥Æ® ó¸®ÇÒ ÇÊ¿ä´Â ¾øÀ½ //by bomchun // ºÒ±ÔÄ¢, ¿Ü°û¼±¿¡¼­ ÀÛ¾÷±¸¿ª Ãß°¡½Ã »ç°¢ÇüÀ¸·Î¸¸ µÇ±â ¶§¹®¿¡ ¾Æ·¡ ³»¿ë ÁÖ¼®Ã³¸® - by monkman (2006.11.15) //ExitItem(); //InitItem(WI_SHAPE); StatusOutline(); END_LOG; } //---------------------------------------------------------------------------- //--------------------------------------------------------------------------- // ¹öư Ŭ¸¯ //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbShapeClick(TObject *Sender) { BEGIN_LOG(""); // if (WindowForm){ // WindowForm->pnShape->Top = WindowForm->Panel->Height; // WindowForm->pnShape->BringToFront(); // } ExitItem(); InitItem(WI_SHAPE); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbIrregularClick(TObject *Sender) { BEGIN_LOG(""); ExitItem(); InitItem(WI_IRREGULAR); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineClick(TObject *Sender) { BEGIN_LOG(""); ExitItem(); InitItem(WI_OUTLINE); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbFullClick(TObject *Sender) { BEGIN_LOG(""); if (WindowForm){ ExitItem(); // »ç¿ëÁßÀÌ´ø Item »óŸ¦ ³¡³¿. InitItem(Item); // Àüü¼±Åà ÈÄ ÀÌÀü¿¡ ¼±ÅÃÇß´ø ItemÀ¸·Î ´Ù½Ã ÃʱâÈ­ ½ÃÅ´. } WindowFull(); ShowWorkAreaSize(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOffClick(TObject *Sender) { BEGIN_LOG(""); WindowOff(); ShowWorkAreaSize(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::WindowOff() { BEGIN_LOG(""); /* if (MainImageForm->WorkArea->Mask){ MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method MainImageForm->WorkArea->PushUndo(); } ResetBitmapRegion(); MainImageForm->WorkAreaChange(); if (MainForm->rztoolbarWorkArea->Visible) PostMessage(MainForm->Handle, TPM_EXITFUNCTION, 0, 0); MainForm->MainMenuMan->showWindow = false; */ //if (WindowForm) // À©µµ¿ì ÆûÀÌ ÀÖ¾î¾ß¸¸ Ŭ·Î¿ìÁî // WindowForm->ExitItem(); if (MainImageForm->WorkArea->Mask){ MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method MainImageForm->WorkArea->PushUndo(); } ResetBitmapRegion(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); if(WindowForm) WindowForm->rzmtbtOff->Enabled = false; /* if (WindowForm) PostMessage(WindowForm->hWnd, TPM_EXITFUNCTION, 0, 0); MainMenuForm->showWindow = false; by altang */ END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbUndoClick(TObject *Sender) { BEGIN_LOG(""); if (WindowForm){ WindowForm->pnUndo->Top = WindowForm->Panel->Height; WindowForm->pnUndo->BringToFront(); } ExitItem(); WindowForm->ClientHeight = WindowForm->pnUndo->Top + WindowForm->pnUndo->Height; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::RunUndoClick(TObject *Sender) { BEGIN_LOG(""); int dx, dy; String str, un; un = MainImageForm->UnitName(); if (MainImageForm->WorkArea->StatusUndo()) { if (MainImageForm->WorkArea->Mask && WindowForm) WindowForm->rbSwap->Enabled = true; } else { ExitItem(); InitItem(WI_SHAPE); } if (WindowForm && WindowForm->rbStack->Checked) { MainImageForm->WorkArea->PopUndo(); MainImageForm->iMainImage->OutlineBitmapRgn(MainImageForm->WorkArea->bComplex); MainImageForm->iMainImage->Repaint(); StatusItem(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); } else if (WindowForm && WindowForm->rbSwap->Checked) { MainImageForm->WorkArea->SwapUndo(); MainImageForm->iMainImage->OutlineBitmapRgn(MainImageForm->WorkArea->bComplex); MainImageForm->iMainImage->Repaint(); StatusItem(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); } dx = MainImageForm->WorkArea->Range.left - MainImageForm->WorkArea->Range.right + 1; dy = MainImageForm->WorkArea->Range.top - MainImageForm->WorkArea->Range.bottom + 1; str = returnSize(dx, dy); if (WindowForm) WindowForm->lbShape->Caption = String(IDS_COMMON_SIZE) + " : " + str + " " + un; MainImageForm->TempLabel->Caption = str; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::WindowFormButtonImageChange(TObject *Sender) { String strSender = Sender->ClassName(); if (strSender.Compare("TMenuItem") == 0){ TMenuItem *mi = (TMenuItem *)Sender; if (Item == WI_SHAPE) { WindowForm->rzmtbtShape->Glyph->Assign(mi->Bitmap); WindowForm->rzmtbtShape->Hint = mi->Caption; } else if (Item == WI_OUTLINE) { WindowForm->rzmtbtOutline->Glyph->Assign(mi->Bitmap); WindowForm->rzmtbtOutline->Hint = mi->Caption; } } } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbShapeSquareClick(TObject *Sender) { BEGIN_LOG(""); // ¾î¶² ItemÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) if (WindowForm) WindowForm->popupShape->Tag = WindowForm->miShapeSquare->Tag; ExitItem(); InitItem(WI_SHAPE); SubItem = WSI_SQUARE; if (Sender) WindowFormButtonImageChange(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbShapeCircleClick(TObject *Sender) { BEGIN_LOG(""); // ¾î¶² ItemÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) if (WindowForm) WindowForm->popupShape->Tag = WindowForm->miShapeCircle->Tag; ExitItem(); InitItem(WI_SHAPE); SubItem = WSI_CIRCLE; if (Sender) WindowFormButtonImageChange(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbShapeRectangleClick(TObject *Sender) { BEGIN_LOG(""); // ¾î¶² ItemÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) if (WindowForm) WindowForm->popupShape->Tag = WindowForm->miShapeRectangle->Tag; ExitItem(); InitItem(WI_SHAPE); SubItem = WSI_RECTANGLE; if (Sender) WindowFormButtonImageChange(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbShapeEllipseClick(TObject *Sender) { BEGIN_LOG(""); // ¾î¶² ItemÀÌ ¼±ÅõǾú´ÂÁö ±â·ÏÇϱâ À§ÇØ - by monkman (2010.08.27) if (WindowForm) WindowForm->popupShape->Tag = WindowForm->miShapeEllipse->Tag; ExitItem(); InitItem(WI_SHAPE); SubItem = WSI_ELLIPSE; if (Sender) WindowFormButtonImageChange(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::DeleteLastPoint() { BEGIN_LOG(""); DeleteClick = 1; //lhskys delete ¹öưÀ» ´­·¶À»¶§ if (Step==23) { //°ªÀ» ÁöÁ¤ z۸¦ »ç¿ëÇÒ ¼ö ÀÖµµ·Ï WADraw(-4); Step = 21; } else if (Step==22) { WADraw(-2); Step = 21; } else { WADraw(-1); } PopPointList(); if (PointList->Count>0) WADraw(-1); else Step = 0; StatusIrregular(); MainImageForm->iMainImage->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbIrreDeleteClick(TObject *Sender) { BEGIN_LOG(""); DeleteClick = 1; //lhskys delete ¹öưÀ» ´­·¶À»¶§ if (Step==23) { //°ªÀ» ÁöÁ¤ z۸¦ »ç¿ëÇÒ ¼ö ÀÖµµ·Ï WADraw(-4); Step = 21; } else if (Step==22) { WADraw(-2); Step = 21; } else { WADraw(-1); } PopPointList(); if (PointList->Count>0) WADraw(-1); else Step = 0; StatusIrregular(); MainImageForm->iMainImage->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbIrreCloseClick(TObject *Sender) { BEGIN_LOG(""); WADraw(-2); SetBitmapRegion(); ResetPointList(); ShowWorkAreaSize(); if (WindowForm){ WindowForm->cbIrreCurve->Checked = false; WindowForm->cbIrreCurve->Enabled = false; } Step = 0; StatusItem(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineSurfaceMultiClick(TObject *Sender) { BEGIN_LOG(""); if(WindowForm && WindowForm->Similar->Enabled == false) WindowForm->Similar->Enabled = true; if(SubItem == WSI_BORDER && Step>0){ MainImageForm->DrawRectangleLocate(Temp); Step = 0; isDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo maneupdate = true; } SubItem = WSI_SURFACEMULTI; StatusOutline(); if (Sender) WindowFormButtonImageChange(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineSurfaceSingleClick(TObject *Sender) { BEGIN_LOG(""); if(WindowForm && WindowForm->Similar->Enabled == false) WindowForm->Similar->Enabled = true; if(Step >0){ MainImageForm->DrawRectangleLocate(Temp); Step = 0; isDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo if(SubItem == WSI_BORDER)maneupdate = true; } SubItem = WSI_SURFACESINGLE; StatusOutline(); if (Sender) WindowFormButtonImageChange(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineBorderClick(TObject *Sender) { BEGIN_LOG(""); if(WindowForm) WindowForm->Similar->Enabled = false; if (SubItem == WSI_SURFACEMULTI && Step>0) { MainImageForm->DrawRectangleLocate(Temp); Step = 0; isDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } //WindowForm->ClientHeight = WindowForm->Panel->Height; SubItem = WSI_BORDER; StatusOutline(); if (Sender) WindowFormButtonImageChange(Sender); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::cbOutlinePositionClick(TObject *Sender) { BEGIN_LOG(""); StatusOutline(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineNewClick(TObject *Sender) { BEGIN_LOG(""); if (WindowForm){ WindowForm->csSurfaceMulti->Initial(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineAllClick(TObject *Sender) { BEGIN_LOG(""); if (WindowForm){ TCursor cursor; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->SearchWholeColor(WindowForm->csSurfaceMulti->ChoiceColor); WindowForm->csSurfaceMulti->Invalid(); Screen->Cursor = cursor; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineOneClick(TObject *Sender) { if (WindowForm){ if (WindowForm->sbSurfaceMultiOne->Down) WindowForm->sbSurfaceMultiOne->Hint = IDS_COMMON_ONECOLOR; else WindowForm->sbSurfaceMultiOne->Hint = IDS_COMMON_BLOCKCOLOR; } } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineDeleteClick(TObject *Sender) { if (WindowForm){ if (WindowForm->sbSurfaceMultiDelete->Down) WindowForm->sbSurfaceMultiDelete->Hint = IDS_COMMON_DELETECOLOR; else WindowForm->sbSurfaceMultiDelete->Hint = IDS_COMMON_INSERTCOLOR; } } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::sbOutlineBeforeClick(TObject *Sender) { if (WindowForm) WindowForm->csSurfaceMulti->LoadFromFile(AppDataItem + "\\Window.Ini", "ColorSelector(Outline)"); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //ÄÚµåºÎºÐ //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::InitItem(TWindowItem i) { BEGIN_LOG(""); Item = i; switch (Item) { case WI_SHAPE: MainImageForm->iMainImage->OnPaintZoom = PaintZoomRectangle; if (WindowForm){ // WindowForm->pnShape->Top = WindowForm->Panel->Height; // WindowForm->ClientHeight = WindowForm->pnShape->Top + WindowForm->pnShape->Height; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //WindowForm->Parent->Height = WindowForm->ParentHeight + WindowForm->ClientHeight; // WindowForm->pnShape->BringToFront(); // WindowForm->pnShape->Enabled = true; // WindowForm->pnShape->Visible = true; if (WindowForm->popupShape->Tag == WindowForm->miShapeRectangle->Tag) SubItem = WSI_RECTANGLE; else if (WindowForm->popupShape->Tag == WindowForm->miShapeSquare->Tag) SubItem = WSI_SQUARE; else if (WindowForm->popupShape->Tag == WindowForm->miShapeEllipse->Tag) SubItem = WSI_ELLIPSE; else if (WindowForm->popupShape->Tag == WindowForm->miShapeCircle->Tag) SubItem = WSI_CIRCLE; // if(WindowForm->sbShapeRectangle->Down)SubItem = WSI_RECTANGLE; // if(WindowForm->sbShapeEllipse->Down)SubItem = WSI_ELLIPSE; // if(WindowForm->sbShapeSquare->Down)SubItem = WSI_SQUARE; // if(WindowForm->sbShapeCircle->Down)SubItem = WSI_CIRCLE; //WindowForm->sbShape->Down = true; WindowForm->rzmtbtShape->Down = true; WindowForm->ClientHeight = WindowForm->Panel->Height; } break; case WI_IRREGULAR: MainImageForm->iMainImage->OnPaintZoom = PaintZoomIrregular; if (WindowForm){ // WindowForm->pnShape->Top = WindowForm->Panel->Height; // WindowForm->pnIrregular->Top = WindowForm->pnShape->Top + WindowForm->pnShape->Height; // WindowForm->ClientHeight = WindowForm->pnShape->Top + WindowForm->pnShape->Height; WindowForm->pnIrregular->Top = WindowForm->Panel->Height;// + WindowForm->pnUndo->Height+4; WindowForm->ClientHeight = WindowForm->pnIrregular->Top + WindowForm->pnIrregular->Height; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //WindowForm->Parent->Height = WindowForm->ParentHeight + WindowForm->ClientHeight; WindowForm->pnIrregular->BringToFront(); WindowForm->pnIrregular->Enabled = true; WindowForm->pnIrregular->Visible = true; WindowForm->rzmtbtIrregular->Down = true; WindowForm->cbIrreCurve->Enabled = true; } StatusIrregular(); break; case WI_OUTLINE: if (WindowForm){ // ³ôÀÌ¿Í À§Ä¡´Â StatusOutline() ÇÔ¼ö¿¡¼­ ó¸®ÇÑ´Ù //WindowForm->pnOutline->Top = WindowForm->Panel->Height;//+WindowForm->pnUndo->Height+4; //WindowForm->ClientHeight = WindowForm->pnOutline->Top+WindowForm->pnOutline->Height; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //WindowForm->Parent->Height = WindowForm->ParentHeight+WindowForm->ClientHeight; WindowForm->pnOutline->BringToFront(); WindowForm->pnOutline->Enabled = true; WindowForm->pnOutline->Visible = true; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { WindowForm->miOutlineSurfaceMulti->Caption = WindowForm->StringTable.operator [](9);//IDS_SURFACEMULTI; WindowForm->miOutlineSurfaceSingle->Caption = WindowForm->StringTable.operator [](11);//IDS_SURFACESINGLE; WindowForm->miOutlineSurfaceMulti->Hint = WindowForm->StringTable.operator [](14);//IDS_MULTISURFACEFILL; WindowForm->miOutlineSurfaceSingle->Hint = WindowForm->StringTable.operator [](16);//IDS_SINGLESURFACEFILL; WindowForm->pnSurfaceMulti->Visible = true; WindowForm->pnMagic->Visible = false; } else { WindowForm->miOutlineSurfaceMulti->Caption = WindowForm->StringTable.operator [](12);//IDS_MAGIC; WindowForm->miOutlineSurfaceSingle->Caption = WindowForm->StringTable.operator [](13);//IDS_SURFACE; WindowForm->miOutlineSurfaceMulti->Hint = WindowForm->StringTable.operator [](12);//IDS_MAGIC; WindowForm->miOutlineSurfaceSingle->Hint = WindowForm->StringTable.operator [](13);//IDS_SURFACE; WindowForm->pnSurfaceMulti->Visible = false; WindowForm->pnMagic->Visible = true; WindowForm->cbMagic->ItemIndex = 0; bMagicPosition = false; } if (WindowForm->PopupOutline->Tag == WindowForm->miOutlineSurfaceSingle->Tag) SubItem = WSI_SURFACESINGLE; else if (WindowForm->PopupOutline->Tag == WindowForm->miOutlineSurfaceMulti->Tag) SubItem = WSI_SURFACEMULTI; else if (WindowForm->PopupOutline->Tag == WindowForm->miOutlineBorder->Tag) SubItem = WSI_BORDER; StatusOutline(); WindowForm->rzmtbtOutline->Down = true; // WindowForm->pnShape->Top = WindowForm->Panel->Height; // WindowForm->ClientHeight = WindowForm->pnShape->Top + WindowForm->pnShape->Height; } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel != 8) bMagicPosition = false; StatusOutline(); } break; default: if (WindowForm){ WindowForm->ClientHeight = WindowForm->Panel->Height; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //WindowForm->Parent->Height = WindowForm->ParentHeight+WindowForm->ClientHeight; } break; } StatusItem(); StatusOutline(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::ExitItem() { BEGIN_LOG(""); switch (Item) { case WI_SHAPE: MainImageForm->iMainImage->OnPaintZoom = NULL; MainImageForm->TempLabel->Visible = false; if (Step>0) Step = 0; //if (WindowForm){ // WindowForm->pnShape->Enabled = false; // WindowForm->pnShape->Visible = false; //} break; case WI_IRREGULAR: if(MainImageForm)MainImageForm->iMainImage->OnPaintZoom = NULL; //by bomchun ¸ÞÀÎÀ̹ÌÁö°¡ ¾øÀ»°æ¿ì ¿¡·¯°¡ ³ª¼­ if ¹®À¸·Î °Ë»ç if (Step>0) { ResetPointList(); Step = 0; } if (WindowForm){ WindowForm->cbIrreCurve->Checked = false; WindowForm->cbIrreCurve->Enabled = false; WindowForm->pnIrregular->Enabled = false; WindowForm->pnIrregular->Visible = false; } break; case WI_OUTLINE: if (SubItem == WSI_SURFACEMULTI || SubItem == WSI_BORDER) { if(Step>0){ MainImageForm->DrawRectangleLocate(Temp); Step = 0; isDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } } if (WindowForm){ WindowForm->pnOutline->Enabled = false; WindowForm->pnOutline->Visible = false; } break; } MainImageForm->iMainImage->Repaint(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::StatusItem() { BEGIN_LOG(""); if (WindowForm){ WindowForm->rzmtbtOff->Enabled = false; if (MainImageForm->WorkArea->Mask) WindowForm->rzmtbtOff->Enabled = true; if (MainImageForm->WorkArea->StatusUndo()) { //WindowForm->rzmtbtUndo->Enabled = true; WindowForm->rzbitbtnRunUndo->Enabled = true; WindowForm->rbSwap->Enabled = true; WindowForm->rbStack->Enabled = true; } else { //WindowForm->rzmtbtUndo->Enabled = false; WindowForm->rzbitbtnRunUndo->Enabled = false; WindowForm->rbSwap->Enabled = false; WindowForm->rbStack->Enabled = false; } WindowForm->rbAddition->Enabled = Number>0; WindowForm->rbSubtraction->Enabled = Number>0; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::PaintZoomRectangle(TObject *Sender, HDC dc) { BEGIN_LOG(""); // get item image from event sender object TPItemImage* Image = dynamic_cast(Sender); if (Image == NULL) { END_LOG; return; } int diff = abs(First.x-Second.x) - abs(First.y-Second.y); if (Step > 0) { if (SubItem==WSI_CIRCLE||SubItem==WSI_SQUARE){ // by jeegeo if (diff > 0) { if (First.x > Second.x) { Second.x+=diff; } else { Second.x-=diff; } } else { if (First.y > Second.y) { Second.y-=diff; } else { Second.y+=diff; } } } RECT rr; rr.left = min(First.x, Second.x); rr.top = min(First.y, Second.y); rr.right = max(First.x, Second.x)+1;//ÀåÁø¸¸: +1ÀÌ ¿Ö ÇÊ¿äÇÑÁö? rr.bottom = max(First.y, Second.y)+1; //rr.right = max(First.x, Second.x); //rr.bottom = max(First.y, Second.y); rr.left = Image->BitmapToCanvasX(rr.left); rr.top = Image->BitmapToCanvasY(rr.top)-Image->MarginY; rr.right = Image->BitmapToCanvasX(rr.right); rr.bottom = Image->BitmapToCanvasY(rr.bottom)-Image->MarginY; HBRUSH hOldBrush = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH)); COLORREF clOldBk = SetBkColor(dc, clWhite); HPEN hPen = CreatePen(PS_DOT, 1, clBlack); HPEN hOldPen = (HPEN)SelectObject(dc, hPen); if (SubItem==WSI_ELLIPSE||SubItem==WSI_CIRCLE) { Ellipse(dc, rr.left, rr.top, rr.right, rr.bottom); } if (SubItem==WSI_RECTANGLE||SubItem==WSI_SQUARE) { Rectangle(dc, rr.left, rr.top, rr.right, rr.bottom); } SelectObject(dc, hOldPen); DeleteObject(hPen); SetBkColor(dc, clOldBk); SelectObject(dc, hOldBrush); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::PaintZoomIrregular(TObject *Sender, HDC dc) { BEGIN_LOG(""); TPItemImage *Image = (TPItemImage *)Sender; HBRUSH hOldBrush; COLORREF clOldBk; HPEN hPen, hOldPen; RECT rr; int i; TWAPointData *pd; TPoint pt[3]; double length; //lhskys ±æÀ̸¦ ÀÌ¿ëÇϱâ À§Çؼ­ double dx,dy,lx,ly; //lhskys x,yÀÇ º¯È­·® if (Step>0 && PointList && PointList->Count > 0) { hOldBrush = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH)); clOldBk = SetBkColor(dc, clWhite); hPen = CreatePen(PS_DOT, 1, clBlack); hOldPen = (HPEN)SelectObject(dc, hPen); if (Method<0) { pd = (TWAPointData *)PointList->First(); pt[2].x = Image->BitmapToCanvasX(pd->Pos.x); pt[2].y = Image->BitmapToCanvasY(pd->Pos.y)-Image->MarginY; MoveToEx(dc, pt[2].x, pt[2].y, NULL); if (PointList->Count>1) { for (i=1; i<=PointList->Count-1; i++) { pd = (TWAPointData *)PointList->Items[i]; pt[2].x = Image->BitmapToCanvasX(pd->Pos.x); pt[2].y = Image->BitmapToCanvasY(pd->Pos.y)-Image->MarginY; if (pd->Curve) { pt[0].x = Image->BitmapToCanvasX(pd->Apex.x); pt[0].y = Image->BitmapToCanvasY(pd->Apex.y)-Image->MarginY; pt[1] = pt[0]; PolyBezierTo(dc, pt, 3); } else { LineTo(dc, pt[2].x, pt[2].y); } } } switch (Method) { case -2: if(Item==WI_IRREGULAR && pressZ==1){ //lhskys zŰ Á÷°¢Ç¥½Ã Second=pd->Pos; //lhskys ¹þ¾î³ª´ÂÁ¡À» Àç À§Ä¡·Î... if(DeleteClick==1)Second=pt[2]; //lhskys ÇÑÁ¡µÚ·Î ÇßÀ»¶§ Á¡°ªÀ» ´Ù½Ã ÀÔ·Â int x1,x2,y1,y2; // °¢µµ üũ x1=First.x; // ¹× x2=Second.x; // ±×¸®±â y1=First.y; y2=Second.y; if((y2-y1>=x2-x1)&&(y2-y1>=x1-x2)){ First.x=Second.x; pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y); LineTo(dc,pt[2].x,pt[2].y); } if((y2-y1>=x2-x1)&&(y2-y1<=x1-x2)){ First.y=Second.y; // y = x ±âÁØÀ¸·Î pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y); LineTo(dc,pt[2].x,pt[2].y); } if((y2-y1<=x2-x1)&&(y2-y1>=x1-x2)){ First.y=Second.y; pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y); LineTo(dc,pt[2].x,pt[2].y); } if((y2-y1<=x2-x1)&&(y2-y1<=x1-x2)){ First.x=Second.x; pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y); LineTo(dc,pt[2].x,pt[2].y); } DeleteClick = 0; break; } //¿ä±â±îÁö pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y)-Image->MarginY; LineTo(dc, pt[2].x, pt[2].y); break; case -3: pd = (TWAPointData *)PointList->First(); pt[2].x = Image->BitmapToCanvasX(pd->Pos.x); pt[2].y = Image->BitmapToCanvasY(pd->Pos.y)-Image->MarginY; LineTo(dc, pt[2].x, pt[2].y); break; case -4: pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y)-Image->MarginY; pt[0].x = Image->BitmapToCanvasX(Second.x); pt[0].y = Image->BitmapToCanvasY(Second.y)-Image->MarginY; pt[1] = pt[0]; PolyBezierTo(dc, pt, 3); break; } } else { if (Method==0) { pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y)-Image->MarginY; MoveToEx(dc, pt[2].x, pt[2].y, NULL); } else { pd = (TWAPointData *)PointList->First(); pt[2].x = Image->BitmapToCanvasX(pd->Pos.x); pt[2].y = Image->BitmapToCanvasY(pd->Pos.y)-Image->MarginY; MoveToEx(dc, pt[2].x, pt[2].y, NULL); } if (PointList->Count>1) { for (i=1; i<=PointList->Count-1; i++) { pd = (TWAPointData *)PointList->Items[i]; if (pd->Curve) { pt[2].x = Image->BitmapToCanvasX(pd->Apex.x); pt[2].y = Image->BitmapToCanvasY(pd->Apex.y)-Image->MarginY; if (Method==i) { pt[0].x = Image->BitmapToCanvasX(First.x); pt[0].y = Image->BitmapToCanvasY(First.y)-Image->MarginY; pt[1] = pt[0]; PolyBezierTo(dc, pt, 3); } else { pt[0].x = Image->BitmapToCanvasX(pd->Pos.x); pt[0].y = Image->BitmapToCanvasY(pd->Pos.y)-Image->MarginY; pt[1] = pt[0]; PolyBezierTo(dc, pt, 3); } } else { if (Method==i) { pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y)-Image->MarginY; LineTo(dc, pt[2].x, pt[2].y); } else { pt[2].x = Image->BitmapToCanvasX(pd->Pos.x); pt[2].y = Image->BitmapToCanvasY(pd->Pos.y)-Image->MarginY; LineTo(dc, pt[2].x, pt[2].y); } } } } if (Method==0) { pt[2].x = Image->BitmapToCanvasX(First.x); pt[2].y = Image->BitmapToCanvasY(First.y)-Image->MarginY; LineTo(dc, pt[2].x, pt[2].y); } else { pd = (TWAPointData *)PointList->First(); pt[2].x = Image->BitmapToCanvasX(pd->Pos.x); pt[2].y = Image->BitmapToCanvasY(pd->Pos.y)-Image->MarginY; LineTo(dc, pt[2].x, pt[2].y); } } SelectObject(dc, hOldPen); DeleteObject(hPen); SetBkColor(dc, clOldBk); SelectObject(dc, hOldBrush); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::WADraw(int m) { BEGIN_LOG(""); if (Item==WI_IRREGULAR) Method = m; #if defined(TEXSTYLIST) TPItemImage *Image=MainImageForm->iMainImage; double ratio=Image->ZoomOut/Image->ZoomIn; int minx,miny,maxx,maxy; TWAPointData *pd; minx=maxx=Second.x; miny=maxy=Second.y; for (int i=0; iCount; i++) { pd = (TWAPointData *)PointList->Items[i]; //=================== 2001.3.27. lhskys C++Builder 5 ¿¡¼­ int Ãß°¡... minx=min(minx,(int)pd->Pos.x); maxx=max(maxx,(int)pd->Pos.x); miny=min(miny,(int)pd->Pos.y); maxy=max(maxy,(int)pd->Pos.y); minx=min(minx,(int)pd->Apex.x); maxx=max(maxx,(int)pd->Apex.x); miny=min(miny,(int)pd->Apex.y); maxy=max(maxy,(int)pd->Apex.y); } minx=min(minx,(int)First.x); maxx=max(maxx,(int)First.x); miny=min(miny,(int)First.y); maxy=max(maxy,(int)First.y); //============================================== static RECT oldrc=Rect(minx-ratio*1-1,miny-ratio*1-1,maxx+ratio*1+1,maxy+ratio*1+1); if (Image->Reflection){ RECT rt; if (MainImageForm->reflection->ChangeRectPaintRange(oldrc, rt)){ MainImageForm->iMainImage->RectPaint(rt); } } else { MainImageForm->iMainImage->RectPaint(oldrc, true); } oldrc=Rect(minx-ratio*1-1,miny-ratio*1-1,maxx+ratio*1+1,maxy+ratio*1+1); #else MainImageForm->iMainImage->Invalidate(); #endif END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::RectangleMouseDown(TMouseButton Button, 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){ END_LOG; return; } } POINT snapped_point = FullViewForm->getSnappedPoint(X, Y);//ÀåÁø¸¸ if (Button==mbLeft) { if (Step>0) { Second = snapped_point;//ÀåÁø¸¸ if(MainImageForm->sbSnapGrid->Down){ if(First.x > Second.x) First.x -= 1; else Second.x -= 1; if(First.y > Second.y) First.y -= 1; else Second.y -= 1; } SetBitmapRegion(); MainImageForm->iMainImage->Invalidate(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); MainImageForm->TempLabel->Visible = false; Step = 0; ShowWorkAreaSize(); } else { MainImageForm->WorkArea->PushUndo(); //ÁÖ¼®À» ÇØ¾ßÇϴ°ÇÁö ¾ÈÇÏ´Â°Ô ¸Â´Â°ÇÁö ¾ÆÁ÷ ¸ð¸§ ÁÖÀÇ! MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method if (WindowForm){ if (WindowForm->rbSet->Checked){ ResetBitmapRegion(); } } else ResetBitmapRegion(); First = Point(snapped_point.x, snapped_point.y); Second = First; MainImageForm->TempLabel->Visible = true; Step = 11; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::RectangleMouseMove(int X, int Y) { BEGIN_LOG(""); String str; int lx, ly, sx, sy, dx, dy; TSize size; 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){ END_LOG; return; } } bool firstx = false, firsty = false; POINT snapped_point = FullViewForm->getSnappedPoint(X, Y);//ÀåÁø¸¸ if (Step>0) { Second = snapped_point;//ÀåÁø¸¸ if(MainImageForm->sbSnapGrid->Down){ if(First.x > Second.x){ First.x -= 1; firstx = true; } else Second.x -= 1; if(First.y > Second.y){ First.y -= 1; firsty = true; } else Second.y -= 1; } dx = First.x - Second.x; dy = First.y - Second.y; str = returnSize(abs(dx), abs(dy)); if (WindowForm) WindowForm->lbShape->Caption = String(IDS_COMMON_SIZE) + " : " + str + " " + String(MainImageForm->UnitName()); MainImageForm->TempLabel->Caption = str; lx = Second.x-First.x; ly = Second.y-First.y; size.cx = MainImageForm->TempLabel->Width; size.cy = MainImageForm->TempLabel->Height; sx = MainImageForm->iMainImage->BitmapToCanvasX(Second.x); sy = MainImageForm->iMainImage->BitmapToCanvasY(Second.y); if (ly>0) { //ÀÛ¾÷±¸¿ª sizeÇ¥½Ã À§Ä¡ º¯°æ sy = sy+5; if(Second.y + size.cy > MainImageForm->iMainImage->uBitmap->Height){ sy = MainImageForm->iMainImage->BitmapToCanvasY(Second.y); sy = sy-5-size.cy; } } else { sy = sy-5-size.cy; if(sy < 0){ sy = MainImageForm->iMainImage->BitmapToCanvasY(Second.y); sy = sy+5; } } if (lx>0){ sx = sx+5; if(Second.x + size.cx > MainImageForm->iMainImage->uBitmap->Width){ sx = MainImageForm->iMainImage->BitmapToCanvasX(Second.x); sx = sx-5-size.cx; } }else { sx = sx-5-size.cx; if(sx < 0){ sx = MainImageForm->iMainImage->BitmapToCanvasX(Second.x); sx = sx+5; } } MainImageForm->TempLabel->Left = sx; MainImageForm->TempLabel->Top = sy; WADraw(0); } if(firstx == true) First.x += 1; if(firsty == true) First.y += 1; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::ResetPointList() { TWAPointData *pd; while (PointList->Count>0) { pd = (TWAPointData *)PointList->Last(); PointList->Remove(pd); delete pd; } bDeleteLastPoint = false; if (WindowForm){ WindowForm->sbIrreClose->Enabled = false; WindowForm->sbIrreDelete->Enabled = false; } } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::PushPointList(bool curve, TPoint pos, TPoint apex) { TWAPointData *pd; RECT rtPointListOutLine, rtLastPointIncludeOutLine; if ((pd = new TWAPointData)==NULL) return false; pd->Curve = curve; pd->Pos = pos; pd->Apex = apex; PointList->Add(pd); return true; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::PopPointList() { TWAPointData *pd; pd = (TWAPointData *)PointList->Last(); PointList->Remove(pd); delete pd; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::StatusIrregular() { if (Item==WI_IRREGULAR) { if (WindowForm){ WindowForm->sbIrreDelete->Enabled = PointList->Count>0; WindowForm->sbIrreClose->Enabled = PointList->Count>2; } bDeleteLastPoint = PointList->Count > 0; } } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::IrregularMouseDown(TMouseButton Button, 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){ END_LOG; return; } } TRect r; double length; //lhskys ±æÀ̸¦ ÀÌ¿ëÇϱâ À§Çؼ­ double dx,dy,lx,ly; //lhskys x,yÀÇ º¯È­·® if (Button==mbLeft) { if (Step>0) { if (WindowForm && WindowForm->cbIrreCurve->Checked) { if (Step==23) { Second = Point(X, Y); PushPointList(true, First, Second); if (WindowForm) WindowForm->cbIrreCurve->Enabled = true; Step = 22; Second=First; //lhskys °î¼±¿¡¼­ first ¿Í second ÀÇ ÀÚ¸®¹Ù²Þ } else { First = Point(X, Y); if (WindowForm)WindowForm->cbIrreCurve->Enabled = false; Step = 23; } } else { if(Item==WI_IRREGULAR && pressZ==1){ //lhskys zŰ Ŭ¸¯ int x1,x2,y1,y2; // °¢µµ üũ x1=X; // ¹× x2=Second.x; // ±×¸®±â y1=Y; y2=Second.y; if((y2-y1>=x2-x1)&&(y2-y1>=x1-x2)) X=Second.x; if((y2-y1>=x2-x1)&&(y2-y1<=x1-x2)) Y=Second.y; if((y2-y1<=x2-x1)&&(y2-y1>=x1-x2)) // y = x ±âÁØÀ¸·Î Y=Second.y; if((y2-y1<=x2-x1)&&(y2-y1<=x1-x2)) X=Second.x; pressZ=0; } First = Point(X, Y); Second = First; PushPointList(false, First, Second); Step = 21; } } else { MainImageForm->WorkArea->PushUndo(); MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method if (WindowForm){ if (WindowForm->rbSet->Checked){ ResetBitmapRegion(); } } else ResetBitmapRegion(); First = Point(X, Y); Second = First; StatusItem(); PushPointList(false, First, Second); if (WindowForm) WindowForm->cbIrreCurve->Enabled = true; Step = 21; } StatusIrregular(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::IrregularMouseMove(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){ END_LOG; return; } } if (Step>0) { if (Shift.Contains(ssLeft)) { if (WindowForm && WindowForm->cbIrreCurve->Checked==false) { First = Point(X,Y); //lhskys if ((abs(First.x-Second.x)+ abs(First.y-Second.y)>6) && pressZ != 1) { PushPointList(false, Second, First); //lhskys Second, FirstÀ§Ä¡±³È¯ WADraw(-1); Second = First; } } else if (!WindowForm){ First = Point(X,Y); //lhskys if ((abs(First.x-Second.x)+ abs(First.y-Second.y)>6) && pressZ != 1) { PushPointList(false, Second, First); //lhskys Second, FirstÀ§Ä¡±³È¯ WADraw(-1); Second = First; } } } else { if (Step==23) { Second = Point(X, Y); //°î¼± WADraw(-4); } else { First = Point(X, Y); WADraw(-2); } if (Step==21) Step = 22; } } StatusIrregular(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::IrregularMouseUp(TShiftState Shift, int X, int Y) { } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::StatusOutline() { BEGIN_LOG(""); bool b = false; if (Item==WI_OUTLINE && SubItem==WSI_SURFACEMULTI) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel!=8) { if (WindowForm)WindowForm->bnRun->Enabled = bMagicPosition; if (bMagicPosition && WindowForm) { switch (MainImageForm->CurrentUnit) { case uDot: WindowForm->lbMagicPosition->Caption = Format("%d x %d", OPENARRAY(TVarRec, ((int)First.x, (int)First.y))); break; case uInch: WindowForm->lbMagicPosition->Caption = Format("%.2f x %.2f", OPENARRAY(TVarRec, ((double)First.x/MainImageForm->CanvasInfor.DotsPerInch, (double)First.y/MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm: WindowForm->lbMagicPosition->Caption = Format("%.2f x %.2f", OPENARRAY(TVarRec, (2.54*First.x/MainImageForm->CanvasInfor.DotsPerInch, 2.54*First.y/MainImageForm->CanvasInfor.DotsPerInch))); break; } if (WindowForm) WindowForm->spMagic->Brush->Color = (TColor) FillColor; } } } else { b = false; if (WindowForm) WindowForm->cbSurfaceMulti->Enabled = false; } if (Item==WI_OUTLINE) { b = WindowForm->cbSurfaceMulti->Checked==false; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (SubItem == WSI_SURFACESINGLE) { WindowForm->rzpnlSimilar->Top = WindowForm->Panel->Height; WindowForm->ClientHeight = WindowForm->rzpnlSimilar->Top+WindowForm->rzpnlSimilar->Height; WindowForm->rzpnlSimilar->BringToFront(); } else if (SubItem == WSI_SURFACEMULTI) { if (WindowForm) WindowForm->cbSurfaceMulti->Enabled = true; WindowForm->rzpnlSimilar->Top = WindowForm->Panel->Height;//+WindowForm->pnUndo->Height+4; WindowForm->pnOutline->Top = WindowForm->Panel->Height+WindowForm->rzpnlSimilar->Height; WindowForm->ClientHeight = WindowForm->pnOutline->Top+WindowForm->pnOutline->Height; WindowForm->rzpnlSimilar->BringToFront(); } else if (SubItem == WSI_BORDER) { WindowForm->ClientHeight = WindowForm->Panel->Top+WindowForm->Panel->Height; WindowForm->rzpnlSimilar->BringToFront(); } } else if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 24) { if (SubItem == WSI_SURFACESINGLE) { WindowForm->rzpnlSimilar->Top = WindowForm->Panel->Height; WindowForm->ClientHeight = WindowForm->rzpnlSimilar->Top+WindowForm->rzpnlSimilar->Height; WindowForm->rzpnlSimilar->BringToFront(); } else if (SubItem == WSI_SURFACEMULTI) { WindowForm->rzpnlSimilar->Top = WindowForm->Panel->Height;//+WindowForm->pnUndo->Height+4; WindowForm->pnOutline->Top = WindowForm->Panel->Height+WindowForm->rzpnlSimilar->Height; WindowForm->ClientHeight = WindowForm->pnOutline->Top+WindowForm->pnOutline->Height; WindowForm->rzpnlSimilar->BringToFront(); } else if (SubItem == WSI_BORDER) { WindowForm->ClientHeight = WindowForm->Panel->Top+WindowForm->Panel->Height; WindowForm->rzpnlSimilar->BringToFront(); } } } if (WindowForm){ WindowForm->csSurfaceMulti->Enabled = b; WindowForm->sbSurfaceMultiNew->Enabled = b; WindowForm->sbSurfaceMultiAll->Enabled = b; WindowForm->sbSurfaceMultiOne->Enabled = b; WindowForm->sbSurfaceMultiDelete->Enabled = b; WindowForm->sbSurfaceMultiBefore->Enabled = b; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::OutlineMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); bool bReflection = false; 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){ END_LOG; return; } bReflection = true; } RECT r; int ix, iy; TUnionBitmap *tb; // convert by celberus Byte *bp; switch (SubItem) { case WSI_SURFACEMULTI: if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==24 || WindowForm && WindowForm->cbSurfaceMulti->Checked) { if (Button==mbLeft) { MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method MainImageForm->WorkArea->PushUndo(); if (WindowForm){ if (WindowForm->rbSet->Checked) ResetBitmapRegion(); } else ResetBitmapRegion(); First.x = X; First.y = Y; SetBitmapRegion(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); } } else { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { if (WindowForm){ tb = MainImageForm->iMainImage->uBitmap; if (WindowForm->sbSurfaceMultiOne->Down) { POINT pt; if (bReflection) pt = MainImageForm->reflection->FindOriginalPos(X, Y); else { pt.x = X; pt.y = Y; } if (WindowForm->sbSurfaceMultiDelete->Down) { WindowForm->csSurfaceMulti->DeleteColor(tb->GetPixelColor(pt.x, pt.y)); } else { WindowForm->csSurfaceMulti->AddColor(tb->GetPixelColor(pt.x, pt.y)); } } else { if (Step>0) { 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 (bReflection){ POINT ptl, ptr; ptl = MainImageForm->reflection->FindOriginalPos(r.left, r.top); ptr = MainImageForm->reflection->FindOriginalPos(r.right, r.bottom); r.left = min(ptl.x, ptr.x); r.top = min(ptl.y, ptr.y); r.right = max(ptl.x, ptr.x); r.bottom = max(ptl.y, ptr.y); } if (tb->StartScanLine()) { if (WindowForm->sbSurfaceMultiDelete->Down) { for (iy=r.top; iyGetScanLine(iy); for (ix=r.left; ixcsSurfaceMulti->DeleteColor(*(bp+ix)); } } } else { for (iy=r.top; iyGetScanLine(iy); for (ix=r.left; ixcsSurfaceMulti->AddColor(*(bp+ix)); } } } tb->StopScanLine(); } else { SAVE_EXCEPTION(EC_MEMORY_LACK); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return;} Step = 0; isDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } else { Temp.left = Temp.top = X; Temp.top = Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); isDraw = true; Step = 11; } } } } } break; case WSI_SURFACESINGLE: if (Button==mbLeft) { MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method MainImageForm->WorkArea->PushUndo(); if (WindowForm && WindowForm->rbSet->Checked) ResetBitmapRegion(); First.x = X; First.y = Y; SetBitmapRegion(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); } break; case WSI_BORDER: if (Button==mbLeft) { if (Step>0) { maneupdate = true; if (WindowForm && WindowForm->rbSet->Checked) ResetBitmapRegion(); Second.x = X; Second.y = Y; SetBitmapRegion(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); Step = 0; } else { MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method MainImageForm->WorkArea->PushUndo(); if(WindowForm && WindowForm->rbSet->Checked)ResetBitmapRegion(); First.x = X; First.y = Y; Step = 1; maneupdate = false; } } break; } ShowWorkAreaSize(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::OutlineMouseMove(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){ END_LOG; return; } } switch (SubItem) { case WSI_SURFACEMULTI: if (WindowForm && WindowForm->sbSurfaceMultiOne->Down==false) { if (Step>0) { if (isDraw) MainImageForm->DrawRectangleLocate(Temp); Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); isDraw = true; } } break; } END_LOG; } //--------------------------------------------------------------------------- COLORREF __fastcall TWorkAreaMenu::SearchColor(RGBQUAD *rgb, int n) { BEGIN_LOG(""); COLORREF nColor; int i; while (true) { nColor = rand()&0xFFFFFF; if (nColor==0) continue; for (i=0; i<256; i++) { if (nColor==RGB(rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue)) break; } if (i>=256) { rgb[n].rgbRed = GetRValue(nColor); rgb[n].rgbGreen = GetGValue(nColor); rgb[n].rgbBlue = GetBValue(nColor); break; } } END_LOG; return nColor; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::SetBitmapRegion() { BEGIN_LOG(""); TCursor cursor; TPItemImage *Image; pBITMAPHANDLE bh; RGNXFORM XForm; HRGN rgnSrc, rgnDst; HDC dc; TWAPointData *pd; TPoint pt[3]; int i; int diff = abs(First.x-Second.x) - abs(First.y-Second.y); RECT rc; bool sw = false; XFORM xForm; DWORD dwSize; double r, h, l, s; RGBQUAD rgb; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; TPException ec = EC_NONE; TPoint size; BITMAPHANDLE *temp; TTexpiaBitmap *tMaskBitmap = NULL; if((Image = MainImageForm->iMainImage) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if((bh = Image->uBitmap->RgnBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} // convert by celberus if (Image->Reflection == false){ size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; } else { size.x = MainImageForm->reflection->ScreenWidth; size.y = MainImageForm->reflection->ScreenHeight; } if ((tMaskBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!tMaskBitmap->Create(size.x, size.y, 1)); //goto fail; //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; switch (Item) { case WI_SHAPE: if (SubItem==WSI_CIRCLE||SubItem==WSI_SQUARE){ //by jeegeo if (diff > 0) { if (First.x>Second.x) { Second.x+=diff; } else { Second.x-=diff; } } else { if (First.y>Second.y) { Second.y-=diff; } else { Second.y+=diff; } } } rc.left = min(First.x, Second.x); rc.top = min(First.y, Second.y); rc.right = max(First.x, Second.x)+1;//ÀåÁø¸¸: +1ÀÌ ¿ÖÇÊ¿äÇÑÁö? rc.bottom = max(First.y, Second.y)+1; if (SubItem==WSI_ELLIPSE||SubItem==WSI_CIRCLE) { //by jeegeo if (L_BitmapHasRgn(bh)) { if (WindowForm && WindowForm->rbSubtraction->Checked) { if(L_SetBitmapRgnEllipse(bh, &XForm, &rc, L_RGN_ANDNOTRGN) != SUCCESS) goto fail; } else { if(L_SetBitmapRgnEllipse(bh, &XForm, &rc, L_RGN_OR) != SUCCESS) goto fail; } } else { if(L_SetBitmapRgnEllipse(bh, &XForm, &rc, L_RGN_SET) != SUCCESS) goto fail; } } else { if (L_BitmapHasRgn(bh)) { if (WindowForm && WindowForm->rbSubtraction->Checked) { if(L_SetBitmapRgnRect(bh, &XForm, &rc, L_RGN_ANDNOTRGN) != SUCCESS) goto fail; } else { if(L_SetBitmapRgnRect(bh, &XForm, &rc, L_RGN_OR) != SUCCESS) goto fail; } } else { if(L_SetBitmapRgnRect(bh, &XForm, &rc, L_RGN_SET) != SUCCESS) goto fail; } } sw = true; break; case WI_IRREGULAR: if((hWnd = MainForm->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if((dc = GetDC(hWnd)) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} // shin 070327 Vista¿¡¼­ GetDC(NULL)ÇÏ¸é ¾ÈµÊ. (¾Æ¹« DC³ª ¸¸µé¾îÁÖ¸é µÊ) if (dc) { BeginPath(dc); if((pd = (TWAPointData *)PointList->First()) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(pd->Pos.x < 0) pd->Pos.x = 0; if(pd->Pos.y < 0) pd->Pos.y = 0; pt[2].x = pd->Pos.x; pt[2].y = pd->Pos.y; MoveToEx(dc, pt[2].x, pt[2].y, NULL); if (PointList->Count>1) { for (i=1; i<=PointList->Count-1; i++) { if((pd = (TWAPointData *)PointList->Items[i]) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(pd->Pos.x < 0) pd->Pos.x = 0; if(pd->Pos.y < 0) pd->Pos.y = 0; pt[2].x = pd->Pos.x; pt[2].y = pd->Pos.y; if (pd->Curve) { if(pd->Apex.x < 0) pd->Apex.x = 0; if(pd->Apex.y < 0) pd->Apex.y = 0; pt[0].x = pd->Apex.x; pt[0].y = pd->Apex.y; pt[1] = pt[0]; PolyBezierTo(dc, pt, 3); } else { LineTo(dc, pt[2].x, pt[2].y); } } } CloseFigure(dc); EndPath(dc); rgnSrc = PathToRegion(dc); ReleaseDC(0, dc); if (L_BitmapHasRgn(bh)) { if (WindowForm && WindowForm->rbSubtraction->Checked) { if(L_SetBitmapRgnHandle(bh, &XForm, rgnSrc, L_RGN_ANDNOTRGN) != SUCCESS) goto fail; } else { if(L_SetBitmapRgnHandle(bh, &XForm, rgnSrc, L_RGN_OR) != SUCCESS) goto fail; } } else { if(L_SetBitmapRgnHandle(bh, &XForm, rgnSrc, L_RGN_SET) != SUCCESS) goto fail; } DeleteObject(rgnSrc); sw = true; } break; case WI_OUTLINE: xForm.eM11 = 1.0F; xForm.eM12 = 0.0F; xForm.eM21 = 0.0F; xForm.eM22 = 1.0F; xForm.eDx = 0.0F; xForm.eDy = 0.0F; switch (SubItem) { case WSI_SURFACEMULTI: if (WindowForm){ if (Image->uBitmap->BitsPerPixel==8) { if(WindowForm && !WindowForm->Similar->Checked) rgnDst = Fill(Image, First, SurfaceFillRead8Multi); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { bool multi = SimilarMultiMask(Image, First, tMaskBitmap); //by bomchun multi°ªÀÌ false·Î ³ª¿À¸é ¸¶½ºÅ©ºñÆ®¸Ê Àç´ë·Î ¾È³ª¿Â°ÍÀ̹ǷΠÀûÀýÈ÷ 󸮿äÇÔ if(!multi) { if (sw) { if(L_GetBitmapRgnHandle(bh, &XForm, &rgnDst) < 1) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} MainImageForm->WorkArea->SetMask(rgnDst); DeleteObject(rgnDst); Image->OutlineBitmapRgn(MainImageForm->WorkArea->bComplex); Image->Repaint(); if (WindowForm->rbSet->Checked==false) { Number++; if (Number>=999) { MessageDlg(IDS_MESSAGE_NOSETWINDOW, mtInformation, TMsgDlgButtons() << mbYes, 0); WindowForm->rbSet->Checked = true; Number = 0; } } else { Number = 1; } StatusItem(); } Screen->Cursor = cursor; if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } END_LOG; return; } if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked && multi) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked && multi) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked && multi) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } else { if (Image->Reflection){ POINT pt = MainImageForm->reflection->FindOriginalPos(First.x, First.y); FillColor = Image->uBitmap->GetPixelColor(pt.x, pt.y); } else { FillColor = Image->uBitmap->GetPixelColor(First.x, First.y); } bMagicPosition = true; StatusOutline(); if (WindowForm && WindowForm->cbMagic->ItemIndex) { TColor2HLS((TColor)FillColor, h, l, s); r = 360*WindowForm->tbMagic->Position/200.0; FillHue[0] = h-r; FillHue[1] = h+r; r = WindowForm->tbMagic->Position/200.0; FillLig[0] = l-r; FillLig[1] = l+r; if (FillLig[0]<0) { FillLig[0] = 0.0; FillLig[1] = WindowForm->tbMagic->Position/100.0; } else if (FillLig[1]>1.0) { FillLig[0] = (100-WindowForm->tbMagic->Position)/100.0; FillLig[1] = 1.0; } FillSat[0] = s-r; FillSat[1] = s+r; if (FillSat[0]<0) { FillSat[0] = 0.0; FillSat[1] = WindowForm->tbMagic->Position/100.0; } else if (FillSat[1]>1.0) { FillSat[0] = (100-WindowForm->tbMagic->Position)/100.0; FillSat[1] = 1.0; } #if defined(TEXSTYLIST) if (Image->LayerMask) { //rgnDst = FillLayer(Image, First, MagicFillRead24HLSLayer); if(WindowForm && !WindowForm->Similar->Checked) rgnDst = FillLayer(Image, First, MagicFillRead24HLSLayer); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { HLSFullColorLayerSimilarMultiMask(Image, First, tMaskBitmap); if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } else { if(WindowForm && !WindowForm->Similar->Checked)rgnDst = Fill(Image, First, MagicFillRead24HLS); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { HLSFullColorSimilarMultiMask(Image, First, tMaskBitmap); if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } #else rgnDst = Fill(Image, First, MagicFillRead24HLS); #endif } else { rgb = TColorToRGB((TColor)FillColor); r = 255*WindowForm->tbMagic->Position/200; if (rgb.rgbRed-r<0) { FillRGB[0].rgbRed = 0; FillRGB[1].rgbRed = 255*WindowForm->tbMagic->Position/100; } else if (rgb.rgbRed+r>255) { FillRGB[0].rgbRed = 255*(100-WindowForm->tbMagic->Position)/100; FillRGB[1].rgbRed = 255; } else { FillRGB[0].rgbRed = rgb.rgbRed-r; FillRGB[1].rgbRed = rgb.rgbRed+r; } if (rgb.rgbGreen-r<0) { FillRGB[0].rgbGreen = 0; FillRGB[1].rgbGreen = 255*WindowForm->tbMagic->Position/100; } else if (rgb.rgbGreen+r>255) { FillRGB[0].rgbGreen = 255*(100-WindowForm->tbMagic->Position)/100; FillRGB[1].rgbGreen = 255; } else { FillRGB[0].rgbGreen = rgb.rgbGreen-r; FillRGB[1].rgbGreen = rgb.rgbGreen+r; } if (rgb.rgbBlue-r<0) { FillRGB[0].rgbBlue = 0; FillRGB[1].rgbBlue = 255*WindowForm->tbMagic->Position/100; } else if (rgb.rgbBlue+r>255) { FillRGB[0].rgbBlue = 255*(100-WindowForm->tbMagic->Position)/100; FillRGB[1].rgbBlue = 255; } else { FillRGB[0].rgbBlue = rgb.rgbBlue-r; FillRGB[1].rgbBlue = rgb.rgbBlue+r; } #if defined(TEXSTYLIST) if (Image->LayerMask) { //rgnDst = FillLayer(Image, First, MagicFillRead24RGBLayer); if(WindowForm && !WindowForm->Similar->Checked)rgnDst = FillLayer(Image, First, MagicFillRead24RGBLayer); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { FullColorLayerSimilarMultiMask(Image, First, tMaskBitmap); if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } else { //rgnDst = Fill(Image, First, MagicFillRead24RGB); if(WindowForm && !WindowForm->Similar->Checked)rgnDst = Fill(Image, First, MagicFillRead24RGB); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { FullColorSimilarMultiMask(Image, First, tMaskBitmap); if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } #else rgnDst = Fill(Image, First, MagicFillRead24RGB); #endif } } } break; case WSI_SURFACESINGLE: if (Image->Reflection){ POINT pt = MainImageForm->reflection->FindOriginalPos(First.x, First.y); FillColor = Image->uBitmap->GetPixelColor(pt.x, pt.y); } else { FillColor = Image->uBitmap->GetPixelColor(First.x, First.y); } if (Image->uBitmap->BitsPerPixel==8) { if(WindowForm && !WindowForm->Similar->Checked)rgnDst = Fill(Image, First, SurfaceFillRead8Single); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { SimilarMask(Image, First, tMaskBitmap); if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } else { #if defined(TEXSTYLIST) if (Image->LayerMask) { if(WindowForm && !WindowForm->Similar->Checked)rgnDst = FillLayer(Image, First, SurfaceFillRead24Layer); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { FullColorLayerSimilarMask(Image, First, tMaskBitmap); if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } else { if(WindowForm && !WindowForm->Similar->Checked)rgnDst = Fill(Image, First, SurfaceFillRead24); //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) else { FullColorSimilarMask(Image, First, tMaskBitmap); if((temp = tMaskBitmap->Handle) == NULL) { ec = EC_RESOURCE_LACK ; SAVE_EXCEPTION(ec) ; goto fail;} if(WindowForm && WindowForm->rbSet->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_SET); else if(WindowForm && WindowForm->rbAddition->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_OR); else if(WindowForm && WindowForm->rbSubtraction->Checked) L_SetBitmapRgnFromMask(bh, &XForm, temp, L_RGN_ANDNOTRGN); if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } } } #else rgnDst = Fill(Image, First, SurfaceFillRead24); #endif } break; case WSI_BORDER: if (Image->Reflection){ POINT pt = MainImageForm->reflection->FindOriginalPos(Second.x, Second.y); FillColor = Image->uBitmap->GetPixelColor(pt.x, pt.y); } else { FillColor = Image->uBitmap->GetPixelColor(Second.x, Second.y); } if (Image->uBitmap->BitsPerPixel==8) { rgnDst = Fill(Image, First, BorderFillRead8); } else { rgnDst = Fill(Image, First, BorderFillRead24); // layer check°¡ ÇÊ¿ä¾øÀ» °Í °°½À´Ï´Ù.. } break; } // Similar°¡ üũµÇ¾î À־ WSI_BORDERÀÌ µÇµµ·Ï ¼öÁ¤ - by monkman (2010.05.12) if (L_BitmapHasRgn(bh) && WindowForm) { //by bomchun Similar ±â´É ‹š¹®¿¡ ¼öÁ¤ (2006.11.02) if (!WindowForm->Similar->Checked || SubItem == WSI_BORDER) { if (WindowForm->rbSubtraction->Checked) { if (L_SetBitmapRgnHandle(bh, &XForm, rgnDst, L_RGN_ANDNOTRGN) != SUCCESS) goto fail; } else { if (L_SetBitmapRgnHandle(bh, &XForm, rgnDst, L_RGN_OR) != SUCCESS) goto fail; } } } else if(WindowForm){ if (!WindowForm->Similar->Checked || SubItem == WSI_BORDER) { if (L_SetBitmapRgnHandle(bh, &XForm, rgnDst, L_RGN_SET) != SUCCESS) goto fail; } } DeleteObject(rgnDst); sw = true; break; } if (sw) { if (L_GetBitmapRgnHandle(bh, &XForm, &rgnDst) != SUCCESS) goto fail; MainImageForm->WorkArea->SetMask(rgnDst); DeleteObject(rgnDst); Image->OutlineBitmapRgn(MainImageForm->WorkArea->bComplex); Image->Repaint(); if (WindowForm && WindowForm->rbSet->Checked==false) { Number++; if (Number>=999) { MessageDlg(IDS_MESSAGE_NOSETWINDOW, mtInformation, TMsgDlgButtons() << mbYes, 0); WindowForm->rbSet->Checked = true; Number = 0; } } else { Number = 1; } StatusItem(); } Screen->Cursor = cursor; if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } END_LOG; return; fail: if(tMaskBitmap) { delete tMaskBitmap; tMaskBitmap = NULL; } if (rgnDst) DeleteObject(rgnDst); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- // externÀ¸·Î º¯°æ void ResetBitmapRegion() { BEGIN_LOG(""); pBITMAPHANDLE bh; RGNXFORM XForm; RECT rc; bh = MainImageForm->iMainImage->uBitmap->RgnBitmap->Handle; // convert by celberus if (L_BitmapHasRgn(bh)) { XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; L_GetBitmapRgnBounds(bh, &XForm, &rc); L_FreeBitmapRgn(bh); MainImageForm->WorkArea->SetMask(NULL); InvalidateRect(MainImageForm->iMainImage->Parent->Handle, &rc, false); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::MoveWorkArea(int nDirection) //by bomchun ÀÛ¾÷±¸¿ª ÁÂÇ¥À̵¿(2006.11.16) { BEGIN_LOG(""); RGNXFORM XForm; HRGN rgnDst; pBITMAPHANDLE bh; TPItemImage *Image; Image = MainImageForm->iMainImage; bh = Image->uBitmap->RgnBitmap->Handle; // convert by celberus XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; L_GetBitmapRgnHandle(bh, &XForm, &rgnDst); //------------------ if(nDirection == 0/*up*/) { XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = -1; } else if(nDirection == 1/*right*/) { XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 1; XForm.nYOffset = 0; } else if(nDirection == 2/*down*/) { XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 1; } else if(nDirection == 3/*left*/) { XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = -1; XForm.nYOffset = 0; } //------------------ L_SetBitmapRgnHandle(bh, &XForm, rgnDst, L_RGN_SET); XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; L_GetBitmapRgnHandle(bh, &XForm, &rgnDst); MainImageForm->WorkArea->SetMask(rgnDst); DeleteObject(rgnDst); Image->OutlineBitmapRgn(MainImageForm->WorkArea->bComplex); Image->Repaint(); if (WindowForm && WindowForm->rbSet->Checked==false) { Number++; if (Number>=999) { MessageDlg(IDS_MESSAGE_NOSETWINDOW, mtInformation, TMsgDlgButtons() << mbYes, 0); WindowForm->rbSet->Checked = true; Number = 0; } } else { Number = 1; } StatusItem(); END_LOG; } //*/ //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::SurfaceFillRead8Single(Byte *p, int x) { return *(p+x)==(Byte)FillColor; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::SurfaceFillRead8Multi(Byte *p, int x) { BEGIN_LOG(""); bool rtn = false; if (WindowForm){ rtn = WindowForm->csSurfaceMulti->Number[*(p+x)]csSurfaceMulti->Count; } END_LOG; return rtn; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::BorderFillRead8(Byte *p, int x) { return *(p+x)!=(Byte)FillColor; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::MagicFillRead24RGB(Byte *p, int x) { BEGIN_LOG(""); COLORREF c; RGBQUAD rgb; p += 3*x; GetPixel24(p, c); rgb = TColorToRGB((TColor)c); if (rgb.rgbRedFillRGB[1].rgbRed) { END_LOG; return false; } if (rgb.rgbGreenFillRGB[1].rgbGreen) { END_LOG; return false; } if (rgb.rgbBlueFillRGB[1].rgbBlue) { END_LOG; return false; } END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::MagicFillRead24HLS(Byte *p, int x) { BEGIN_LOG(""); COLORREF c; THLS hls; p += 3*x; GetPixel24(p, c); TColor2HLS((TColor)c, hls.Hue, hls.Lig, hls.Sat); if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) { END_LOG; return false; } } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) { END_LOG; return false; } } else { if (hls.HueFillHue[1]) { END_LOG; return false; } } } if (hls.LigFillLig[1]) { END_LOG; return false; } if (hls.SatFillSat[1]) { END_LOG; return false; } END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::SurfaceFillRead24(Byte *p, int x) { BEGIN_LOG(""); COLORREF c; p += 3*x; GetPixel24(p, c); END_LOG; return c==FillColor; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::BorderFillRead24(Byte *p, int x) { BEGIN_LOG(""); COLORREF c; p += 3*x; GetPixel24(p, c); END_LOG; return c!=FillColor; } //--------------------------------------------------------------------------- HRGN __fastcall TWorkAreaMenu::Fill(TPItemImage *Image, const TPoint start, TWindowFillRead read) { BEGIN_LOG(""); HRGN hRgn = NULL; TPBitmap *FillMask = NULL; int x, y, savex, savey, xr, xl, i, j; TPoint size, now, *sp; TList *stack = NULL, *rcList = NULL; RECT rcTemp, *lpRect; Byte *p, *m; TPException ec = EC_NONE; int posx = 0, posy = 0, width = 0, height = 0; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; if ((rcList = new TList)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((stack = new TList)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; if ((FillMask = new TPBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!FillMask->Create(size.x, size.y, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TPDEBUG if (!FillMask->Lock()) SHOWDEBUG; #else FillMask->Lock(); #endif FillMask->Fill(0); if (bReflection == false){ stack->Add(new TPoint(start)); } else { POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; stack->Add(new TPoint(pt)); } if (!Image->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } while (stack->Count) { sp = (TPoint *)stack->Last(); stack->Remove(sp); x = sp->x; y = sp->y; delete sp; p = Image->uBitmap->GetScanLine(y); m = FillMask->ScanLine(y); *(m+(x>>3)) |= 0x80>>(x&7); savex = x; while (1) { x++; if (x>3))&(0x80>>(x&7)))==0 && read(p, x)) *(m+(x>>3)) |= 0x80>>(x&7); else break; } xr = x-1; x = savex; while (1) { x--; if (x>=posx && (*(m+(x>>3))&(0x80>>(x&7)))==0 && read(p, x)) *(m+(x>>3)) |= 0x80>>(x&7); else break; } xl = x+1; if (bReflection == false){ rcTemp = Rect(xl, y, xr+1, y+1); } else { int rx = 0, ry = 0, lx = 0, ly = 0; lx = xl; ly = y; rx = xr + 1; ry = y + 1; if (lx < posx) lx = posx; if (lx >= width + posx) lx = posx + width - 1; if (ly < posy) ly = posy; if (ly >= height + posy) ly = posy + height - 1; if (rx < posx) rx = posx; if (rx >= width + posx) rx = posx + width - 1; if (ry < posy) ry = posy; if (ry >= height + posy) ry = posy + height - 1; rcTemp = Rect(lx, ly, rx, ry); } for (j=0; jCount; j++) { lpRect = (RECT *)rcList->Items[j]; if (lpRect->top==rcTemp.bottom) { if (lpRect->left==rcTemp.left && lpRect->right==rcTemp.right) { lpRect->top = rcTemp.top; break; } } else if (lpRect->bottom==rcTemp.top) { if (lpRect->left==rcTemp.left && lpRect->right==rcTemp.right) { lpRect->bottom = rcTemp.bottom; break; } } if (lpRect->left==rcTemp.right) { if (lpRect->top==rcTemp.top && lpRect->bottom==rcTemp.bottom) { lpRect->left = rcTemp.left; break; } } else if (lpRect->right==rcTemp.left) { if (lpRect->top==rcTemp.top && lpRect->bottom==rcTemp.bottom) { lpRect->right = rcTemp.right; break; } } } if (j>=rcList->Count) { rcList->Add(new TRect(rcTemp)); } x = xl; savey = y; y++; if (yuBitmap->GetScanLine(y); m = FillMask->ScanLine(y); if (y>3))&(0x80>>(x&7))) || read(p, x)==false) x++; else { while (1) { if (x<=xr) { if ((*(m+(x>>3))&(0x80>>(x&7)))==0 && read(p, x)) x++; else { now.x = x-1; x++; break; } } else { now.x = x-1; break; } } now.y = y; stack->Add(new TPoint(now)); } } } x = xl; } y = savey; y--; if (y>=posy) { p = Image->uBitmap->GetScanLine(y); m = FillMask->ScanLine(y); if (y>=posy) { while (x<=xr) { if ((*(m+(x>>3))&(0x80>>(x&7))) || read(p, x)==false) x++; else { while (1) { if (x<=xr) { if ((*(m+(x>>3))&(0x80>>(x&7)))==0 && read(p, x)) x++; else { now.x = x-1; x++; break; } } else { now.x = x-1; break; } } now.y = y; stack->Add(new TPoint(now)); } } } } } if (FillMask){ delete FillMask; FillMask = NULL; } Image->uBitmap->StopScanLine(); if (bReflection == false){ while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx + add, lpRect->top - posy, lpRect->right - posx + add, lpRect->bottom - posy )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx, lpRect->top - posy + add, lpRect->right - posx, lpRect->bottom - posy + add )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, width - (lpRect->left - posx), lpRect->top - posy, width - (lpRect->right - posx), lpRect->bottom - posy )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else { while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx + width, lpRect->top - posy, lpRect->right - posx + width, lpRect->bottom - posy )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx, height - (lpRect->top - posy), lpRect->right - posx, height - (lpRect->bottom - posy) )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else { while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx, lpRect->top - posy + height, lpRect->right - posx, lpRect->bottom - posy + height )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } } */ } delete stack; stack = NULL; delete rcList; END_LOG; return hRgn; fail: if (FillMask) delete FillMask; if (stack) delete stack; if (hRgn) DeleteObject(hRgn); if (rcList) { while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); rcList->Remove(lpRect); delete lpRect; } delete rcList; } EXCEPTION_MESSAGE_OK(ec); END_LOG; return NULL; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::SimilarMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) BEGIN_LOG(""); Byte TargetColor; Byte *uBitmapHeightLine,*MaskHeightLine, *temp; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; POINT st; int posx = 0, posy = 0, width = 0, height = 0; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } if (!Image->uBitmap->StartScanLine()); if (!MaskBitmap->StartScanLine()) ; temp = Image->uBitmap->GetScanLine(st.y); TargetColor = *(temp + st.x); if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { if(*(uBitmapHeightLine + x) == TargetColor) *(MaskHeightLine + x/8) |= (0x80>>x%8); else *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if(*(uBitmapHeightLine + x) == TargetColor){ *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); } else { *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { if(*(uBitmapHeightLine + x) == TargetColor){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if(*(uBitmapHeightLine + x) == TargetColor){ *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); } else { *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if(*(uBitmapHeightLine + x) == TargetColor){ *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); } else { *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if(*(uBitmapHeightLine + x) == TargetColor){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { if(*(uBitmapHeightLine + x) == TargetColor){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+height); } } } */ } Image->uBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::FullColorSimilarMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) BEGIN_LOG(""); Byte R,G,B; Byte *uBitmapHeightLine,*MaskHeightLine, *temp; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; POINT st; int posx = 0, posy = 0, width = 0, height = 0; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } if (!Image->uBitmap->StartScanLine());// goto fail; if (!MaskBitmap->StartScanLine()) ;//goto fail; temp = Image->uBitmap->GetScanLine(st.y); R = *(temp + st.x * 3); G = *(temp + st.x * 3 + 1); B = *(temp + st.x * 3 + 2); if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { if( (*(uBitmapHeightLine + x*3) == R) && (*(uBitmapHeightLine + x*3 + 1) == G) && (*(uBitmapHeightLine + x*3 + 2) == B)) *(MaskHeightLine + x/8) |= (0x80>>x%8); else *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(uBitmapHeightLine + x*3) == R) && (*(uBitmapHeightLine + x*3 + 1) == G) && (*(uBitmapHeightLine + x*3 + 2) == B)){ *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); } else { *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(uBitmapHeightLine + x*3) == R) && (*(uBitmapHeightLine + x*3 + 1) == G) && (*(uBitmapHeightLine + x*3 + 2) == B)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(uBitmapHeightLine + x*3) == R) && (*(uBitmapHeightLine + x*3 + 1) == G) && (*(uBitmapHeightLine + x*3 + 2) == B)){ *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); } else { *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(uBitmapHeightLine + x*3) == R) && (*(uBitmapHeightLine + x*3 + 1) == G) && (*(uBitmapHeightLine + x*3 + 2) == B)){ *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); } else { *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(uBitmapHeightLine + x*3) == R) && (*(uBitmapHeightLine + x*3 + 1) == G) && (*(uBitmapHeightLine + x*3 + 2) == B)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(uBitmapHeightLine + x*3) == R) && (*(uBitmapHeightLine + x*3 + 1) == G) && (*(uBitmapHeightLine + x*3 + 2) == B)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+height); } } } */ } Image->uBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::FullColorLayerSimilarMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) BEGIN_LOG(""); Byte R,G,B; Byte *LayerBitmapHeightLine,*MaskHeightLine, *temp; TPLayer *lay=(TPLayer *) MainImageForm->iMainImage->LayerList->Items[MainImageForm->iMainImage->Index]; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; POINT st; int posx = 0, posy = 0, width = 0, height = 0; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } if (!lay->LBitmap->StartScanLine());// goto fail; if (!MaskBitmap->StartScanLine()) ;//goto fail; temp = lay->LBitmap->GetScanLine(st.y); R = *(temp + st.x * 3); G = *(temp + st.x * 3 + 1); B = *(temp + st.x * 3 + 2); if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { if( (*(LayerBitmapHeightLine + x*3) == R) && (*(LayerBitmapHeightLine + x*3 + 1) == G) && (*(LayerBitmapHeightLine + x*3 + 2) == B)) *(MaskHeightLine + x/8) |= (0x80>>x%8); else *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(LayerBitmapHeightLine + x*3) == R) && (*(LayerBitmapHeightLine + x*3 + 1) == G) && (*(LayerBitmapHeightLine + x*3 + 2) == B)) { *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); } else { *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(LayerBitmapHeightLine + x*3) == R) && (*(LayerBitmapHeightLine + x*3 + 1) == G) && (*(LayerBitmapHeightLine + x*3 + 2) == B)) { *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(LayerBitmapHeightLine + x*3) == R) && (*(LayerBitmapHeightLine + x*3 + 1) == G) && (*(LayerBitmapHeightLine + x*3 + 2) == B)) { *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); } else { *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(LayerBitmapHeightLine + x*3) == R) && (*(LayerBitmapHeightLine + x*3 + 1) == G) && (*(LayerBitmapHeightLine + x*3 + 2) == B)) { *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); } else { *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(LayerBitmapHeightLine + x*3) == R) && (*(LayerBitmapHeightLine + x*3 + 1) == G) && (*(LayerBitmapHeightLine + x*3 + 2) == B)) { *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { if( (*(LayerBitmapHeightLine + x*3) == R) && (*(LayerBitmapHeightLine + x*3 + 1) == G) && (*(LayerBitmapHeightLine + x*3 + 2) == B)) { *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+height); } } } */ } lay->LBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::SimilarMultiMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.06) BEGIN_LOG(""); bool flag; Byte TargetColor; Byte *uBitmapHeightLine,*MaskHeightLine, *temp; POINT st; int posx = 0, posy = 0, width = 0, height = 0; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } if (!Image->uBitmap->StartScanLine());// goto fail; if (!MaskBitmap->StartScanLine()) ;//goto fail; temp = Image->uBitmap->GetScanLine(st.y); TargetColor = *(temp + st.x); flag = false; for(int z = 0; z < WindowForm->csSurfaceMulti->ChoiceColor->Count; z++) { if(TargetColor == WindowForm->csSurfaceMulti->ChoiceColor->Code[z]) flag = true; } if(!flag) { Image->uBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return false; } if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { flag = false; for(int w = 0; w < WindowForm->csSurfaceMulti->ChoiceColor->Count; w++) { if(*(uBitmapHeightLine + x) == WindowForm->csSurfaceMulti->ChoiceColor->Code[w]) flag = true; } if(flag) *(MaskHeightLine + x/8) |= (0x80>>x%8); else *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { flag = false; for(int w = 0; w < WindowForm->csSurfaceMulti->ChoiceColor->Count; w++) { if(*(uBitmapHeightLine + x) == WindowForm->csSurfaceMulti->ChoiceColor->Code[w]) flag = true; } if(flag) *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); else *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { flag = false; for(int w = 0; w < WindowForm->csSurfaceMulti->ChoiceColor->Count; w++) { if(*(uBitmapHeightLine + x) == WindowForm->csSurfaceMulti->ChoiceColor->Code[w]) flag = true; } if(flag) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { flag = false; for(int w = 0; w < WindowForm->csSurfaceMulti->ChoiceColor->Count; w++) { if(*(uBitmapHeightLine + x) == WindowForm->csSurfaceMulti->ChoiceColor->Code[w]) flag = true; } if(flag) *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); else *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { flag = false; for(int w = 0; w < WindowForm->csSurfaceMulti->ChoiceColor->Count; w++) { if(*(uBitmapHeightLine + x) == WindowForm->csSurfaceMulti->ChoiceColor->Code[w]) flag = true; } if(flag) *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); else *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { flag = false; for(int w = 0; w < WindowForm->csSurfaceMulti->ChoiceColor->Count; w++) { if(*(uBitmapHeightLine + x) == WindowForm->csSurfaceMulti->ChoiceColor->Code[w]) flag = true; } if(flag) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { flag = false; for(int w = 0; w < WindowForm->csSurfaceMulti->ChoiceColor->Count; w++) { if(*(uBitmapHeightLine + x) == WindowForm->csSurfaceMulti->ChoiceColor->Code[w]) flag = true; } if(flag) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(j+height); } } } */ } Image->uBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::FullColorSimilarMultiMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) BEGIN_LOG(""); COLORREF c; RGBQUAD rgb; Byte *uBitmapHeightLine,*MaskHeightLine, *temp; POINT st; int posx = 0, posy = 0, width = 0, height = 0; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } if (!Image->uBitmap->StartScanLine());// goto fail; if (!MaskBitmap->StartScanLine());//goto fail; if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + x/8) |= (0x80>>x%8); } else { *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); } else { *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); } else { *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); } else { *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+height); } } } */ } Image->uBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::FullColorLayerSimilarMultiMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) BEGIN_LOG(""); TPoint size; COLORREF c; RGBQUAD rgb; Byte *LayerBitmapHeightLine,*MaskHeightLine, *temp; POINT st; int posx = 0, posy = 0, width = 0, height = 0; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } TPLayer *lay=(TPLayer *) MainImageForm->iMainImage->LayerList->Items[MainImageForm->iMainImage->Index]; if (!lay->LBitmap->StartScanLine());// goto fail; if (!MaskBitmap->StartScanLine());//goto fail; if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + x/8) |= (0x80>>x%8); } else { *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); } else { *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); } else { *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); } else { *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); if((rgb.rgbRed>=FillRGB[0].rgbRed && rgb.rgbRed<=FillRGB[1].rgbRed) && (rgb.rgbGreen>=FillRGB[0].rgbGreen && rgb.rgbGreen<=FillRGB[1].rgbGreen) && (rgb.rgbBlue>=FillRGB[0].rgbBlue && rgb.rgbBlue<=FillRGB[1].rgbBlue)){ *(MaskHeightLine + k/8) |= (0x80>>k%8); } else { *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } } MaskBitmap->PutScanLine(j+height); } } } */ } lay->LBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::HLSFullColorSimilarMultiMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) BEGIN_LOG(""); COLORREF c; RGBQUAD rgb; THLS hls; bool flag; Byte *uBitmapHeightLine,*MaskHeightLine, *temp; POINT st; int posx = 0, posy = 0, width = 0, height = 0; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } if (!Image->uBitmap->StartScanLine()); if (!MaskBitmap->StartScanLine()); if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + x/8) |= (0x80>>x%8); else *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); else *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); else *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); else *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { uBitmapHeightLine = Image->uBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(uBitmapHeightLine + x*3); rgb.rgbGreen = *(uBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(uBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(j+height); } } } */ } Image->uBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::HLSFullColorLayerSimilarMultiMask(TPItemImage *Image, const TPoint start, TTexpiaBitmap *MaskBitmap) { //by bomchun Similar ±â´É Ãß°¡ (2006.11.02) BEGIN_LOG(""); COLORREF c; RGBQUAD rgb; THLS hls; bool flag; Byte *LayerBitmapHeightLine,*MaskHeightLine, *temp; POINT st; int posx = 0, posy = 0, width = 0, height = 0; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; if (bReflection == false){ st.x = start.x; st.y = start.y; } else { posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); st.x = pt.x; st.y = pt.y; } TPLayer *lay=(TPLayer *) MainImageForm->iMainImage->LayerList->Items[MainImageForm->iMainImage->Index]; if (!lay->LBitmap->StartScanLine());// goto fail; if (!MaskBitmap->StartScanLine());//goto fail; if (bReflection == false){ TPoint size; size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; for(int y = 0; y < size.y; y++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(y); for(int x = 0; x < size.x; x++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + x/8) |= (0x80>>x%8); else *(MaskHeightLine + x/8) &= ~(0x80>>x%8); } MaskBitmap->PutScanLine(y); } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + (k+add)/8) |= (0x80>>(k+add)%8); else *(MaskHeightLine + (k+add)/8) &= ~(0x80>>(k+add)%8); } MaskBitmap->PutScanLine(j); } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+add); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(j+add); } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + (width-1-k)/8) |= (0x80>>(width-1-k)%8); else *(MaskHeightLine + (width-1-k)/8) &= ~(0x80>>(width-1-k)%8); } MaskBitmap->PutScanLine(j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + (k+width)/8) |= (0x80>>(k+width)%8); else *(MaskHeightLine + (k+width)/8) &= ~(0x80>>(k+width)%8); } MaskBitmap->PutScanLine(j); } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(height-1-j); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(height-1-j); } } else { for(int y = posy, j = 0; y < posy + height; y++, j++) { LayerBitmapHeightLine = lay->LBitmap->GetScanLine(y); MaskHeightLine = MaskBitmap->GetScanLine(j+height); for(int x = posx, k = 0; x < posx + width; x++, k++) { rgb.rgbBlue = *(LayerBitmapHeightLine + x*3); rgb.rgbGreen = *(LayerBitmapHeightLine + x*3 + 1); rgb.rgbRed = *(LayerBitmapHeightLine + x*3 + 2); RGB2HLS(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, hls.Hue, hls.Lig, hls.Sat); flag = true; if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) flag = false; } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) flag = false; } else { if (hls.HueFillHue[1]) flag = false; } } if (hls.LigFillLig[1]) flag = false; if (hls.SatFillSat[1]) flag = false; if(flag == true) *(MaskHeightLine + k/8) |= (0x80>>k%8); else *(MaskHeightLine + k/8) &= ~(0x80>>k%8); } MaskBitmap->PutScanLine(j+height); } } } */ } lay->LBitmap->StopScanLine(); MaskBitmap->StopScanLine(); END_LOG; return true; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::MagicFillRead24RGBLayer(Byte *p, Byte *lm, int x) { COLORREF c; RGBQUAD rgb; if (*(lm + (x >> 3)) & (0x80 >> (x & 7))) return false; else { p += 3*x; GetPixel24(p, c); rgb = TColorToRGB((TColor)c); if (rgb.rgbRedFillRGB[1].rgbRed) return false; if (rgb.rgbGreenFillRGB[1].rgbGreen) return false; if (rgb.rgbBlueFillRGB[1].rgbBlue) return false; return true; } } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::MagicFillRead24HLSLayer(Byte *p, Byte *lm, int x) { BEGIN_LOG(""); COLORREF c; THLS hls; if (*(lm + (x >> 3)) & (0x80 >> (x & 7))) { END_LOG; return false; } else { p += 3*x; GetPixel24(p, c); TColor2HLS((TColor)c, hls.Hue, hls.Lig, hls.Sat); if (hls.Sat>0.0) { if (FillHue[0]<0) { if (hls.HueFillHue[1]) { END_LOG; return false; } } else if (FillHue[1]>=360) { if (hls.HueFillHue[1]-360) { END_LOG; return false; } } else { if (hls.HueFillHue[1]) { END_LOG; return false; } } } if (hls.LigFillLig[1]) { END_LOG; return false; } if (hls.SatFillSat[1]) { END_LOG; return false; } END_LOG; return true; } END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TWorkAreaMenu::SurfaceFillRead24Layer(Byte *p, Byte *lm, int x) { BEGIN_LOG(""); COLORREF c; if (*(lm + (x >> 3)) & (0x80 >> (x & 7))) { END_LOG; return false; } else { p += 3*x; GetPixel24(p, c); END_LOG; return c==FillColor; } END_LOG; } //--------------------------------------------------------------------------- HRGN __fastcall TWorkAreaMenu::FillLayer(TPItemImage *Image, const TPoint start, TWindowFillReadLayer read) { BEGIN_LOG(""); HRGN hRgn = NULL; TPBitmap *FillMask = NULL; int x, y, savex, savey, xr, xl, i, j; TPoint size, now, *sp; TList *stack = NULL, *rcList = NULL; RECT rcTemp, *lpRect; Byte *p, *m, *lm; TPException ec = EC_NONE; int posx = 0, posy = 0, width = 0, height = 0; bool bReflection = false; if (Image->Reflection && MainImageForm->reflection) bReflection = true; if ((rcList = new TList)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((stack = new TList)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } size.x = Image->uBitmap->Width; size.y = Image->uBitmap->Height; if ((FillMask = new TPBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!FillMask->Create(size.x, size.y, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TPDEBUG if (!FillMask->Lock()) SHOWDEBUG; #else FillMask->Lock(); #endif FillMask->Fill(0); if (bReflection == false){ stack->Add(new TPoint(start)); } else { POINT pt = MainImageForm->reflection->FindOriginalPos(start.x, start.y); posx = MainImageForm->reflection->BitmapRange.left; posy = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; stack->Add(new TPoint(pt)); } if (!Image->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Image->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } while (stack->Count) { sp = (TPoint *)stack->Last(); stack->Remove(sp); x = sp->x; y = sp->y; delete sp; p = Image->uBitmap->GetScanLine(y); lm = Image->LayerMask->GetScanLine(y); m = FillMask->ScanLine(y); *(m+(x>>3)) |= 0x80>>(x&7); savex = x; while (1) { x++; if (x>3))&(0x80>>(x&7)))==0 && read(p, lm, x)) *(m+(x>>3)) |= 0x80>>(x&7); else break; } xr = x-1; x = savex; while (1) { x--; if (x >= posx && (*(m+(x>>3))&(0x80>>(x&7)))==0 && read(p, lm, x)) *(m+(x>>3)) |= 0x80>>(x&7); else break; } xl = x+1; if (bReflection == false){ rcTemp = Rect(xl, y, xr+1, y+1); } else { int rx = 0, ry = 0, lx = 0, ly = 0; lx = xl; ly = y; rx = xr + 1; ry = y + 1; if (lx < posx) lx = posx; if (lx >= width + posx) lx = posx + width - 1; if (ly < posy) ly = posy; if (ly >= height + posy) ly = posy + height - 1; if (rx < posx) rx = posx; if (rx >= width + posx) rx = posx + width - 1; if (ry < posy) ry = posy; if (ry >= height + posy) ry = posy + height - 1; rcTemp = Rect(lx, ly, rx, ry); } for (j=0; jCount; j++) { lpRect = (RECT *)rcList->Items[j]; if (lpRect->top==rcTemp.bottom) { if (lpRect->left==rcTemp.left && lpRect->right==rcTemp.right) { lpRect->top = rcTemp.top; break; } } else if (lpRect->bottom==rcTemp.top) { if (lpRect->left==rcTemp.left && lpRect->right==rcTemp.right) { lpRect->bottom = rcTemp.bottom; break; } } if (lpRect->left==rcTemp.right) { if (lpRect->top==rcTemp.top && lpRect->bottom==rcTemp.bottom) { lpRect->left = rcTemp.left; break; } } else if (lpRect->right==rcTemp.left) { if (lpRect->top==rcTemp.top && lpRect->bottom==rcTemp.bottom) { lpRect->right = rcTemp.right; break; } } } if (j>=rcList->Count) { rcList->Add(new TRect(rcTemp)); } x = xl; savey = y; y++; if (y < size.y) { p = Image->uBitmap->GetScanLine(y); lm = Image->LayerMask->GetScanLine(y); m = FillMask->ScanLine(y); if (y < size.y) { while (x <= xr) { if ((*(m+(x>>3))&(0x80>>(x&7))) || read(p, lm, x)==false) x++; else { while (1) { if (x <= xr) { if ((*(m+(x>>3))&(0x80>>(x&7)))==0 && read(p, lm, x)) x++; else { now.x = x-1; x++; break; } } else { now.x = x-1; break; } } now.y = y; stack->Add(new TPoint(now)); } } } x = xl; } y = savey; y--; if (y >= posy) { p = Image->uBitmap->GetScanLine(y); lm = Image->LayerMask->GetScanLine(y); m = FillMask->ScanLine(y); if (y >= posy) { while (x <= xr) { if ((*(m+(x>>3))&(0x80>>(x&7))) || read(p, lm, x)==false) x++; else { while (1) { if (x <= xr) { if ((*(m+(x>>3))&(0x80>>(x&7)))==0 && read(p, lm, x)) x++; else { now.x = x-1; x++; break; } } else { now.x = x-1; break; } } now.y = y; stack->Add(new TPoint(now)); } } } } } Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); delete FillMask; FillMask = NULL; delete stack; stack = NULL; if (bReflection == false){ while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else { // shin 1117 if (MainImageForm->reflection->Direction == D_LR){ int add = 0; if (MainImageForm->reflection->WorkSide == D_RIGHT) add = width; while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx + add, lpRect->top - posy, lpRect->right - posx + add, lpRect->bottom - posy )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else if (MainImageForm->reflection->Direction == D_TB){ int add = 0; if (MainImageForm->reflection->WorkSide == D_BOTTOM) add = height; while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx, lpRect->top - posy + add, lpRect->right - posx, lpRect->bottom - posy + add )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } /* if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, width - (lpRect->left - posx), lpRect->top - posy, width - (lpRect->right - posx), lpRect->bottom - posy )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else { while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx + width, lpRect->top - posy, lpRect->right - posx + width, lpRect->bottom - posy )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx, height - (lpRect->top - posy), lpRect->right - posx, height - (lpRect->bottom - posy) )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } else { while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); if (!MergeRegion(hRgn, lpRect->left - posx, lpRect->top - posy + height, lpRect->right - posx, lpRect->bottom - posy + height )) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } rcList->Remove(lpRect); delete lpRect; } } } */ } delete rcList; END_LOG; return hRgn; fail: if (FillMask) delete FillMask; if (stack) delete stack; if (hRgn) DeleteObject(hRgn); if (rcList) { while (rcList->Count>0) { lpRect = (RECT *)rcList->First(); rcList->Remove(lpRect); delete lpRect; } delete rcList; } EXCEPTION_MESSAGE_OK(ec); END_LOG; return NULL; } //--------------------------------------------------------------------------- //Public //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::tbMagicChange(TObject *Sender) { if (WindowForm) WindowForm->seMagic->Value = WindowForm->tbMagic->Position; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::bnRunClick(TObject *Sender) { BEGIN_LOG(""); if (WindowForm && WindowForm->rbSet->Checked) ResetBitmapRegion(); SetBitmapRegion(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::seMagicChange(TObject *Sender) { BEGIN_LOG(""); if (WindowForm && WindowForm->seMagic->Text.Length()>0) { WindowForm->tbMagic->Position = WindowForm->seMagic->Value; } END_LOG; } //--------------------------------------------------------------------------- String __fastcall TWorkAreaMenu::returnSize(int dx, int dy) { String str; if (SubItem==WSI_CIRCLE||SubItem==WSI_SQUARE) dx=dy=min(dx,dy); //by jeegeo if (MainImageForm->CurrentUnit==uInch) { str = Format("%f x %f", OPENARRAY(TVarRec, ((fabs(dx)+1)/MainImageForm->CanvasInfor.DotsPerInch, (fabs(dy)+1)/MainImageForm->CanvasInfor.DotsPerInch))); } else if (MainImageForm->CurrentUnit==uCm) { str = Format("%f x %f", OPENARRAY(TVarRec, (2.54*(fabs(dx)+1)/MainImageForm->CanvasInfor.DotsPerInch, 2.54*(fabs(dy)+1)/MainImageForm->CanvasInfor.DotsPerInch))); } else { str = Format("%d x %d", OPENARRAY(TVarRec, (abs(dx)+1, abs(dy)+1))); } return str; } //--------------------------------------------------------------------------- // ¿ÜºÎ¿¡¼­ WorkAreaMenuÀÌ »ý¼ºµÇÁö ¾Ê¾Æµµ »ó°ü¾øÀÌ ºÒ¸±¼ö ÀÖµµ·Ï StaticÀ¸·Î º¯°æÇß´Ù. // by maxleo21c 05.07.12 void __fastcall TWorkAreaMenu::WindowFull() { BEGIN_LOG(""); TCursor cursor; TPItemImage *Image; pBITMAPHANDLE bh; RGNXFORM XForm; RECT rc; HRGN rgn; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; //if (WindowForm) WindowForm->ExitItem(); Image = MainImageForm->iMainImage; bh = Image->uBitmap->RgnBitmap->Handle; // convert by celberus MainImageForm->UndoSave(UK_WORKAREA,Rect(0,0,0,0)); //by linuxjun Undo_Method MainImageForm->WorkArea->PushUndo(); ResetBitmapRegion(); XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; if (Image->Reflection && MainImageForm->reflection){ if (MainImageForm->reflection->Direction == D_LR){ if (MainImageForm->reflection->WorkSide == D_LEFT){ rc.left = 0; rc.top = 0; rc.right = MainImageForm->reflection->BitmapWidth; rc.bottom = MainImageForm->reflection->BitmapHeight; } else { rc.left = MainImageForm->reflection->BitmapWidth; rc.top = 0; rc.right = MainImageForm->reflection->BitmapWidth*2; rc.bottom = MainImageForm->reflection->BitmapHeight; } } else if (MainImageForm->reflection->Direction == D_TB){ if (MainImageForm->reflection->WorkSide == D_TOP){ rc.left = 0; rc.top = 0; rc.right = MainImageForm->reflection->BitmapWidth; rc.bottom = MainImageForm->reflection->BitmapHeight; } else { rc.left = 0; rc.top = MainImageForm->reflection->BitmapHeight; rc.right = MainImageForm->reflection->BitmapWidth; rc.bottom = MainImageForm->reflection->BitmapHeight*2; } } } else { rc.left = 0; rc.top = 0; rc.right = Image->uBitmap->Width; rc.bottom = Image->uBitmap->Height; } L_SetBitmapRgnRect(bh, &XForm, &rc, L_RGN_SET); L_GetBitmapRgnHandle(bh, &XForm, &rgn); MainImageForm->WorkArea->SetMask(rgn); DeleteObject(rgn); Image->OutlineBitmapRgn(); Image->Repaint(); //StatusItem(); MainImageForm->WorkAreaChange(); MainForm->UpdateMenuItems(NULL); Screen->Cursor = cursor; if(WindowForm) WindowForm->rzmtbtOff->Enabled = true; /*if (WindowForm) PostMessage(WindowForm->hWnd, TPM_EXITFUNCTON, 0, 0); by altang */ END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::WindowPopupMenuPopup(TObject *Sender) { if (WindowForm){ if (MainImageForm->WorkArea->Mask) { WindowForm->UnderLinePopup->Visible = true; WindowForm->InvertRegionPopup->Visible = true; WindowForm->TransformRegionPopup->Visible = true; } else { WindowForm->UnderLinePopup->Visible = false; WindowForm->InvertRegionPopup->Visible = false; WindowForm->TransformRegionPopup->Visible = false; } } } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::Rectangle1Click(TObject *Sender) { BEGIN_LOG(""); TMenuItem *sp = (TMenuItem *)Sender; ExitItem(); InitItem(WI_SHAPE); switch (sp->Tag) { case 0 : SubItem = WSI_RECTANGLE; if (WindowForm){ WindowForm->popupShape->Tag = WindowForm->miShapeRectangle->Tag; WindowFormButtonImageChange(WindowForm->miShapeRectangle); } break; case 1 : SubItem = WSI_SQUARE; if (WindowForm){ WindowForm->popupShape->Tag = WindowForm->miShapeSquare->Tag; WindowFormButtonImageChange(WindowForm->miShapeSquare); } break; case 2 : SubItem = WSI_CIRCLE; if (WindowForm){ WindowForm->popupShape->Tag = WindowForm->miShapeCircle->Tag; WindowFormButtonImageChange(WindowForm->miShapeCircle); } break; case 3 : SubItem = WSI_ELLIPSE; if (WindowForm) { WindowForm->popupShape->Tag = WindowForm->miShapeEllipse->Tag; WindowFormButtonImageChange(WindowForm->miShapeEllipse); } break; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::SurfaceMulti1Click(TObject *Sender) { BEGIN_LOG(""); TSpeedButton *sp = (TSpeedButton *)Sender; ExitItem(); InitItem(WI_OUTLINE); switch (sp->Tag) { case 1 : sbOutlineSurfaceMultiClick(Sender); if (WindowForm){ WindowForm->PopupOutline->Tag = WindowForm->miOutlineSurfaceMulti->Tag; WindowFormButtonImageChange(WindowForm->miOutlineSurfaceMulti); } break; case 2 : sbOutlineSurfaceSingleClick(Sender); if (WindowForm) { WindowForm->PopupOutline->Tag = WindowForm->miOutlineSurfaceSingle->Tag; WindowFormButtonImageChange(WindowForm->miOutlineSurfaceSingle); } break; case 3 : sbOutlineBorderClick(Sender); if (WindowForm) { WindowForm->PopupOutline->Tag = WindowForm->miOutlineBorder->Tag; WindowFormButtonImageChange(WindowForm->miOutlineBorder); } break; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::IrregularPopupClick(TObject *Sender) { BEGIN_LOG(""); ExitItem(); InitItem(WI_IRREGULAR); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::FullPopupClick(TObject *Sender) { BEGIN_LOG(""); WindowFull(); MainMenuForm->showWindow = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::OffPopupClick(TObject *Sender) { BEGIN_LOG(""); WindowOff(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::InvertRegionPopupClick(TObject *Sender) { BEGIN_LOG(""); MainImageForm->WorkArea->InvertRegion(); MainImageForm->iMainImage->Invalidate(); MainMenuForm->UpdateItem(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::TransformRegionPopupClick(TObject *Sender) { BEGIN_LOG(""); MainMenuForm->ExitForm(); MainMenuForm->Item = T_REGION; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::MakeMenuHintByShortcut() { BEGIN_LOG(""); WindowForm->miShapeSquare->Caption = TexActionManager->GetHint("WorkArea", "Square"); WindowForm->miShapeRectangle->Caption = TexActionManager->GetHint("WorkArea", "Rectangle"); WindowForm->miShapeCircle->Caption = TexActionManager->GetHint("WorkArea", "Circle"); WindowForm->miShapeEllipse->Caption = TexActionManager->GetHint("WorkArea", "Ellipse"); WindowForm->cbIrreCurve->Hint = TexActionManager->GetHint("WorkArea", "Irregular"); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { WindowForm->miOutlineSurfaceMulti->Caption = TexActionManager->GetHint("WorkArea", "SurfaceByMultiColors"); WindowForm->miOutlineSurfaceSingle->Caption = TexActionManager->GetHint("WorkArea", "SurfaceBySingleColor"); } else { WindowForm->miOutlineSurfaceMulti->Caption = TexActionManager->GetHint("WorkArea", "Magic"); WindowForm->miOutlineSurfaceSingle->Caption = TexActionManager->GetHint("WorkArea", "Surface"); } WindowForm->miOutlineBorder->Caption = TexActionManager->GetHint("WorkArea", "Outline"); WindowForm->rzmtbtFull->Hint = TexActionManager->GetHint("WorkArea", "Whole"); WindowForm->rzmtbtOff->Hint = TexActionManager->GetHint("WorkArea", "Release"); WindowForm->rzmtbtUndo->Hint = TexActionManager->GetHint("WorkArea", "Undo"); WindowForm->InvertRegionPopup->Caption = TexActionManager->GetHint("WorkArea", "Invert"); WindowForm->IrregularPopup->Caption = WindowForm->cbIrreCurve->Hint; WindowForm->FullPopup->Caption = WindowForm->rzmtbtFull->Hint; WindowForm->OffPopup->Caption = WindowForm->rzmtbtOff->Hint; WindowForm->Rectangle1->Caption = WindowForm->miShapeRectangle->Caption; WindowForm->Square1->Caption = WindowForm->miShapeSquare->Caption; WindowForm->Circle1->Caption = WindowForm->miShapeCircle->Caption; WindowForm->Ellipse1->Caption = WindowForm->miShapeEllipse->Caption; WindowForm->SurfaceMulti1->Caption = WindowForm->miOutlineSurfaceMulti->Caption; WindowForm->SurfaceSingle1->Caption = WindowForm->miOutlineSurfaceSingle->Caption; WindowForm->Border1->Caption = WindowForm->miOutlineBorder->Caption; END_LOG; } //----------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::BorderPopup(TObject *Sender) { BEGIN_LOG(""); if (WindowForm) WindowForm->PopupOutline->Tag = WindowForm->miOutlineBorder->Tag; ExitItem(); InitItem(WI_OUTLINE); sbOutlineBorderClick(Sender); END_LOG; } //----------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::SurfaceSinglePopup(TObject *Sender) { BEGIN_LOG(""); if (WindowForm) WindowForm->PopupOutline->Tag = WindowForm->miOutlineSurfaceSingle->Tag; ExitItem(); InitItem(WI_OUTLINE); sbOutlineSurfaceSingleClick(Sender); END_LOG; } //----------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::SurfaceMultiPopup(TObject *Sender) { BEGIN_LOG(""); if (WindowForm) WindowForm->PopupOutline->Tag = WindowForm->miOutlineSurfaceMulti->Tag; ExitItem(); InitItem(WI_OUTLINE); sbOutlineSurfaceMultiClick(Sender); END_LOG; } //----------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::ExecuteHotKey(String command) { BEGIN_LOG(""); if (command == "Square") { if (Item != WI_SHAPE) { ExitItem(); InitItem(WI_SHAPE); } SubItem = WSI_SQUARE; if (WindowForm != NULL) { WindowForm->rzmtbtShape->Glyph->Assign(WindowForm->miShapeSquare->Bitmap); WindowForm->rzmtbtShape->Hint = WindowForm->miShapeSquare->Caption; WindowForm->popupShape->Tag = WindowForm->miShapeSquare->Tag; } } else if (command == "Rectangle") { if (Item != WI_SHAPE) { ExitItem(); InitItem(WI_SHAPE); } SubItem = WSI_RECTANGLE; if (WindowForm != NULL) { WindowForm->rzmtbtShape->Glyph->Assign(WindowForm->miShapeRectangle->Bitmap); WindowForm->rzmtbtShape->Hint = WindowForm->miShapeRectangle->Caption; WindowForm->popupShape->Tag = WindowForm->miShapeRectangle->ImageIndex; } } else if (command == "Circle") { if (Item != WI_SHAPE) { ExitItem(); InitItem(WI_SHAPE); } SubItem = WSI_CIRCLE; if (WindowForm != NULL) { WindowForm->rzmtbtShape->Glyph->Assign(WindowForm->miShapeCircle->Bitmap); WindowForm->rzmtbtShape->Hint = WindowForm->miShapeCircle->Caption; WindowForm->popupShape->Tag = WindowForm->miShapeCircle->Tag; } } else if (command == "Ellipse") { if (Item != WI_SHAPE) { ExitItem(); InitItem(WI_SHAPE); } SubItem = WSI_ELLIPSE; if (WindowForm != NULL) { WindowForm->rzmtbtShape->Glyph->Assign(WindowForm->miShapeEllipse->Bitmap); WindowForm->rzmtbtShape->Hint = WindowForm->miShapeEllipse->Caption; WindowForm->popupShape->Tag = WindowForm->miShapeEllipse->Tag; } } else if (command == "Irregular") { if (Item != WI_IRREGULAR) { ExitItem(); InitItem(WI_IRREGULAR); } else { if (WindowForm != NULL) { if (WindowForm->cbIrreCurve->Checked == true) WindowForm->cbIrreCurve->Checked = false; else WindowForm->cbIrreCurve->Checked = true; } } } else if (command == "SurfaceByMultiColors" || command == "Magic") { if (Item != WI_OUTLINE) { ExitItem(); InitItem(WI_OUTLINE); } SubItem = WSI_SURFACEMULTI; StatusOutline(); if (WindowForm != NULL) { WindowForm->rzmtbtOutline->Glyph->Assign(WindowForm->miOutlineSurfaceMulti->Bitmap); WindowForm->rzmtbtOutline->Hint = WindowForm->miOutlineSurfaceMulti->Caption; WindowForm->PopupOutline->Tag = WindowForm->miOutlineSurfaceMulti->Tag; } } else if (command == "SurfaceBySingleColor" || command == "Surface") { if (Item != WI_OUTLINE) { ExitItem(); InitItem(WI_OUTLINE); } if (SubItem == WSI_SURFACEMULTI && Step > 0) { MainImageForm->DrawRectangleLocate(Temp); Step = 0; isDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } SubItem = WSI_SURFACESINGLE; StatusOutline(); if (WindowForm != NULL) { WindowForm->rzmtbtOutline->Glyph->Assign(WindowForm->miOutlineSurfaceSingle->Bitmap); WindowForm->rzmtbtOutline->Hint = WindowForm->miOutlineSurfaceSingle->Caption; WindowForm->PopupOutline->Tag = WindowForm->miShapeEllipse->Tag; } } else if (command == "Outline") { if (Item != WI_OUTLINE) { ExitItem(); InitItem(WI_OUTLINE); } sbOutlineBorderClick(NULL); if (WindowForm != NULL) { WindowForm->rzmtbtOutline->Glyph->Assign(WindowForm->miOutlineBorder->Bitmap); WindowForm->rzmtbtOutline->Hint = WindowForm->miOutlineBorder->Caption; WindowForm->PopupOutline->Tag = WindowForm->miOutlineBorder->Tag; } } else if (command == "Undo") { if (WindowForm != NULL && WindowForm->rzmtbtUndo->Enabled == true) WindowForm->workAreaMenu->sbUndoClick(NULL); } END_LOG; } //----------------------------------------------------------------------------- void __fastcall TWorkAreaMenu::ShowWorkAreaSize() { if (MainImageForm->WorkArea->Mask){ String str = ""; /* RECT trimRect; int rtn = L_GetAutoTrimRect(MainImageForm->WorkArea->Mask->Handle, 0, &trimRect); if (rtn >= 1){ str = returnSize(abs(trimRect.right - trimRect.left), abs(trimRect.bottom - trimRect.top)); } else { str = returnSize(MainImageForm->WorkArea->Mask->Width, MainImageForm->WorkArea->Mask->Height); } */ str = returnSize(MainImageForm->WorkArea->Mask->Width-1, MainImageForm->WorkArea->Mask->Height-1); if (WindowForm) WindowForm->lbShape->Caption = String(IDS_COMMON_SIZE) + " : " + str + " " + String(MainImageForm->UnitName()); } else { if (WindowForm) WindowForm->lbShape->Caption = String(IDS_COMMON_SIZE); } } //-----------------------------------------------------------------------------