// --------------------------------------------------------------------------- #include #include #include #pragma hdrstop #include "MainImage.h" #include "ColorLibrary_F.h" #include "FullView.h" #include "Layer_F.h" #include "History.h" #include "Main.h" #include "MainMenu.h" #include "Palette.h" #include "PenManager.h" #include "ProtectCard.h" #include "Undo.h" #include "AutoRepView.h" #include "Dialog_F.h" #include "Grouping_F.h" #include "PatternRepeat.h" #include "Text_F.h" #include "Draw_F.h" #include "TexWork_F.h" #include "Menu3D_F.h" #include "Style_F.h" #include "APTable_F.h" #include "APMenu_F.h" #include "UserColor_F.h" #include "LeadToolsFileOption.h" #include "Autosave.h" #include "ManualRepeat_F.h" #include "AutoRepeat_F.h" #include "Window.h" #include "Windowlib_F.h" #include "VecDraw.h" // By GreenFish ÀÛ¾÷Áß #include "Vector_F.h" #include "Undo_F.h" #include "N3DMapping.h" #include "N3DPattern.h" #include "NewGrouping_F.h" #include "Combo_F.h" // added by maxleo21c (05.03.08) #include "RasterizeDialogBox_F.h" // º¤ÅÍ ¿ÀºêÁ§Æ® ºñÆ®¸ÊÈ­ ¸Þ½ÃÁö ¹Ú½º - by monkman (2005.05.23) #include "Kasuri_F.h" //by bomchun °¡½º¸® ÀÜ»ó ¿¡·¯ ¼öÁ¤¹®Á¦·Î ÀÎŬ·çµå (2002.02.23) #include "define.h" #include "ImageVectorizer_F.h" #include "Reflection.h" #include "Reflection_F.h" #include "Library_F.h" #include "DataTrans.h" #include #include // --------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPImage" #pragma link "TPSelectImage" #pragma link "TPRuler2D" #pragma link "TPLayerImage" #pragma link "TPImage" #pragma resource "*.dfm" // --------------------------------------------------------------------------- #define IDS_ZOOMIN StringTable[0] #define IDS_ZOOMOUT StringTable[1] #define IDS_GRID StringTable[2] #define IDS_RULER StringTable[3] #define IDS_PROTECTION StringTable[4] #define IDS_UNIT StringTable[5] #define IDS_AUTOREPEAT StringTable[6] #define IDS_MESSAGE_VECTOREXIST StringTable[7] #define IDS_VERTICALREFLECTION StringTable[8] #define IDS_HORIZONTALREFLECTION StringTable[9] #define IDS_ENDREFLECTION StringTable[10] #define IDS_FIXAXIS StringTable[11] #define IDS_RELEASEAXIS StringTable[12] #define IDS_FORSK1 StringTable[13]//It can't be connected to E-Focus. #define IDS_FORSK2 StringTable[14]//It's disconnected from E-Focus. #define IDS_CrossLine StringTable[15] #define IDS_SnapGrid StringTable[16] #define IDS_MSG_SAVEJPG StringTable[17] //--------------------------------------------------------------------------- //SK°ü·Ã - by maxleo21c(07.01.11) #ifdef SK_SMART DWORD WINAPI MainThread(LPVOID mtr); //For SK E-Focus (07.01.04) by maxleo21c String IDS_MI_SK_MSG1_1; String IDS_MI_SK_MSG2_1; #endif // --------------------------------------------------------------------------- TMainImageForm *MainImageForm; int MainImageCount = 0; // --------------------------------------------------------------------------- __fastcall TMainImageForm::TMainImageForm(TComponent* Owner) : TForm(Owner) { TPException ec = EC_NONE; // Text°ü·Ã ComboboxÀÇ Index°ªÀ» ÀúÀåÇϱâ À§Çؼ­ ¸¸µé¾ú´Ù. - by maxleo21c (04.11.15) fontIndex = -1; styleIndex = -1; sizeIndex = -1; wGapIndex = -1; hGapIndex = -1; // --------------------------------------------------------------------- Number = MainImageCount; MainImageCount++; memsize = 0; // tmemsize = 0; // temp line hMemLine = NULL; // htMemLine = NULL; // temp line msx = NULL; // tsx = NULL; // temp line BtnClick = false; DownState = false; bProtect = false; bMaskArea = false; bDrawPen = true; ALLClose = false; // MainMenu ´ÝÇôµµ Filemanager´Â »ç¿ë °¡´ÉÇÏ°Ô WATEMP = false; iMainImage->OnPaintDirectly = PaintDirectly; iMainImage->OnPaintVector = PaintVector; iMainImage->OnPaintVectorModify = PaintVectorModify; iMainImage->OnPaintCursor = NULL; iMainImage->OnPaintCrossLine = NULL; iMainImage->OnPaintZoom = NULL; iMainImage->OnPaintLocate = NULL; isPaintDirectlyClean = false; isFirst = true; LineList = new TList; DrawORStitch = false; bOnImage = false; MouseEnterStep = 0; MouseState = 0; gff = gffNON; new3d = NULL; #ifdef TRIAL WaterMarkPaint = false; #endif // ================================ //2001.4.11. by lhskys congi¿¡¼­ unit ³Ö±â // CurrentUnit = uCm; // ======================================== StringTable.Create(DirectoryItem, Language, "MainImage"); SetSmallFont(Font); SetSmallFont(TempLabel->Font); SetSmallFont(sbUnit->Font); sbZoomIn->Hint = IDS_ZOOMIN; sbZoomOut->Hint = IDS_ZOOMOUT; sbGrid->Hint = IDS_GRID; sbRuler->Hint = IDS_RULER; sbProtect->Hint = IDS_PROTECTION; sbMaskArea->Hint = IDS_COMMON_MASKAREA; sbMaskShow->Hint = IDS_COMMON_MASKSHOW; sbAutoRepView->Hint = IDS_AUTOREPEAT; sbVertical->Hint = IDS_VERTICALREFLECTION; sbHorizontal->Hint = IDS_HORIZONTALREFLECTION; sbLock->Hint = IDS_FIXAXIS; sbCrossLine->Hint = IDS_CrossLine; sbSnapGrid->Hint = IDS_SnapGrid; // ======================================== TIniFile *IniFile = new TIniFile(AppDataItem + "\\status.ini"); int unit; if ((Undo = new TUndo) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by linuxjun Undo-Method if (TUnits == "uCm") unit = 2; else if (TUnits == "uInch") unit = 1; else unit = 0; // dot IniFile->WriteInteger("MainImage", "Unit", unit); // ================================= // TIniFile *IniFile = new TIniFile(AppDataItem+"\\status.ini"); if (IniFile) { unit = IniFile->ReadInteger("MainImage", "Unit", 0); if (unit == 0) { sbUnit->Caption = String(IDS_UNIT) + " : Dot"; UnitChange(uDot); } else if (unit == 1) { sbUnit->Caption = String(IDS_UNIT) + " : Inch"; UnitChange(uInch); } else { sbUnit->Caption = String(IDS_UNIT) + " : Cm"; UnitChange(uCm); } // IniFile->WriteInteger("Window", "MaxUndo", spEditUndo->Value); // Undo->SetMaxUndoNum(IniFile->ReadInteger("Undo", "Maximum", 100)); Undo->SetMaxUndoNum(IniFile->ReadInteger("Window", "MaxUndo", 100)); delete IniFile; } else { Undo->SetMaxUndoNum(100); } cbTime = 0; Modify = false; PaletteForm->StyleUseColor = true; T3DAutoSave = false; Palette = NULL; WorkArea = NULL; TempBitmap = TempMask = NULL; LARSW = false; // AutoBitmap = NULL; // AutoLayerMask = NULL; LayerCNT = 1; ARLayerCnt = 1; WidthR = false; HeightR = false; LayerListCount = 1; IndexSW = false; grid_state = 0; // ÀåÁø¸¸ #ifndef N_3D Data3D = NULL; #endif VUndoList = new TList; VRedoList = new TList; VectorUndo = new TPVectorUndo; // by linuxjun StyleHeader = new TList; bDrawCaret = false; // shin vectorform // bVectorMove = false; // ĵ¹ö½º À̵¿½Ã Vector MoveDraw()·Î ±×¸®±â - by monkman (2008.10.17) // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - by monkman(2005.02.16) VectorReflectionBitmap = NULL; // ¹ÝÀü °Å¿ï ºñÆ®¸Ê - by monkman (2011.04.22) VectorReflectionMask = NULL; // ¹ÝÀü °Å¿ï ºñÆ®¸Ê - by monkman (2011.04.22) // bVectorReflectionMode = false; // ¹ÝÀü °Å¿ï »óÅ ¿©ºÎ // ReflectionVH = 0; // ¹ÝÀü °Å¿ï ±âÁؼ±ÀÌ ¼öÁ÷ÀÎÁö ¼öÆòÀÎÁö (0:None 1:¼öÁ÷ 2:¼öÆò 3:¼öÁ÷±×¸®´ÂÁß 4:¼öÆò±×¸®´ÂÁß) // ReflectionVIndex = -1; // ReflectionHIndex = -1; // ¹ÝÀü °Å¿ï ±âÁؼ±ÀÇ ÁÂÇ¥ // ReflectFirstIndex = true; // IndexPoint Áߺ¹ ±ÝÁö º¯¼ö // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- bDestroy = false; // added by maxleo21c (05.04.01) --------------------------------------- downDone = false; ShortcutData = 0; bShortcutForEnlarge = false; gdp::GdiplusStartup(&gdp_token_, &gdp::GdiplusStartupInput(), NULL); // ---------------------------------------------------------------------- oneCloseMsgBox = false; Panel->DoubleBuffered = true; // ±ô¹ÚÀÓÀ» Á¦°ÅÇϱâ À§Çؼ­ by maxleo21c(06.01.19) PanelVert->DoubleBuffered = true; PanelHorz->DoubleBuffered = true; GroupIndexState = 0; // by siuaa 080429 for vector group index ReverseMask = false; reflection = NULL; NVector = new TNVector; VecDraw->MappingVariable(this->NVector); VecDraw->InitVariable(this->NVector); #ifdef SK_SMART IDS_MI_SK_MSG1_1 = IDS_FORSK1; //for SK IDS_MI_SK_MSG2_1 = IDS_FORSK2; bWebConnected = false; // for sk (07.02.12) TimerForSK->Enabled = true; #endif return; fail: EXCEPTION_MESSAGE_OK(ec); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormActivate(TObject *Sender) { if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } Current_DPI = CanvasInfor.DotsPerInch; iMainImage->CanvasPaint = true; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // FormÀÌ »õ·Î Ȱ¼ºÈ­µÇ¾úÀ» ¶§ Z KeyÀÇ È°¼ºÈ­¸¦ ¾ø¾Ø´Ù.. - by monkman (2005.04.20) // motive ¶§¹®¿¡ if¹®À¸·Î º¯°æ by david 090420 if (!(VectorForm && VectorForm->sbSpray->Down && VectorForm->sbSprayMotive->Down)) VecDraw->bZKey = false; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (MainImageForm != this) { VecDraw->BeReadyEdit = false; // shin vectorform // added by maxleo21c (04.12.20) º¤ÅͰ¡ Merge»óÅ¿¡¼­ ´Ù¸¥ MainImageFormÀ» // ¼±ÅÃÇϸé ÇöÀç Merge»óÅÂÀÇ Vector¸¦ Áö¿öÁÖ´Â ºÎºÐÀÌ´Ù. if (VectorForm && VecDraw->NVector && VecDraw->NVector->bMergeMode){ VecDraw->ExitMerge(); } else { if (VecDraw->NVector && VectorForm){ VecDraw->NVector->Item = VectorForm->V_Item; } } if (MainImageForm != NULL) { MainImageForm->iMainImage->Deactivate(); if (MainImageForm->new3d) { for (int i = 0; i < MainImageForm->new3d->ListOf3CP->Count; i++) { T3CP *t3cp = (T3CP*)MainImageForm->new3d->ListOf3CP->Items[i]; t3cp->Deactivate(); } } } iMainImage->Activate(); if (MainImageForm != NULL) { if (MainImageForm->AutoRepeat && (LayerCNT == ARLayerCnt)) { if (AutoRepViewForm) { MainImageForm->sbAutoRepView->Down = false; ARViewExitForm(); } } else if (MainImageForm->AutoRepeat) { MainMenuForm->ARExitForm(); } } // shin vectorform if (MainMenuForm->Item != T_VECTOR) MainMenuForm->ExitForm(1); else if (MainMenuForm->Item == T_VECTOR) { Panel->PopupMenu = VectorForm->VectorPopupMenu; // if (bDrawCaret && VectorForm && VectorForm->sbNewTextEdit->Down && VecDraw->BeReadyEdit) // { // // ¾Æ·¡ÀÇ º¯¼öµéÀº VectorForm->DrawCaretTimer¿¡¼­ ¹®Á¦°¡ ¹ß»ýÇØ¼­ ¸¸µé¾ú´Ù. // // °¢ MainImage¿¡¼­ Ä¿¼­¸¦ Ç¥ÇöÇØ¾ß Çϴµ¥ °¢°¢ÀÇ Ä¿¼­ À§Ä¡¿Í °¢µµ¸¦ ÀúÀåÇϰí, Àоî¿Â´Ù. // VecDraw->xCaretPoz = CaretPozX; // VecDraw->yCaretPoz = CaretPozY; // VecDraw->TextAngle = CaretAngle; // } } if (MainImageForm) MainImageForm->iMainImage->Repaint(); // ÀÌÀü MainImageFormÀÌ ÀÖ´Ù¸é Çѹø ´Ù½Ã ±×¸°´Ù - by monkman(2009.05.01) MainImageForm = this; if (VecDraw != NULL) { if (VecDraw->NVector) { VecDraw->NVector->bExtend = false; VecDraw->NVector->bProportion = false; VecDraw->NVector->bRotation = false; } VecDraw->MappingVariable(this->NVector); if (VectorForm){ VectorForm->MappingVariable(this->NVector); if (VecDraw->NVector && (VecDraw->NVector->Item == M_D_LINE || VecDraw->NVector->Item == M_D_CURVE) && (VectorForm->V_Item != M_D_LINE && VectorForm->V_Item != M_D_CURVE)){ VecDraw->NVector->bFstLine = true; VecDraw->NVector->step = 0; } } } if (PenManagerForm != NULL) { PenManagerForm->InitPenForm(); } } // //Vector Text´Â MainImage¿¡ SetFocus¸¦ ÁÖ¾î¾ß¸¸ ¹æÇâ۰¡ ÀÛµ¿Çϱ⠶§¹®¿¡ ÀÌ·¸°Ô ó¸®Çß´Ù. // if (VectorForm && VectorForm->V_Item == M_D_NEWTEXT) return; // - 05.07.25 maxleo21c Undo->Set(iMainImage, Palette, WorkArea); // by linuxjun for Undo_Method if (MainMenuForm && MainMenuForm->Item == T_COMBO && ComboMenu && !ComboMenu->isLoad) { // added by maxleo21c (05.02.21) ; } else { FullViewForm->InitForm(iMainImage); PaletteForm->InitForm(Palette); // ÆÈ·¹Æ® ÁÖ¼Ò ¾÷µ¥ÀÌÆ® PaletteForm->UpdateForm(iMainImage->uBitmap->BitsPerPixel); } LayerForm->InitForm(); ReviewStatusBar(); ReleaseCapture(); ShowZoomText(); // ================================================= for Auto Repeat by kjs if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) { MainMenuForm->AutoRepUpdateItem(); } // ================================================== if (N3DMappingForm) { N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); } if (N3DPatternForm) { N3DPatternForm->UpdateAll(); } // VecDraw->MappingVariable(this->NVector); // if (VectorForm){ // VectorForm->MappingVariable(this->NVector); // // if ((VecDraw->NVector->Item == M_D_LINE || VecDraw->NVector->Item == M_D_CURVE) // && (VectorForm->V_Item != M_D_LINE && VectorForm->V_Item != M_D_CURVE)){ // VecDraw->NVector->bFstLine = true; // VecDraw->NVector->step = 0; // } // } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDraw, VectorForm º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // º¯¼ö¸¦ VecDraw¿Í VectorFormÀÌ Æ÷ÀÎÅÍ º¯¼öµé°ú ¿¬°á ½ÃÄÑÁØ´Ù // VecDraw->MappingMainImageVariable(this); // if (VectorForm) // VectorForm->MappingMainImageVariable(this); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï °ü·Ã - Ȱ¼ºÈ­µÈ Æû Áß¿¡ Çϳª¸¸ ¹ÝÀü°Å¿ïÀÌ È°¼ºÈ­µÈ´Ù // º¤ÅÍ ÆûÀÌ ÀÖÀ» ¶§, ÀÌÀü ĵ¹ö½º¿¡¼­ ¹ÝÀü °Å¿ï ÁßÀÎ °ÍÀÌ ÀÖ´Ù¸é ÇöÀç ĵ¹ö½º´Â ¹ÝÀü °Å¿ï »óÅ¿¡ µé¾î°¡¼­´Â ¾ÈµÇ°í // ¹ÝÀü °Å¿ï ÁßÀÎ °ÍÀÌ ¾ø´Ù¸é ÇöÀç ĵ¹ö½º¸¦ ¹ÝÀü °Å¿ïÀÌ °¡´ÉÇÏ°Ô ¸¸µé¾îÁØ´Ù. Ãß°¡ ¼öÁ¤ - by monkman (2005.07.28) TMainImageForm *mif = NULL; int ReflectionModeFormNumber = -1; if (VectorForm) { for (int i = 0; i < MainForm->MDIChildCount; i++) { // ÀÌÀü ĵ¹ö½º ¼±ÅÃÇØ¼­ Activate - by monkman (2005.01.19) mif = (TMainImageForm*)MainForm->MDIChildren[i]; if (mif && mif->NVector->bVectorReflectionMode) { ReflectionModeFormNumber = mif->Number; } else { mif->sbVertical->Enabled = false; mif->sbHorizontal->Enabled = false; mif->sbLock->Enabled = false; } } if (!this->NVector->bVectorReflectionMode) { if (ReflectionModeFormNumber < 0) { ElementSet element; element.Clear(); element = VecDraw->ElementsInList(this->NVector->DataList, true); //this->V_DATA, true); if (element.Contains(E_TEXTBOX) || element.Contains(E_PFILL) || element.Contains(E_PTEXTBOX)) { this->sbVertical->Enabled = false; this->sbHorizontal->Enabled = false; this->sbLock->Enabled = false; } else { this->sbVertical->Enabled = true; this->sbHorizontal->Enabled = true; } } else { this->sbVertical->Enabled = false; this->sbHorizontal->Enabled = false; this->sbLock->Enabled = false; } } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Motive Merge½Ã ¹®Á¦°¡ À־ Repaint - by monkman (2009.04.30) if (VectorForm && MainImageForm == this && VecDraw->NVector && VecDraw->NVector->bMergeMode == true && VecDraw->NVector->bSelected == true) { MainImageForm->iMainImage->Repaint(); } else { iMainImage->Repaint(); } // todo : ¡Ù¡Ù ¼Óµµ °³¼± - by monkman (2005.07.20) VecDraw->FullViewBitmapDraw(-1, -1, -1, -1); MainForm->UpdateMenuItems(NULL); MainForm->ChangeCanvasTab(dynamic_cast(this)); iMainImage->CanvasPaint = false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormClose (TObject *Sender, TCloseAction &Action) { TIniFile *IniFile = new TIniFile(AppDataItem + "\\status.ini"); int unit; if (TUnits == "uCm") unit = 2; else if (TUnits == "uInch") unit = 1; else unit = 0; // dot if (IniFile) { IniFile->WriteInteger("MainImage", "Unit", unit); IniFile->WriteInteger("Window", "MaxUndo", Undo->GetMaxUndoNum()); delete IniFile; } Action = caFree; // if(VecUndo){delete VecUndo;} // Close È£Ãâ½Ã OnDestroy¿¡ µé¾î°¡Áö ¾Ê´Â´Ù. MainForm->RemoveCanvasTab(dynamic_cast(this)); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormCloseQuery(TObject *Sender, bool &CanClose) { String msg, fn, ext; TCursor cur; int Btn; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - ¹ÝÀü °Å¿ï Æû´Ý±â - by monkman (2005.02.24) if (VectorForm) { if (!VectorForm->ExitReflectionMirror()) { CanClose = false; return; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- switch(gff) { #ifdef TRIAL case gffTEX_TRIAL: { ext = String(".ttex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors Trial File (*.ttex)|*.ttex"); break; } case gffTFC_TRIAL: { ext = String(".ttfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors Trial File (*.ttfc)|*.ttfc"); break; } #else case gffTEX: { ext = String(".tex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.tex)|*.tex"); break; } case gffTFC: { ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); break; } #endif #ifndef N_3D #ifdef TRIAL case gffT3D_TRIAL: { ext = String(".tt3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D Trial File (*.tt3d)|*.tt3d"); break; } #else case gffT3D: { ext = String(".t3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D File (*.t3d)|*.t3d"); break; } #endif #ifdef NOTN3D #else case gffN3D: { ext = String(".n3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile New 3D File (*.n3d)|*.n3d"); break; } #endif #endif case gffBMP: case gffJPG: case gffPCT: case gffPCX: case gffPNG: case gffPSD: case gffRAS: case gffTGA: case gffTIF: case gffEPS: case gffDXF: case gffSVG: { if (gff == gffBMP) ext = String(".bmp"); else if (gff == gffJPG) ext = String(".jpg"); else if (gff == gffPCT) ext = String(".pct"); else if (gff == gffPCX) ext = String(".pcx"); else if (gff == gffPNG) ext = String(".png"); else if (gff == gffPSD) ext = String(".psd"); else if (gff == gffRAS) ext = String(".ras"); else if (gff == gffTGA) ext = String(".tga"); else if (gff == gffTIF) ext = String(".tif"); else if (gff == gffEPS) ext = String(".eps"); else if (gff == gffDXF) ext = String(".dxf"); else if (gff == gffSVG) ext = String(".svg"); String fileExtension = ExtractFileExt(FileName); if (LowerCase(fileExtension) == String(".tfc") || LowerCase (fileExtension) == String(".tex")) { FileName.Delete(FileName.Pos(fileExtension), FileName.Length()); FileName = MainForm->FMOnFileName(FileName, gff); } break; } default: { #ifdef TRIAL ext = String(".ttex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors Trial File (*.ttex)|*.ttex"); #else ext = String(".tex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.tex)|*.tex"); #endif break; } } /* if (NewGroupingForm) { // new grouping ´ÝÀ»±î? if (Application->MessageBox(IDS_MESSAGE_NEWGROUPCLOSE.c_str(), L"Warning", MB_OKCANCEL) == IDCANCEL) { CanClose = false; return; } } */ // shin vectorform if (!MainMenuForm->ExitForm(1)) { // modified by maxleo21c (05.05.17) CanClose = false; // new combo¿¡¼­ Ãë¼Ò¸¦ ´©¸£¸é cancelÀÌ µÇ¾ß Çϱ⠶§¹®¿¡ return; // À§Ä¡ À̵¿~ (¾Æ·¡¿¡¼­ À§·Î) } // oneCloseMsgBox º¯¼ö Ãß°¡ - by maxleo21c (05.06.09) // ÀÌÀ¯: ctrl+F4¸¦ ÀÌ¿ëÇÏ¿© mainimageformÀ» ´ÝÀ»¶§ msgbox°¡ ¶ß´Â °æ¿ì°¡ ÀÖ´Ù. // msgbox°¡ ÀÖ´Â »óÅ¿¡¼­ °è¼Ó ctrl+F4¸¦ ´©¸£¸é mainimage°¡ ´ÝÇû´Âµ¥µµ msgbox°¡ // ¶° ÀÖ°í ±×°ÍÀ» ´ÝÀ»¶§ access°¡ ¹ß»ýÇϱ⠶§¹®¿¡ ÀÌ¿Í °°ÀÌ Ã³¸®Çß´Ù. if (Modify && !oneCloseMsgBox) { oneCloseMsgBox = true; BringToFront(); msg = Format(L" %s", OPENARRAY(TVarRec, (FileName.c_str()))); Btn = MessageDlg(IDS_MESSAGE_SAVECHANGE + msg, mtWarning, TMsgDlgButtons() << mbYes << mbNo << mbCancel, 0); oneCloseMsgBox = false; } else if (oneCloseMsgBox) { CanClose = false; return; } if (Btn != 2) { if (MainForm->MDIChildCount == 1) { // lhskys ALLClose = true; // MainMenu ´ÝÇôµµ Filemanager´Â »ç¿ë °¡´ÉÇÏ°Ô /* if (TexWork){ #ifndef TRIAL if (TexWork->Modify ){ String msgTW; if(TexWork->OpenDialog1->FileName != String("")) msgTW = TexWork->OpenDialog1->FileName; else msgTW = String("Noname.fst"); int BtnTW = MessageDlg(String(IDS_MESSAGE_SAVECHANGE + " ") + msgTW, mtWarning, TMsgDlgButtons()<tbSaveClick(this); } TexWork->Modify = false; } #endif bool canClose = true; TexWork->FormCloseQuery(this, canClose); } */ } } // MainMenuForm->ExitForm(1); // ÁÖ¼®Ã³¸® À§·Î ¿Å±è - by maxleo21c (05.06.09) if (Modify) { // msg = Format(" %s", OPENARRAY (TVarRec,(FileName))); // int Btn = MessageDlg(IDS_MESSAGE_SAVECHANGE + msg, mtWarning, TMsgDlgButtons()<SaveDialog->InitialDir = IniFile->ReadString ("FileManager", "DirectoryName", "C:\\"); delete IniFile; } if (MainForm->SaveDialog->Execute()) { fn = MainForm->SaveDialog->FileName; if (LowerCase(ExtractFileExt(fn)) != ext) fn += ext; DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); CanClose = true; } } else { #ifdef NOTN3D if (MainImageForm->WorkArea->Mask && gff != gffT3D) { #else if (MainImageForm->WorkArea->Mask && gff != gffT3D && gff != gffN3D) { #endif if (Application->MessageBox(IDS_MESSAGE_ONLYWORKREGIONSAVE.c_str(), L"Save", MB_OKCANCEL) == IDOK) { CanClose = true; } else { CanClose = false; return; } } if (FileExists(FullPathName(DirName, FileName))) { int btn = MessageDlg(IDS_MESSAGE_SAMENAMEOVERWRIGHT, mtWarning, TMsgDlgButtons() << mbYes << mbNo, 0); if (btn == 6) { if (gff == gffT3D) { T3DAutoSave = true; MainMenuForm->Init3DForm(); SaveToFile(DirName, FileName, gffT3D, MainForm->CompressMethod); T3DAutoSave = false; } else { MakeBackupFile(DirName, FileName); SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); CanClose = true; } } else if (btn == 7) { CanClose = false; } } else { if (gff == gffT3D) { T3DAutoSave = true; MainMenuForm->Init3DForm(); SaveToFile(DirName, FileName, gffT3D, MainForm->CompressMethod); T3DAutoSave = false; } else { SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); CanClose = true; } } } } else if (Btn == mrNo) { CanClose = true; } else { CanClose = false; return; } } else { CanClose = true; } if (CanClose) { PaletteForm->DIB256Palette->ChoiceIndex = 2; if (DirName.IsEmpty() == false) { if (FileExists(FullPathName(DirName, FileName))) { FileHistory->InsertHistory(DirName, ExtractFileName(FileName), gff, iMainImage->uBitmap->BitsPerPixel); } } // ====================================================== for Auto Repeat by kjs if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) { AutoRepUpdateMenu(true); AutoRepeat = false; if (AutoRepViewForm) ARViewExitForm(); } // ====================================================== } if (CanClose) Modify = false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormCreate(TObject *Sender) { MainMenuForm->Visible = true; PenManagerForm->Visible = true; FullViewForm->Visible = true; PaletteForm->Visible = true; TGrid g; #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC if (ProtectCard->isHacked(hsTexStylist, TexStylistVersion)) { EXCEPTION_MESSAGE_OK(EC_HASPKEYNOTFOUND); Application->Terminate(); } #endif #endif // ====================================== if ((WorkArea = new TPWorkArea(&(iMainImage->uBitmap))) == NULL) goto fail; // convert by celberus if ((Palette = new TPalette) == NULL) goto fail; // ====================================== for Auto Repeat by kjs AutoRepeat = false; AutoRepViewForm = NULL; // ====================================== MainImageForm = this; CanvasInfor.DotsPerInch = 160; CanvasInfor.SetExtFileOption(); ApplyEnvironment(); Panel->PopupMenu = MainMenuForm->PopupMenu1; iMainImage->Cursor = crPen; ZoomChange(1, 1); PaletteForm->InitForm(Palette); // PaletteForm->DIB256Palette->ChoiceIndex = 2; // PaletteForm->DIB256Palette->UseColor =2; PenManagerForm->InitPenForm(); ReviewStatusBar(); initsave = true; MainForm->AddCanvasTab(dynamic_cast(this), Name); return; fail: doDestroy(Palette)doDestroy(WorkArea) } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormDestroy(TObject *Sender) { PSTYLEDATAFILEHEADER pheader; TVecData *data; TVUndoData *udata; // shin vectorform if (MainMenuForm->Item!=T_VECTOR) MainMenuForm->ExitForm(2); iMainImage->OnPaintZoom = NULL; #ifndef N_3D doDestroy(new3d)doDestroy(Data3D) if (MainForm->MDIChildCount <= 1) { LayerForm->Visible = false; } #endif DelLineMem(); // DelTempLineMem(); // temp line doDestroy(Palette)doDestroy(WorkArea)FullViewForm->InitForm(NULL); doDestroy(Undo) // by linuxjun for Undo doDestroy(OverlapBack) //110201 by david doDestroy(OverlapBitmap) /////////////////AutoRepeat¿¡¼­ Resource LeakÀÌ ÀϾ´Â °ÍÀ» ¸·±âÀ§ÇØ ÇÊ¿äÇÔ // if (MainImageForm->AutoBitmap){ delete MainImageForm->AutoBitmap; MainImageForm->AutoBitmap = NULL;} // if (MainImageForm->AutoLayerMask){ delete MainImageForm->AutoLayerMask; MainImageForm->AutoLayerMask = NULL;} //////////////////////////////////////////////////////////////////////////// LineListData * line; while (LineList->Count > 0) { line = (LineListData*)LineList->Last(); LineList->Remove(line); delete line; } delete LineList; // while (VDataList->Count) { // data = (TVecData*)VDataList->First(); // delete data; // VDataList->Remove(data); // } while (VUndoList->Count) { udata = (TVUndoData*)VUndoList->First(); if (udata->VUndoData) delete udata->VUndoData; delete udata; VUndoList->Remove(udata); } while (VRedoList->Count) { udata = (TVUndoData*)VRedoList->First(); if (udata->VUndoData) delete udata->VUndoData; delete udata; VRedoList->Remove(udata); } //delete VDataList; delete VUndoList; delete VRedoList; if (VectorUndo) { delete(TPVectorUndo*)VectorUndo; VectorUndo = NULL; } // by linuxjun // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Vector¸¦ ±×¸±¶§ DrawCurrentObject()¿¡¼­ Access°¡ ³ª´Â °ÍÀ» ¼öÁ¤ - by monkman (2005.02.11) if (VecDraw) NVector->step = 0; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- delete NVector; NVector = NULL; VecDraw->NVector = NULL; if (VectorForm) VectorForm->NVector = NULL; while (StyleHeader->Count) { pheader = (PSTYLEDATAFILEHEADER)StyleHeader->First(); delete pheader; StyleHeader->Remove(pheader); } delete StyleHeader; // ¹ÝÀü °Å¿ï ºñÆ®¸Ê - by monkman (2011.04.22) if (VectorReflectionBitmap) delete VectorReflectionBitmap; VectorReflectionBitmap = NULL; if (VectorReflectionMask) delete VectorReflectionMask; VectorReflectionMask = NULL; PostMessage(MainForm->Handle, TPM_DESTROYCHILDFORM, 0, 0); MainImageForm = NULL; bDestroy = true; // ¼Ò¸êµÇ±â Á÷ÀüÀ» ¾Ë·ÁÁÜ.. if (iMainImage->Reflection && reflection) { DeleteReflection(); } if (ALLClose) { MainMenuForm->CloseMainMenuItem(); // MainMenu ´ÝÇôµµ Filemanager´Â »ç¿ë °¡´ÉÇÏ°Ô // PaletteForm ¿¡·¯ ¼öÁ¤ (¾Æ·¡ 2ÁÙ Ãß°¡) - by celberus (2005.01.17) // PaletteForm->InitForm(NULL); FullViewForm->Enabled = false; PenManagerForm->Enabled = false; PaletteForm->Enabled = false; LayerForm->Enabled = false; } else { for (int i = 0; MainForm->MDIChildCount-1 >= i; i++) { // ÀÌÀü ĵ¹ö½º ¼±ÅÃÇØ¼­ Activate - by monkman (2005.01.19) TMainImageForm *mif = (TMainImageForm *)MainForm->MDIChildren[i]; if (mif && !mif->bDestroy) { // ¼Ò¸êµÇ±â Á÷ÀüÀΠĵ¹ö½º´Â ¼±ÅÃÀÌ µÇÁö ¾Êµµ·Ï.. mif->FormActivate(mif); break; } } } if (N3DMappingForm) { N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); } // added by maxleo21c (05.04.15) gdp::GdiplusShutdown(gdp_token_); //MainForm->RemoveCanvasTab(dynamic_cast(this)); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormPaint(TObject *Sender) { // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormResize(TObject *Sender) { Ruler->Width = ClientWidth - PanelVert->Width; Ruler->Height = ClientHeight - PanelHorz->Height; if (sbRuler->Down) { Panel->Left = Ruler->Thick; Panel->Top = Ruler->Thick; Panel->Width = Ruler->Width - Ruler->Thick; Panel->Height = Ruler->Height - Ruler->Thick; } else { Panel->Left = 0; Panel->Top = 0; Panel->Width = Ruler->Width; Panel->Height = Ruler->Height; } PanelHorz->Top = Ruler->Top + Ruler->Height + 1; PanelHorz->Width = Ruler->Width; sbHorz->Width = PanelHorz->Width - sbHorz->Left - 2; PanelVert->Left = Ruler->Left + Ruler->Width + 1; PanelVert->Height = Ruler->Height; sbVert->Height = PanelVert->Height - sbVert->Top - 2; sbVert->Width = sbHorz->Height; // vertical scroll barÀÇ ÆøÀÌ 13¶Ç´Â 16À¸·Î º¯ÇÏ´Â CBuilder¹ö±× ¶§¹®¿¡... sbVert->Left = 2; // Âü°í·Î jeegeo's computer¿¡¼­´Â 13À¸·Î º¯Çϰí lhskys, greenfish¿¡¼­´Â 16À¸·Î º¯ÇÑ´Ù// Á¤»ó°ªÀº 18 if(NVector != NULL){ NVector->bVectorMove = true; } iMainImage->SetPosition(); FullViewForm->SetSize(); // bmScreenResize(); // temp line tmVectorMoveDraw->Enabled = true; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseEnter(TObject *Sender) { sbCrossLineClick(NULL); if (Ruler->Cursor == crHSplit || Ruler->Cursor == crVSplit) { isPaintDirectlyClean = false; PaintDirectly(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); } if (this->Active) MainMenuForm->iMainImageMouseEnter(this); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseLeave(TObject *Sender) { isFirst = true; // ¸¶¿ì½º°¡ MainImageForm¸¦ ¹þ¾î³µÀ» ¶§, MouseMove¿¡¼­ óÀ½ µé¾î¿Ô´Ù´Â °ÍÀ» // üũÇϰí MainImageForm¿¡ Æ÷Ä¿½º¸¦ ÁÖ±â À§Çؼ­.. MouseEnterStep = 0; /* if(iMainImage->OnPaintCursor) iMainImage->OnPaintCursor(iMainImage,iMainImage->Canvas->Handle,Pen.x,Pen.y); if(iMainImage->OnPaintCrossLine) iMainImage->OnPaintCrossLine(iMainImage,iMainImage->Canvas->Handle); */ iMainImage->OnPaintCursor = NULL; iMainImage->OnPaintCrossLine = NULL; // if(iMainImage->OnPaintIndexPoint) // iMainImage->OnPaintIndexPoint(iMainImage,iMainImage->Canvas->Handle); FirstIndex = true; PaintCurrentIndexPoint(); // if (!VectorForm || (VectorForm && // (VectorForm->V_Item != M_O_ROTATION && VectorForm->V_MainItem != 1))) if ((!VectorForm || (VectorForm && VectorForm->V_Item == M_O_EDIT)) && iMainImage->SubBitmap == NULL) iMainImage->CanvasPaint = true; iMainImage->Repaint(); MainMenuForm->iMainImageMouseLeave(this); #ifdef FASTPEN // ------------------------------------------------------------- if (Active) { if (bDrawPen) { PenManagerForm->SpecialMouseLeave(Sender); // if (AutoRepeat && (PaletteForm->Item != PAL_PROTECT) && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) // RedrawingRepeat(PenManagerForm->sbMask->Down, true); if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) FullViewForm->InitForm(iMainImage); } } // ------------------------------------------------------------- #endif iMainImage->Cursor = crDefault; iMainImage->CanvasPaint = false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDraw, VectorForm º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.04.01) // º¯¼ö¸¦ VecDraw¿Í VectorFormÀÌ Æ÷ÀÎÅÍ º¯¼öµé°ú ¿¬°á ½ÃÄÑÁØ´Ù VecDraw->MappingVariable(this->NVector); if (VectorForm) VectorForm->MappingVariable(this->NVector); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // todo : ¡Ù¡Ù ¼Óµµ °³¼± - by monkman (2005.07.20) // VecDraw->FullViewBitmapDraw(-1, -1, -1, -1); // iMainImageMouseMove(NULL, Shift, X+100, Y); if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) // diekun. 2007.01.05. ExitFormÀ» ÅëÇØ Menu3D_FÀ» Áö¿ö¼­, »ç¿ë ½Ã¿¡ Á¦´ë·Î ÃʱâÈ­ µÇ°Ô ¸¸µç´Ù. // shin vectorform if (Button == mbRight) { if (MainMenuForm->Item == T_VECTOR) { Panel->PopupMenu = VectorForm->VectorPopupMenu; } else { MainMenuForm->ExitForm(); Panel->PopupMenu = MainMenuForm->PopupMenu1; } } // MainMenuForm->ExitForm(1); TCursor cur; cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (!AutoRepeat) { EnlargeCanvas(X, Y); Undo->RemoveAll(); } else if (AutoRepeat) { EXCEPTION_MESSAGE_OK(EC_AUTOREPEATENLARGE); } Screen->Cursor = cur; bShortcutForEnlarge = false; TempLabel->Visible = false; //À̹ÌÁö°¡ ÀÛ¾ÆÁø °ÍÀ» ±âÁØÀ¸·Î ½ºÅ©·ÑÀÇ À§Ä¡¸¦ ÀçÀ§Ä¡ ½ÃŲ´Ù. //º¤ÅͰ¡ ±×·ÁÁö´Â À§Ä¡°¡ ½ºÅ©·Ñ(À̹ÌÁö iMainImage->PositionX(Y))¸¦ ±âÁØÀ¸·Î //ó¸®Çؼ­ ¾Æ·¡¿Í °°ÀÌ ÇÏÁö ¾ÊÀ¸¸é À̹ÌÁö¿Í º¤ÅÍÀÇ À§Ä¡°¡ ´Ù¸£°Ô º¸ÀÌ´Â ¹®Á¦°¡ ÀÖ´Ù. UpdateImage(); iMainImage->PositionX = sbHorz->Max; iMainImage->PositionY = sbVert->Max; return; } long lpos = 0; // lpos = Y; // lpos << 32; // lpos += X + 10; // SendMessage(this, WM_MOUSEMOVE, NULL, lpos); // PostMessage(hWnd, WM_MOUSEMOVE, NULL, lpos); POINT snapped_point; // ÀåÁø¸¸ snapped_point = FullViewForm->getSnappedPoint(X, Y); #ifdef TEST MainForm->TimeCheckStart(); // by minw428 Time Check #endif PaintDirectly(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); isPaintDirectlyClean = true; TRect r; COLORREF c; Byte color; // ============================= 2001.6.4. by lhskys ÀÛ¾÷±¸¿ª save if (MainForm->WReopenMove) { WindowLibForm->iMainImageMouseDown(this, Button, Shift, X, Y); if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) RedrawingRepeat(false, true); MainForm->WReopenMove = false; MainMenuForm->Item = T_WIN; isPaintDirectlyClean = false; PaintDirectly(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); MainMenuForm->ExitForm(1); return; } // ============================= 2001.6.4. by lhskys if (Active) { // if (Button==mbRight) return; // style imagedelete¶§¹®¿¡ ¸·À½ 99/10/01 if (X >= 0 && X < iMainImage->uBitmap->Width && Y >= 0 && Y < iMainImage->uBitmap->Height) { DownState = true; if (Shift.Contains(ssCtrl) && !Shift.Contains(ssShift) && !Shift.Contains (ssAlt) && Button == mbLeft) { MouseState = 1; iMainImage->Cursor = crHandPoint; ptFirst = Point(X, Y); } else { if (Button == mbMiddle || (Shift.Contains(ssShift) && Button == mbLeft && MainMenuForm->Item != T_VECTOR)) { if (VectorForm /*&& (VectorForm->V_Item == M_O_COLOR || VectorForm->V_Item == M_O_FILL)*/ && VecDraw->GetVectorColor(X, Y, &c)) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¼±ÅÃÇÑ À§Ä¡¿¡ Vector°¡ ÀÖÀ» °æ¿ì Vector Color ÃßÃâ - Vector Color ÃßÃâ - by monkman (2005.02.03) if (iMainImage->uBitmap->BitsPerPixel == 24) { PaletteForm->DIB256Palette->SetNormal (PaletteForm->DIB256Palette->ChoiceIndex, GetRValue(c), GetGValue(c), GetBValue(c)); color = PaletteForm->DIB256Palette->ChoiceIndex; PaletteForm->DIB256Palette->Repaint(); } else color = iMainImage->uBitmap->GetPixelColor(X, Y); PenManagerForm->SelectColor(color); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } else if (Button == mbMiddle) { // °¡¿îµ¥ ¹öư¸¸ »ö ¼±ÅÃÀÌ °¡´ÉÇϵµ·Ï º¯°æ - by monkman (2011.05.02) if (iMainImage->Reflection && reflection){ POINT pt = reflection->FindOriginalPos(X, Y); c = iMainImage->uBitmap->GetPixelColor(pt.x, pt.y); } else { c = iMainImage->uBitmap->GetPixelColor(X, Y); } if (iMainImage->uBitmap->BitsPerPixel == 24) { // Full Color ĵ¹ö½ºÀÇ º¤ÅÍ¿¡¼­´Â ¹ÙÅÁ»öÀÌ ¾È µé¾î°¡µµ·Ï ÇÑ´Ù - by monkman (2005.05.23) if ((VectorForm == NULL) || (VectorForm != NULL && c != 0xFFFFFF)) { PaletteForm->DIB256Palette->SetNormal (PaletteForm->DIB256Palette->ChoiceIndex, GetRValue(c), GetGValue(c), GetBValue(c)); color = PaletteForm->DIB256Palette->ChoiceIndex; PaletteForm->DIB256Palette->Repaint(); // } } else color = c; // ÀÌ ¶óÀÎ PenManagerForm->SelectColor(color); // À§ ¶óÀΰú ÇÔ²² ÁÖ¼® 󸮰¡ µÇ¾î À־ Pen»öÀÌ º¯°æµÇÁö ¾ÊÀ½ by david 081230 } else { // 256 ĵ¹ö½ºÀÇ º¤ÅÍ¿¡¼­´Â ¹ÙÅÁ»öÀÌ ¾È µé¾î°¡µµ·Ï ÇÑ´Ù - by monkman (2005.05.23) if ((VectorForm == NULL) || (VectorForm != NULL && c != 1)) { color = c; PenManagerForm->SelectColor(color); } } } } if (MainMenuForm->iMainImageMouseDown(this, Button, Shift, X, Y)) { PaletteForm->iMainImageMouseDown(Sender, Button, Shift, X, Y); if (Button == mbMiddle || (Shift.Contains(ssShift) && Button == mbLeft)) { // PenManagerForm->SelectColor(iMainImage->uBitmap->GetPixelColor(X, Y)); PenManagerForm->SpecialMouseDown(Button, Shift, X, Y); } else if (Button == mbLeft) { if (bDrawPen) { if (FullViewForm->iMainImageMouseDown(Sender, X, Y)) { // PenManagerForm->SpecialMouseDown(Button, Shift, X, Y); PenManagerForm->SpecialMouseDown (Button, Shift, snapped_point.x, snapped_point.y); // ÀåÁø¸¸ BtnClick = true; } } } } } } } // GreenFish (Index Point) // if ((Ruler->Cursor==crHSplit || Ruler->Cursor==crVSplit) && Button==mbLeft) { if ((HIndexSelected || VIndexSelected) && Button == mbLeft) { POINT cp = iMainImage->GetCrossPos(); if (HIM || VIM) { if (HIM) HIndex[HIM - 1] = cp.y / iMainImage->ZoomIn * iMainImage->ZoomOut + sbVert->Position; else VIndex[VIM - 1] = cp.x / iMainImage->ZoomIn * iMainImage->ZoomOut + sbHorz->Position; Ruler->Cursor = crDefault; HIM = NULL; VIM = NULL; iMainImage->Repaint(); } if (Ruler->Cursor == crHSplit) { // À妽ºÀÇ ÁÂÇ¥µéÀ» ¹è¿­¿¡ ÀúÀå VIndex[VI++] = cp.x / iMainImage->ZoomIn * iMainImage->ZoomOut + sbHorz->Position; } else if (Ruler->Cursor == crVSplit) { HIndex[HI++] = cp.y / iMainImage->ZoomIn * iMainImage->ZoomOut + sbVert->Position; } Ruler->Cursor = crDefault; // Ruler->Cursor°¡ À妽º Æ÷ÀÎÆ® ±×¸®±âÀÇ ÁöÇ¥ÀÌ´Ù VIndexSelected = false; HIndexSelected = false; iMainImage->OnPaintCursor = PaintPenLocate; MainMenuForm->Item = T_NONE; sbCrossLine->Enabled = true; } if (iMainImage->OnPaintIndexPoint && (HIM || VIM) && Button == mbLeft && !IndexLock1->Checked) { if (VIM) { Ruler->Cursor = crHSplit; VIndexSelected = true; VIndex[VIM - 1] = -10; } else { Ruler->Cursor = crVSplit; HIndexSelected = true; HIndex[HIM - 1] = -10; } FirstIndex = true; iMainImage->Repaint(); } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - by monkman (2005.02.17) if (NVector->bVectorReflectionMode && iMainImage->OnPaintVectorReflectIndexPoint && (NVector->ReflectionVH > 0) && VectorForm && (MainMenuForm->Item == T_VECTOR)) { // »óÅ¿¡ µû¸¥ ÁÂÇ¥¸¦ ´ëÀÔÇÏ°í »óŸ¦ º¯°æÇÑ´Ù switch(NVector->ReflectionVH) { case 1: // ¼öÁ÷ ±âÁؼ± if (!NVector->bReflectionGuideLineLock && NVector->ReflectionVIndex - 5 < X && X < NVector->ReflectionVIndex + 5) { // °¡À̵å¶óÀÎ ¼³Á¤½Ã¸¸.. - by monkman (2005.03.17) NVector->step = 0; NVector->bFstLine = true; NVector->bFirst = true; // Undo¸¦ À§ÇØ.. NVector->ReflectionVH = 3; } break; case 2: // ¼öÆò ±âÁؼ± if (!NVector->bReflectionGuideLineLock && NVector->ReflectionHIndex - 5 < Y && Y < NVector->ReflectionHIndex + 5) { // °¡À̵å¶óÀÎ ¼³Á¤½Ã¸¸.. - by monkman (2005.03.17) NVector->step = 0; NVector->bFstLine = true; NVector->bFirst = true; // Undo¸¦ À§ÇØ.. NVector->ReflectionVH = 4; } break; case 3: // ¼öÁ÷ ±âÁؼ± ±×¸®´Â Áß // iMainImage ¿µ¿ª ¾È¿¡¼­¸¸.. - by monkman (2005.03.17) if (X > 0 && iMainImage->uBitmap->Width > X) { NVector->ReflectionVIndex = X; NVector->ReflectionVH = 1; } break; case 4: // ¼öÆò ±âÁؼ± ±×¸®´Â Áß if (Y > 0 && iMainImage->uBitmap->Height > Y) { NVector->ReflectionHIndex = Y; NVector->ReflectionVH = 2; } break; } iMainImage->Repaint(); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // if (MainForm->MotiveFileName != "") { // MainForm->MotiveLoadClick (this); // } isPaintDirectlyClean = false; PaintDirectly(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); #ifdef TEST MainForm->TimeCheckEnd(); // by minw428 Time Check #endif } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseMove (TObject *Sender, TShiftState Shift, int X, int Y) { // if(MainMenuForm->Item == T_MOVECOPY){//ÀåÁø¸¸ // SetFocusedControl(MainImageForm); // sbHorz->SetFocus(); // } if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; HDC dc = iMainImage->Canvas->Handle; int pointx, pointy; gdp::Graphics graphics(dc); // using GDI+ // Create a Pen object. gdp::Pen blackPen(gdp::Color(255, 0, 0, 0), 1); // Create a Rect object. pointx = iMainImage->BitmapToCanvasX(X); pointy = iMainImage->BitmapToCanvasY(Y); gdp::Rect rect(0, 0, pointx, pointy); // Draw rect. iMainImage->Repaint(); graphics.DrawRectangle(&blackPen, rect); TempLabel->Caption = returnSize(X, Y); TempLabel->Left = pointx - TempLabel->Width - 3; TempLabel->Top = pointy - TempLabel->Height - 3; TempLabel->Visible = true; goto next; } POINT snapped_point; // ÀåÁø¸¸ snapped_point = FullViewForm->getSnappedPoint(X, Y); AutoSavebackup->Enabled = false; AutoSavebackup->Enabled = true; PaintDirectly2(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); isPaintDirectlyClean = true; isFirst = false; if (MainForm->WReopenMove && iMainImage->SubBitmap != NULL) { ReopenMove(X, Y); goto next; } Pen.x = iMainImage->BitmapToCanvasX(X); Pen.y = iMainImage->BitmapToCanvasY(Y); if (sbCrossLine->Down && !DrawORStitch) { iMainImage->OnPaintCrossLine = PaintCrossLine; iMainImage->OnPaintCursor = NULL; } else { iMainImage->OnPaintCrossLine = NULL; if (iMainImage->Cursor == crPen) iMainImage->OnPaintCursor = PaintPenLocate; else iMainImage->OnPaintCursor = NULL; } // GreenFish (IndexPoint»ý¼º) if (Ruler->Cursor == crHSplit || Ruler->Cursor == crVSplit) { MainMenuForm->Item = T_INDEX; if (!FirstIndex) PaintCurrentIndexPoint(); iMainImage->SetCrossPos(Point(X, Y)); FirstIndex = false; PaintCurrentIndexPoint(); } // IndexPoint À̵¿ if (iMainImage->OnPaintIndexPoint && (MainMenuForm->Item == T_NONE || MainMenuForm->Item == T_INDEX) && Ruler->Cursor == crDefault && !IndexLock1->Checked && DownState == false && FullViewForm->Tapeline == 0) { // if (iMainImage->OnPaintIndexPoint && (MainMenuForm->Item == T_NONE || MainMenuForm->Item == T_INDEX) // && Ruler->Cursor == crDefault && ( (!IndexLock1) || !IndexLock1->Checked )){ // iMainImage->OnPaintCursor = PaintPenLocate;//ÀåÁø¸¸: °¡À̵å¹Ù ÄѰí CrossLine ÄѸé Ä¿¼­ ÀÌ»óÇØÁö´Â Çö»ó if (sbCrossLine->Down) iMainImage->OnPaintCursor = NULL; else iMainImage->OnPaintCursor = PaintPenLocate; MainMenuForm->Item = T_NONE; VIM = NULL; HIM = NULL; for (int i = 0; i < VI; i++) { if (X <= VIndex[i] + 3 * iMainImage->ZoomOut / iMainImage->ZoomIn && X >= VIndex[i] - 3 * iMainImage->ZoomOut / iMainImage->ZoomIn && X >= iMainImage->PositionX) { // X > iMainImage->PositionX iMainImage->OnPaintCursor = NULL; iMainImage->Cursor = crHandPoint; VIM = i + 1; // Vertical Index Move function MainMenuForm->Item = T_INDEX; break; } } for (int j = 0; j < HI; j++) { if (Y <= HIndex[j] + 3 * iMainImage->ZoomOut / iMainImage->ZoomIn && Y >= HIndex[j] - 3 * iMainImage->ZoomOut / iMainImage->ZoomIn && Y >= iMainImage->PositionY) { iMainImage->OnPaintCursor = NULL; iMainImage->Cursor = crHandPoint; VIM = NULL; // °ãÃÄ ÀÖ´Â °æ¿ì Horizonal Index °¡ ¿ì¼±ÇÑ´Ù HIM = j + 1; MainMenuForm->Item = T_INDEX; break; } } } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - by monkman (2005.02.17) if (NVector->bVectorReflectionMode && iMainImage->OnPaintVectorReflectIndexPoint && NVector->ReflectionVH > 0 && VectorForm && (MainMenuForm->Item == T_VECTOR)) { // ÁÂÇ¥ ±Ùó¿¡ ¿À°ÔµÇ¸é Ä¿¼­°¡ º¯ÇÏ°Ô µÇ¸ç, ±×¸®´Â ÁßÀ̾ú´Ù¸é ÁÂÇ¥¸¦ ´Ù½Ã ¼³Á¤ÇÑ´Ù switch(NVector->ReflectionVH) { case 1: // ¼öÁ÷ ±âÁؼ± if (!NVector->bReflectionGuideLineLock && NVector->ReflectionVIndex - 5 < X && X < NVector->ReflectionVIndex + 5) { // °¡À̵å¶óÀÎ ¼³Á¤½Ã¸¸.. - by monkman (2005.03.17) iMainImage->Cursor = crHSplit; } else iMainImage->Cursor = crDefault; break; case 2: // ¼öÆò ±âÁؼ± if (!NVector->bReflectionGuideLineLock && NVector->ReflectionHIndex - 5 < Y && Y < NVector->ReflectionHIndex + 5) { // °¡À̵å¶óÀÎ ¼³Á¤½Ã¸¸.. - by monkman (2005.03.17) iMainImage->Cursor = crVSplit; } else iMainImage->Cursor = crDefault; break; case 3: // ¼öÁ÷ ±âÁؼ± ±×¸®´Â Áß case 4: // ¼öÆò ±âÁؼ± ±×¸®´Â Áß iMainImage->SetReflectionPos(Point(X, Y)); NVector->ReflectFirstIndex = false; break; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- POINT pt; COLORREF color; // int px, py; //<-- playzzang TCursor cursor, OldCursor; // --> playzzang if (Active) { if (X < 0 || X >= iMainImage->uBitmap->Width || Y < 0 || Y >= iMainImage->uBitmap->Height) { BtnClick = false; } else if (iMainImage->Reflection){ if (X >= MainImageForm->reflection->ScreenWidth || Y >= MainImageForm->reflection->ScreenHeight) BtnClick = false; } // px = (X - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut; // py = (Y - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut; /* if (px < 0 || px >= iMainImage->Width || py < 0 || py >= iMainImage->Height) { MainMenuForm->iMainImageMouseLeave(this); iMainImage->Cursor = crDefault; } */ // ¿Ö Àִ°ÅÁÒ?? ¹Ø¿¡ Àִµ¥...ÀÌÇØ ºÒ°¡ ´©°¡ ¾ËÄÑÁÖ¿ä By GreenFish if ((!iMainImage->Reflection && X >= 0 && X < iMainImage->uBitmap->Width && Y >= 0 && Y < iMainImage->uBitmap->Height) || (iMainImage->Reflection && (X >= 0 && X < MainImageForm->reflection->ScreenWidth && Y >= 0 && Y < MainImageForm->reflection->ScreenHeight))) { if (!bOnImage) { bOnImage = true; MainMenuForm->iMainImageMouseEnter(this); } if (iMainImage->Cross) { iMainImage->SetCrossPos(Point(X, Y)); if (!DrawORStitch) iMainImage->Cursor = crNone; } else Screen->Cursor = crDefault; CursorPosition.x = X; CursorPosition.y = Y; if (MouseState && DownState) { ptSecond = Point(X, Y); pt.x = ptSecond.x - ptFirst.x; pt.y = ptSecond.y - ptFirst.y; // ¼Óµµ °³¼±À» À§ÇØ ¿òÁ÷ÀÏ °æ¿ì (GDI·Î ±×¸°´Ù - ¿ÀºêÁ§Æ® À̵¿, ĵ¹ö½º À̵¿ µîÀ» À̵¿ÇÒ ¶§) - by monkman (2005.07.11) TList *DataList = form->V_DATA; if (VecDraw->NVector) VecDraw->NVector->bVectorMove = true; iMainImage->SetPosition(iMainImage->PositionX - pt.x, iMainImage->PositionY - pt.y); ptFirst.x = ptSecond.x - pt.x; ptFirst.y = ptSecond.y - pt.y; // Ctrl+¸¶¿ì½º µå·¡±×·Î È­¸éÀ̵¿À» ÇÒ ¶§ ÀÌ¿ë if (this->Active) { if (VectorForm && VectorForm->sbNewTextEdit->Down) { VectorForm->CaretPozChange(); // SetFocusedControl(this);// ¹öưÀ» Ŭ¸¯ÇÏ¸é ±×°÷¿¡ Æ÷Ä¿½º°¡ À־ "¹æÇâŰ"°¡ // // 󸮵ÇÁö ¾Ê´Â ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ »ç¿ë // tempRadioButton->SetFocus(); } } } else { if (DownState == false) { color = iMainImage->uBitmap->GetPixelColor (CursorPosition.x, CursorPosition.y); PaletteForm->DIB256Palette->CursorIndex = color; } if (MainMenuForm->iMainImageMouseMove(this, Shift, X, Y)) { if (bDrawPen) { if (FullViewForm->iMainImageMouseMove(Sender, Shift, X, Y)) { if (PenManagerForm->acolor == 1) { // PenManagerForm->SpecialMouseMove(Shift, X, Y); PenManagerForm->SpecialMouseMove(Shift, snapped_point.x, snapped_point.y); // ÀåÁø¸¸ if (!iMainImage->Cross) iMainImage->Cursor = crCross; } else { // if(BtnClick) { // std::fstream f("c:\\before_special_tablet_test_24.txt", std::ios_base::out | std::ios_base::app); // f << " Pressure : " << Tablet->prsNew << std::endl; // f.close(); // } if (BtnClick) PenManagerForm->SpecialMouseMove (Shift, snapped_point.x, snapped_point.y); // ÀåÁø¸¸ if (!iMainImage->Cross && !KasuriForm) iMainImage->Cursor = crPen; // by bomchun °¡½º¸®Æû Àܻ󿡷¯·Î Æ÷ÀÎÅÍ ¼öÁ¤ÇÏ´À¶ó °íħ(2007.02.23) } } else { if (!iMainImage->Cross) iMainImage->Cursor = crCross; } } PaletteForm->iMainImageMouseMove(Sender, Shift, X, Y); } } } else { MainMenuForm->iMainImageMouseLeave(this); iMainImageMouseLeave(this); iMainImage->Cursor = crDefault; bOnImage = false; } } next: isPaintDirectlyClean = false; PaintDirectly2(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseUp (TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { // GDI+·Î ±×¸®µµ·Ï µ¹·Á³õ´Â´Ù - by monkman (2008.10.20) if (Shift.Contains(ssCtrl) == false) { if (false == iMainImage->bVectorModify) tmVectorMoveDraw->Enabled = true; else { if (VecDraw->NVector) VecDraw->NVector->bVectorMove = false; } if (VecDraw->NVector) VecDraw->NVector->bSelectedVectorMove = false; } if (bShortcutForEnlarge) { bShortcutForEnlarge = false; TempLabel->Visible = false; iMainImage->Repaint(); return; } PaintDirectly(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); isPaintDirectlyClean = true; if (Active) { if (MouseState && DownState) { ptSecond = Point(X, Y); iMainImageChange(); iMainImage->SetPosition(iMainImage->PositionX - (ptSecond.x - ptFirst.x), iMainImage->PositionY - (ptSecond.y - ptFirst.y)); MouseState = 0; DownState = false; iMainImage->Cursor = crDefault; } else { if ((X < iMainImage->uBitmap->Width) && (Y < iMainImage->uBitmap->Height) ) { bool isNonePen = MainMenuForm->iMainImageMouseUp (this, Button, Shift, X, Y); if (isNonePen) { PenManagerForm->SpecialMouseUp(Button, Shift, X, Y); if (AutoRepeat && (PaletteForm->Item != PAL_PROTECT) && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) if (!(Button == mbMiddle || (Shift.Contains(ssShift) && Button == mbLeft))) RedrawingRepeat(PenManagerForm->sbMask->Down, true); // if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt))FullViewForm->InitForm(iMainImage); if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) FullViewForm->RepaintForm(iMainImage); // ÀåÁø¸¸ BtnClick = false; } if (iMainImage->uBitmap->BitsPerPixel == 24) { if (!isNonePen) { if (!VectorForm) // shin vector iMainImage->Repaint(); if (FullViewForm->Visible == true) FullViewForm->View(); if (LayerForm->Visible == true) { ((TPLayer*)(iMainImage->LayerList->Items[iMainImage->Index])) ->UpdateMiniBitmap(iMainImage->Frgb); LayerForm->LayerGrid->Repaint(); } } } else { if (!isNonePen) { if (!VectorForm) // shin vector iMainImage->Repaint(); if (FullViewForm->Visible == true) FullViewForm->View(); if (LayerForm->Visible == true) { ((TPLayer*)(iMainImage->LayerList->Items[iMainImage->Index])) ->UpdateMiniBitmap(iMainImage->Frgb); LayerForm->LayerGrid->Repaint(); } } } DownState = false; } } // if (this->Active) { // if ((MainMenuForm->UseEditFunction) // || (VectorForm && (VectorForm->V_MainItem == 2 || VectorForm->V_MainItem == 3))) { // For TextBox by maxleo21c (04.10.19) // // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // // ¹æÇâŰ·Î ¹Ì¼¼ À̵¿ - by monkman (2005.01.31) // // SetFocusedControl(this); // ¹öưÀ» Ŭ¸¯ÇÏ¸é ±×°÷¿¡ Æ÷Ä¿½º°¡ À־ "¹æÇâŰ"°¡ // // 󸮵ÇÁö ¾Ê´Â ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ »ç¿ë // if (!tempRadioButton->Focused()) tempRadioButton->SetFocus(); // // // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // } // } } isPaintDirectlyClean = false; PaintDirectly(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImagePaint(TObject *Sender) { // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImagePositionChange(TObject *Sender) { UpdateImage(); Ruler->StartX = iMainImage->PositionX; Ruler->StartY = iMainImage->PositionY; sbHorz->Position = iMainImage->PositionX; sbVert->Position = iMainImage->PositionY; FullViewForm->SetPositionX(iMainImage->PositionX); FullViewForm->SetPositionY(iMainImage->PositionY); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbUnitClick(TObject *Sender) { if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } if (CurrentUnit == uDot) UnitChange(uInch); else if (CurrentUnit == uInch) UnitChange(uCm); else if (CurrentUnit == uCm) UnitChange(uDot); // ================================== for fit size by kjs // v7.1À» ÄÄÆÄÀÏÇϱâ À§ÇØ Àá½Ã ¸·¾Æ³ð.. if (MainMenuForm->sb3D->Enabled) MainMenuForm->Show_FabricSize(); // =================================== } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::TempLabelMouseDown (TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int x, y; if (Button == mbLeft) { x = iMainImage->CanvasToBitmapX(TempLabel->Left + X); y = iMainImage->CanvasToBitmapY(TempLabel->Top + Y); iMainImageMouseDown(this, Button, Shift, x, y); } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbZoomInClick(TObject *Sender) { switch(iMainImage->ZoomIn) { // Zoom ´Ü°è 17´Ü°è·Î ¼öÁ¤ By GreenFish case 1: switch(iMainImage->ZoomOut) { case 1: ZoomChange(3, 2); break; case 2: ZoomChange(2, 3); break; case 3: ZoomChange(1, 2); break; case 4: ZoomChange(1, 3); break; case 6: ZoomChange(1, 4); break; case 8: ZoomChange(1, 6); break; case 12: ZoomChange(1, 8); break; case 16: ZoomChange(1, 12); break; } break; case 2: switch(iMainImage->ZoomOut) { case 1: ZoomChange(3, 1); break; case 3: ZoomChange(1, 1); break; } break; case 3: switch(iMainImage->ZoomOut) { case 1: ZoomChange(4, 1); break; case 2: ZoomChange(2, 1); break; } break; case 4: ZoomChange(6, 1); break; case 6: ZoomChange(8, 1); break; case 8: ZoomChange(12, 1); break; case 12: ZoomChange(16, 1); break; } if (this->Active) { if (VectorForm && VectorForm->sbNewTextEdit->Down) { VectorForm->CaretPozChange(); // SetFocusedControl(this);// ¹öưÀ» Ŭ¸¯ÇÏ¸é ±×°÷¿¡ Æ÷Ä¿½º°¡ À־ "¹æÇâŰ"°¡ // // 󸮵ÇÁö ¾Ê´Â ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ »ç¿ë // tempRadioButton->SetFocus(); } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbZoomOutClick(TObject *Sender) { switch(iMainImage->ZoomIn) { case 1: switch(iMainImage->ZoomOut) { case 1: ZoomChange(2, 3); break; case 2: ZoomChange(1, 3); break; case 3: ZoomChange(1, 4); break; case 4: ZoomChange(1, 6); break; case 6: ZoomChange(1, 8); break; case 8: ZoomChange(1, 12); break; case 12: ZoomChange(1, 16); break; } break; case 2: switch(iMainImage->ZoomOut) { case 1: ZoomChange(3, 2); break; case 3: ZoomChange(1, 2); break; } break; case 3: switch(iMainImage->ZoomOut) { case 1: ZoomChange(2, 1); break; case 2: ZoomChange(1, 1); break; } break; case 4: ZoomChange(3, 1); break; case 6: ZoomChange(4, 1); break; case 8: ZoomChange(6, 1); break; case 12: ZoomChange(8, 1); break; case 16: ZoomChange(12, 1); break; } if (this->Active) { if (VectorForm && VectorForm->sbNewTextEdit->Down) { VectorForm->CaretPozChange(); // SetFocusedControl(this);// ¹öưÀ» Ŭ¸¯ÇÏ¸é ±×°÷¿¡ Æ÷Ä¿½º°¡ À־ "¹æÇâŰ"°¡ // // 󸮵ÇÁö ¾Ê´Â ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ »ç¿ë // tempRadioButton->SetFocus(); } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbGridClick(TObject *Sender) { grid_state++; // ÀåÁø¸¸ if (grid_state >= 3) grid_state = 0; if (grid_state == 0) { sbGrid->Visible = true; sbGrid->Down = false; sbSnapGrid->Down = false; } else if (grid_state == 1) { sbGrid->Visible = true; sbGrid->Down = true; sbSnapGrid->Down = false; } else if (grid_state == 2) { sbGrid->Visible = false; sbGrid->Down = true; sbSnapGrid->Down = true; } sbSnapGrid->Visible = !sbGrid->Visible; // ¿©±â±îÁö ÀåÁø¸¸ iMainImageChange(); iMainImage->Grid = sbGrid->Down; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbSnapGridClick(TObject *Sender) { sbGridClick(Sender); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbRulerClick(TObject *Sender) { if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } VIndexSelected = false; HIndexSelected = false; static bool indexVisible; if (sbRuler->Down == false) { if (Visible1->Checked) { indexVisible = true; Ruler->Cursor = crDefault; // Ruler->Cursor°¡ À妽º Æ÷ÀÎÆ® ±×¸®±âÀÇ ÁöÇ¥ÀÌ´Ù VIndexSelected = false; HIndexSelected = false; HIM = VIM = NULL; IndexSW = false; iMainImage->OnPaintCursor = PaintPenLocate; // ItemÀÌ T_NONEÀÌ ¾Æ´Ï¸é ExitForm()ÀÌ È£ÃâµÇ¹Ç·Î º¤ÅÍÆûÀÌ ´ÝÇô¹ö¸®³×¿ä. // ÀÏ´Ü ¸·¾Æ ³õ½À´Ï´Ù.. - by monkman (2005.05.31) // ===========================================// // if(MainMenuForm->Item != T_NONE) // // MainMenuForm->ExitForm(); // // MainMenuForm->Item = T_NONE; //¿Ö T_NONE À¸·Î ÇßÀ»±î¿ä??? // ===========================================// iMainImage->Repaint(); Visible1Click(this); } else { indexVisible = false; } // Visible1->Checked = true; } else { if (indexVisible) { if (Visible1->Checked == false) Visible1Click(this); } } iMainImageChange(); FormResize(this); sbCrossLine->Enabled = true; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbProtectClick(TObject *Sender) { BEGIN_LOG(""); if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } TSpeedButton *s = (TSpeedButton*)Sender; if (s == sbProtect) { bProtect ^= 1; SetProtectBackGround(); MainMenuForm->SuperChange(Sender); } else if (s == sbMaskArea) { bMaskArea ^= 1; MainMenuForm->SuperChange(Sender); } else if (s == sbMaskShow) { SetMaskShow(sbMaskShow->Down); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbCrossLineClick(TObject *Sender) { if (sbCrossLine->Down) { iMainImage->Cross = true; iMainImage->CrossLine = true; if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } } else { iMainImage->Cross = false; iMainImage->CrossLine = false; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbMaskAreaClick(TObject *Sender) { BEGIN_LOG(""); if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } TSpeedButton *s = (TSpeedButton*)Sender; if (s == sbProtect) { bProtect ^= 1; SetProtectBackGround(); MainMenuForm->SuperChange(Sender); } else if (s == sbMaskArea) { bMaskArea ^= 1; MainMenuForm->SuperChange(Sender); } else if (s == sbMaskShow) { SetMaskShow(sbMaskShow->Down); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbMaskShowClick(TObject *Sender) { BEGIN_LOG(""); if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } TSpeedButton *s = (TSpeedButton*)Sender; if (s == sbProtect) { bProtect ^= 1; SetProtectBackGround(); MainMenuForm->SuperChange(Sender); } else if (s == sbMaskArea) { bMaskArea ^= 1; MainMenuForm->SuperChange(Sender); } else if (s == sbMaskShow) { SetMaskShow(sbMaskShow->Down); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbAutoRepViewClick(TObject *Sender) { BEGIN_LOG(""); if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } if (AutoRepeat) { if (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt) { if (sbAutoRepView->Down) { AutoRepViewForm = new TAutoRepViewForm(NULL); AutoRepViewForm->Parent = MainForm; AutoRepViewForm->Visible = true; } else { ARViewExitForm(); } } else { ShowMessage(IDS_MESSAGE_NOAUTOREPEAT); sbAutoRepView->Down = false; } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbHorzScroll (TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { if (VecDraw->NVector) VecDraw->NVector->bVectorMove = true; iMainImageChange(); iMainImage->PositionX = sbHorz->Position; if (this->Active) { if (VectorForm && VectorForm->sbNewTextEdit->Down) { VectorForm->CaretPozChange(); // SetFocusedControl(this);// ¹öưÀ» Ŭ¸¯ÇÏ¸é ±×°÷¿¡ Æ÷Ä¿½º°¡ À־ "¹æÇâŰ"°¡ // // 󸮵ÇÁö ¾Ê´Â ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ »ç¿ë // tempRadioButton->SetFocus(); } } tmVectorMoveDraw->Enabled = true; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbVertScroll (TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { if (VecDraw->NVector) VecDraw->NVector->bVectorMove = true; iMainImageChange(); iMainImage->PositionY = sbVert->Position; if (this->Active) { if (VectorForm && VectorForm->sbNewTextEdit->Down) { VectorForm->CaretPozChange(); // SetFocusedControl(this);// ¹öưÀ» Ŭ¸¯ÇÏ¸é ±×°÷¿¡ Æ÷Ä¿½º°¡ À־ "¹æÇâŰ"°¡ // // 󸮵ÇÁö ¾Ê´Â ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ »ç¿ë // tempRadioButton->SetFocus(); } } tmVectorMoveDraw->Enabled = true; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Private Function // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- int TMainImageForm::WMNCPaint(TMessage &msg) { DefWindowProc(Handle, WM_NCPAINT, msg.WParam, msg.LParam); return 0; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetCaption() { String fn = ExtractFileName(FileName); if (MainForm->AutoRepPreV) { if (iMainImage->uBitmap->BitsPerPixel == 8) { Caption = "AutoRepeatPreviewForm - 256 Colors"; } else { Caption = "AutoRepeatPreviewForm - Full Colors"; } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { Caption = (DirName.Length() > 0 ? FullPathName(DirName, fn) : fn) + String (" - 256 Colors"); } else { Caption = (DirName.Length() > 0 ? FullPathName(DirName, fn) : fn) + String (" - Full Colors"); } } if (iMainImage->uBitmap->BitsPerPixel == 8) { sbProtect->Enabled = true; } else { sbProtect->Enabled = false; } MainForm->UpdateCanvasTab(dynamic_cast(this), FileName, Modify); } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromFile(String FileName, TGraphicFileFormat Index, TUnionBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &ci, bool &layer, WORD bpp) { // 8.0 conversion TEXPIAFILEHEADER tpfh; int x, y; RGBQUAD rgb[256]; Byte c[256]; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; bool vector; TGraphicFileFormat gff = Index; BEGIN_LOG(""); if (Index == gffTEX || Index == gffTFC #ifdef TRIAL || Index == gffTEX_TRIAL || Index == gffTFC_TRIAL #endif ) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TRIAL if (Index == gffTEX_TRIAL || Index == gffTFC_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, true, NULL, true)) != EC_NONE) goto fail; } else { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff)) != EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff)) != EC_NONE) goto fail; #endif // UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number >= 230) { if (tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } // 090527 upper version if (!ReadFile(hFile, &layer, sizeof(bool), &dwRead, NULL)) goto fail; if (layer) { if (bpp == pBitmap->BitsPerPixel) { if (bpp == 8) { pPalette->ToRGBQUAD(rgb, 256); iMainImage->LoadFromLayerFile(hFile, tpfh.Version.Number, rgb); } else { iMainImage->LoadFromLayerFile(hFile, tpfh.Version.Number); } LayerCNT = iMainImage->Index + 1; } else { layer = false; } } if (tpfh.Version.Number >= 240) { if (!ReadFile(hFile, &vector, sizeof(bool), &dwRead, NULL)) goto fail; if (vector) VecDraw->LoadFromFile(hFile); // By GreenFish Vector File Load (8.1) // layer°¡ ÀÖÀ» °æ¿ì¿¡ BitmapÀº 8bitÀ̸鼭 tfc·Î ÀúÀåÀ» ÇßÀ» °æ¿ì ¹®Á¦°¡ ¹ß»ýÇÑ´Ù. // ÇØ°á ¹æ¹ýÀº 8bit·Î ÀúÀåµÈ bitmap°ú layer¸¦ 24bit·Î ÄÁ¹öÆ® ½ÃŰ´Â ÇÔ¼ö°¡ ÇÊ¿äÇÏ´Ù. // if (vector){ // by shin(8.2) // if (!VecDraw->LoadFromFile(hFile)) {ec = EC_NO_MESSAGE; goto fail;} // } } } CloseHandle(hFile); #ifdef NOTN3D #else } else if (Index == gffN3D) { // N3D_jeegeo if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!new3d) new3d = new TN3D(iMainImage); if ((ec = new3d->LoadFromFile(hFile, pPalette, tpfh)) != EC_NONE) goto fail; N3DMappingForm->Visible = true; N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); LayerForm->Visible = false; if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number >= 230) { if (tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } // 090527 upper version ec = EC_NONE; } else { ec = EC_FILE_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } ci = tpfh.CanvasInfor; UserColorLibForm->ThisFileHasUserColor(pPalette); layer = true; if (tpfh.Version.Number >= 240) { // 240ÀÌ»óÀ϶§¸¸ vector if (!ReadFile(hFile, &vector, sizeof(bool), &dwRead, NULL)) goto fail; // if (vector) VecDraw->LoadFromFile(hFile);// By GreenFish Vector File Load if (vector) { VecDraw->LoadFromFile(hFile); // By GreenFish Vector File Load // if (!VecDraw->LoadFromFile(hFile)) {ec = EC_NO_MESSAGE; goto fail;} } } CloseHandle(hFile); #endif } else if (Index == gffWEA || Index == gffWAV || Index == gffKNT //|| Index == gffPIL #ifdef TRIAL || Index == gffWEA_TRIAL || Index == gffKNT_TRIAL #endif ) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TRIAL if (Index == gffWEA_TRIAL || Index == gffKNT_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, false, NULL, true)) != EC_NONE) goto fail; } else { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, false)) != EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, false)) != EC_NONE) goto fail; #endif UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; CloseHandle(hFile); } else { if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } ci.DotsPerInch = pBitmap->DotsPerInch; // By GreenFish ci.SetSize(cstFree, pBitmap->Width, pBitmap->Height); if (pBitmap->BitsPerPixel == 8) { pBitmap->GetColors(0, 256, rgb); pPalette->SetNormal(0, 0, 0, 0); for (x = 0; x < 250; x++) { pPalette->SetNormal(x + 2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } pPalette->SetNormal(255, 255, 255, 255); } } END_LOG; return EC_NONE; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadToSelectImage (String FileName, TGraphicFileFormat Index, TUnionBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &ci) { TEXPIAFILEHEADER tpfh; int x, y; float MergeRatio; RGBQUAD rgb[256]; Byte c[256]; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; bool layer, vector; TGraphicFileFormat gff = Index; BEGIN_LOG(""); if (Index == gffTEX || Index == gffTFC #ifdef TRIAL || Index == gffTEX_TRIAL || Index == gffTFC_TRIAL #endif ) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TRIAL if (Index == gffTEX_TRIAL || Index == gffTFC_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, true, NULL, true)) != EC_NONE) goto fail; } else { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff)) != EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff)) != EC_NONE) goto fail; #endif UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; // 090527 upper version if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } double MergeRatio = (double)CanvasInfor.DotsPerInch / ci.DotsPerInch; ci.Height *= MergeRatio; // By GreenFish ci.Width *= MergeRatio; // Merge ¼öÁ¤ (DPIº¯È­¿¡ ´ëÇÑ Å©±â ºñÀ² Á¶Àý) ci.DotsPerInch = CanvasInfor.DotsPerInch; if (iMainImage->uBitmap->BitsPerPixel == 24 && pBitmap->BitsPerPixel != 24) pBitmap->ColorResolution(24, CRF_OPTIMIZEDPALETTE, NULL, 256); // ==============Vector Merge if (tpfh.Version.Number >= 240) { if (!ReadFile(hFile, &layer, sizeof(bool), &dwRead, NULL)) goto fail; if (!layer) { if (!ReadFile(hFile, &vector, sizeof(bool), &dwRead, NULL)) goto fail; if (vector) VecDraw->InitMerge(hFile); // By GreenFish Vector File Merge } } // ============== CloseHandle(hFile); } else if (Index == gffWEA || Index == gffWAV || Index == gffKNT //|| Index == gffPIL #ifdef TRIAL || Index == gffWEA_TRIAL || Index == gffKNT_TRIAL #endif ) { if (!FileExists(FileName)) { ec = EC_FILE_NOT_EXIST; SAVE_EXCEPTION(ec); goto fail; } if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TRIAL if (Index == gffWEA_TRIAL || Index == gffKNT_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, false, NULL, true)) != EC_NONE) goto fail; } else { if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, false)) != EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, gff, false)) != EC_NONE) goto fail; #endif UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; // 090527 upper version if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 24 && pBitmap->BitsPerPixel != 24) pBitmap->ColorResolution(24, CRF_OPTIMIZEDPALETTE, NULL, 256); CloseHandle(hFile); } else { // 090527 upper version if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } if (!pBitmap->LoadFromFile(FileName)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } ci.DotsPerInch = pBitmap->DotsPerInch; // By GreenFish ci.SetSize(cstFree, pBitmap->Width, pBitmap->Height); if (iMainImage->uBitmap->BitsPerPixel == 8) { if (pBitmap->BitsPerPixel == 8) { pBitmap->GetColors(0, 256, rgb); pPalette->SetNormal(0, 0, 0, 0); for (x = 0; x <= 249; x++) { pPalette->SetNormal(x + 2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } pPalette->SetNormal(255, 255, 255, 255); // dog err[bmp merge to 256]*.tex ¿Í *.bmp¸¦ 256¿¡ mergeÇÒ¶§ iMainImage->uBitmap, SubBitmap¿¡ Byte cc[256], *sp; // »öÀÌ ÀÌ»óÇÏ°Ô µé¾î°¡¼­ °íÄ£ °Í. int xx, yy; memset(cc, 0, 256); if (!pBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (yy = 0; yy < pBitmap->Height; yy++) { sp = pBitmap->GetScanLine(yy); // for (xx = 0; xx < pBitmap->Width; xx++, sp++) { *sp += 2; cc[*sp] = 1; } pBitmap->PutScanLine(yy); // } pBitmap->StopScanLine(); for (xx = 251; xx >= 1; xx--) { if (cc[xx] == 1) { pPalette->UseColor = xx; break; } } pPalette->ToRGBQUAD(rgb, 256); pBitmap->PutColors(0, 256, rgb); } // end dog } else { if (pBitmap->BitsPerPixel != iMainImage->uBitmap->BitsPerPixel) pBitmap->ColorResolution(iMainImage->uBitmap->BitsPerPixel, CRF_OPTIMIZEDPALETTE, NULL, 256); } } END_LOG; return EC_NONE; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ReviewStatusBar() { MainForm->StatusBar->Panels->Items[StatusBarSize]->Text = "Size : " + CanvasInfor.Name(CurrentUnit, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); MainForm->StatusBar->Panels->Items[StatusBarDPI]->Text = Format ("DPI : %d", OPENARRAY(TVarRec, (CanvasInfor.DotsPerInch))); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetProtectBackGround() { BEGIN_LOG(""); if (bProtect) { iMainImage->InitBackGround(0x10); } else { iMainImage->ExitBackGround(0x10); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetProtect(bool Value) { BEGIN_LOG(""); if (Value != bProtect) { bProtect = Value; if (bProtect) sbProtect->Down = true; else sbProtect->Down = false; SetProtectBackGround(); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetMaskArea(bool Value) { if (Value != bMaskArea) { bMaskArea = Value; sbMaskArea->Enabled = Value; sbMaskArea->Down = Value; sbMaskShow->Enabled = Value; } } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::AllocLineMem(int d) { BEGIN_LOG(""); if (d != memsize) { DelLineMem(); if ((hMemLine = GlobalAlloc(GHND, 2 * d*sizeof(int))) == NULL) goto fail; if ((msx = (int*)GlobalLock(hMemLine)) == NULL) goto fail; mex = (int*)msx + d; memsize = d; } END_LOG; return true; fail: DelLineMem(); END_LOG; return false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::DelLineMem() { if (hMemLine) { if (msx) { GlobalUnlock(hMemLine); msx = NULL; } GlobalFree(hMemLine); hMemLine = NULL; } memsize = 0; } // --------------------------------------------------------------------------- /* bool __fastcall TMainImageForm::AllocTempLineMem(int d) { if (d!=tmemsize) { DelTempLineMem(); if ((htMemLine = GlobalAlloc(GHND, 2*d*sizeof(int)))==NULL) goto fail; if ((tsx = (int *)GlobalLock(htMemLine))==NULL) goto fail; tex = (int *)tsx + d; tmemsize = d; } return true; fail: DelTempLineMem(); return false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DelTempLineMem() { if (htMemLine) { if (tsx) { GlobalUnlock(htMemLine); tsx = NULL; } GlobalFree(htMemLine); htMemLine = NULL; } tmemsize = 0; } */ // --------------------------------------------------------------------------- void __fastcall TMainImageForm::pos_in(TLineData &ld, int by, int bsx, int bex, int ch) { double d; if ((by >= 0) && (by < iMainImage->uBitmap->Height)) { if (*(msx + by) > bsx) { if (ch) { d = (ld.dx1 - bsx) * (ld.dx1 - bsx) + (ld.dy1 - by) * (ld.dy1 - by); if (d < ld.d1) { ld.psx1 = bsx; ld.pex1 = ld.ex + (bsx - ld.sx); ld.psy1 = by; ld.pey1 = ld.ey + (by - ld.sy); ld.d1 = d; } } *(msx + by) = bsx; } if (*(mex + by) < bex) { if (ch) { d = (ld.dx2 - bex) * (ld.dx2 - bex) + (ld.dy2 - by) * (ld.dy2 - by); if (d < ld.d2) { ld.psx2 = bex; ld.pex2 = ld.ex + (bex - ld.sx); ld.psy2 = by; ld.pey2 = ld.ey + (by - ld.sy); ld.d2 = d; } } *(mex + by) = bex; } } } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToJPEG(TTexpiaBitmap *tb, String fn) { BEGIN_LOG(""); TDialogForm *Form = NULL; int nFormat, QFactor, ec = EC_NONE; Form = new TDialogForm(this); Form->Caption = "JPEG Option"; Form->PanelJPEG->BringToFront(); if (Form->ShowModal() == mrOk) { switch(Form->cbComKind->ItemIndex) { case 0: nFormat = FILE_JFIF; QFactor = 2; break; case 1: nFormat = FILE_LEAD2JFIF; QFactor = Form->spQFactor->Value; break; case 2: nFormat = FILE_LEAD1JFIF; QFactor = Form->spQFactor->Value; } if (!tb->SaveToFile(fn, nFormat, QFactor)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToJPEG(TUnionBitmap *ub, String fn) { BEGIN_LOG(""); // Å« »çÀÌÁî ºñÆ®¸ÊÀ» ÀúÀåÇÒ ¼ö ÀÖµµ·Ï ¼öÁ¤ - by monkman (2006.06.02) TDialogForm *Form = NULL; int nFormat, QFactor, ec = EC_NONE; TUnionBitmap *uBitmap24 = NULL; Form = new TDialogForm(this); Form->Caption = "JPEG Option"; Form->PanelJPEG->BringToFront(); if (Form->ShowModal() == mrOk) { switch(Form->cbComKind->ItemIndex) { case 0: nFormat = FILE_JFIF; QFactor = 2; break; case 1: nFormat = FILE_LEAD2JFIF; QFactor = Form->spQFactor->Value; break; case 2: nFormat = FILE_LEAD1JFIF; QFactor = Form->spQFactor->Value; } // 256 Ä÷¯ ºñÆ®¸ÊµµJPEG·Î ÀúÀåÇÒ ¼ö ÀÖµµ·Ï ±¸Çö - by monkman (2009.07.22) if (ub->BitsPerPixel == 8) { uBitmap24 = new TUnionBitmap; if (uBitmap24) { uBitmap24->Create(ub->Width, ub->Height, 24, NULL); ub->CopyToBitmapByBitsPerPixel(uBitmap24); // ´Ù¸¥ BitsPerPixel·Î º¹»ç // if(!uBitmap24->SaveToFile(fn, nFormat, QFactor)) {ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } if (!uBitmap24->SaveToFile(fn, nFormat, QFactor, CanvasInfor.DotsPerInch)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } delete uBitmap24; } } else { // if(!ub->SaveToFile(fn, nFormat, QFactor)) {ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } if (!ub->SaveToFile(fn, nFormat, QFactor, CanvasInfor.DotsPerInch)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } } } END_LOG; return ec; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoSaveToFile(String dn, String fn, TGraphicFileFormat Index, TCompressMethod cm) { HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; TTexpiaBitmap *tag = NULL; // , *tb = NULL; TUnionBitmap *ub = NULL; TPException ec = EC_NONE; bool layer; DWORD dwWrite; if (AutoRepeat) return; BEGIN_LOG(""); if (Index == gffTEX || Index == gffTFC #ifdef TRIAL || Index == gffTEX_TRIAL || Index == gffTFC_TRIAL #endif ) { if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } tpfh.Version = TexVersion('P', 'T', TextileFileVersion); tpfh.CanvasInfor = CanvasInfor; tpfh.CanvasInfor.Width = iMainImage->uBitmap->Width; // abcdabcdabcd tpfh.CanvasInfor.Height = iMainImage->uBitmap->Height; // abcdabcdabcd tpfh.BitsPerPixel = iMainImage->uBitmap->BitsPerPixel; tpfh.Compress = cm; src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; if (iMainImage->LayerList->Count > 1) { if ((ub = iMainImage->Composition()) == NULL) goto fail; if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MakeTexpiaTag(tag, ub, src, 0); ////////////// HDC dcTemp = NULL; if ((dcTemp = tag->CreateDC()) == NULL) goto fail; VecDraw->TagDraw(dcTemp, tag->Width, tag->Height, src); tag->DeleteDC(dcTemp); dcTemp = NULL; //////// Vector Tag By GreenFIsh if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, ub, &WorkArea->Range)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, ub)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } layer = true; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; if (!iMainImage->SaveToLayerFile(hFile, tpfh.Version.Number)) goto fail; delete ub; } else { if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MakeTexpiaTag(tag, iMainImage->uBitmap, src, 0); ////////////// HDC dcTemp = NULL; if ((dcTemp = tag->CreateDC()) == NULL) goto fail; VecDraw->TagDraw(dcTemp, tag->Width, tag->Height, src); tag->DeleteDC(dcTemp); dcTemp = NULL; //////// Vector Tag By GreenFIsh if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->uBitmap)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; } CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; } else if (Index == gffT3D #ifdef TRIAL || Index == gffT3D_TRIAL #endif ) { if (MainForm->T3D_Item) { if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } // tpfh.Version = TexVersion('P', 'T', 230); // for fit size and point by kjs.... 230 --> 232 tpfh.Version = TexVersion('P', 'T', TextileFileVersion); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; tpfh.Compress = cm; src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = MainMenuForm->SaveTo3DFile(hFile, tpfh, tag, iMainImage->uBitmap)) != EC_NONE) goto fail; CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; } } SetCaption(); Modify = false; END_LOG; return; fail: if (ub) { delete ub; } if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange_none() { BEGIN_LOG(""); Byte *ssl = NULL, *dsl = NULL, *usl = NULL, *mml = NULL, usecolor; int x, y; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; //TTexpiaBitmap *SBitmap = NULL; TUnionBitmap *SBitmap = NULL; TUnionBitmap *UBitmap = NULL; RECT rc, urc; THistoryData *ud; //SBitmap = FullViewForm->OverlapBitmap; //rc = FullViewForm->OverlapRect; SBitmap = OverlapBitmap; rc = OverlapRect; int addx = 0, addy = 0; if (MainImageForm->reflection) { RECT rtRange; POINT pt = MainImageForm->reflection->ChangeAvailableOriginalRange(rc, rtRange); rc.left = rtRange.left; rc.top = rtRange.top; rc.right = rtRange.right; rc.bottom = rtRange.bottom; addx = pt.x; addy = pt.y; } //if (FullViewForm->OverlapBack) { if (OverlapBack) { urc = rc; } else { ud = Undo->GetLast(); if (ud == NULL) { END_LOG; return; } urc = ud->getRectRange(); // by linuxjun UBitmap = ud->uBitmap; if (UBitmap == NULL) { END_LOG; return; } UBitmap->PartialUndo->LoadLast(ud->FromRgb); } if (SBitmap && UBitmap) { PaletteForm->DIB256Palette->UseColor = preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartUndoScanLine()) goto fail; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (!iMainImage->Mask->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { if (SBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (Palette->ColorData[*usl]->Protect == 0 && (*mml == 0)) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*mml == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel == 8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx * 3; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); iMainImage->Mask->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartUndoScanLine()) goto fail; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { if (SBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (Palette->ColorData[*usl]->Protect == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } iMainImage->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel == 8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx * 3; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); END_LOG; return; fail: ExitOverlap(); iMainImage->uBitmap->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange_none2(bool flipX, bool flipY) { BEGIN_LOG(""); Byte *ssl = NULL, *dsl = NULL, *usl = NULL, *mml = NULL, usecolor; int x, y; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; //TTexpiaBitmap *SBitmap = NULL; TUnionBitmap *SBitmap = NULL; TUnionBitmap *UBitmap = NULL; RECT rc, urc; THistoryData *ud; //SBitmap = FullViewForm->OverlapBitmap; //rc = FullViewForm->OverlapRect; SBitmap = OverlapBitmap; rc = OverlapRect; //if (FullViewForm->OverlapBack) { if (OverlapBack) { urc = rc; } else { ud = Undo->GetLast(); if (ud == NULL) { END_LOG; return; } urc = ud->getRectRange(); // by linuxjun UBitmap = ud->uBitmap; if (UBitmap == NULL) { END_LOG; return; } UBitmap->PartialUndo->LoadLast(ud->FromRgb); } if (SBitmap && UBitmap) { int height = rc.bottom - rc.top; int width = rc.right - rc.left; PaletteForm->DIB256Palette->UseColor = preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartUndoScanLine()) goto fail; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (!iMainImage->Mask->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { if (SBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { if (flipY) { for (int y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y); usl = UBitmap->GetUndoScanLine(y); mml = iMainImage->Mask->GetScanLine(y); for (int x = rc.left, k = 0; x < rc.right; x++, k++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (Palette->ColorData[usl[rc.right - 1 - k]]->Protect == 0 && (mml[x] == 0)) { if (usl[rc.right - 1 - k] > 1) { if ((color = Overlap(usl[rc.right - 1 - k], ssl[width - 1 - k])) == 0xFF) goto fail; dsl[rc.right - 1 - k] = color; } else { dsl[rc.right - 1 - k] = ssl[width - 1 - k]; } } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(height - k); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(rc.bottom - k) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (Palette->ColorData[*usl]->Protect == 0 && (*mml == 0)) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (Palette->ColorData[*usl]->Protect == 0 && (*mml == 0)) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } } else { if (flipY) { for (int y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y); // + rc.left; usl = UBitmap->GetUndoScanLine(y); // + rc.left; //For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); // + rc.left; for (int x = rc.left, k = 0; x < rc.right; x++, k++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; // , ssl++, dsl++, mml++, usl++) { if (mml[x] == 0) { if (usl[rc.right - 1 - k] > 1) { if ((color = Overlap(usl[rc.right - 1 - k], ssl[width - 1 - k])) == 0xFF) goto fail; dsl[rc.right - 1 - k] = color; } else { dsl[rc.right - 1 - k] = ssl[width - 1 - k]; } } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(height - 1 - k); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(rc.bottom - 1 - k) + rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*mml == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*mml == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel == 8) { SBitmap->GetColors(0, 256, rgb); if (flipY) { for (int y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y); // + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); for (int x = rc.left, k = 0; x < rc.right; x++, k++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; // ssl++, dsl+=3, usl+=3) { if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[ssl[width - 1 - k]]); int temp = (rc.right - 1 - k) * 3; GetPixel24(usl[temp], dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl[temp], color); } else { SetPixel24(dsl[temp], sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(height - 1 - k); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(rc.bottom - 1 - k) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } } else { if (flipY) { for (int y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y); // + 3*rc.left; //For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); for (int x = rc.left, k = 0; x < rc.right; x++, k++, dsl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; // , ssl+=3, dsl+=3, usl+=3) { if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { int temp = (width - 1 - k) * 3; int temp2 = (rc.right - 1 - k) * 3; GetPixel24(ssl[temp], sc); GetPixel24(usl[temp2], dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl[temp2], color); } else { SetPixel24(dsl[temp2], sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(height - 1 - k); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(rc.bottom - 1 - k) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); iMainImage->Mask->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartUndoScanLine()) goto fail; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { if (SBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { if (flipY) { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y); // + rc.left; usl = UBitmap->GetUndoScanLine(y); // + rc.left; //For New Undo by linuxjun for (int x = rc.left, k = 0; x < rc.right; x++, k++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; // , ssl++, dsl++, usl++) { int temp = rc.right - 1 - k; int temp2 = width - 1 - k; if (Palette->ColorData[usl[temp]]->Protect == 0) { if (usl[temp] > 1) { if ((color = Overlap(usl[temp], ssl[temp2])) == 0xFF) goto fail; dsl[temp] = color; } else { dsl[temp] = ssl[temp2]; } } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(height - 1 - k); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(rc.bottom - 1 - k) + rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (Palette->ColorData[*usl]->Protect == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (Palette->ColorData[*usl]->Protect == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } } else { if (flipY) { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y); // + rc.left; usl = UBitmap->GetUndoScanLine(y); // + rc.left; //For New Undo by linuxjun for (int x = rc.left, k = 0; x < rc.right; x++, k++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; // , ssl++, dsl++, usl++) { if (usl[rc.right - 1 - k] > 1) { if ((color = Overlap(usl[rc.right - 1 - k], ssl[width - 1 - k])) == 0xFF) goto fail; dsl[rc.right - 1 - k] = color; } else { dsl[rc.right - 1 - k] = ssl[width - 1 - k]; } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(k); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } iMainImage->uBitmap->PutScanLine(y); } } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel == 8) { SBitmap->GetColors(0, 256, rgb); if (flipY) { for (int y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y); // + 3*rc.left; for (int x = rc.left, k = 0; x < rc.right; x++, k++, dsl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; // ssl++, dsl+=3, usl+=3) { sc = RGBToTColor(rgb[ssl[width - 1 - k]]); int temp = (rc.right - 1 - k) * 3; GetPixel24(usl[temp], dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl[temp], color); } else { SetPixel24(dsl[temp], sc); } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(height - 1 - k); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(rc.bottom - 1 - k) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } } else { if (flipY) { for (int y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y); // + 3*rc.left; for (int x = rc.left, k = 0; x < rc.right; x++, k++, dsl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; // ssl+=3, dsl+=3, usl+=3) { int temp = (rc.right - 1 - k) * 3; int temp2 = (width - 1 - k) * 3; GetPixel24(ssl[temp2], sc); GetPixel24(usl[temp], dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl[temp], color); } else { SetPixel24(dsl[temp], sc); } } iMainImage->uBitmap->PutScanLine(y); } } else if (flipX) { for (int y = rc.top, k = 0; y < rc.bottom; y++, k++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(height - 1 - k); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(rc.bottom - 1 - k) + 3 * rc.left; for (int x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y - rc.top); dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); END_LOG; return; fail: ExitOverlap(); iMainImage->uBitmap->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange_layer() // bool flipX, bool flipY) { BEGIN_LOG(""); Byte *ssl = NULL, *dsl = NULL, *usl = NULL, *mml = NULL, *lp = NULL, usecolor; int x, y; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; //TTexpiaBitmap *SBitmap = NULL; TUnionBitmap *SBitmap = NULL; TUnionBitmap *UBitmap = NULL; // TUndoManager *UBitmap = NULL; RECT rc, urc; THistoryData *ud = NULL; //SBitmap = FullViewForm->OverlapBitmap; //rc = FullViewForm->OverlapRect; SBitmap = OverlapBitmap; rc = OverlapRect; int addx = 0, addy = 0; if (MainImageForm->reflection) { RECT rtRange; POINT pt = MainImageForm->reflection->ChangeAvailableOriginalRange(rc, rtRange); rc.left = rtRange.left; rc.top = rtRange.top; rc.right = rtRange.right; rc.bottom = rtRange.bottom; addx = pt.x; addy = pt.y; } //if (FullViewForm->OverlapBack) { //±âÁ¸ÀÇ overlapback´Â overlapbitmapÀ» ³Ö±â ÀüÀÇ ¿µ¿ªÀ» ¹Ì¸® ÀúÀåÇØ¼­ 󸮸¦ //ÇßÁö¸¸ ÇöÀç´Â undo bitmapÀ» ÀÌ¿ëÇϵµ·Ï µÇ¾îÁ® ÀÖ´Ù. µû¶ó¼­ ÇÊ¿ä¾ø´Ù. //±âÁ¸ ¼Ò½º¸¦ ÁÖ¼®À¸·Î 󸮸¦ ÇßÀ» ¶§ Á¤»óÀûÀ¸·Î layer¿¡¼­ overlap ±â´ÉÀÌ //ÀÛµ¿ÇÏ´Â °ÍÀ» È®ÀÎ Çß´Ù. by david 110513 // if (OverlapBack) { // urc = rc; // // UBitmap = FullViewForm->OverlapBack; need-conversion // } // else { ud = Undo->GetLast(); if (ud == NULL) { END_LOG; return; } urc = ud->getRectRange(); UBitmap = ud->uBitmap; if (UBitmap == NULL) { END_LOG; return; } UBitmap->PartialUndo->LoadLast(ud->FromRgb); // } if (SBitmap && UBitmap) { PaletteForm->DIB256Palette->UseColor = preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartUndoScanLine()) goto fail; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (!iMainImage->Mask->StartScanLine()) goto fail; if (!iMainImage->LayerMask->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { if (SBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++, lp++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*lp) continue; if (Palette->ColorData[*usl]->Protect == 0 && (*mml == 0)) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++, lp++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*lp) continue; if (*mml == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel == 8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((lp[x >> 3] & (0x80 >> (x & 7))) != 0) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx * 3; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((lp[x >> 3] & (0x80 >> (x & 7))) != 0) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); iMainImage->Mask->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartUndoScanLine()) goto fail; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (!iMainImage->LayerMask->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { if (SBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*lp) continue; if (Palette->ColorData[*usl]->Protect == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; usl = UBitmap->GetUndoScanLine(y) + rc.left; // For New Undo by linuxjun lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if (*lp) continue; if (*usl > 1) { if ((color = Overlap(*usl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } iMainImage->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel == 8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun lp = iMainImage->LayerMask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl++, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((lp[x >> 3] & (0x80 >> (x & 7))) != 0) continue; sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { if (y < 0) continue; if (y >= iMainImage->uBitmap->Height) break; ssl = SBitmap->GetScanLine(y + addy - rc.top) + addx * 3; dsl = iMainImage->uBitmap->GetScanLine(y) + 3 * rc.left; usl = UBitmap->GetUndoScanLine(y) + 3 * rc.left; // For New Undo by linuxjun lp = iMainImage->LayerMask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, usl += 3) { if (x < 0) continue; if (x >= iMainImage->uBitmap->Width) break; if ((lp[x >> 3] & (0x80 >> (x & 7))) != 0) continue; GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->uBitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); END_LOG; return; fail: ExitOverlap(); iMainImage->uBitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopUndoScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); END_LOG; } // --------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////// // Gauze 8 ////////////////////////////////////////////////////////////////////////////// void __fastcall TMainImageForm::Merge_Mask_Protect_TempMask_Gauze8 (TUnionBitmap *Bitmap, int px, int py) // convert by celberus { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; // Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { if (*TM == 0) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Protect_Gauze8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; // Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Gauze8 (TUnionBitmap *Bitmap, int px, int py) // convert by celberus { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; // Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (*MM == 0) { if (*TM == 0) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Gauze8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; // Byte *TB, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++, MM++) { if (*MM == 0) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_TempMask_Gauze8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL; // Byte *TB, *TM, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_Gauze8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Gauze8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (*TM == 0) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Gauze8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++) { if (*PP > 1) { if ((x + y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- // Gauze 24 void __fastcall TMainImageForm::Merge_Mask_Temp8_TempMask_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if (((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) && Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Temp8_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_TempMask_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; x = 0; mm = 0x80; *MP = 0; while (1) { if (*TM == 0) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; x = 0; mm = 0x80; *MP = 0; while (1) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } x++; if (x >= w) break; PP += 3; DP += 3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *TM = NULL, *MM = NULL, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { if ((*TM & mm) == 0) { GetPixel24(PP, cc); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB += 3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { GetPixel24(PP, cc); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB += 3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *TM = NULL, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; x = 0; mm = 0x80; *MP = 0; while (1) { if ((*TM & mm) == 0) { GetPixel24(PP, cc); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB += 3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Gauze24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; x = 0; mm = 0x80; *MP = 0; while (1) { GetPixel24(PP, cc); if (cc != bgc) { if ((x + y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } x++; if (x >= w) break; PP += 3; DP += 3; TB += 3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////// // Default 8 ///////////////////////////////////////////////////////////////////////////// void __fastcall TMainImageForm::Merge_Mask_Protect_TempMask_Default8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Protect_Default8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Default8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (*MM == 0) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Default8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++, MM++) { if (*MM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_TempMask_Default8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); // Byte *TB=NULL, *TM=NULL, *DP=NULL, *MP=NULL, *PP=NULL; Byte *TB, *TM, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_Default8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); // Byte *TB=NULL, *DP=NULL, *MP=NULL, *PP=NULL; Byte *TB, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Default8 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Default8(int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); for (x = 0; x < w; x++, DP++, TB++, MP++) { *DP = *TB; *MP = 0; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- // Default 24 void __fastcall TMainImageForm::Merge_Mask_Temp8_TempMask_Default24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *MM = NULL, *PP = NULL, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if (((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) && Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Temp8_Default24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_TempMask_Default24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *TM = NULL, *DP = NULL, *MP = NULL, *PP = NULL, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; x = 0; mm = 0x80; *MP = 0; while (1) { if (*TM == 0) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_Default24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; x = 0; mm = 0x80; *MP = 0; while (1) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); x++; if (x >= w) break; PP += 3; DP += 3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Default24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *TM = NULL, *MM = NULL, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { if ((*TM & mm) == 0) { CopyPixel24(DP, TB); } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB += 3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Default24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *MM = NULL, mm; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { CopyPixel24(DP, TB); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB += 3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Default24 (TUnionBitmap *Bitmap, int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, *PP = NULL, *TM = NULL, mm; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3 * px; x = 0; mm = 0x80; *MP = 0; while (1) { if ((*TM & mm) == 0) { CopyPixel24(DP, TB); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP += 3; DP += 3; TB += 3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Default24(int px, int py) { BEGIN_LOG(""); Byte *TB = NULL, *DP = NULL, *MP = NULL, mm; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); x = 0; mm = 0x80; *MP = 0; while (1) { CopyPixel24(DP, TB); x++; if (x >= w) break; DP += 3; TB += 3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem_none(int X, int Y) { BEGIN_LOG(""); RECT rc, rcWorkArea; Byte *dsl = NULL, *ssl = NULL, *mml = NULL, *sml = NULL, mm; COLORREF sc, dc, color, bgc; int x, y; RGBQUAD rgb[256]; TPItemImage *Image = iMainImage; Image->SubVisible = true; Image->SubVisible = false; // by celberus LayerImageÀÇ PaintTop¿¡¼­ SubBitmapÀÌ ÀÖÀ¸¸é UpperLayer´Â bmScreen¿¡ ±×·ÁÁöÁö ¾Ê´Â´Ù. x = X - Center.x; if (x < 0) x = 0; else if (x + Image->SubBitmap->Width > Image->uBitmap->Width) x = Image->uBitmap->Width - Image->SubBitmap->Width; y = Y - Center.y; if (y < 0) y = 0; else if (y + Image->SubBitmap->Height > Image->uBitmap->Height) y = Image->uBitmap->Height - Image->SubBitmap->Height; rc = Rect(x, y, x + Image->SubBitmap->Width, y + Image->SubBitmap->Height); rcWorkArea = rc; if (FullViewForm->Super == sOverlap) { FullViewForm->ReadyToOverlapChange(Image->SubBitmap, rc, Palette->UseColor); } int addx = 0, addy = 0; if (MainImageForm->reflection) { MainImageForm->reflection->ChangeAvailableScreenRange(rc, rcWorkArea); RECT changeRange; POINT pt = MainImageForm->reflection->ChangeAvailableOriginalRange(rc, changeRange); addx = pt.x; addy = pt.y; rc.left = changeRange.left; rc.top = changeRange.top; rc.right = changeRange.right; rc.bottom = changeRange.bottom; } if (bMaskArea) { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->uBitmap->StartScanLine()) goto fail; if (!Image->Mask->StartScanLine()) goto fail; if (FullViewForm->Super == sOverlap) { if (!InitOverlap()) goto fail; if (Image->uBitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; mml = Image->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, mml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[*dsl]->Protect == 0 && (*mml == 0)) { if (*dsl > 1) { if ((color = Overlap(*dsl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; mml = Image->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, mml++) { if (*sml == 0xFF) continue; if (*mml == 0) { if (*dsl > 1) { if ((color = Overlap(*dsl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl += 3) { if (*sml == 0xFF) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(dsl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3) { if ((*sml & mm) == 0) { if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(dsl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[dsl[x]]->Protect == 0 && (mml[x] == 0)) { dsl[x] = ssl[x - rc.left]; } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (mml[x] == 0) { dsl[x] = ssl[x - rc.left]; } } iMainImage->uBitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl += 3) { if (*sml == 0xFF) continue; if ((*(mml + (x >> 3)) & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3) { if ((*sml & mm) == 0) { if ((*(mml + (x >> 3)) & (0x80 >> (x & 7))) == 0) { CopyPixel24(dsl, ssl); } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); } else { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->uBitmap->StartScanLine()) goto fail; if (FullViewForm->Super == sOverlap) { if (!InitOverlap()) goto fail; if (Image->uBitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++) { if (*sml == 0xFF) continue; if (Palette->ColorData[*dsl]->Protect == 0) { if (*dsl > 1) { if ((color = Overlap(*dsl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++) { if (*sml == 0xFF) continue; if (*dsl > 1) { if ((color = Overlap(*dsl, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } Image->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl += 3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); GetPixel24(dsl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3) { if ((*sml & mm) == 0) { GetPixel24(ssl, sc); GetPixel24(dsl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (Image->uBitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[dsl[x]]->Protect == 0) { dsl[x] = ssl[x - rc.left]; } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; dsl[x] = ssl[x - rc.left]; } Image->uBitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl += 3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3) { if ((*sml & mm) == 0) { CopyPixel24(dsl, ssl); } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->uBitmap->StopScanLine(); } if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) RedrawingRepeat(false, true); // for using clibboard to copy if (MainMenuForm->SubItem == 0) { WorkArea->SetRectangle(rcWorkArea); WorkAreaChange(); MainForm->UpdateMenuItems(MainImageForm); // WorkAreaChange() ³»ºÎ ±¸Á¶ º¯°æÀ¸·Î Ãß°¡ - by monkman (2010.03.17) } // ================== By GreenFish (irreguler WorkArea) if (MainForm->MotiveLoad->Checked) { // Motive Library¿¡¼­ ±×¸²À» ºÒ·¯¿À¸é WorkArea->IrregularRegion(Image->SubMask, rc); // ±×¸²ÀÇ ÇüÅ¿¡ µû¶ó ÀÛ¾÷±¸¿ªÀÌ »ý±âµµ·Ï WorkAreaChange(); // ¸¸µé¾îÁÖ´Â ºÎºÐÀÔ´Ï´Ù - By GreenFish MainForm->UpdateMenuItems(MainImageForm); // WorkAreaChange() ³»ºÎ ±¸Á¶ º¯°æÀ¸·Î Ãß°¡ - by monkman (2010.03.17) } END_LOG; return true; fail: if (FullViewForm->Super == sOverlap) { //FullViewForm->ExitOverlapChange(); doDestroy(OverlapBitmap) doDestroy(OverlapBack) FullViewForm->OverlapBitmap = NULL; FullViewForm->OverlapBack = NULL; ExitOverlap(); } Image->uBitmap->StopScanLine(); if (bMaskArea) Image->Mask->StopScanLine(); Image->SubBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); END_LOG; return false; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem_layer(int X, int Y) { BEGIN_LOG(""); RECT rc, rcWorkArea; Byte *dsl = NULL, *ssl = NULL, *mml = NULL, *bml = NULL, *sml = NULL, mm; COLORREF sc, dc, color, bgc; int x, y; RGBQUAD rgb[256]; TPItemImage *Image = iMainImage; // Image->SubVisible = true; Image->SubVisible = false; // by celberus x = X - Center.x; if (x < 0) x = 0; else if (x + Image->SubBitmap->Width > Image->uBitmap->Width) x = Image->uBitmap->Width - Image->SubBitmap->Width; y = Y - Center.y; if (y < 0) y = 0; else if (y + Image->SubBitmap->Height > Image->uBitmap->Height) y = Image->uBitmap->Height - Image->SubBitmap->Height; rc = Rect(x, y, x + Image->SubBitmap->Width, y + Image->SubBitmap->Height); rcWorkArea = rc; if (FullViewForm->Super == sOverlap) { FullViewForm->ReadyToOverlapChange(Image->SubBitmap, rc, Palette->UseColor); } int addx = 0, addy = 0; if (MainImageForm->reflection) { MainImageForm->reflection->ChangeAvailableScreenRange(rc, rcWorkArea); RECT changeRange; POINT pt = MainImageForm->reflection->ChangeAvailableOriginalRange(rc, changeRange); addx = pt.x; addy = pt.y; rc.left = changeRange.left; rc.top = changeRange.top; rc.right = changeRange.right; rc.bottom = changeRange.bottom; } /* if (MainImageForm->reflection) { POINT pts, pte; pts = MainImageForm->reflection->FindOriginalPos(rc.left, rc.top); pte = MainImageForm->reflection->FindOriginalPos(rc.right, rc.bottom); int psx = pts.x, psy = pts.y, pex = pte.x, pey = pte.y; if (MainImageForm->reflection->Direction == D_LR) { if (MainImageForm->reflection->WorkSide == D_LEFT) { if (psx < 0) { addx -= psx; psx = MainImageForm->reflection->BitmapRange.left; } if (pex < 0) { pex = MainImageForm->reflection->BitmapRange.right; } else if (pex > MainImageForm->reflection->BitmapRange.right) { pex = MainImageForm->reflection->BitmapRange.right; } if (psy < 0) { addy -= psy; psy = MainImageForm->reflection->BitmapRange.top; } if (pey < 0) { pey = MainImageForm->reflection->BitmapRange.bottom; } else if (pey > MainImageForm->reflection->BitmapRange.bottom) { pey = MainImageForm->reflection->BitmapRange.bottom; } if (rcWorkArea.left > MainImageForm->reflection->BitmapWidth) rcWorkArea.left = MainImageForm->reflection->BitmapWidth; if (rcWorkArea.top < 0) rcWorkArea.top = 0; if (rcWorkArea.right > MainImageForm->reflection->BitmapWidth) rcWorkArea.right = MainImageForm->reflection->BitmapWidth; if (rcWorkArea.bottom > MainImageForm->reflection->BitmapHeight) rcWorkArea.bottom = MainImageForm->reflection->BitmapHeight; } else { if (psx < 0) { addx -= psx; psx = MainImageForm->reflection->BitmapRange.left; } if (pex > MainImageForm->reflection->BitmapRange.right) { pex = MainImageForm->reflection->BitmapRange.right; } if (psy < 0) { addy -= psy; psy = MainImageForm->reflection->BitmapRange.top; } if (pey < 0) { pey = MainImageForm->reflection->BitmapRange.bottom; } else if (pey > MainImageForm->reflection->BitmapRange.bottom) { pey = MainImageForm->reflection->BitmapRange.bottom; } if (rcWorkArea.left <= MainImageForm->reflection->BitmapWidth) rcWorkArea.left = MainImageForm->reflection->BitmapWidth; if (rcWorkArea.top < 0) rcWorkArea.top = 0; if (rcWorkArea.right >= MainImageForm->reflection->BitmapWidth * 2) rcWorkArea.right = MainImageForm->reflection->BitmapWidth * 2; if (rcWorkArea.bottom >= MainImageForm->reflection->BitmapHeight) rcWorkArea.bottom = MainImageForm->reflection->BitmapHeight; } } else { if (MainImageForm->reflection->WorkSide == D_TOP) { if (psx < 0) { addx -= psx; psx = MainImageForm->reflection->BitmapRange.left; } if (pex < 0) { pex = MainImageForm->reflection->BitmapRange.right; } else if (pex > MainImageForm->reflection->BitmapRange.right) { pex = MainImageForm->reflection->BitmapRange.right; } if (psy < 0) { addy -= psy; psy = MainImageForm->reflection->BitmapRange.top; } if (pey < 0) { pey = MainImageForm->reflection->BitmapRange.bottom; } else if (pey > MainImageForm->reflection->BitmapRange.bottom) { pey = MainImageForm->reflection->BitmapRange.bottom; } if (rcWorkArea.left < 0) rcWorkArea.left = 0; if (rcWorkArea.top < 0) rcWorkArea.top = 0; if (rcWorkArea.right > MainImageForm->reflection->BitmapWidth) rcWorkArea.right = MainImageForm->reflection->BitmapWidth; if (rcWorkArea.bottom > MainImageForm->reflection->BitmapHeight) rcWorkArea.bottom = MainImageForm->reflection->BitmapHeight; } else { if (pex < 0) { pex = MainImageForm->reflection->BitmapRange.right; } else if (pex > MainImageForm->reflection->BitmapRange.right) { pex = MainImageForm->reflection->BitmapRange.right; } if (psy < 0) { addy -= psy; psy = MainImageForm->reflection->BitmapRange.top; } if (pey < 0) { pey = MainImageForm->reflection->BitmapRange.bottom; } else if (pey > MainImageForm->reflection->BitmapRange.bottom) { pey = MainImageForm->reflection->BitmapRange.bottom; } if (rcWorkArea.left < 0) rcWorkArea.left = 0; if (rcWorkArea.top < MainImageForm->reflection->BitmapHeight) rcWorkArea.top = MainImageForm->reflection->BitmapHeight; if (rcWorkArea.right > MainImageForm->reflection->BitmapWidth) rcWorkArea.right = MainImageForm->reflection->BitmapWidth; if (rcWorkArea.bottom > MainImageForm->reflection->BitmapHeight * 2) rcWorkArea.bottom = MainImageForm->reflection->BitmapHeight * 2; } } rc.left = min(psx, pex); rc.top = min(psy, pey); rc.right = max(psx, pex); rc.bottom = max(psy, pey); } */ if (bMaskArea) { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->uBitmap->StartScanLine()) goto fail; if (!Image->Mask->StartScanLine()) goto fail; if (!Image->BackGround->StartScanLine()) goto fail; if (FullViewForm->Super == sOverlap) { if (!InitOverlap()) goto fail; if (Image->uBitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; mml = Image->Mask->GetScanLine(y) + rc.left; bml = Image->BackGround->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, mml++, bml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[*dsl /* *bml */ ]->Protect == 0 && (*mml == 0)) { if (*bml > 1) { if ((color = Overlap(*bml, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; mml = Image->Mask->GetScanLine(y) + rc.left; bml = Image->BackGround->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, mml++, bml++) { if (*sml == 0xFF) continue; if (*mml == 0) { if (*bml > 1) { if ((color = Overlap(*bml, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); bml = Image->BackGround->GetScanLine(y) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl += 3, bml += 3) { if (*sml == 0xFF) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(bml, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); bml = Image->BackGround->GetScanLine(y) + 3 * rc.left; mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, bml += 3) { if ((*sml & mm) == 0) { if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(bml, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); bml = Image->BackGround->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[dsl[x] /* bml[x] */ ]->Protect == 0 && (mml[x] == 0)) { dsl[x] = ssl[x - rc.left]; } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (mml[x] == 0) { dsl[x] = ssl[x - rc.left]; } } iMainImage->uBitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl += 3) { if (*sml == 0xFF) continue; if ((*(mml + (x >> 3)) & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mml = Image->Mask->GetScanLine(y); mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3) { if ((*sml & mm) == 0) { if ((*(mml + (x >> 3)) & (0x80 >> (x & 7))) == 0) { CopyPixel24(dsl, ssl); } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->BackGround->StopScanLine(); Image->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); } else { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->uBitmap->StartScanLine()) goto fail; if (!Image->BackGround->StartScanLine()) goto fail; if (FullViewForm->Super == sOverlap) { if (!InitOverlap()) goto fail; if (Image->uBitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; bml = Image->BackGround->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, bml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[*dsl /* *bml */ ]->Protect == 0) { if (*bml > 1) { if ((color = Overlap(*bml, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + rc.left; bml = Image->BackGround->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, bml++) { if (*sml == 0xFF) continue; if (*bml > 1) { if ((color = Overlap(*bml, *ssl)) == 0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } Image->uBitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; bml = Image->BackGround->GetScanLine(y) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl += 3, bml += 3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); GetPixel24(bml, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; bml = Image->BackGround->GetScanLine(y) + 3 * rc.left; mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3, bml += 3) { if ((*sml & mm) == 0) { GetPixel24(ssl, sc); GetPixel24(bml, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (Image->uBitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); bml = Image->BackGround->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[dsl[x] /* bml[x] */ ]->Protect == 0) { dsl[x] = ssl[x - rc.left]; } } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; dsl[x] = ssl[x - rc.left]; } Image->uBitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + addx; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl += 3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } Image->uBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y + addy - rc.top) + addx * 3; sml = Image->SubMask->GetScanLine(y + addy - rc.top) + (addx + 8) / 8 - 1; dsl = Image->uBitmap->GetScanLine(y) + 3 * rc.left; mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl += 3, dsl += 3) { if ((*sml & mm) == 0) { CopyPixel24(dsl, ssl); } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->BackGround->StopScanLine(); Image->uBitmap->StopScanLine(); } if (Image->LayerMask) Image->LayerMask->CopyToRect(rc.left, rc.top, Image->SubMask, SRCAND); if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) RedrawingRepeat(false, true); // for using clibboard to copy if (MainMenuForm->SubItem == 0) { WorkArea->SetRectangle(rcWorkArea); WorkAreaChange(); MainForm->UpdateMenuItems(MainImageForm); // WorkAreaChange() ³»ºÎ ±¸Á¶ º¯°æÀ¸·Î Ãß°¡ - by monkman (2010.03.17) } END_LOG; return true; fail: if (FullViewForm->Super == sOverlap) { //FullViewForm->ExitOverlapChange(); doDestroy(OverlapBitmap) doDestroy(OverlapBack) FullViewForm->OverlapBitmap = NULL; FullViewForm->OverlapBack = NULL; ExitOverlap(); } Image->uBitmap->StopScanLine(); if (bMaskArea) Image->Mask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->BackGround->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); END_LOG; return false; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToClipboard() { BEGIN_LOG(""); RGBQUAD rgb[256]; BITMAPHANDLE bh, *pbh = NULL; int i, x, y; int saveWidth, saveHeight; HDC dcSrc = NULL, dcMask = NULL, dcDst = NULL; HGLOBAL hMem = NULL; Byte *lpData = NULL; TClipboardInfo cbi; TColorData *cd = NULL; Byte *mp = NULL, *bp = NULL; COLORREF c; bool bClipboard = false; TPException ec = EC_NONE; int ColorDataSize = 0; for (int i = 1; i <= Palette->UseColor; i++) { ColorDataSize += Palette->ColorData[i]->ClipboardSize; } if (WorkArea->Mask) { memset(&bh, 0, sizeof(BITMAPHANDLE)); saveWidth = WorkArea->Range.right - WorkArea->Range.left; saveHeight = WorkArea->Range.bottom - WorkArea->Range.top; // if (L_CreateBitmap(&bh, sizeof(BITMAPHANDLE), TYPE_CONV, saveWidth, saveHeight, iMainImage->uBitmap->BitsPerPixel, ORDER_BGR, NULL, TOP_LEFT, NULL, 0) < 1) goto next1; if (iMainImage->uBitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); L_PutBitmapColors(&bh, 0, 256, rgb); WorkArea->Mask->PutColors(0, 256, rgb); } if ((dcDst = L_CreateLeadDC(&bh)) == NULL) goto next1; iMainImage->uBitmap->UnionBitBlt(dcDst, 0, 0, saveWidth, saveHeight, WorkArea->Range.left, WorkArea->Range.top, SRCCOPY, false); // convert by celberus if ((dcMask = WorkArea->Mask->CreateDC()) == NULL) goto next1; BitBlt(dcDst, 0, 0, saveWidth, saveHeight, dcMask, 0, 0, SRCAND); WorkArea->Mask->DeleteDC(dcMask); dcMask = NULL; L_DeleteLeadDC(dcDst); dcDst = NULL; #ifndef TRIAL if (L_CopyToClipboard(MainForm->Handle, &bh, COPY2CB_EMPTY | COPY2CB_DIB) < 1) goto next1; #endif L_FreeBitmap(&bh); goto next2; next1: if (dcDst) { if (dcMask) WorkArea->Mask->DeleteDC(dcMask); if (dcSrc) iMainImage->uBitmap->DeleteDC(dcSrc); L_DeleteLeadDC(dcDst); } L_FreeBitmap(&bh); next2: // ´Ù¸¥ ÇÁ·Î±×·¥À¸·Î ÀоîµéÀ̱â À§ÇÑ ºÎºÐ.. if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { // Version 0 -> 1 : PantoneColor Ãß°¡ // Version 1 -> 2 : colordata tagtypeÀ¸·Î º¯°æ cbi.Version = 2; cbi.Time = clock(); cbi.Width = saveWidth; cbi.Height = saveHeight; cbi.Mask = true; if (iMainImage->uBitmap->BitsPerPixel == 8) { cbi.BitsPerPixel = 8; cbi.Colors = Palette->UseColor; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo) + (ColorDataSize+sizeof(int)) + cbi.Width * cbi.Height)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((lpData = (Byte*)GlobalLock(hMem)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); int len = 0; memcpy(lpData, &ColorDataSize, sizeof(int)); lpData += sizeof(int); for (int i = 1; i <= cbi.Colors; i++) { Palette->ColorData[i]->SaveClipboard(lpData); lpData += Palette->ColorData[i]->ClipboardSize; } // SetClipboardColorData(cbi.Colors, lpData); // lpData += ColorDataSize; if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi.Height; y++) { bp = iMainImage->uBitmap->GetScanLine(WorkArea->Range.top + y); mp = WorkArea->Mask->GetScanLine(y); for (x = 0; x < cbi.Width; x++, mp++) { if (*mp) { *(lpData + x) = *(bp + WorkArea->Range.left + x); } else { *(lpData + x) = 0; } } lpData += cbi.Width; } iMainImage->uBitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); GlobalUnlock(hMem); } else { cbi.BitsPerPixel = 24; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+sizeof(COLORREF) + 3 * cbi.Width * cbi.Height + WorkArea->Mask->BytesPerLine * cbi.Height)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((lpData = (Byte*)GlobalLock(hMem)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); c = Palette->Color[1]; memcpy(lpData, &c, sizeof(COLORREF)); lpData += sizeof(COLORREF); if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi.Height; y++) { bp = iMainImage->uBitmap->GetScanLine(WorkArea->Range.top + y) + 3 * WorkArea->Range.left; memcpy(lpData, bp, 3 * cbi.Width); lpData += 3 * cbi.Width; } iMainImage->uBitmap->StopScanLine(); if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi.Height; y++) { mp = WorkArea->Mask->GetScanLine(y); for (x = 0; x < WorkArea->Mask->BytesPerLine; x++) { *(lpData + x) = ~*(mp + x); } lpData += WorkArea->Mask->BytesPerLine; } WorkArea->Mask->StopScanLine(); GlobalUnlock(hMem); } SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } else { if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { // Version 0 -> 1 : PantoneColor Ãß°¡ // Version 1 -> 2 : colordata tagtypeÀ¸·Î º¯°æ cbi.Version = 2; cbi.Time = clock(); cbi.Width = iMainImage->uBitmap->Width; cbi.Height = iMainImage->uBitmap->Height; cbi.Mask = false; if (iMainImage->uBitmap->BitsPerPixel == 8) { cbi.BitsPerPixel = 8; cbi.Colors = Palette->UseColor; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo) + ColorDataSize+sizeof(int) + cbi.Width * cbi.Height)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((lpData = (Byte*)GlobalLock(hMem)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); int len = 0; memcpy(lpData, &ColorDataSize, sizeof(int)); lpData += sizeof(int); for (int i = 1; i <= cbi.Colors; i++) { Palette->ColorData[i]->SaveClipboard(lpData); lpData += Palette->ColorData[i]->ClipboardSize; } // SetClipboardColorData(cbi.Colors, lpData); // lpData += ColorDataSize; if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi.Height; y++) { bp = iMainImage->uBitmap->GetScanLine(y); memcpy(lpData, bp, cbi.Width); lpData += cbi.Width; } iMainImage->uBitmap->StopScanLine(); GlobalUnlock(hMem); } else { cbi.BitsPerPixel = 24; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+sizeof(COLORREF) + 3 * cbi.Width * cbi.Height)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((lpData = (Byte*)GlobalLock(hMem)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); c = Palette->Color[1]; memcpy(lpData, &c, sizeof(COLORREF)); lpData += sizeof(COLORREF); if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi.Height; y++) { bp = iMainImage->uBitmap->GetScanLine(y); memcpy(lpData, bp, 3 * cbi.Width); lpData += 3 * cbi.Width; } iMainImage->uBitmap->StopScanLine(); GlobalUnlock(hMem); } SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } END_LOG; return EC_NONE; fail: if (bClipboard) { if (hMem) { if (lpData) { if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); GlobalUnlock(hMem); } GlobalFree(hMem); } CloseClipboard(); } END_LOG; return ec; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperOff (TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { BEGIN_LOG(""); RGBQUAD rgb[256]; int x, y; Byte *sp = NULL, *bp = NULL, *mp = NULL; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); if (!TempBitmap->StartScanLine()) goto fail; if (cbi->Mask) { if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) goto fail; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) goto fail; sp = Bitmap; if (!TempMask->StartScanLine()) goto fail; for (y = 0; y < cbi->Height; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x = 0; x < cbi->Width; x++, bp++, mp++) { if (*bp < 1) { *bp = 0; *mp = 0xFF; } else { *bp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempMask->StopScanLine(); } else { // TempMask = NULL; sp = Bitmap; for (y = 0; y < cbi->Height; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); for (x = 0; x < cbi->Width; x++) { if (*(bp + x) < 1) { *(bp + x) = 0; } else { *(bp + x) += UseColor; } } TempBitmap->PutScanLine(y); sp += cbi->Width; } } TempBitmap->StopScanLine(); END_LOG; return true; fail: doDestroy(TempMask)TempBitmap->StopScanLine(); END_LOG; return false; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperNormal (TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { BEGIN_LOG(""); RGBQUAD rgb[256]; int x, y; Byte *sp = NULL, *bp = NULL, *mp = NULL; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); if (!TempBitmap->StartScanLine()) goto fail; if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) goto fail; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) goto fail; sp = Bitmap; if (!TempMask->StartScanLine()) goto fail; for (y = 0; y < cbi->Height; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x = 0; x < cbi->Width; x++, bp++, mp++) { if (*bp < 2) { *bp = 0; *mp = 0xFF; } else { *bp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempMask->StopScanLine(); TempBitmap->StopScanLine(); END_LOG; return true; fail: doDestroy(TempMask)TempBitmap->StopScanLine(); END_LOG; return false; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperGauge (TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { BEGIN_LOG(""); RGBQUAD rgb[256]; int x, y; Byte *sp = NULL, *bp = NULL, *mp = NULL; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); if (!TempBitmap->StartScanLine()) goto fail; if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) goto fail; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) goto fail; sp = Bitmap; if (!TempMask->StartScanLine()) goto fail; for (y = 0; y < cbi->Height; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x = 0; x < cbi->Width; x++, bp++, mp++) { if (*bp < 2 || ((x + y) & 1)) { *bp = 0; *mp = 0xFF; } else { *bp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempMask->StopScanLine(); TempBitmap->StopScanLine(); END_LOG; return true; fail: doDestroy(TempMask)TempBitmap->StopScanLine(); END_LOG; return false; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat8To8 (TClipboardInfo *cbi) { BEGIN_LOG(""); TRect r; int i, x, y, bg; bool sw = false; TColorData *Color = NULL; Byte *Bitmap = NULL, *sp = NULL; TPException ec = EC_NONE; if (cbi->Version < 1) { try { Color = (TColorData*)((Byte*)cbi+sizeof(TClipboardInfo)); Bitmap = (Byte*)Color + cbi->Colors*sizeof(TColorData); // sizeof(TColorData) 32 if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } switch(FullViewForm->Super) { case sOff: bg = 0; sp = Bitmap; for (y = 0; y < cbi->Height; y++) { for (x = 0; x < cbi->Width; x++) { if (*(sp + x) == 1) { bg = 1; goto next1; } } sp += cbi->Width; } next1: if (cbTime == cbi->Time) { sw = true; if (Palette->UseColor == cbUseColor + cbi->Colors) { for (i = 2 - bg; i <= cbi->Colors; i++) { if (Palette->ColorData[cbUseColor + i]->Compare(Color + i - 1) == false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { TColorData *tempColor; tempColor = Color + i - 1; if ((tempColor->Infor & 0x6) || (tempColor->Infor & 0x16)) { throw EC_CLIPBOARD_NOT_READ; } Palette->ColorData[cbUseColor + i]->Copy(tempColor); // Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { TColorData *tempColor; tempColor = Color + i - 1; if ((tempColor->Infor & 0x6) || (tempColor->Infor & 0x16)) { throw EC_CLIPBOARD_NOT_READ; } Palette->ColorData[cbUseColor + i]->Copy(tempColor); // Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } break; case sOverlap: case sNormal: if (cbTime == cbi->Time) { sw = true; if (Palette->UseColor == cbUseColor + cbi->Colors) { for (i = 2; i <= cbi->Colors; i++) { if (Palette->ColorData[cbUseColor + i]->Compare(Color + i - 1) == false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Palette->UseColor + cbi->Colors - 1 >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1; for (i = 2; i <= cbi->Colors; i++) { TColorData *tempColor; tempColor = Color + i - 1; if ((tempColor->Infor & 0x6) || (tempColor->Infor & 0x16)) { throw EC_CLIPBOARD_NOT_READ; } Palette->ColorData[cbUseColor + i]->Copy(tempColor); // Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor + cbi->Colors - 1 >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1; for (i = 2; i <= cbi->Colors; i++) { TColorData *tempColor; tempColor = Color + i - 1; if ((tempColor->Infor & 0x6) || (tempColor->Infor & 0x16)) { throw EC_CLIPBOARD_NOT_READ; } Palette->ColorData[cbUseColor + i]->Copy(tempColor); // Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } break; case sGauze: bg = 0; sp = Bitmap; for (y = 0; y < cbi->Height; y++) { for (x = 0; x < cbi->Width; x++) { if (*(sp + x) == 1) { bg = 1; goto next2; } } sp += cbi->Width; } next2: if (cbTime == cbi->Time) { sw = true; if (Palette->UseColor == cbUseColor + cbi->Colors) { for (i = 2 - bg; i <= cbi->Colors; i++) { if (Palette->ColorData[cbUseColor + i]->Compare(Color + i - 1) == false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { TColorData *tempColor; tempColor = Color + i - 1; if ((tempColor->Infor & 0x6) || (tempColor->Infor & 0x16)) { throw EC_CLIPBOARD_NOT_READ; } Palette->ColorData[cbUseColor + i]->Copy(tempColor); // Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { TColorData *tempColor; tempColor = Color + i - 1; if ((tempColor->Infor & 0x6) || (tempColor->Infor & 0x16)) { throw EC_CLIPBOARD_NOT_READ; } Palette->ColorData[cbUseColor + i]->Copy(tempColor); // Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } break; } } catch(...) { if (ec == EC_NONE) ec = EC_CLIPBOARD_NOT_READ; goto fail; } } else if (cbi->Version <= 2) { int colorCount = cbi->Colors; TColorData *CopyData[256]; for (int i = 0; i < colorCount; i++) { CopyData[i] = new TColorData(); } try { Byte *lpData = NULL; lpData = ((Byte*)cbi+sizeof(TClipboardInfo)); int ColorDataSize = 0; memcpy(&ColorDataSize, lpData, sizeof(int)); lpData += sizeof(int); if (cbi->Version == 1) { GetClipboardColorData(colorCount, CopyData, lpData); Bitmap = (Byte*)lpData + ColorDataSize; } else { int dataSize = 0; for (int i = 0; i < colorCount; i++) { dataSize = CopyData[i]->GetClipboard(lpData); lpData += dataSize; } Bitmap = (Byte*)lpData; } if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } switch(FullViewForm->Super) { case sOff: bg = 0; sp = Bitmap; for (y = 0; y < cbi->Height; y++) { for (x = 0; x < cbi->Width; x++) { if (*(sp + x) == 1) { bg = 1; goto next21; } } sp += cbi->Width; } next21: if (cbTime == cbi->Time) { sw = true; if (Palette->UseColor == cbUseColor + cbi->Colors) { for (i = 2 - bg; i <= cbi->Colors; i++) { if (Palette->ColorData[cbUseColor + i]->Compare(CopyData[i - 1]) == false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { Palette->ColorData[cbUseColor + i]->Copy(CopyData[i - 1]); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { Palette->ColorData[cbUseColor + i]->Copy(CopyData[i - 1]); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } break; case sOverlap: case sNormal: if (cbTime == cbi->Time) { sw = true; if (Palette->UseColor == cbUseColor + cbi->Colors) { for (i = 2; i <= cbi->Colors; i++) { if (Palette->ColorData[cbUseColor + i]->Compare(CopyData[i - 1]) == false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Palette->UseColor + cbi->Colors - 1 >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1; for (i = 2; i <= cbi->Colors; i++) { Palette->ColorData[cbUseColor + i]->Copy(CopyData[i - 1]); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor + cbi->Colors - 1 >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1; for (i = 2; i <= cbi->Colors; i++) { Palette->ColorData[cbUseColor + i]->Copy(CopyData[i - 1]); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } break; case sGauze: bg = 0; sp = Bitmap; for (y = 0; y < cbi->Height; y++) { for (x = 0; x < cbi->Width; x++) { if (*(sp + x) == 1) { bg = 1; goto next22; } } sp += cbi->Width; } next22: if (cbTime == cbi->Time) { sw = true; if (Palette->UseColor == cbUseColor + cbi->Colors) { for (i = 2 - bg; i <= cbi->Colors; i++) { if (Palette->ColorData[cbUseColor + i]->Compare(CopyData[i - 1]) == false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { Palette->ColorData[cbUseColor + i]->Copy(CopyData[i - 1]); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor + cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i = 2 - bg; i <= cbi->Colors; i++) { Palette->ColorData[cbUseColor + i]->Copy(CopyData[i - 1]); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Palette->UseColor = cbUseColor + cbi->Colors; cbTime = cbi->Time; } break; } } catch(...) { for (int i = 0; i < colorCount; i++) { delete CopyData[i]; } if (ec == EC_NONE) ec = EC_CLIPBOARD_NOT_READ; goto fail; } for (int i = 0; i < colorCount; i++) { delete CopyData[i]; } } else { // ó¸®ÇÒ¼ö¾ø´Â ¹öÀüÀº ¿©±â·Î µé¾î¿À°ÔÇÒ°Í (Á¤»óÀ϶§¸¸ EC_NONEÀ¸·Î ³ª°¡¾ßÇÔ) if (ec == EC_NONE) ec = EC_CLIPBOARD_NOT_READ; return ec; } END_LOG; return EC_NONE; fail: doDestroy(TempBitmap)END_LOG; return ec; } // --------------------------------------------------------------------------- // void __fastcall TMainImageForm::SetClipboardColorData(int colorCount, Byte *lpData) // { // BEGIN_LOG(""); // // TColorData *cd; // int len = 0; // // for (int i=1; i<=colorCount; i++){ // cd = Palette->ColorData[i]; // Word infor = cd->Infor; // memcpy(lpData, &infor, sizeof(Word)); // lpData += sizeof(Word); // // Word page = cd->Page; // memcpy(lpData, &page, sizeof(Word)); // lpData += sizeof(Word); // // Byte number = cd->Number; // memcpy(lpData, &number, sizeof(Byte)); // lpData += sizeof(Byte); // // RGBQUAD rgb = cd->RGB; // memcpy(lpData, &rgb, sizeof(RGBQUAD)); // lpData += sizeof(RGBQUAD); // // len = 0; // if (cd->FileName){ // len = _tcslen(cd->FileName) + 1; // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // memcpy(lpData, cd->FileName, sizeof(Char) * len); // lpData += sizeof(Char)*len; // } // else { // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // } // // len = 0; // if (cd->ColorName){ // len = _tcslen(cd->ColorName) + 1; // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // memcpy(lpData, cd->ColorName, sizeof(Char) * len); // lpData += sizeof(Char)*len; // } // else { // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // } // // len = 0; // if (cd->PantoneColor){ // len = _tcslen(cd->PantoneColor) + 1; // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // memcpy(lpData, cd->PantoneColor, sizeof(Char) * len); // lpData += sizeof(Char)*len; // } // else { // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // } // len = 0; // if (cd->PantoneFileName){ // len = _tcslen(cd->PantoneFileName) + 1; // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // memcpy(lpData, cd->PantoneFileName, sizeof(Char) * len); // lpData += sizeof(Char)*len; // } // else { // memcpy(lpData, &len, sizeof(int)); // lpData += sizeof(int); // } // } // // END_LOG; // } ////--------------------------------------------------------------------------- void __fastcall TMainImageForm::GetClipboardColorData (int colorCount, TColorData **CopyData, Byte *lpData) { BEGIN_LOG(""); for (int i = 0; i < colorCount; i++) { Word infor; memcpy(&infor, lpData, sizeof(Word)); CopyData[i]->Infor = infor; lpData += sizeof(Word); Word page; memcpy(&page, lpData, sizeof(Word)); CopyData[i]->Page = page; lpData += sizeof(Word); Byte number; memcpy(&number, lpData, sizeof(Byte)); CopyData[i]->Number = number; lpData += sizeof(Byte); RGBQUAD rgb; memcpy(&rgb, lpData, sizeof(RGBQUAD)); CopyData[i]->RGB = rgb; lpData += sizeof(RGBQUAD); int len = 0; memcpy(&len, lpData, sizeof(int)); lpData += sizeof(int); if (len > 0) { char *name = new char[len + 1]; // shin ¼öÁ¤ strncpy(name, lpData, sizeof(char) * len); CopyData[i]->SetFileName(len, String(name).c_str()); CopyData[i]->Kind |= 0x4000; lpData += sizeof(char) * len; delete[]name; } else CopyData[i]->FileName = NULL; memcpy(&len, lpData, sizeof(int)); lpData += sizeof(int); if (len > 0) { char *name = new char[len + 1]; // shin ¼öÁ¤ strncpy(name, lpData, sizeof(char) * len); CopyData[i]->SetColorName(len, String(name).c_str()); lpData += sizeof(char) * len; delete[]name; } else CopyData[i]->ColorName = NULL; memcpy(&len, lpData, sizeof(int)); lpData += sizeof(int); if (len > 0) { char *name = new char[len + 1]; // shin ¼öÁ¤ strncpy(name, lpData, sizeof(char) * len); // CopyData[i]->SetPantoneColorName(len, name);//lpData); CopyData[i]->additionalColorData->AddTag (TAG_PANTONE_COLOR, TAG_CHAR_TYPE, strlen(name) + 1, name); CopyData[i]->Kind |= 0x0006; delete[]name; lpData += sizeof(char) * len; } memcpy(&len, lpData, sizeof(int)); lpData += sizeof(int); if (len > 0) { char *name = new char[len + 1]; // shin ¼öÁ¤ strncpy(name, lpData, sizeof(char) * len); // CopyData[i]->SetPantoneFileName(len, name);//lpData); CopyData[i]->additionalColorData->AddTag(TAG_PANTONE_FILE_NAME, TAG_CHAR_TYPE, strlen(name) + 1, name); CopyData[i]->Kind |= 0x4000; delete[]name; lpData += sizeof(char) * len; } } END_LOG; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat8To24 (TClipboardInfo *cbi) { BEGIN_LOG(""); TColorData *Color = NULL; int i, x, y; RGBQUAD rgb[256]; Byte *Bitmap = NULL, *sp = NULL, *ip = NULL, *mp = NULL; TPException ec = EC_NONE; Palette->ToRGBQUAD(rgb, 256); if (cbi->Version < 1) { Color = (TColorData*)((Byte*)cbi+sizeof(TClipboardInfo)); for (i = 1; i <= cbi->Colors; i++) { rgb[i] = Color[i - 1].RGB; } Bitmap = (Byte*)Color + cbi->Colors*sizeof(TColorData); // sizeof(TColorData) 32 } else if (cbi->Version <= 2) { Byte *lpData = NULL; int colorCount = cbi->Colors; lpData = ((Byte*)cbi+sizeof(TClipboardInfo)); int ColorDataSize = 0; memcpy(&ColorDataSize, lpData, sizeof(int)); lpData += sizeof(int); TColorData *CopyData[256]; for (int i = 0; i < cbi->Colors; i++) { CopyData[i] = new TColorData(); } if (cbi->Version == 1) { GetClipboardColorData(cbi->Colors, CopyData, lpData); Bitmap = (Byte*)lpData + ColorDataSize; } else { for (int i = 0; i < colorCount; i++) { CopyData[i]->GetClipboard(lpData); lpData += CopyData[i]->ClipboardSize; } Bitmap = (Byte*)lpData; } for (i = 1; i <= cbi->Colors; i++) { rgb[i] = CopyData[i - 1]->RGB; delete CopyData[i - 1]; } } else { ec = EC_CLIPBOARD_NOT_READ; goto fail; } if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } switch(FullViewForm->Super) { case sOff: if (cbi->Mask) { if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x = 0; x < cbi->Width; x++, mp++) { if (*(ip + x) < 1) { *mp = 0xFF; } else { *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } else { sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); TempBitmap->PutScanLine(y); sp += cbi->Width; } TempBitmap->StopScanLine(); } break; case sOverlap: case sNormal: if ((TempMask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x = 0; x < cbi->Width; x++, ip++, mp++) { if (*ip < 2) { *ip = 0; *mp = 0xFF; } else { *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempBitmap->StopScanLine(); TempMask->StopScanLine(); break; case sGauze: if ((TempMask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cbi->Mask) { for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x = 0; x < cbi->Width; x++, ip++, mp++) { if (*ip < 2) { *ip = 0; *mp = 0xFF; } else { *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } } TempBitmap->StopScanLine(); TempMask->StopScanLine(); break; } END_LOG; return EC_NONE; fail: if (TempBitmap) { doDestroy(TempMask)delete TempBitmap; TempBitmap = NULL; } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat24To24 (TClipboardInfo *cbi) { BEGIN_LOG(""); BYTE *sp = NULL, *ip = NULL, *mp = NULL, mm, b; WORD w; int x, y; COLORREF bgc, c; TPException ec = EC_NONE; sp = (Byte*)cbi+sizeof(TClipboardInfo); memcpy(&bgc, sp, sizeof(COLORREF)); sp += sizeof(COLORREF); if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cbi->BitsPerPixel == 15) { for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); for (x = 0; x < cbi->Width; x++, sp += 2) { w = *(WORD*)sp; b = w & 0x1F; *ip = (b << 3) | ((b & 0x1C) >> 2); ip++; w >>= 5; b = w & 0x1F; *ip = (b << 3) | ((b & 0x1C) >> 2); ip++; w >>= 5; b = w & 0x1F; *ip = (b << 3) | ((b & 0x1C) >> 2); ip++; } TempBitmap->PutScanLine(y); } } else { for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, 3 * cbi->Width); TempBitmap->PutScanLine(y); sp += 3 * cbi->Width; } } TempBitmap->StopScanLine(); switch(FullViewForm->Super) { case sOff: if (cbi->Mask) { if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); memcpy(mp, sp, TempMask->BytesPerLine); mm = 0x80; for (x = 0; x < cbi->Width; x++, ip += 3) { if (*mp & mm) { SetPixel24(ip, 0); } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += TempMask->BytesPerLine; } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } break; case sOverlap: case sGauze: case sNormal: if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cbi->Mask) { for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); memcpy(mp, sp, TempMask->BytesPerLine); mm = 0x80; for (x = 0; x < cbi->Width; x++, ip += 3) { GetPixel24(ip, c); if ((*mp & mm) || c == bgc) { SetPixel24(ip, 0); *mp |= mm; } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += TempMask->BytesPerLine; } } else { for (y = 0; y < cbi->Height; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); *mp = 0; mm = 0x80; // ============================================================================== x = 0; while (1) { GetPixel24(ip, c); if (c == bgc) { SetPixel24(ip, 0); *mp |= mm; } x++; if (x >= cbi->Width) break; ip += 3; if (mm == 1) { mp++; *mp = 0; mm = 0x80; } else mm >>= 1; } /* for (x=0; xWidth; x++, ip+=3) { GetPixel24(ip, c); if (c==bgc) { SetPixel24(ip, 0); *mp |= mm; } if (mm==1) { mp++; *mp = 0; mm = 0x80; } else mm >>= 1; } */ // ============================================================================== TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += TempMask->BytesPerLine; } } TempBitmap->StopScanLine(); TempMask->StopScanLine(); break; } END_LOG; return EC_NONE; fail: if (TempBitmap) { doDestroy(TempMask)delete TempBitmap; TempBitmap = NULL; } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat8To8 (BITMAPHANDLE *bh, int colors, short *color) { BEGIN_LOG(""); TRect r; int i, j, x, y; RGBQUAD rgb[256]; HANDLE hBuffer = NULL; Byte *pBuffer = NULL, *bp = NULL; TPException ec = EC_NONE; if (Palette->UseColor + colors - 1 >= 252) { ec = EC_COLOR_OVERFLOW; goto fail; } L_GetBitmapColors(bh, 0, 256, rgb); cbUseColor = Palette->UseColor; for (i = 0, j = cbUseColor + 1; i < 256; i++) { if (color[i]) { Palette->SetNormal(j, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue); color[i] = j; j++; } } Palette->ToRGBQUAD(rgb, 256); if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } L_AccessBitmap(bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((pBuffer = (Byte*)GlobalLock(hBuffer)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } switch(FullViewForm->Super) { case sOff: case sNormal: case sOverlap: case sGauze: if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < bh->Height; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); bp = TempBitmap->GetScanLine(y); memcpy(bp, pBuffer, bh->Width); for (x = 0; x < bh->Width; x++, bp++) { *bp = color[*bp]; } TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); break; } Palette->UseColor = cbUseColor + colors; GlobalUnlock(hBuffer); GlobalFree(hBuffer); hBuffer = NULL; L_ReleaseBitmap(bh); END_LOG; return EC_NONE; fail: if (TempBitmap) { if (hBuffer) { if (pBuffer) { doDestroy(TempMask)GlobalUnlock(hBuffer); } GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat8To24 (BITMAPHANDLE *bh, int colors, short *color) { BEGIN_LOG(""); HANDLE hBuffer = NULL; Byte *pBuffer = NULL; int i, x, y, nBlack, nWhite; RGBQUAD rgb[256], t; Byte *ip = NULL; TPException ec = EC_NONE; L_GetBitmapColors(bh, 0, 256, rgb); nBlack = -1; if (rgb[0].rgbRed != 0 || rgb[0].rgbGreen != 0 || rgb[0].rgbBlue != 0) { for (i = 1; i < 255; i++) { if (rgb[i].rgbRed == 0 && rgb[i].rgbGreen == 0 && rgb[i].rgbBlue == 0) { nBlack = i; break; } } } else nBlack = 0; if (nBlack == -1) { for (i = 1; i < 255; i++) { if (color[i] == 0) { nBlack = i; rgb[i].rgbRed = rgb[i].rgbGreen = rgb[i].rgbBlue = 0; color[i] = colors; colors++; break; } } if (i >= 255) { END_LOG; return EC_COLOR_OVERFLOW; } } nWhite = -1; if (rgb[255].rgbRed != 255 || rgb[255].rgbGreen != 255 || rgb[255] .rgbBlue != 255) { for (i = 1; i < 255; i++) { if (rgb[i].rgbRed == 255 && rgb[i].rgbGreen == 255 && rgb[i] .rgbBlue == 255) { nWhite = i; break; } } } else nWhite = 255; if (nWhite == -1) { for (i = 1; i < 255; i++) { if (color[i] == 0) { nWhite = i; rgb[i].rgbRed = rgb[i].rgbGreen = rgb[i].rgbBlue = 255; color[i] = colors; colors++; break; } } if (i >= 255) { END_LOG; return EC_COLOR_OVERFLOW; } } if (nBlack != 0) { t = rgb[0]; rgb[0] = rgb[nBlack]; rgb[nBlack] = t; } if (nWhite != 255) { t = rgb[255]; rgb[255] = rgb[nWhite]; rgb[nWhite] = t; } if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((pBuffer = (Byte*)GlobalLock(hBuffer)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } L_AccessBitmap(bh); if (nBlack != 0 || nWhite != 255) { for (y = 0; y < bh->Height; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); ip = pBuffer; for (x = 0; x < bh->Width; x++, ip++) { if (*ip == nBlack) * ip = 0; else if (*ip == 0) * ip = nBlack; else if (*ip == nWhite) * ip = 255; else if (*ip == 255) * ip = nWhite; } } } switch(FullViewForm->Super) { case sOff: case sNormal: case sOverlap: case sGauze: if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < bh->Height; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); ip = TempBitmap->GetScanLine(y); memcpy(ip, pBuffer, bh->Width); TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); break; } L_ReleaseBitmap(bh); GlobalUnlock(hBuffer); GlobalFree(hBuffer); hBuffer = NULL; END_LOG; return EC_NONE; fail: if (TempBitmap) { if (hBuffer) { if (pBuffer) { doDestroy(TempMask)GlobalUnlock(hBuffer); } GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat24To24 (BITMAPHANDLE *bh) { BEGIN_LOG(""); HANDLE hBuffer = NULL; Byte *pBuffer = NULL; Byte *ip = NULL; int x, y; TPException ec = EC_NONE; if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } L_AccessBitmap(bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((pBuffer = (Byte*)GlobalLock(hBuffer)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < bh->Height; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); ip = TempBitmap->GetScanLine(y); memcpy(ip, pBuffer, 3 * bh->Width); TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); GlobalUnlock(hBuffer); pBuffer = NULL; GlobalFree(hBuffer); hBuffer = NULL; L_ReleaseBitmap(bh); END_LOG; return EC_NONE; fail: if (TempBitmap) { doDestroy(TempMask) if (hBuffer) { if (pBuffer) GlobalUnlock(hBuffer); GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } END_LOG; return ec; } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::Irregularrect(HDC dcDst, TRect Src, TRect Dst) { BEGIN_LOG(""); TRect Msrc; RGBQUAD rgb[256]; TTexpiaBitmap *Mask = NULL; HDC dcSrc = NULL; if (iMainImage->uBitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); Mask = WorkArea->Mask; Mask->PutColors(0, 256, rgb); } else { Mask = new TTexpiaBitmap; if (WorkArea->GetMask(Mask, 1) == false) goto fail; } Msrc.Left = Src.Left - WorkArea->Range.left; Msrc.Right = Src.Right - WorkArea->Range.left; Msrc.Top = Src.Top - WorkArea->Range.top; Msrc.Bottom = Src.Bottom - WorkArea->Range.top; if ((dcSrc = Mask->CreateDC()) == NULL) goto fail; SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, Dst.Left, Dst.Top, Dst.Right - Dst.Left, Dst.Bottom - Dst.Top, dcSrc, Msrc.Left, Msrc.Top, Msrc.Right - Msrc.Left, Msrc.Bottom - Msrc.Top, MERGEPAINT); Mask->DeleteDC(dcSrc); if (Mask != WorkArea->Mask) doDestroy(Mask) END_LOG; return true; fail: if (dcSrc) Mask->DeleteDC(dcSrc); if (Mask && Mask != WorkArea->Mask) doDestroy(Mask)END_LOG; return false; } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::Irregularrect (TUnionBitmap *dstBitmap, TRect Src, TRect Dst) { BEGIN_LOG(""); TRect Msrc; RGBQUAD rgb[256]; // TTexpiaBitmap *Mask = NULL; // TTexpiaBitmap *tempBitmap = NULL; // HDC dcSrc = NULL, dcDst = NULL; int x, y, z; Byte *mp, *bp; Src = MainImageForm->WorkArea->Range; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (!dstBitmap->StartScanLine()) goto fail; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { for (y = Src.top, z = 0; y < Src.bottom; y++, z++) { bp = dstBitmap->GetScanLine(z); mp = MainImageForm->WorkArea->Mask->GetScanLine(z); // bp += Src.left; for (int x = 0; x < Src.right - Src.left; x++, mp++) { if (*mp) { } else { *(bp + x) = 0xFF; // *(bp+x) = 1; } } dstBitmap->PutScanLine(z); } MainImageForm->WorkArea->Mask->StopScanLine(); dstBitmap->StopScanLine(); } else { // Full Color TColor TempC = clWhite; for (int y = Src.top, z = 0; y < Src.bottom; y++, z++) { bp = dstBitmap->GetScanLine(z); mp = MainImageForm->WorkArea->Mask->GetScanLine(z); // bp += Src.left*3; for (int x = 0; x < Src.right - Src.left; x++, bp += 3) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { *(bp + 2) = TempC & 0xFF; *(bp + 1) = (TempC >> 8) & 0xFF; *bp = (TempC >> 16) & 0xFF; } } dstBitmap->PutScanLine(z); } MainImageForm->WorkArea->Mask->StopScanLine(); dstBitmap->StopScanLine(); } END_LOG; return true; /* if (iMainImage->uBitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); Mask = WorkArea->Mask; Mask->PutColors(0, 256, rgb); } else { Mask = new TTexpiaBitmap; if (WorkArea->GetMask(Mask, 1) == false) goto fail; } Msrc.Left = Src.Left-WorkArea->Range.left; Msrc.Right = Src.Right-WorkArea->Range.left; Msrc.Top = Src.Top-WorkArea->Range.top; Msrc.Bottom = Src.Bottom-WorkArea->Range.top; if ((dcSrc = Mask->CreateDC())==NULL) goto fail; tempBitmap = new TTexpiaBitmap; if(!tempBitmap->Create(dstBitmap->Width, dstBitmap->Height, dstBitmap->BitsPerPixel, dstBitmap->RGB))goto fail; dstBitmap->CopyToTexpia(tempBitmap, 0, 0, tempBitmap->Width, tempBitmap->Height, 0, 0, SRCCOPY); dcDst = tempBitmap->CreateDC(); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, Dst.Left, Dst.Top, Dst.Right-Dst.Left, Dst.Bottom-Dst.Top, dcSrc, Msrc.Left, Msrc.Top, Msrc.Right-Msrc.Left, Msrc.Bottom-Msrc.Top, MERGEPAINT); Mask->DeleteDC(dcSrc); delete tempBitmap; if (Mask != WorkArea->Mask) ::doDestroy(Mask); return true; */ fail: MainImageForm->WorkArea->Mask->StopScanLine(); dstBitmap->StopScanLine(); // if (tempBitmap) delete tempBitmap; // if (dcSrc) Mask->DeleteDC(dcSrc); // if (Mask && Mask!=WorkArea->Mask) ::doDestroy(Mask); END_LOG; return false; } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::Repeat_Method (TUnionBitmap *Pattern, TSize r, TSize s, TRect Src, int len, int item, TUnionBitmap *Bitmap) { // convert by celberus irregularrect needs conversion BEGIN_LOG(""); int P; TRect Source, Dst; int x, y; // HDC dcSrc = NULL, dcDst = NULL; Source = Src; switch(item) { // 0: Normal, 1: Half Drop Horizontal, 2: Half Drop Vertical case 0: for (y = 0; y < r.cy; y++) { Dst.Top = y * s.cy; Dst.Bottom = Dst.Top + s.cy; for (x = 0; x < r.cx; x++) { Dst.Left = x * s.cx; Dst.Right = Dst.Left + s.cx; Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right - Dst.Left), (Dst.Bottom - Dst.Top), Bitmap, Src.Left, Src.Top, (Src.Right - Src.Left), (Src.Bottom - Src.Top), SRCCOPY); // by celberus if (WorkArea->Mask) { if (!Irregularrect(Pattern, Src, Dst)) goto fail; // convert by celberus } } } break; case 1: for (y = 0; y < r.cy; y++) { Dst.Top = y * s.cy; Dst.Bottom = Dst.Top + s.cy; Src = Source; // Src¸¦ ´Ù½Ã ÃʱâÈ­ for (x = 0; x < r.cx; x++) { if (x == 0) { Dst.Left = 0; if (y == 0) Dst.Right = s.cx; else { Dst.Right = y * len - s.cx; Src.Left = Source.Right - len * y; if (Dst.Right == 0) Dst.Right = s.cx; else if (Dst.Right < 0) Dst.Right = y * len; if (Src.Left < Source.Left) Src.Left = Source.Right - (Source.Left - Src.Left); P = Src.Left; } } else { Dst.Left = Dst.Right; Dst.Right = Dst.Left + s.cx; Src.Left = Source.Left; } Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right - Dst.Left), (Dst.Bottom - Dst.Top), Bitmap, Src.Left, Src.Top, (Src.Right - Src.Left), (Src.Bottom - Src.Top), SRCCOPY); // by celberus if (WorkArea->Mask) { if (!Irregularrect(Pattern, Src, Dst)) goto fail; // convert by celberus } } if (Dst.Right < Pattern->Width) { Dst.Left = Dst.Right; Dst.Right = Pattern->Width; Src.Left = Source.Left; Src.Right = P; Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right - Dst.Left), (Dst.Bottom - Dst.Top), Bitmap, Src.Left, Src.Top, (Src.Right - Src.Left), (Src.Bottom - Src.Top), SRCCOPY); // by celberus if (WorkArea->Mask) { if (!Irregularrect(Pattern, Src, Dst)) goto fail; // convert by celberus } } } break; case 2: for (x = 0; x < r.cx; x++) { Dst.Left = x * s.cx; Dst.Right = Dst.Left + s.cx; Src = Source; // Src¸¦ ´Ù½Ã ÃʱâÈ­ for (y = 0; y < r.cy; y++) { if (y == 0) { Dst.Top = 0; if (x == 0) Dst.Bottom = s.cy; else { Dst.Bottom = x * len - s.cy; Src.Top = Source.Bottom - len * x; if (Dst.Bottom == 0) Dst.Bottom = s.cy; else if (Dst.Bottom < 0) Dst.Bottom = x * len; if (Src.Top < Source.Top) Src.Top = Source.Bottom - (Source.Top - Src.Top); P = Src.Top; } } else { Dst.Top = Dst.Bottom; Dst.Bottom = Dst.Top + s.cy; Src.Top = Source.Top; } Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right - Dst.Left), (Dst.Bottom - Dst.Top), Bitmap, Src.Left, Src.Top, (Src.Right - Src.Left), (Src.Bottom - Src.Top), SRCCOPY); // by celberus if (WorkArea->Mask) { if (!Irregularrect(Pattern, Src, Dst)) goto fail; // convert by celberus } } if (Dst.Bottom < Pattern->Height) { Dst.Top = Dst.Bottom; Dst.Bottom = Pattern->Height; Src.Top = Source.Top; Src.Bottom = P; Pattern->UnionStretchBlt(Dst.Left, Dst.Top, (Dst.Right - Dst.Left), (Dst.Bottom - Dst.Top), Bitmap, Src.Left, Src.Top, (Src.Right - Src.Left), (Src.Bottom - Src.Top), SRCCOPY); // by celberus if (WorkArea->Mask) { if (!Irregularrect(Pattern, Src, Dst)) goto fail; // convert by celberus } } } break; } END_LOG; return true; fail: // if (dcSrc) Bitmap->DeleteDC(dcSrc); // if (dcDst) Pattern->DeleteDC(dcDst); END_LOG; return false; } // ---------------------------------------------------------------------------- void __fastcall TMainImageForm::MosaicDraw8 (TUnionBitmap *bm, int k, int m, int w, int h, int pi) { BEGIN_LOG(""); BYTE *p = NULL; TRect rect; int y, l; int mk = k * w; int mm = m * h; if (mk == 0) mk = 1; if (mm == 0) mm = 1; rect = Rect(mk - 1, mm - 1, (k + 1) * w, (m + 1) * h); bm->StartScanLine(); p = (BYTE*)(bm->GetScanLine(rect.Top) + rect.Left); memset(p, 0, rect.Right - rect.Left); bm->PutScanLine(rect.Top); for (y = rect.Top + 1; y < rect.Bottom - 1; y++) { p = bm->GetScanLine(y) + rect.Left; *p = 0; p++; l = rect.Right - rect.Left - 2; memset(p, pi, l); p += l; *p = 0; bm->PutScanLine(y); } p = bm->GetScanLine(rect.Bottom - 1) + rect.Left; memset(p, 0, rect.Right - rect.Left); bm->PutScanLine(rect.Bottom - 1); bm->StopScanLine(); END_LOG; } // ---------------------------------------------------------------------------- void __fastcall TMainImageForm::MosaicDraw24 (TUnionBitmap *bm, int k, int m, int w, int h, RGBQUAD rgb) { BEGIN_LOG(""); BYTE *p = NULL; DWORD color = RGB(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue); TRect rect; int y, l; int mk = k * w; int mm = m * h; if (mk == 0) mk = 1; if (mm == 0) mm = 1; rect = Rect(mk - 1, mm - 1, (k + 1) * w, (m + 1) * h); bm->StartScanLine(); p = (BYTE*)(bm->GetScanLine(rect.Top) + 3 * rect.Left); memset24(p, 0, rect.Right - rect.Left); bm->PutScanLine(rect.Top); for (y = rect.Top + 1; y < rect.Bottom - 1; y++) { p = bm->GetScanLine(y) + 3 * rect.Left; SetPixel24(p, 0); p += 3; l = rect.Right - rect.Left - 2; memset24(p, color, l); p += 3 * l; SetPixel24(p, 0); bm->PutScanLine(y); } p = bm->GetScanLine(rect.Bottom - 1) + 3 * rect.Left; memset24(p, 0, rect.Right - rect.Left); bm->PutScanLine(rect.Bottom - 1); bm->StopScanLine(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::NormalDrawing(bool MaskBmp) { BEGIN_LOG(""); int w, h; int x, y; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dp, sp; THistoryData *ud = NULL; TPException ec = EC_NONE; w = arwindow.size.x; h = arwindow.size.y; if ((ud = Undo->GetLast()) == NULL) { END_LOG; return; } // if ((ud = Undo->GetLastPatternUd()) == NULL) return; MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); if (MaskBmp) MainImageForm->iMainImage->Mask->PartialUndo->LoadLast(ud->FromRgb); if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->Mask->StartUndoScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!iMainImage->uBitmap->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (ud->uBitmap) if (!ud->uBitmap->StartUndoScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } TCursor old_cursor; old_cursor = Screen->Cursor; Screen->Cursor = crHourGlass; #ifdef FASTAR // ½Å ¹öÁ¯ (8.2 ÀÌÈÄ) drawRepeat(MaskBmp, 0); #else // ±¸ ¹öÁ¯ dp = Point(arwindow.s.x, arwindow.s.y); // Left - Top sp = Point(arwindow.s.x, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp, w / 2); dp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.s.y); // Right - Top sp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.e.y); AR_NHBDrawing(MaskBmp, w, h, dp, sp, (w + ARWidthR) / 2); dp = Point(arwindow.s.x, arwindow.e.y - h / 2 - ARHeightR); // Left - Bottom sp = Point(arwindow.s.x, arwindow.s.y - h / 2 - ARHeightR); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, w / 2); dp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.e.y - h / 2 - ARHeightR); // Right - Bottom sp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.s.y - h / 2 - ARHeightR); AR_NHBDrawing(MaskBmp, w, h + ARHeightR, dp, sp, (w + ARWidthR) / 2); #endif Screen->Cursor = old_cursor; if (MaskBmp) { iMainImage->Mask->StopUndoScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); if (ud->uBitmap) ud->uBitmap->StopUndoScanLine(); iMainImage->uBitmap->StopScanLine(); } END_LOG; return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::HDHORDrawing(bool MaskBmp) { int hw; TPoint dp, sp; THistoryData *ud = NULL; TPException ec = EC_NONE; hw = arwindow.size.x / 2; if ((ud = Undo->GetLast()) == NULL) return; BEGIN_LOG(""); MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); // 1_1 if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->iMainImage->Mask->PartialUndo->LoadLast(ud->FromRgb); // 1_2 // if (!ud->Mask->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->iMainImage->Mask->StartUndoScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!iMainImage->uBitmap->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if (!ud->uBitmap->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->iMainImage->uBitmap->StartUndoScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } #ifdef FASTAR__//¿¹Àü°ÍÀ¸·Î µ¹¸°´Ù. ¿¡·¯°¡ ÀÖ°í ¿Ö ¸¸µé¾î Á³´ÂÁö ¾Ë¼ö ¾øÀ½...(07.02.15) by maxleo21c // Ȥ½Ã ´Ù¸¥ °÷¿¡¼­ »ç¿ëÇÒ ¼ö Àֱ⠶§¹®¿¡ FASTAR defineÀº ±×´ë·Î µÎ°í À̸§À» FASTAR__·Î º¯°æ drawRepeat(MaskBmp, 1); #else if (hw > MWdiv) { MWdivDrawing1(MaskBmp); } else if (hw == MWdiv) { MWdivDrawing2(MaskBmp); } else if (hw < MWdiv) { MWdivDrawing3(MaskBmp); } #endif if (MaskBmp) { // ud->Mask->StopScanLine(); MainImageForm->iMainImage->Mask->StopUndoScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); // ud->uBitmap->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); iMainImage->uBitmap->StopScanLine(); } END_LOG; return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::HDVERDrawing(bool MaskBmp) // ¼¼·ÎºÐÇÒ { int hh; THistoryData *ud = NULL; TPException ec = EC_NONE; hh = arwindow.size.y / 2; if ((ud = Undo->GetLast()) == NULL) return; BEGIN_LOG(""); if (MaskBmp) { MainImageForm->iMainImage->Mask->PartialUndo->LoadLast(ud->FromRgb); // 1_1 if (!iMainImage->Mask->StartScanLineN(4)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if (!ud->Mask->StartScanLineN(4)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->iMainImage->Mask->StartUndoScanLineN(4)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // 2_1 } else { MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); // 1_2 if (!iMainImage->uBitmap->StartScanLineN(4)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if (!ud->uBitmap->StartScanLineN(4)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->iMainImage->uBitmap->StartUndoScanLineN(4)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // 2_2 if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(4)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } TCursor old_cursor; old_cursor = Screen->Cursor; Screen->Cursor = crHourGlass; #ifdef FASTAR0 // ¼¼·Î ºÐÇÒ ½Å ¹öÁ¯ (8.2ºÎÅÍ Àû¿ëµÊ) // ¼¼·ÎºÐÇÒÀÌ µå·ÎÀ׽à À§Ä¡°¡ 1px Ʋ¸®°Ô ±×·ÁÁö´Â ¿À·ù°¡ À־ ±âÁ¸ ¹öÁ¯ »ç¿ë // »õ ¹öÁ¯ »ç¿ëÀ» ¿øÇÒ ½Ã¿¡´Â À§ÀÇ FASTAR0(ÀӽüöÁ¤)¸¦ FASTAR·Î ¼öÁ¤ by Altang 2007. 1. 8. drawRepeat(MaskBmp, 2); #else // ¼¼·Î ºÐÇÒ ±¸ ¹öÁ¯ if (hh > MHdiv) { MHdivDrawing1(MaskBmp); } else if (hh == MHdiv) { MHdivDrawing2(MaskBmp); } else if (hh < MHdiv) { MHdivDrawing3(MaskBmp); } #endif Screen->Cursor = old_cursor; if (MaskBmp) { // ud->Mask->StopScanLine(); MainImageForm->iMainImage->Mask->StopUndoScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); // ud->uBitmap->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); iMainImage->uBitmap->StopScanLine(); } END_LOG; return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- int __fastcall TMainImageForm::Comp_Value(COLORREF A, COLORREF B, COLORREF C, COLORREF D, COLORREF UA, COLORREF UB, COLORREF UC, COLORREF UD) { if ((B == C) && (C == D) && (D != A)) { // order A, B, C, D return 1; } else if ((C == D) && (D == A) && (A != B)) { return 2; } else if ((D == A) && (A == B) && (B != C)) { return 3; } else if ((A == B) && (B == C) && (C != D)) { return 4; } else { if (A == B) { if (C == D) { if (A == UA) return 3; else return 1; } else { return 3; } } else if (A == C) { if (B == D) { if (A == UA) return 2; else return 1; } else { return 2; } } else if (A == D) { if (B == C) { if (A == UA) return 2; else return 1; } else { return 2; } } else if (B == C) { if (A != D) return 1; } else if (B == D) { if (A != C) return 1; } else if (C == D) { if (A != B) return 1; } } return-1; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::drawRepeat(bool MaskBmp, int repeatType) { BEGIN_LOG(""); THistoryData *ud = NULL; ud = Undo->GetLast(); RECT wholeArea; wholeArea.left = arwindow.s.x - (arwindow.size.x + 1) / 2; wholeArea.top = arwindow.s.y - (arwindow.size.y + 1) / 2; wholeArea.right = wholeArea.left + arwindow.size.x * 2; wholeArea.bottom = wholeArea.top + arwindow.size.y * 2; RECT undoRect; if (MaskBmp) { undoRect = MainImageForm->iMainImage->Mask->PartialUndo->GetUndoRect(); } else { undoRect = MainImageForm->iMainImage->uBitmap->PartialUndo->GetUndoRect(); } // resize undoRect if (undoRect.top < wholeArea.top) undoRect.top = wholeArea.top; if (undoRect.bottom > wholeArea.bottom) undoRect.bottom = wholeArea.bottom; if (undoRect.left < wholeArea.left) undoRect.left = wholeArea.left; if (undoRect.right > wholeArea.right) undoRect.right = wholeArea.right; // if (undoRect.right <= undoRect.left || undoRect.bottom <= undoRect.top) { END_LOG; return; } // repeat ¿µ¿ª ¹Û¿¡ ÀÛ¾÷ RepeatDraw *repeatDraw; if (repeatType == 0) { repeatDraw = (RepeatDraw*)new NormalRepeatDraw(&arwindow, wholeArea); } else if (repeatType == 1) { repeatDraw = (RepeatDraw*)new WdivRepeatDraw(&arwindow, wholeArea, MWdiv); } else if (repeatType == 2) { repeatDraw = (RepeatDraw*)new HdivRepeatDraw(&arwindow, wholeArea, MHdiv); } // °á°ú·Î ³ª¿Ã 4 ¿µ¿ªÀ» ÃʱâÈ­ÇÑ´Ù. 0, 0, 0, 0 À¸·Î ÇØµµ µÊ RECT centerRect[4] = { { arwindow.s.x, arwindow.s.y, arwindow.s.x, arwindow.s.y }, { arwindow.e.x, arwindow.s.y, arwindow.e.x, arwindow.s.y }, { arwindow.s.x, arwindow.e.y, arwindow.s.x, arwindow.e.y }, { arwindow.e.x, arwindow.e.y, arwindow.e.x, arwindow.e.y } }; // TL, TR, BL, BR ÀÇ ¼ø¼­ RECT intersectRect, unionRect; // °øÅë ºÎºÐÀ» ÀúÀåÇÒ Àӽà ¿µ¿ª RECT transformRect; // intersecdtRect¸¦ ¼¾ÅÍ ¿µ¿ªÀ¸·Î À̵¿ÇÑ ¿µ¿ª int rectNum; for (int i = 0; i < 9; i++) { if (IntersectRect(&intersectRect, &undoRect, &repeatDraw->dividedRect[i])) { // °øÅë ºÎºÐÀÌ ÀÖÀ¸¸é transformRect = repeatDraw->transToCenter(intersectRect); if (i == 1 || i == 2) { transformRect.left--; transformRect.right--; } // 4 ¿µ¿ª Áß ÇØ´ç ºÎºÐ¿¡ Àû¿ëÇÑ´Ù. for (rectNum = 0; rectNum < 4; rectNum++) { if (centerRect[rectNum].left >= transformRect.left && centerRect [rectNum].right <= transformRect.right && centerRect[rectNum] .top >= transformRect.top && centerRect[rectNum].bottom <= transformRect.bottom) { // ¿µ¿ªÀ» Æ÷ÇÔÇÏ´Â ºÎºÐÀ̸é centerRect[rectNum] = transformRect; // ¿µ¿ªÀÌ È®ÀåµÇÁö·Õ break; } } if (rectNum == 4) { // Æ÷ÇԵǴ ºÎºÐÀÌ ¾øÀ¸¸é.. for (rectNum = 0; rectNum < 4; rectNum++) { if (IsRectEmpty(centerRect[rectNum])) { centerRect[rectNum] = transformRect; // ºó°÷¿¡ ³Ö´Â´Ù. break; } } } } } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { if (IntersectRect(&intersectRect, ¢erRect[i], ¢erRect[j])) { if (UnionRect(&unionRect, ¢erRect[i], ¢erRect[j])) { centerRect[i] = unionRect; centerRect[j] = Rect(0, 0, 0, 0); } } } } int StartX, StartY, EndX, EndY; repeatDraw->initItr(iMainImage, MaskBmp); for (int i = 0; i < 4; i++) { if (IsRectEmpty(centerRect[i])) continue; StartX = centerRect[i].left; StartY = centerRect[i].top; EndX = centerRect[i].right; EndY = centerRect[i].bottom; repeatDraw->setLoopArea(StartX, StartY, EndX, EndY); repeatDraw->initPoint(); for (int y = StartY; y < EndY; y++) { repeatDraw->initPointX(); repeatDraw->getScanLine(); for (int x = StartX; x < EndX; x++) { repeatDraw->copyValue(); repeatDraw->proceedPoint(); } repeatDraw->initPointX(); repeatDraw->putScanLine(); repeatDraw->proceedPointY(); } } delete repeatDraw; END_LOG; } // --------------------------------------------------------------------------- /* void __fastcall TMainImageForm::AR_NHADrawing(bool Maskbmp, int w, int h, TPoint dp, TPoint spp, int hhw,TUnionBitmap *udMask,TUnionBitmap *udBitmap) { // BeConverted by linuxjun Don't Forget!! Undo_Method //For New Undo by linuxjun int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp=NULL, *mp1=NULL, *tp=NULL, *tp1=NULL, *lmp=NULL, *ltp=NULL; Byte *ump=NULL, *ump1=NULL, *utp=NULL, *utp1=NULL; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; THistoryData *ud=NULL; ud = Undo->GetLast(); hw = hhw; hh = h/2; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; // ux = ud->getRectRange().left; //for new undo // uy = ud->getRectRange().top; //for new undo ux = arwindow.s.x-w/2-1; uy = arwindow.s.y-h/2-1; if (Maskbmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; ump = udMask->GetScanLine(dp.y - uy + y) + dp.x - ux; //For New Undo by linuxjun utp = udMask->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; //For New Undo by linuxjun // ump = ud->Mask->GetScanLine(dp.y + y) + dp.x; // utp = ud->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); ump = udMask->GetScanLine(dp.y - uy + y); utp = udMask->GetScanLineN(spp.y - uy + y, 1); // ump = udMask->GetUndoScanLine(dp.y + y); //For New Undo by linuxjun // utp = udMask->GetScanLineN(spp.y + y, 1); //For New Undo by linuxjun mx = dp.x; tx = spp.x; // umx = dp.x-ux, utx = spp.x-ux; umx = dp.x, utx = spp.x; //For New Undo by linuxjun for (x=0; x>3))&(0x80>>(mx&7))) > 0) ? 1 : 0; //1 cv1 = ((*(mp+((mx+w)>>3))&(0x80>>((mx+w)&7))) > 0) ? 1 : 0; //2 cv2 = ((*(tp+(tx>>3))&(0x80>>(tx&7))) > 0 ) ? 1 : 0; //3 cv3 = ((*(tp+((tx+w)>>3))&(0x80>>((tx+w)&7))) > 0) ? 1 : 0; //4 umv = ((*(ump+(umx>>3))&(0x80>>(umx&7))) > 0) ? 1 : 0; ucv1 = ((*(ump+((umx+w)>>3))&(0x80>>((umx+w)&7))) > 0) ? 1 : 0; ucv2 = ((*(utp+(utx>>3))&(0x80>>(utx&7))) > 0 ) ? 1 : 0; ucv3 = ((*(utp+((utx+w)>>3))&(0x80>>((utx+w)&7))) > 0) ? 1 : 0; if (!((mv==cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } else if (point == 2) { if (cv1) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 3) { if (cv2) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 4) { if (cv3) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> ((mx)&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1) + spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; // ump = udBitmap->GetScanLine(dp.y + y) + dp.x; //For New Undo by linuxjun // utp = udBitmap->GetScanLineN(spp.y + y, 1) + spp.x; //For New Undo by linuxjun lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; // ump = udBitmap->GetScanLine(dp.y + y) + dp.x; //For New Undo by linuxjun // utp = udBitmap->GetScanLineN(spp.y + y, 1) + spp.x; //For New Undo by linuxjun for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; yuBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); // ump = udBitmap->GetScanLine(dp.y + y) + 3*(dp.x); //For New Undo by linuxjun // utp = udBitmap->GetScanLineN(spp.y + y, 1) + 3*(spp.x); //For New Undo by linuxjun lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 2) { SetPixel24(mp, cv1); SetPixel24(tp, cv1); SetPixel24(tp1, cv1); if (*(lmp + ((dp.x+x+w)>>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp1, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } } iMainImage->uBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; yuBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); // ump = udBitmap->GetScanLine(dp.y + y) + 3*(dp.x); //For New Undo by linuxjun // utp = udBitmap->GetScanLineN(spp.y + y, 1) + 3*(spp.x); //For New Undo by linuxjun for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } } } */ // --------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_NHADrawing (bool Maskbmp, int w, int h, TPoint dp, TPoint spp, int hhw) { BEGIN_LOG(""); ///* BeConverted by linuxjun Don't Forget!! Undo_Method //For New Undo by linuxjun int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp = NULL, *mp1 = NULL, *tp = NULL, *tp1 = NULL, *lmp = NULL, *ltp = NULL; Byte *ump = NULL, *ump1 = NULL, *utp = NULL, *utp1 = NULL; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; THistoryData *ud = NULL; // TUndoManager *udMask, *udBitmap; TUnionBitmap *udMask, *udBitmap; ud = Undo->GetLast(); // 2 hw = hhw; hh = h / 2; ux = arwindow.s.x - hw; uy = arwindow.s.y - hh; // ux = ud->getRectRange().left; //for new undo // uy = ud->getRectRange().top; //for new undo if (Maskbmp) { udMask = MainImageForm->iMainImage->Mask; } else { udBitmap = MainImageForm->iMainImage->uBitmap; } if (Maskbmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y = 0; y < hh; y++) { // Repeat Area => mp[x] if (!udMask->PartialUndo->HasPenUndoBitmap(dp.y - uy + y, dp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y - uy + y, spp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y + y, spp.x, hw + w)) { y += udMask->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->Mask->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + spp.x; // iMainImage->Mask->UndoCheckActivePart(dp.y - uy + y); ump = udMask->GetUndoScanLine(dp.y - uy + y, dp.x - ux, hw + w) + dp.x - ux; // For New Undo by linuxjun // iMainImage->Mask->UndoCheckActivePart(spp.y - uy + y); utp = udMask->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1) + spp.x - ux; // For New Undo by linuxjun // ump = ud->Mask->GetScanLine(dp.y + y) + dp.x; // utp = ud->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x = 0; x < hw; x++, mp++, tp++, ump++, utp++) { if (!((*mp == *(mp + w)) && (*(mp + w) == *tp) && (*tp == *(tp + w))) ) { point = Comp_Value(*mp, *(mp + w), *tp, *(tp + w), *ump, *(ump + w) , *utp, *(utp + w)); if (point == 1) { *(tp + w) = *mp; *(mp + w) = *mp; *tp = *mp; } else if (point == 2) { *mp = *(mp + w); *tp = *(mp + w); *(tp + w) = *(mp + w); } else if (point == 3) { *mp = *tp; *(mp + w) = *tp; *(tp + w) = *tp; } else if (point == 4) { *mp = *(tp + w); *(mp + w) = *(tp + w); *tp = *(tp + w); } } } iMainImage->Mask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->Mask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } else { for (y = 0; y < hh; y++) { // Repeat Area => mp[x] if (!udMask->PartialUndo->HasPenUndoBitmap(dp.y - uy + y, dp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y - uy + y, spp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y + y, spp.x, hw + w)) { y += udMask->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->Mask->GetScanLine(dp.y + y, dp.x, hw + w); tp = iMainImage->Mask->GetScanLineN(spp.y + y, spp.x, hw + w, 1); // iMainImage->Mask->UndoCheckActivePart(dp.y - uy + y); ump = udMask->GetUndoScanLine(dp.y - uy + y, dp.x, hw + w); // iMainImage->Mask->UndoCheckActivePart(spp.y - uy + y); utp = udMask->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1); // ump = ud->Mask->GetScanLine(dp.y + y); //For New Undo by linuxjun // utp = ud->Mask->GetScanLineN(spp.y + y, 1); //For New Undo by linuxjun mx = dp.x; tx = spp.x; // umx = dp.x-ux, utx = spp.x-ux; umx = dp.x, utx = spp.x; // For New Undo by linuxjun for (x = 0; x < hw; x++, mx++, tx++, umx++, utx++) { mv = ((*(mp + (mx >> 3)) & (0x80 >> (mx & 7))) > 0) ? 1 : 0; // 1 cv1 = ((*(mp + ((mx + w) >> 3)) & (0x80 >> ((mx + w) & 7))) > 0) ? 1 : 0; // 2 cv2 = ((*(tp + (tx >> 3)) & (0x80 >> (tx & 7))) > 0) ? 1 : 0; // 3 cv3 = ((*(tp + ((tx + w) >> 3)) & (0x80 >> ((tx + w) & 7))) > 0) ? 1 : 0; // 4 umv = ((*(ump + (umx >> 3)) & (0x80 >> (umx & 7))) > 0) ? 1 : 0; ucv1 = ((*(ump + ((umx + w) >> 3)) & (0x80 >> ((umx + w) & 7))) > 0) ? 1 : 0; ucv2 = ((*(utp + (utx >> 3)) & (0x80 >> (utx & 7))) > 0) ? 1 : 0; ucv3 = ((*(utp + ((utx + w) >> 3)) & (0x80 >> ((utx + w) & 7))) > 0) ? 1 : 0; if (!((mv == cv1) && (cv1 == cv2) && (cv2 == cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(mp + ((mx + w) >> 3)) |= 0x80 >> ((mx + w) & 7); *(tp + ((tx + w) >> 3)) |= 0x80 >> ((tx + w) & 7); *(tp + (tx >> 3)) |= 0x80 >> (tx & 7); } else { *(mp + ((mx + w) >> 3)) &= ~(0x80 >> ((mx + w) & 7)); *(tp + ((tx + w) >> 3)) &= ~(0x80 >> ((tx + w) & 7)); *(tp + (tx >> 3)) &= ~(0x80 >> (tx & 7)); } } else if (point == 2) { if (cv1) { *(mp + (mx >> 3)) |= 0x80 >> (mx & 7); *(tp + (tx >> 3)) |= 0x80 >> (tx & 7); *(tp + ((tx + w) >> 3)) |= 0x80 >> ((tx + w) & 7); } else { *(mp + (mx >> 3)) &= ~(0x80 >> (mx & 7)); *(tp + (tx >> 3)) &= ~(0x80 >> (tx & 7)); *(tp + ((tx + w) >> 3)) &= ~(0x80 >> ((tx + w) & 7)); } } else if (point == 3) { if (cv2) { *(mp + (mx >> 3)) |= 0x80 >> (mx & 7); *(mp + ((mx + w) >> 3)) |= 0x80 >> ((mx + w) & 7); *(tp + ((tx + w) >> 3)) |= 0x80 >> ((tx + w) & 7); } else { *(mp + (mx >> 3)) &= ~(0x80 >> (mx & 7)); *(mp + ((mx + w) >> 3)) &= ~(0x80 >> ((mx + w) & 7)); *(tp + ((tx + w) >> 3)) &= ~(0x80 >> ((tx + w) & 7)); } } else if (point == 4) { if (cv3) { *(mp + (mx >> 3)) |= 0x80 >> (mx & 7); *(mp + ((mx + w) >> 3)) |= 0x80 >> ((mx + w) & 7); *(tp + (tx >> 3)) |= 0x80 >> (tx & 7); } else { *(mp + (mx >> 3)) &= ~(0x80 >> ((mx) & 7)); *(mp + ((mx + w) >> 3)) &= ~(0x80 >> ((mx + w) & 7)); *(tp + (tx >> 3)) &= ~(0x80 >> (tx & 7)); } } } } iMainImage->Mask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->Mask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y = 0; y < hh; y++) { // Repeat Area => mp[x] if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x - ux, hw + w) + dp.x - ux; // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN (spp.y - uy + y, spp.x - ux, hw + w, 1) + spp.x - ux; // ump = udBitmap->GetScanLine(dp.y + y) + dp.x; //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + spp.x; //For New Undo by linuxjun lmp = iMainImage->LayerMask->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN (spp.y + y, spp.x, hw + w, 1) + spp.x; for (x = 0; x < hw; x++, mp++, tp++, ump++, utp++, lmp++, ltp++) { if (!((*(mp + w) == *tp) && (*tp == *(tp + w)) && (*(tp + w) == *mp) )) { point = Comp_Value(*mp, *(mp + w), *tp, *(tp + w), *ump, * (ump + w), *utp, *(utp + w)); if (point == 1) { *(mp + w) = *mp; *(lmp + w) = *lmp; *tp = *mp; *ltp = *lmp; *(tp + w) = *mp; *(ltp + w) = *lmp; } else if (point == 2) { *mp = *(mp + w); *lmp = *(lmp + w); *tp = *(mp + w); *ltp = *(lmp + w); *(tp + w) = *(mp + w); *(ltp + w) = *(lmp + w); } else if (point == 3) { *mp = *tp; *lmp = *ltp; *(mp + w) = *tp; *(lmp + w) = *ltp; *(tp + w) = *tp; *(ltp + w) = *ltp; } else if (point == 4) { *mp = *(tp + w); *lmp = *(ltp + w); *(mp + w) = *(tp + w); *(lmp + w) = *(ltp + w); *tp = *(tp + w); *ltp = *(ltp + w); } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); iMainImage->LayerMask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->LayerMask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } else { for (y = 0; y < hh; y++) { // Repeat Area => mp[x] if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x - ux, hw + w) + dp.x - ux; // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN (spp.y - uy + y, spp.x - ux, hw + w, 1) + spp.x - ux; // ump = ud->uBitmap->GetScanLine(dp.y + y) + dp.x; //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + spp.x; //For New Undo by linuxjun for (x = 0; x < hw; x++, mp++, tp++, ump++, utp++) { if (!((*(mp + w) == *tp) && (*tp == *(tp + w)) && (*(tp + w) == *mp) )) { // if(dp.y+y+1>=udBitmap->Height || spp.y+y+1>=udBitmap->Height ||dp.x+x+1>=udBitmap->Width || spp.x+x+1>=udBitmap->Width){ // int temp = 0; // } point = Comp_Value(*mp, *(mp + w), *tp, *(tp + w), *ump, * (ump + w), *utp, *(utp + w)); if (point == 1) { *(mp + w) = *mp; *tp = *mp; *(tp + w) = *mp; } else if (point == 2) { *mp = *(mp + w); *tp = *(mp + w); *(tp + w) = *(mp + w); } else if (point == 3) { *mp = *tp; *(mp + w) = *tp; *(tp + w) = *tp; } else if (point == 4) { *mp = *(tp + w); *(mp + w) = *(tp + w); *tp = *(tp + w); } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } } else { if (iMainImage->LayerMask) { for (y = 0; y < hh; y++) { if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + 3 * dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + 3 * spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x - ux, hw + w) + 3 * (dp.x - ux); // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN (spp.y - uy + y, spp.x - ux, hw + w, 1) + 3 * (spp.x - ux); // ump = ud->uBitmap->GetScanLine(dp.y + y) + 3*(dp.x); //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + 3*(spp.x); //For New Undo by linuxjun lmp = iMainImage->LayerMask->GetScanLine(dp.y + y, dp.x, hw + w); ltp = iMainImage->LayerMask->GetScanLineN (spp.y + y, spp.x, hw + w, 1); for (x = 0; x < hw; x++, mp += 3, tp += 3, ump += 3, utp += 3) { mp1 = mp + 3 * w; tp1 = tp + 3 * w; GetPixel24(mp, mv); GetPixel24(mp1, cv1); GetPixel24(tp, cv2); GetPixel24(tp1, cv3); ump1 = ump + 3 * w; utp1 = utp + 3 * w; GetPixel24(ump, umv); GetPixel24(ump1, ucv1); GetPixel24(utp, ucv2); GetPixel24(utp1, ucv3); if (!((cv1 == cv2) && (cv2 == cv3) && (cv3 == mv))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { SetPixel24(mp1, mv); SetPixel24(tp, mv); SetPixel24(tp1, mv); if (*(lmp + ((dp.x + x) >> 3)) & (0x80 >> ((dp.x + x) & 7))) { *(lmp + ((dp.x + x + w) >> 3)) |= (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) |= (0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) |= (0x80 >> ((spp.x + x + w) & 7)); } else { *(lmp + ((dp.x + x + w) >> 3)) &= ~ (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) &= ~(0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) &= ~ (0x80 >> ((spp.x + x + w) & 7)); } } else if (point == 2) { SetPixel24(mp, cv1); SetPixel24(tp, cv1); SetPixel24(tp1, cv1); if (*(lmp + ((dp.x + x + w) >> 3)) & (0x80 >> ((dp.x + x + w) & 7))) { *(lmp + ((dp.x + x) >> 3)) |= (0x80 >> ((dp.x + x) & 7)); *(ltp + ((spp.x + x) >> 3)) |= (0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) |= (0x80 >> ((spp.x + x + w) & 7)); } else { *(lmp + ((dp.x + x) >> 3)) &= ~(0x80 >> ((dp.x + x) & 7)); *(ltp + ((spp.x + x) >> 3)) &= ~(0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) &= ~ (0x80 >> ((spp.x + x + w) & 7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp1, cv2); if (*(ltp + ((spp.x + x) >> 3)) & (0x80 >> ((spp.x + x) & 7))) { *(lmp + ((dp.x + x) >> 3)) |= (0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) |= (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x + w) >> 3)) |= (0x80 >> ((spp.x + x + w) & 7)); } else { *(lmp + ((dp.x + x) >> 3)) &= ~(0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) &= ~ (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x + w) >> 3)) &= ~ (0x80 >> ((spp.x + x + w) & 7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp, cv3); if (*(ltp + ((spp.x + x + w) >> 3)) & (0x80 >> ((spp.x + x + w) & 7))) { *(lmp + ((dp.x + x) >> 3)) |= (0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) |= (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) |= (0x80 >> ((spp.x + x) & 7)); } else { *(lmp + ((dp.x + x) >> 3)) &= ~(0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) &= ~ (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) &= ~(0x80 >> ((spp.x + x) & 7)); } } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); iMainImage->LayerMask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->LayerMask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } else { for (y = 0; y < hh; y++) { if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + 3 * dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + 3 * spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x - ux, hw + w) + 3 * (dp.x - ux); // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN (spp.y - uy + y, spp.x - ux, hw + w, 1) + 3 * (spp.x - ux); // ump = ud->uBitmap->GetScanLine(dp.y + y) + 3*(dp.x); //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + 3*(spp.x); //For New Undo by linuxjun for (x = 0; x < hw; x++, mp += 3, tp += 3, ump += 3, utp += 3) { mp1 = mp + 3 * w; tp1 = tp + 3 * w; GetPixel24(mp, mv); GetPixel24(mp1, cv1); GetPixel24(tp, cv2); GetPixel24(tp1, cv3); ump1 = ump + 3 * w; utp1 = utp + 3 * w; GetPixel24(ump, umv); GetPixel24(ump1, ucv1); GetPixel24(utp, ucv2); GetPixel24(utp1, ucv3); if (!((cv1 == cv2) && (cv2 == cv3) && (cv3 == mv))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { SetPixel24(mp1, mv); SetPixel24(tp, mv); SetPixel24(tp1, mv); } else if (point == 2) { SetPixel24(mp, cv1); SetPixel24(tp, cv1); SetPixel24(tp1, cv1); } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp1, cv2); } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp, cv3); } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } } } END_LOG; // */ /* BeConverted by linuxjun Don't Forget!! Undo_Method //For New Undo by linuxjun int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp=NULL, *mp1=NULL, *tp=NULL, *tp1=NULL, *lmp=NULL, *ltp=NULL; Byte *ump=NULL, *ump1=NULL, *utp=NULL, *utp1=NULL; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; THistoryData *ud=NULL; ud = Undo->GetLast(); hw = hhw; hh = h/2; ux = arwindow.s.x - hw; uy = arwindow.s.y - hh; // ux = ud->getRectRange().left; //for new undo // uy = ud->getRectRange().top; //for new undo if (Maskbmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Mask->GetScanLine(dp.y - uy + y) + dp.x - ux; //For New Undo by linuxjun utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; //For New Undo by linuxjun // ump = ud->Mask->GetScanLine(dp.y + y) + dp.x; // utp = ud->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); ump = ud->Mask->GetScanLine(dp.y - uy + y); utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1); // ump = ud->Mask->GetScanLine(dp.y + y); //For New Undo by linuxjun // utp = ud->Mask->GetScanLineN(spp.y + y, 1); //For New Undo by linuxjun mx = dp.x; tx = spp.x; // umx = dp.x-ux, utx = spp.x-ux; umx = dp.x, utx = spp.x; //For New Undo by linuxjun for (x=0; x>3))&(0x80>>(mx&7))) > 0) ? 1 : 0; //1 cv1 = ((*(mp+((mx+w)>>3))&(0x80>>((mx+w)&7))) > 0) ? 1 : 0; //2 cv2 = ((*(tp+(tx>>3))&(0x80>>(tx&7))) > 0 ) ? 1 : 0; //3 cv3 = ((*(tp+((tx+w)>>3))&(0x80>>((tx+w)&7))) > 0) ? 1 : 0; //4 umv = ((*(ump+(umx>>3))&(0x80>>(umx&7))) > 0) ? 1 : 0; ucv1 = ((*(ump+((umx+w)>>3))&(0x80>>((umx+w)&7))) > 0) ? 1 : 0; ucv2 = ((*(utp+(utx>>3))&(0x80>>(utx&7))) > 0 ) ? 1 : 0; ucv3 = ((*(utp+((utx+w)>>3))&(0x80>>((utx+w)&7))) > 0) ? 1 : 0; if (!((mv==cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } else if (point == 2) { if (cv1) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 3) { if (cv2) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 4) { if (cv3) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> ((mx)&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; // ump = ud->uBitmap->GetScanLine(dp.y + y) + dp.x; //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + spp.x; //For New Undo by linuxjun lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; // ump = ud->uBitmap->GetScanLine(dp.y + y) + dp.x; //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + spp.x; //For New Undo by linuxjun for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; yuBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); // ump = ud->uBitmap->GetScanLine(dp.y + y) + 3*(dp.x); //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + 3*(spp.x); //For New Undo by linuxjun lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 2) { SetPixel24(mp, cv1); SetPixel24(tp, cv1); SetPixel24(tp1, cv1); if (*(lmp + ((dp.x+x+w)>>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp1, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } } iMainImage->uBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; yuBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); // ump = ud->uBitmap->GetScanLine(dp.y + y) + 3*(dp.x); //For New Undo by linuxjun // utp = ud->uBitmap->GetScanLineN(spp.y + y, 1) + 3*(spp.x); //For New Undo by linuxjun for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } } // */ /* BeConverted by linuxjun Don't Forget!! Undo_Method int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp=NULL, *mp1=NULL, *tp=NULL, *tp1=NULL, *lmp=NULL, *ltp=NULL; Byte *ump=NULL, *ump1=NULL, *utp=NULL, *utp1=NULL; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; THistoryData *ud=NULL; ud = Undo->Last; hw = hhw; hh = h/2; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; ux = ud->Range.left; uy = ud->Range.top; if (Maskbmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Mask->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); ump = ud->Mask->GetScanLine(dp.y - uy + y); utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1); mx = dp.x; tx = spp.x; umx = dp.x-ux, utx = spp.x-ux; for (x=0; x>3))&(0x80>>(mx&7))) > 0) ? 1 : 0; //1 cv1 = ((*(mp+((mx+w)>>3))&(0x80>>((mx+w)&7))) > 0) ? 1 : 0; //2 cv2 = ((*(tp+(tx>>3))&(0x80>>(tx&7))) > 0 ) ? 1 : 0; //3 cv3 = ((*(tp+((tx+w)>>3))&(0x80>>((tx+w)&7))) > 0) ? 1 : 0; //4 umv = ((*(ump+(umx>>3))&(0x80>>(umx&7))) > 0) ? 1 : 0; ucv1 = ((*(ump+((umx+w)>>3))&(0x80>>((umx+w)&7))) > 0) ? 1 : 0; ucv2 = ((*(utp+(utx>>3))&(0x80>>(utx&7))) > 0 ) ? 1 : 0; ucv3 = ((*(utp+((utx+w)>>3))&(0x80>>((utx+w)&7))) > 0) ? 1 : 0; if (!((mv==cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } else if (point == 2) { if (cv1) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 3) { if (cv2) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 4) { if (cv3) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> ((mx)&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; yuBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 2) { SetPixel24(mp, cv1); SetPixel24(tp, cv1); SetPixel24(tp1, cv1); if (*(lmp + ((dp.x+x+w)>>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp1, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } } iMainImage->uBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; yuBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } } */ } // --------------------------------------------------------------------------- /* void __fastcall TMainImageForm::AR_NHBDrawing(bool MaskBmp, int w, int h, TPoint dp, TPoint spp, int hhw,TUnionBitmap *udMask,TUnionBitmap *udBitmap) { int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp=NULL, *mp1=NULL, *tp=NULL, *tp1=NULL, *lmp=NULL, *ltp=NULL; Byte *ump=NULL, *ump1=NULL, *utp=NULL, *utp1=NULL; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; THistoryData *ud=NULL; ud = Undo->GetLast(); hw = hhw; hh = h/2; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; ux = arwindow.s.x-w/2-1; uy = arwindow.s.y-h/2-1; if (MaskBmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; ump = udMask->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = udMask->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); ump = udMask->GetScanLine(dp.y - uy + y); utp = udMask->GetScanLineN(spp.y - uy + y, 1); mx = dp.x; tx = spp.x; umx = dp.x-ux; utx = spp.x-ux; for (x=0; x>3))&(0x80>>((mx+w)&7))) > 0) ? 1 : 0; //1 cv1 = ((*(mp+(mx>>3))&(0x80>>(mx&7))) > 0) ? 1 : 0; //2 cv2 = ((*(tp+((tx+w)>>3))&(0x80>>((tx+w)&7))) > 0) ? 1 : 0; //3 cv3 = ((*(tp+(tx>>3))&(0x80>>(tx&7))) > 0 ) ? 1 : 0; //4 umv = ((*(ump+((umx+w)>>3))&(0x80>>((umx+w)&7))) > 0) ? 1 : 0; ucv1 = ((*(ump+(umx>>3))&(0x80>>(umx&7))) > 0) ? 1 : 0; ucv2 = ((*(utp+((utx+w)>>3))&(0x80>>((utx+w)&7))) > 0) ? 1 : 0; ucv3 = ((*(utp+(utx>>3))&(0x80>>(utx&7))) > 0 ) ? 1 : 0; if (!((mv == cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(mp+(mx>>3)) |= 0x80 >> (mx&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); } } else if (point == 2) { if (cv1) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); } } else if (point == 3) { if (cv2) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); } } else if (point == 4) { if (cv3) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3) ) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 2) { SetPixel24(mp1, cv1); SetPixel24(tp1, cv1); SetPixel24(tp, cv1); if (*(lmp + ((dp.x+x)>>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp, cv2); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp1, cv3); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } } } iMainImage->uBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = udBitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = udBitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } } } */ // --------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_NHBDrawing (bool MaskBmp, int w, int h, TPoint dp, TPoint spp, int hhw) { BEGIN_LOG(""); int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp = NULL, *mp1 = NULL, *tp = NULL, *tp1 = NULL, *lmp = NULL, *ltp = NULL; Byte *ump = NULL, *ump1 = NULL, *utp = NULL, *utp1 = NULL; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; THistoryData *ud = NULL; ud = Undo->GetLast(); hw = hhw; hh = h / 2; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; // ux = arwindow.s.x-w/2-1; // uy = arwindow.s.y-h/2-1; TUnionBitmap *udBitmap, *udMask; // TUndoManager *udBitmap,*udMask; // ux = ud->getRectRange().left; //for new undo // uy = ud->getRectRange().top; //for new undo ux = 0; uy = 0; if (MaskBmp) { udMask = iMainImage->Mask; } else { udBitmap = ud->uBitmap; } if (MaskBmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y = 0; y < hh; y++) { // Repeat Area => mp[x+w] if (!udMask->PartialUndo->HasPenUndoBitmap(dp.y - uy + y, dp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y - uy + y, spp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y + y, spp.x, hw + w)) { y += udMask->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->Mask->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + spp.x; // iMainImage->Mask->UndoCheckActivePart(dp.y - uy + y); ump = udMask->GetUndoScanLine(dp.y - uy + y, dp.x, hw + w) + dp.x - ux; // iMainImage->Mask->UndoCheckActivePart(spp.y - uy + y); utp = udMask->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1) + spp.x - ux; for (x = 0; x < hw; x++, mp++, tp++, ump++, utp++) { if (!((*mp == *tp) && (*tp == *(tp + w)) && (*(tp + w) == *(mp + w))) ) { point = Comp_Value(*(mp + w), *mp, *(tp + w), *tp, *(ump + w), *ump, *(utp + w), *utp); if (point == 1) { *mp = *(mp + w); *tp = *(mp + w); *(tp + w) = *(mp + w); } else if (point == 2) { *tp = *mp; *(tp + w) = *mp; *(mp + w) = *mp; } else if (point == 3) { *tp = *(tp + w); *mp = *(tp + w); *(mp + w) = *(tp + w); } else if (point == 4) { *mp = *tp; *(mp + w) = *tp; *(tp + w) = *tp; } } } iMainImage->Mask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->Mask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } else { for (y = 0; y < hh; y++) { // Repeat Area => mp[x+w] if (!udMask->PartialUndo->HasPenUndoBitmap(dp.y - uy + y, dp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y - uy + y, spp.x - ux, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udMask->PartialUndo->HasPenUndoBitmap(spp.y + y, spp.x, hw + w)) { y += udMask->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->Mask->GetScanLine(dp.y + y, dp.x, hw + w); tp = iMainImage->Mask->GetScanLineN(spp.y + y, spp.x, hw + w, 1); // iMainImage->Mask->UndoCheckActivePart(dp.y - uy + y); ump = udMask->GetUndoScanLine(dp.y - uy + y, dp.x, hw + w); // iMainImage->Mask->UndoCheckActivePart(spp.y - uy + y); utp = udMask->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1); mx = dp.x; tx = spp.x; umx = dp.x - ux; utx = spp.x - ux; for (x = 0; x < hw; x++, mx++, tx++, utx++, umx++) { mv = ((*(mp + ((mx + w) >> 3)) & (0x80 >> ((mx + w) & 7))) > 0) ? 1 : 0; // 1 cv1 = ((*(mp + (mx >> 3)) & (0x80 >> (mx & 7))) > 0) ? 1 : 0; // 2 cv2 = ((*(tp + ((tx + w) >> 3)) & (0x80 >> ((tx + w) & 7))) > 0) ? 1 : 0; // 3 cv3 = ((*(tp + (tx >> 3)) & (0x80 >> (tx & 7))) > 0) ? 1 : 0; // 4 umv = ((*(ump + ((umx + w) >> 3)) & (0x80 >> ((umx + w) & 7))) > 0) ? 1 : 0; ucv1 = ((*(ump + (umx >> 3)) & (0x80 >> (umx & 7))) > 0) ? 1 : 0; ucv2 = ((*(utp + ((utx + w) >> 3)) & (0x80 >> ((utx + w) & 7))) > 0) ? 1 : 0; ucv3 = ((*(utp + (utx >> 3)) & (0x80 >> (utx & 7))) > 0) ? 1 : 0; if (!((mv == cv1) && (cv1 == cv2) && (cv2 == cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(tp + (tx >> 3)) |= 0x80 >> (tx & 7); *(tp + ((tx + w) >> 3)) |= 0x80 >> ((tx + w) & 7); *(mp + (mx >> 3)) |= 0x80 >> (mx & 7); } else { *(tp + (tx >> 3)) &= ~(0x80 >> (tx & 7)); *(tp + ((tx + w) >> 3)) &= ~(0x80 >> ((tx + w) & 7)); *(mp + (mx >> 3)) &= ~(0x80 >> (mx & 7)); } } else if (point == 2) { if (cv1) { *(tp + (tx >> 3)) |= 0x80 >> (tx & 7); *(tp + ((tx + w) >> 3)) |= 0x80 >> ((tx + w) & 7); *(mp + ((mx + w) >> 3)) |= 0x80 >> ((mx + w) & 7); } else { *(tp + (tx >> 3)) &= ~(0x80 >> (tx & 7)); *(tp + ((tx + w) >> 3)) &= ~(0x80 >> ((tx + w) & 7)); *(mp + ((mx + w) >> 3)) &= ~(0x80 >> ((mx + w) & 7)); } } else if (point == 3) { if (cv2) { *(tp + (tx >> 3)) |= 0x80 >> (tx & 7); *(mp + (mx >> 3)) |= 0x80 >> (mx & 7); *(mp + ((mx + w) >> 3)) |= 0x80 >> ((mx + w) & 7); } else { *(tp + (tx >> 3)) &= ~(0x80 >> (tx & 7)); *(mp + (mx >> 3)) &= ~(0x80 >> (mx & 7)); *(mp + ((mx + w) >> 3)) &= ~(0x80 >> ((mx + w) & 7)); } } else if (point == 4) { if (cv3) { *(mp + (mx >> 3)) |= 0x80 >> (mx & 7); *(mp + ((mx + w) >> 3)) |= 0x80 >> ((mx + w) & 7); *(tp + ((tx + w) >> 3)) |= 0x80 >> ((tx + w) & 7); } else { *(mp + (mx >> 3)) &= ~(0x80 >> (mx & 7)); *(mp + ((mx + w) >> 3)) &= ~(0x80 >> ((mx + w) & 7)); *(tp + ((tx + w) >> 3)) &= ~(0x80 >> ((tx + w) & 7)); } } } } iMainImage->Mask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->Mask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y = 0; y < hh; y++) { // Repeat Area => mp[x+w] if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x, hw + w) + dp.x - ux; // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1) + spp.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN (spp.y + y, spp.x, hw + w, 1) + spp.x; for (x = 0; x < hw; x++, mp++, tp++, ump++, utp++, lmp++, ltp++) { if (!((*mp == *tp) && (*tp == *(tp + w)) && (*(tp + w) == *(mp + w)) )) { point = Comp_Value(*(mp + w), *mp, *(tp + w), *tp, *(ump + w), *ump, *(utp + w), *utp); if (point == 1) { *tp = *(mp + w); *ltp = *(lmp + w); *(tp + w) = *(mp + w); *(ltp + w) = *(lmp + w); *mp = *(mp + w); *lmp = *(lmp + w); } else if (point == 2) { *tp = *mp; *ltp = *lmp; *(tp + w) = *mp; *(ltp + w) = *lmp; *(mp + w) = *mp; *(lmp + w) = *lmp; } else if (point == 3) { *tp = *(tp + w); *ltp = *(ltp + w); *mp = *(tp + w); *lmp = *(ltp + w); *(mp + w) = *(tp + w); *(lmp + w) = *(ltp + w); } else if (point == 4) { *mp = *tp; *lmp = *ltp; *(mp + w) = *tp; *(lmp + w) = *ltp; *(tp + w) = *tp; *(ltp + w) = *ltp; } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); iMainImage->LayerMask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->LayerMask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } else { for (y = 0; y < hh; y++) { // Repeat Area => mp[x+w] if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x, hw + w) + dp.x - ux; // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1) + spp.x - ux; for (x = 0; x < hw; x++, mp++, tp++, ump++, utp++) { if (!((*mp == *tp) && (*tp == *(tp + w)) && (*(tp + w) == *(mp + w)) )) { point = Comp_Value(*(mp + w), *mp, *(tp + w), *tp, *(ump + w), *ump, *(utp + w), *utp); if (point == 1) { *tp = *(mp + w); *(tp + w) = *(mp + w); *mp = *(mp + w); } else if (point == 2) { *tp = *mp; *(tp + w) = *mp; *(mp + w) = *mp; } else if (point == 3) { *tp = *(tp + w); *mp = *(tp + w); *(mp + w) = *(tp + w); } else if (point == 4) { *mp = *tp; *(mp + w) = *tp; *(tp + w) = *tp; } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } } else { if (iMainImage->LayerMask) { for (y = 0; y < hh; y++) { // Repeat Area => mp[x+w] if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + 3 * dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + 3 * spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x, hw + w) + 3 * (dp.x - ux); // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1) + 3 * (spp.x - ux); lmp = iMainImage->LayerMask->GetScanLine(dp.y + y, dp.x, hw + w); ltp = iMainImage->LayerMask->GetScanLineN (spp.y + y, spp.x, hw + w, 1); for (x = 0; x < hw; x++, mp += 3, tp += 3, ump += 3, utp += 3) { mp1 = mp + 3 * w; tp1 = tp + 3 * w; GetPixel24(mp1, mv); GetPixel24(mp, cv1); GetPixel24(tp1, cv2); GetPixel24(tp, cv3); ump1 = ump + 3 * w; utp1 = utp + 3 * w; GetPixel24(ump1, umv); GetPixel24(ump, ucv1); GetPixel24(utp1, ucv2); GetPixel24(utp, ucv3); if (!((cv1 == cv2) && (cv2 == cv3) && (cv3 == mv))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { SetPixel24(mp, mv); SetPixel24(tp, mv); SetPixel24(tp1, mv); if (*(lmp + ((dp.x + x + w) >> 3)) & (0x80 >> ((dp.x + x + w) & 7))) { *(lmp + ((dp.x + x) >> 3)) |= (0x80 >> ((dp.x + x) & 7)); *(ltp + ((spp.x + x) >> 3)) |= (0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) |= (0x80 >> ((spp.x + x + w) & 7)); } else { *(lmp + ((dp.x + x) >> 3)) &= ~(0x80 >> ((dp.x + x) & 7)); *(ltp + ((spp.x + x) >> 3)) &= ~(0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) &= ~ (0x80 >> ((spp.x + x + w) & 7)); } } else if (point == 2) { SetPixel24(mp1, cv1); SetPixel24(tp1, cv1); SetPixel24(tp, cv1); if (*(lmp + ((dp.x + x) >> 3)) & (0x80 >> ((dp.x + x) & 7))) { *(lmp + ((dp.x + x + w) >> 3)) |= (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) |= (0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) |= (0x80 >> ((spp.x + x + w) & 7)); } else { *(lmp + ((dp.x + x + w) >> 3)) &= ~ (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) &= ~(0x80 >> ((spp.x + x) & 7)); *(ltp + ((spp.x + x + w) >> 3)) &= ~ (0x80 >> ((spp.x + x + w) & 7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp, cv2); if (*(ltp + ((spp.x + x + w) >> 3)) & (0x80 >> ((spp.x + x + w) & 7))) { *(lmp + ((dp.x + x) >> 3)) |= (0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) |= (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) |= (0x80 >> ((spp.x + x) & 7)); } else { *(lmp + ((dp.x + x) >> 3)) &= ~(0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) &= ~ (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x) >> 3)) &= ~(0x80 >> ((spp.x + x) & 7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp1, cv3); if (*(ltp + ((spp.x + x) >> 3)) & (0x80 >> ((spp.x + x) & 7))) { *(lmp + ((dp.x + x) >> 3)) |= (0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) |= (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x + w) >> 3)) |= (0x80 >> ((spp.x + x + w) & 7)); } else { *(lmp + ((dp.x + x) >> 3)) &= ~(0x80 >> ((dp.x + x) & 7)); *(lmp + ((dp.x + x + w) >> 3)) &= ~ (0x80 >> ((dp.x + x + w) & 7)); *(ltp + ((spp.x + x + w) >> 3)) &= ~ (0x80 >> ((spp.x + x + w) & 7)); } } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); iMainImage->LayerMask->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->LayerMask->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } else { for (y = 0; y < hh; y++) { // Repeat Area => mp[x+w] if (!udBitmap->PartialUndo->HasPenUndoBitmap (dp.y - uy + y, dp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y - uy + y, spp.x - ux, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap(dp.y + y, dp.x, hw + w) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp.y + y, spp.x, hw + w)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dp.y - uy + y, spp.y - uy + y, dp.y + y, spp.y + y); continue; } mp = iMainImage->uBitmap->GetScanLine(dp.y + y, dp.x, hw + w) + 3 * dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, spp.x, hw + w, 1) + 3 * spp.x; // iMainImage->uBitmap->UndoCheckActivePart(dp.y - uy + y); ump = udBitmap->GetUndoScanLine(dp.y - uy + y, dp.x, hw + w) + 3 * (dp.x - ux); // iMainImage->uBitmap->UndoCheckActivePart(spp.y - uy + y); utp = udBitmap->GetUndoScanLineN(spp.y - uy + y, spp.x, hw + w, 1) + 3 * (spp.x - ux); for (x = 0; x < hw; x++, mp += 3, tp += 3, ump += 3, utp += 3) { mp1 = mp + 3 * w; tp1 = tp + 3 * w; GetPixel24(mp1, mv); GetPixel24(mp, cv1); GetPixel24(tp1, cv2); GetPixel24(tp, cv3); ump1 = ump + 3 * w; utp1 = utp + 3 * w; GetPixel24(ump1, umv); GetPixel24(ump, ucv1); GetPixel24(utp1, ucv2); GetPixel24(utp, ucv3); if (!((cv1 == cv2) && (cv2 == cv3) && (cv3 == mv))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { SetPixel24(mp, mv); SetPixel24(tp, mv); SetPixel24(tp1, mv); } else if (point == 2) { SetPixel24(mp1, cv1); SetPixel24(tp1, cv1); SetPixel24(tp, cv1); } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp, cv2); } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp1, cv3); } } } iMainImage->uBitmap->PutDiffScanLineN(dp.y + y, dp.x, hw + w, 0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, spp.x, hw + w, 1); } } } } END_LOG; return; /* int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp=NULL, *mp1=NULL, *tp=NULL, *tp1=NULL, *lmp=NULL, *ltp=NULL; Byte *ump=NULL, *ump1=NULL, *utp=NULL, *utp1=NULL; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; THistoryData *ud=NULL; ud = Undo->Last; hw = hhw; hh = h/2; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; ux = ud->Range.left; uy = ud->Range.top; if (MaskBmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Mask->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); ump = ud->Mask->GetScanLine(dp.y - uy + y); utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1); mx = dp.x; tx = spp.x; umx = dp.x-ux; utx = spp.x-ux; for (x=0; x>3))&(0x80>>((mx+w)&7))) > 0) ? 1 : 0; //1 cv1 = ((*(mp+(mx>>3))&(0x80>>(mx&7))) > 0) ? 1 : 0; //2 cv2 = ((*(tp+((tx+w)>>3))&(0x80>>((tx+w)&7))) > 0) ? 1 : 0; //3 cv3 = ((*(tp+(tx>>3))&(0x80>>(tx&7))) > 0 ) ? 1 : 0; //4 umv = ((*(ump+((umx+w)>>3))&(0x80>>((umx+w)&7))) > 0) ? 1 : 0; ucv1 = ((*(ump+(umx>>3))&(0x80>>(umx&7))) > 0) ? 1 : 0; ucv2 = ((*(utp+((utx+w)>>3))&(0x80>>((utx+w)&7))) > 0) ? 1 : 0; ucv3 = ((*(utp+(utx>>3))&(0x80>>(utx&7))) > 0 ) ? 1 : 0; if (!((mv == cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(mp+(mx>>3)) |= 0x80 >> (mx&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); } } else if (point == 2) { if (cv1) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); } } else if (point == 3) { if (cv2) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); } } else if (point == 4) { if (cv3) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3) ) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 2) { SetPixel24(mp1, cv1); SetPixel24(tp1, cv1); SetPixel24(tp, cv1); if (*(lmp + ((dp.x+x)>>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp, cv2); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp1, cv3); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } } } iMainImage->uBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->uBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->uBitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); for (x=0; xuBitmap->PutScanLine(dp.y + y); iMainImage->uBitmap->PutScanLineN(spp.y + y, 1); } } } } */ } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_VDrawing (bool MaskBmp, int hw, int hh, TPoint dsp, TPoint spp1, TPoint spp2, TPoint spp3) { ///* BeConverted by linuxjun Don't Forget!! Undo_Method BEGIN_LOG(""); int x, y, dx, s1x, s2x, s3x; int udx, us1x, us2x, us3x, ux, uy, point = 0; Byte *dst = NULL, *sr1 = NULL, *sr2 = NULL, *sr3 = NULL, *lmp = NULL, *lp1 = NULL, *lp2 = NULL, *lp3 = NULL; Byte *mdst = NULL, *msr1 = NULL, *msr2 = NULL, *msr3 = NULL, *uds = NULL, *ur1 = NULL, *ur2 = NULL, *ur3 = NULL; COLORREF mv, cv1, cv2, cv3, umv, uv1, uv2, uv3; THistoryData *ud = NULL; // TUndoManager *udMask,*udBitmap; TUnionBitmap *udMask, *udBitmap; ud = Undo->GetLast(); udMask = MainImageForm->iMainImage->Mask; udBitmap = MainImageForm->iMainImage->uBitmap; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; // ux = ud->Range.left; // uy = ud->Range.top; ux = 0; // For New Undo by linuxjun uy = 0; // For New Undo by linuxjun if (MaskBmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y = 0; y < hh; y++) { if (!udMask->PartialUndo->HasPenUndoBitmap(dsp.y + y) && !udMask->PartialUndo->HasPenUndoBitmap(spp1.y + y) && !udMask->PartialUndo->HasPenUndoBitmap(spp2.y + y) && !udMask->PartialUndo->HasPenUndoBitmap (spp3.y + y)) { y += udMask->PartialUndo->getMinimumDeltaY (dsp.y + y, spp1.y + y, spp2.y + y, spp3.y + y); continue; } dst = iMainImage->Mask->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = udMask->GetUndoScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = udMask->GetUndoScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = udMask->GetUndoScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = udMask->GetUndoScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; for (x = 0; x < hw; x++, dst++, sr1++, sr2++, sr3++, uds++, ur1++, ur2++, ur3++) { if (!((*sr1 == *sr2) && (*sr2 == *sr3) && (*sr3 == *dst))) { point = Comp_Value(*dst, *sr1, *sr2, *sr3, *uds, *ur1, *ur2, *ur3); if (point == 1) { *sr1 = *dst; *sr2 = *dst; *sr3 = *dst; } else if (point == 2) { *dst = *sr1; *sr2 = *sr1; *sr3 = *sr1; } else if (point == 3) { *dst = *sr2; *sr1 = *sr2; *sr3 = *sr2; } else if (point == 4) { *dst = *sr3; *sr1 = *sr3; *sr2 = *sr3; } } } iMainImage->Mask->PutDiffScanLineN(dsp.y + y, 0); iMainImage->Mask->PutDiffScanLineN(spp1.y + y, 1); iMainImage->Mask->PutDiffScanLineN(spp2.y + y, 2); iMainImage->Mask->PutDiffScanLineN(spp3.y + y, 3); } } else { for (y = 0; y < hh; y++) { if (!udMask->PartialUndo->HasPenUndoBitmap(dsp.y + y) && !udMask->PartialUndo->HasPenUndoBitmap(spp1.y + y) && !udMask->PartialUndo->HasPenUndoBitmap(spp2.y + y) && !udMask->PartialUndo->HasPenUndoBitmap (spp3.y + y)) { y += udMask->PartialUndo->getMinimumDeltaY (dsp.y + y, spp1.y + y, spp2.y + y, spp3.y + y); continue; } dst = iMainImage->Mask->GetScanLine(dsp.y + y); sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1); sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2); sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3); uds = udMask->GetUndoScanLine(dsp.y - uy + y); ur1 = udMask->GetUndoScanLineN(spp1.y - uy + y, 1); ur2 = udMask->GetUndoScanLineN(spp2.y - uy + y, 2); ur3 = udMask->GetUndoScanLineN(spp3.y - uy + y, 3); dx = dsp.x; s1x = spp1.x; s2x = spp2.x; s3x = spp3.x; udx = dsp.x - ux; us1x = spp1.x - ux; us2x = spp2.x - ux; us3x = spp3.x - ux; for (x = 0; x < hw; x++, dx++, s1x++, s2x++, s3x++, udx++, us1x++, us2x++, us3x++) { mv = ((*(dst + (dx >> 3)) & (0x80 >> (dx & 7))) > 0) ? 1 : 0; cv1 = ((*(sr1 + (s1x >> 3)) & (0x80 >> (s1x & 7))) > 0) ? 1 : 0; cv2 = ((*(sr2 + (s2x >> 3)) & (0x80 >> (s2x & 7))) > 0) ? 1 : 0; cv3 = ((*(sr3 + (s3x >> 3)) & (0x80 >> (s3x & 7))) > 0) ? 1 : 0; umv = ((*(uds + (udx >> 3)) & (0x80 >> (udx & 7))) > 0) ? 1 : 0; uv1 = ((*(ur1 + (us1x >> 3)) & (0x80 >> (us1x & 7))) > 0) ? 1 : 0; uv2 = ((*(ur2 + (us2x >> 3)) & (0x80 >> (us2x & 7))) > 0) ? 1 : 0; uv3 = ((*(ur3 + (us3x >> 3)) & (0x80 >> (us3x & 7))) > 0) ? 1 : 0; if (!((mv == cv1) && (cv1 == cv2) && (cv2 == cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, uv1, uv2, uv3); if (point == 1) { if (mv) { *(sr1 + (s1x >> 3)) |= 0x80 >> (s1x & 7); *(sr2 + (s2x >> 3)) |= 0x80 >> (s2x & 7); *(sr3 + (s3x >> 3)) |= 0x80 >> (s3x & 7); } else { *(sr1 + (s1x >> 3)) &= ~(0x80 >> (s1x & 7)); *(sr2 + (s2x >> 3)) &= ~(0x80 >> (s2x & 7)); *(sr3 + (s3x >> 3)) &= ~(0x80 >> (s3x & 7)); } } else if (point == 2) { if (cv1) { *(dst + (dx >> 3)) |= 0x80 >> (dx & 7); *(sr2 + (s2x >> 3)) |= 0x80 >> (s2x & 7); *(sr3 + (s3x >> 3)) |= 0x80 >> (s3x & 7); } else { *(dst + (dx >> 3)) &= ~(0x80 >> (dx & 7)); *(sr2 + (s2x >> 3)) &= ~(0x80 >> (s2x & 7)); *(sr3 + (s3x >> 3)) &= ~(0x80 >> (s3x & 7)); } } else if (point == 3) { if (cv2) { *(dst + (dx >> 3)) |= 0x80 >> (dx & 7); *(sr1 + (s1x >> 3)) |= 0x80 >> (s1x & 7); *(sr3 + (s3x >> 3)) |= 0x80 >> (s3x & 7); } else { *(dst + (dx >> 3)) &= ~(0x80 >> (dx & 7)); *(sr1 + (s1x >> 3)) &= ~(0x80 >> (s1x & 7)); *(sr3 + (s3x >> 3)) &= ~(0x80 >> (s3x & 7)); } } else if (point == 4) { if (cv3) { *(dst + (dx >> 3)) |= 0x80 >> (dx & 7); *(sr1 + (s1x >> 3)) |= 0x80 >> (s1x & 7); *(sr2 + (s2x >> 3)) |= 0x80 >> (s2x & 7); } else { *(dst + (dx >> 3)) &= ~(0x80 >> (dx & 7)); *(sr1 + (s1x >> 3)) &= ~(0x80 >> (s1x & 7)); *(sr2 + (s2x >> 3)) &= ~(0x80 >> (s2x & 7)); } } } } iMainImage->Mask->PutDiffScanLineN(dsp.y + y, 0); iMainImage->Mask->PutDiffScanLineN(spp1.y + y, 1); iMainImage->Mask->PutDiffScanLineN(spp2.y + y, 2); iMainImage->Mask->PutDiffScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y = 0; y < hh; y++) { if (!udBitmap->PartialUndo->HasPenUndoBitmap(dsp.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp1.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp2.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp3.y + y)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dsp.y + y, spp1.y + y, spp2.y + y, spp3.y + y); continue; } dst = iMainImage->uBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = udBitmap->GetUndoScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = udBitmap->GetUndoScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = udBitmap->GetUndoScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = udBitmap->GetUndoScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y) + dsp.x; lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1) + spp1.x; lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2) + spp2.x; lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x = 0; x < hw; x++, dst++, sr1++, sr2++, sr3++, uds++, ur1++, ur2++, ur3++, lmp++, lp1++, lp2++, lp3++) { if (!((*sr1 == *sr2) && (*sr2 == *sr3) && (*sr3 == *dst))) { point = Comp_Value(*dst, *sr1, *sr2, *sr3, *uds, *ur1, *ur2, *ur3); if (point == 1) { *sr1 = *dst; *lp1 = *lmp; *sr2 = *dst; *lp2 = *lmp; *sr3 = *dst; *lp3 = *lmp; } else if (point == 2) { *dst = *sr1; *lmp = *lp1; *sr2 = *sr1; *lp2 = *lp1; *sr3 = *sr1; *lp3 = *lp1; } else if (point == 3) { *dst = *sr2; *lmp = *lp2; *sr1 = *sr2; *lp1 = *lp2; *sr3 = *sr2; *lp3 = *lp2; } else if (point == 4) { *dst = *sr3; *lmp = *lp3; *sr1 = *sr3; *lp1 = *lp3; *sr2 = *sr3; *lp2 = *lp3; } } } iMainImage->uBitmap->PutDiffScanLineN(dsp.y + y, 0); iMainImage->uBitmap->PutDiffScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutDiffScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutDiffScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutDiffScanLineN(dsp.y + y, 0); iMainImage->LayerMask->PutDiffScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutDiffScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutDiffScanLineN(spp3.y + y, 3); } } else { for (y = 0; y < hh; y++) { if (!udBitmap->PartialUndo->HasPenUndoBitmap(dsp.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp1.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp2.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp3.y + y)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dsp.y + y, spp1.y + y, spp2.y + y, spp3.y + y); continue; } dst = iMainImage->uBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = udBitmap->GetUndoScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = udBitmap->GetUndoScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = udBitmap->GetUndoScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = udBitmap->GetUndoScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; for (x = 0; x < hw; x++, dst++, sr1++, sr2++, sr3++, uds++, ur1++, ur2++, ur3++) { if (!((*sr1 == *sr2) && (*sr2 == *sr3) && (*sr3 == *dst))) { point = Comp_Value(*dst, *sr1, *sr2, *sr3, *uds, *ur1, *ur2, *ur3); if (point == 1) { *sr1 = *dst; *sr2 = *dst; *sr3 = *dst; } else if (point == 2) { *dst = *sr1; *sr2 = *sr1; *sr3 = *sr1; } else if (point == 3) { *dst = *sr2; *sr1 = *sr2; *sr3 = *sr2; } else if (point == 4) { *dst = *sr3; *sr1 = *sr3; *sr2 = *sr3; } } } iMainImage->uBitmap->PutDiffScanLineN(dsp.y + y, 0); iMainImage->uBitmap->PutDiffScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutDiffScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutDiffScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->LayerMask) { for (y = 0; y < hh; y++) { if (!udBitmap->PartialUndo->HasPenUndoBitmap(dsp.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp1.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp2.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp3.y + y)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dsp.y + y, spp1.y + y, spp2.y + y, spp3.y + y); continue; } dst = iMainImage->uBitmap->GetScanLine(dsp.y + y) + 3 * dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + 3 * spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + 3 * spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + 3 * spp3.x; uds = udBitmap->GetUndoScanLine(dsp.y - uy + y) + 3 * (dsp.x - ux); ur1 = udBitmap->GetUndoScanLineN(spp1.y - uy + y, 1) + 3 * (spp1.x - ux); ur2 = udBitmap->GetUndoScanLineN(spp2.y - uy + y, 2) + 3 * (spp2.x - ux); ur3 = udBitmap->GetUndoScanLineN(spp3.y - uy + y, 3) + 3 * (spp3.x - ux); lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y); lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1); lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2); lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3); for (x = 0; x < hw; x++, dst += 3, sr1 += 3, sr2 += 3, sr3 += 3, uds += 3, ur1 += 3, ur2 += 3, ur3 += 3) { GetPixel24(ur1, uv1); GetPixel24(ur2, uv2); GetPixel24(ur3, uv3); GetPixel24(uds, umv); GetPixel24(sr1, cv1); GetPixel24(sr2, cv2); GetPixel24(sr3, cv3); GetPixel24(dst, mv); if (!((cv1 == cv2) && (cv2 == cv3) && (cv3 == mv))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, uv1, uv2, uv3); if (point == 1) { SetPixel24(sr1, mv); SetPixel24(sr2, mv); SetPixel24(sr3, mv); if (*(lmp + ((dsp.x + x) >> 3)) & (0x80 >> ((dsp.x + x) & 7))) { *(lp1 + ((spp1.x + x) >> 3)) |= (0x80 >> ((spp1.x + x) & 7)); *(lp2 + ((spp2.x + x) >> 3)) |= (0x80 >> ((spp2.x + x) & 7)); *(lp3 + ((spp3.x + x) >> 3)) |= (0x80 >> ((spp3.x + x) & 7)); } else { *(lp1 + ((spp1.x + x) >> 3)) &= ~(0x80 >> ((spp1.x + x) & 7)); *(lp2 + ((spp2.x + x) >> 3)) &= ~(0x80 >> ((spp2.x + x) & 7)); *(lp3 + ((spp3.x + x) >> 3)) &= ~(0x80 >> ((spp3.x + x) & 7)); } } else if (point == 2) { SetPixel24(dst, cv1); SetPixel24(sr2, cv1); SetPixel24(sr3, cv1); if (*(lp1 + ((spp1.x + x) >> 3)) & (0x80 >> ((spp1.x + x) & 7)) ) { *(lmp + ((dsp.x + x) >> 3)) |= (0x80 >> ((dsp.x + x) & 7)); *(lp2 + ((spp2.x + x) >> 3)) |= (0x80 >> ((spp2.x + x) & 7)); *(lp3 + ((spp3.x + x) >> 3)) |= (0x80 >> ((spp3.x + x) & 7)); } else { *(lmp + ((dsp.x + x) >> 3)) &= ~(0x80 >> ((dsp.x + x) & 7)); *(lp2 + ((spp2.x + x) >> 3)) &= ~(0x80 >> ((spp2.x + x) & 7)); *(lp3 + ((spp3.x + x) >> 3)) &= ~(0x80 >> ((spp3.x + x) & 7)); } } else if (point == 3) { SetPixel24(dst, cv2); SetPixel24(sr1, cv2); SetPixel24(sr3, cv2); if (*(lp2 + ((spp2.x + x) >> 3)) & (0x80 >> ((spp2.x + x) & 7)) ) { *(lmp + ((dsp.x + x) >> 3)) |= (0x80 >> ((dsp.x + x) & 7)); *(lp1 + ((spp1.x + x) >> 3)) |= (0x80 >> ((spp1.x + x) & 7)); *(lp3 + ((spp3.x + x) >> 3)) |= (0x80 >> ((spp3.x + x) & 7)); } else { *(lmp + ((dsp.x + x) >> 3)) &= ~(0x80 >> ((dsp.x + x) & 7)); *(lp1 + ((spp1.x + x) >> 3)) &= ~(0x80 >> ((spp1.x + x) & 7)); *(lp3 + ((spp3.x + x) >> 3)) &= ~(0x80 >> ((spp3.x + x) & 7)); } } else if (point == 4) { SetPixel24(dst, cv3); SetPixel24(sr1, cv3); SetPixel24(sr2, cv3); if (*(lp3 + ((spp3.x + x) >> 3)) & (0x80 >> ((spp3.x + x) & 7)) ) { *(lmp + ((dsp.x + x) >> 3)) |= (0x80 >> ((dsp.x + x) & 7)); *(lp1 + ((spp1.x + x) >> 3)) |= (0x80 >> ((spp1.x + x) & 7)); *(lp2 + ((spp2.x + x) >> 3)) |= (0x80 >> ((spp2.x + x) & 7)); } else { *(lmp + ((dsp.x + x) >> 3)) &= ~(0x80 >> ((dsp.x + x) & 7)); *(lp1 + ((spp1.x + x) >> 3)) &= ~(0x80 >> ((spp1.x + x) & 7)); *(lp2 + ((spp2.x + x) >> 3)) &= ~(0x80 >> ((spp2.x + x) & 7)); } } } } iMainImage->uBitmap->PutDiffScanLineN(dsp.y + y, 0); iMainImage->uBitmap->PutDiffScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutDiffScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutDiffScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutDiffScanLineN(dsp.y + y, 0); iMainImage->LayerMask->PutDiffScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutDiffScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutDiffScanLineN(spp3.y + y, 3); } } else { for (y = 0; y < hh; y++) { if (!udBitmap->PartialUndo->HasPenUndoBitmap(dsp.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp1.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap(spp2.y + y) && !udBitmap->PartialUndo->HasPenUndoBitmap (spp3.y + y)) { y += udBitmap->PartialUndo->getMinimumDeltaY (dsp.y + y, spp1.y + y, spp2.y + y, spp3.y + y); continue; } dst = iMainImage->uBitmap->GetScanLine(dsp.y + y) + 3 * dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + 3 * spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + 3 * spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + 3 * spp3.x; uds = udBitmap->GetUndoScanLine(dsp.y - uy + y) + 3 * (dsp.x - ux); ur1 = udBitmap->GetUndoScanLineN(spp1.y - uy + y, 1) + 3 * (spp1.x - ux); ur2 = udBitmap->GetUndoScanLineN(spp2.y - uy + y, 2) + 3 * (spp2.x - ux); ur3 = udBitmap->GetUndoScanLineN(spp3.y - uy + y, 3) + 3 * (spp3.x - ux); for (x = 0; x < hw; x++, dst += 3, sr1 += 3, sr2 += 3, sr3 += 3, uds += 3, ur1 += 3, ur2 += 3, ur3 += 3) { GetPixel24(ur1, uv1); GetPixel24(ur2, uv2); GetPixel24(ur3, uv3); GetPixel24(uds, umv); GetPixel24(sr1, cv1); GetPixel24(sr2, cv2); GetPixel24(sr3, cv3); GetPixel24(dst, mv); if (!((cv1 == cv2) && (cv2 == cv3) && (cv3 == mv))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, uv1, uv2, uv3); if (point == 1) { SetPixel24(sr1, mv); SetPixel24(sr2, mv); SetPixel24(sr3, mv); } else if (point == 2) { SetPixel24(dst, cv1); SetPixel24(sr2, cv1); SetPixel24(sr3, cv1); } else if (point == 3) { SetPixel24(dst, cv2); SetPixel24(sr1, cv2); SetPixel24(sr3, cv2); } else if (point == 4) { SetPixel24(dst, cv3); SetPixel24(sr1, cv3); SetPixel24(sr2, cv3); } } } iMainImage->uBitmap->PutDiffScanLineN(dsp.y + y, 0); iMainImage->uBitmap->PutDiffScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutDiffScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutDiffScanLineN(spp3.y + y, 3); } } } } END_LOG; // */ /* BeConverted by linuxjun Don't Forget!! Undo_Method int x, y, dx, s1x, s2x, s3x; int udx, us1x, us2x, us3x, ux, uy, point=0; Byte *dst=NULL, *sr1=NULL, *sr2=NULL, *sr3=NULL, *lmp=NULL, *lp1=NULL, *lp2=NULL, *lp3=NULL; Byte *mdst=NULL, *msr1=NULL, *msr2=NULL, *msr3=NULL, *uds=NULL, *ur1=NULL, *ur2=NULL, *ur3=NULL; COLORREF mv, cv1, cv2, cv3, umv, uv1, uv2, uv3; THistoryData *ud=NULL; ud = Undo->Last; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; ux = ud->Range.left; uy = ud->Range.top; if (MaskBmp) { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y=0; yMask->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = ud->Mask->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->Mask->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->Mask->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->Mask->GetScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; for (x=0; xMask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yMask->GetScanLine(dsp.y + y); sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1); sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2); sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3); uds = ud->Mask->GetScanLine(dsp.y - uy + y); ur1 = ud->Mask->GetScanLineN(spp1.y - uy + y, 1); ur2 = ud->Mask->GetScanLineN(spp2.y - uy + y, 2); ur3 = ud->Mask->GetScanLineN(spp3.y - uy + y, 3); dx = dsp.x; s1x = spp1.x; s2x = spp2.x; s3x = spp3.x; udx = dsp.x-ux; us1x = spp1.x-ux; us2x = spp2.x-ux; us3x = spp3.x-ux; for (x=0; x>3)) & (0x80>>(dx&7))) > 0) ? 1 : 0; cv1 = ((*(sr1+(s1x>>3)) & (0x80>>(s1x&7))) > 0) ? 1 : 0; cv2 = ((*(sr2+(s2x>>3)) & (0x80>>(s2x&7))) > 0) ? 1 : 0; cv3 = ((*(sr3+(s3x>>3)) & (0x80>>(s3x&7))) > 0) ? 1 : 0; umv = ((*(uds+(udx>>3)) & (0x80>>(udx&7))) > 0) ? 1 : 0; uv1 = ((*(ur1+(us1x>>3)) & (0x80>>(us1x&7))) > 0) ? 1 : 0; uv2 = ((*(ur2+(us2x>>3)) & (0x80>>(us2x&7))) > 0) ? 1 : 0; uv3 = ((*(ur3+(us3x>>3)) & (0x80>>(us3x&7))) > 0) ? 1 : 0; if (!((mv==cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, uv1, uv2, uv3); if (point == 1) { if (mv) { *(sr1+(s1x>>3)) |= 0x80 >> (s1x&7); *(sr2+(s2x>>3)) |= 0x80 >> (s2x&7); *(sr3+(s3x>>3)) |= 0x80 >> (s3x&7); } else { *(sr1+(s1x>>3)) &= ~(0x80 >> (s1x&7)); *(sr2+(s2x>>3)) &= ~(0x80 >> (s2x&7)); *(sr3+(s3x>>3)) &= ~(0x80 >> (s3x&7)); } } else if (point == 2) { if (cv1) { *(dst+(dx>>3)) |= 0x80 >> (dx&7); *(sr2+(s2x>>3)) |= 0x80 >> (s2x&7); *(sr3+(s3x>>3)) |= 0x80 >> (s3x&7); } else { *(dst+(dx>>3)) &= ~(0x80 >> (dx&7)); *(sr2+(s2x>>3)) &= ~(0x80 >> (s2x&7)); *(sr3+(s3x>>3)) &= ~(0x80 >> (s3x&7)); } } else if (point == 3) { if (cv2) { *(dst+(dx>>3)) |= 0x80 >> (dx&7); *(sr1+(s1x>>3)) |= 0x80 >> (s1x&7); *(sr3+(s3x>>3)) |= 0x80 >> (s3x&7); } else { *(dst+(dx>>3)) &= ~(0x80 >> (dx&7)); *(sr1+(s1x>>3)) &= ~(0x80 >> (s1x&7)); *(sr3+(s3x>>3)) &= ~(0x80 >> (s3x&7)); } } else if (point == 4) { if (cv3) { *(dst+(dx>>3)) |= 0x80 >> (dx&7); *(sr1+(s1x>>3)) |= 0x80 >> (s1x&7); *(sr2+(s2x>>3)) |= 0x80 >> (s2x&7); } else { *(dst+(dx>>3)) &= ~(0x80 >> (dx&7)); *(sr1+(s1x>>3)) &= ~(0x80 >> (s1x&7)); *(sr2+(s2x>>3)) &= ~(0x80 >> (s2x&7)); } } } } iMainImage->Mask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; yuBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y) + dsp.x; lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1) + spp1.x; lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2) + spp2.x; lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xuBitmap->PutScanLine(dsp.y + y); iMainImage->uBitmap->PutScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yuBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; for (x=0; xuBitmap->PutScanLine(dsp.y + y); iMainImage->uBitmap->PutScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->LayerMask) { for (y=0; yuBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + 3*(dsp.x - ux); ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + 3*(spp1.x - ux); ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + 3*(spp2.x - ux); ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + 3*(spp3.x - ux); lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y); lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1); lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2); lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3); for (x=0; x>3)) & (0x80 >> ((dsp.x+x)&7))) { *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if (point == 2) { SetPixel24(dst, cv1); SetPixel24(sr2, cv1); SetPixel24(sr3, cv1); if (*(lp1 + ((spp1.x+x)>>3)) & (0x80 >> ((spp1.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if (point == 3) { SetPixel24(dst, cv2); SetPixel24(sr1, cv2); SetPixel24(sr3, cv2); if (*(lp2 + ((spp2.x+x)>>3)) & (0x80 >> ((spp2.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if (point == 4) { SetPixel24(dst, cv3); SetPixel24(sr1, cv3); SetPixel24(sr2, cv3); if (*(lp3 + ((spp3.x+x)>>3)) & (0x80 >> ((spp3.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); } } } } iMainImage->uBitmap->PutScanLine(dsp.y + y); iMainImage->uBitmap->PutScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yuBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->uBitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->uBitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->uBitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + 3*(dsp.x - ux); ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + 3*(spp1.x - ux); ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + 3*(spp2.x - ux); ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + 3*(spp3.x - ux); for (x=0; xuBitmap->PutScanLine(dsp.y + y); iMainImage->uBitmap->PutScanLineN(spp1.y + y, 1); iMainImage->uBitmap->PutScanLineN(spp2.y + y, 2); iMainImage->uBitmap->PutScanLineN(spp3.y + y, 3); } } } } */ } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderYesMethod_none (TUnionBitmap *Pattern, double ColorChipZoom) { BEGIN_LOG(""); TRect Src, Dst, PDst; TUnionBitmap *UsedColBit = NULL; int w, h, temp, ht, width, height, cnt; bool over; HDC dcDst = NULL; TSize colorChipArea; if ((UsedColBit = new TUnionBitmap) == NULL) goto fail; ComboHeaderUsedColorMethod(UsedColBit, true, ColorChipZoom, colorChipArea); if (colorChipArea.cy < 0) goto fail; if (WorkArea->Mask) { Src = WorkArea->Range; width = Src.Right - Src.Left; height = Src.Bottom - Src.Top; } else { width = iMainImage->uBitmap->Width; height = iMainImage->uBitmap->Height; } w = UsedColBit->Width; // *CanvasInfor.DotsPerInch/160; h = UsedColBit->Height; // *CanvasInfor.DotsPerInch/160; // {µÎ°³ÀÇ BitmapÀ» ÇÕÄ£ PatternÀÇ »õ·Î¿î ³ôÀÌ¿Í ³ÐÀÌ} ht = GetDeviceCaps(Printer()->Handle, VERTRES) * CanvasInfor.DotsPerInch / // *160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); temp = height; // ================================================ if (w > width) width = w; cnt = temp / ht; if ((temp - ht * cnt + h) > ht) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ cnt++; over = true; height = cnt * ht + h; } else { over = false; height = temp + h; } // ================================================ Pattern->Create(width, height, iMainImage->uBitmap->BitsPerPixel, iMainImage->uBitmap->RGB); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (WorkArea->Mask) { Dst = Rect(0, 0, Src.Right - Src.Left, temp); Pattern->Copy(0, 0, Dst.Right, Dst.Bottom, iMainImage->uBitmap, Src.Left, Src.Top, SRCCOPY); // convert by celberus if (!Irregularrect(Pattern, Src, Dst)) goto fail; } else { Pattern->Copy(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, iMainImage->uBitmap, 0, 0, SRCCOPY); // convert by celberus } // ============================================ // PDst = Rect(0, temp , w, temp+h); // if (Pattern->Height>ht) PDst = Rect(0, ht, w, ht+h); if (over) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ PDst = Rect(0, cnt * ht, w, cnt * ht + h); } else { PDst = Rect(0, temp, w, temp + h); } // ============================================ Src = Rect(0, 0, UsedColBit->Width, UsedColBit->Height); Pattern->UnionStretchBlt(PDst.Left, PDst.Top, PDst.Right - PDst.Left, PDst.Bottom - PDst.Top, UsedColBit, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); delete UsedColBit; END_LOG; return true; fail: if (UsedColBit) { delete UsedColBit; } END_LOG; return false; } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderYesMethod_layer (TUnionBitmap *Pattern, double ColorChipZoom) { // convert by celberus BEGIN_LOG(""); TRect Src, Dst, PDst; TUnionBitmap *UsedColBit = NULL, *Bitmap = NULL; int w, h, temp, ht, width, height, cnt; bool over; TSize colorChipArea; if ((UsedColBit = new TUnionBitmap) == NULL) goto fail; ComboHeaderUsedColorMethod(UsedColBit, true, ColorChipZoom, colorChipArea); if (colorChipArea.cy < 0) goto fail; if (WorkArea->Mask) { Src = WorkArea->Range; width = Src.Right - Src.Left; height = Src.Bottom - Src.Top; } else { width = iMainImage->uBitmap->Width; height = iMainImage->uBitmap->Height; } w = UsedColBit->Width; // *CanvasInfor.DotsPerInch/160; h = UsedColBit->Height; // *CanvasInfor.DotsPerInch/160; // {µÎ°³ÀÇ BitmapÀ» ÇÕÄ£ PatternÀÇ »õ·Î¿î ³ôÀÌ¿Í ³ÐÀÌ} ht = GetDeviceCaps(Printer()->Handle, VERTRES) * CanvasInfor.DotsPerInch / // *160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); temp = height; // ================================================ if (w > width) width = w; cnt = temp / ht; if ((temp - ht * cnt + h) > ht) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ cnt++; over = true; height = cnt * ht + h; } else { over = false; height = temp + h; } // ================================================ Pattern->Create(width, height, iMainImage->uBitmap->BitsPerPixel, iMainImage->uBitmap->RGB); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if (WorkArea->Mask) { Dst = Rect(0, 0, Src.Right - Src.Left, temp); Pattern->Copy(0, 0, Dst.Right, Dst.Bottom, Bitmap, Src.Left, Src.Top, SRCCOPY); // convert by celberus if (!Irregularrect(Pattern, Src, Dst)) goto fail; // convert by celberus } else { Pattern->Copy(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, Bitmap, 0, 0, SRCCOPY); // convert by celberus } delete Bitmap; Bitmap = NULL; // ============================================ if (over) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ PDst = Rect(0, cnt * ht, w, cnt * ht + h); } else { PDst = Rect(0, temp, w, temp + h); } // ============================================ Src = Rect(0, 0, UsedColBit->Width, UsedColBit->Height); Pattern->UnionStretchBlt(PDst.Left, PDst.Top, PDst.Right - PDst.Left, PDst.Bottom - PDst.Top, UsedColBit, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); // convert by celberus delete UsedColBit; END_LOG; return true; fail: if (UsedColBit) { delete UsedColBit; } if (Bitmap) { delete Bitmap; Bitmap = NULL; } END_LOG; return false; } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderMosaicMethod_none (TUnionBitmap *Pattern, int mx, int my) { // convert by celberus BEGIN_LOG(""); Byte max, maxp, *sl = NULL, *Msl = NULL; short color[256]; RGBQUAD rgb[256]; int i, j, k, m, w, h, wh, sum, red, green, blue; TRect Dst, Wrc, Re; COLORREF c; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right - Wrc.Left) / mx; h = (Wrc.Bottom - Wrc.Top) / my; wh = w * h / 2; Pattern->Create(mx * w + 1, my * h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { memset(color, 0, sizeof(color)); sum = 0; max = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < (Wrc.Bottom - Wrc.Top)) { sl = iMainImage->uBitmap->GetScanLine(j + Wrc.Top) + Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = iMainImage->uBitmap->GetScanLine(j + Wrc.Top) + Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); #endif for (i = k * w; i < (k + 1) * w; i++) { #ifdef TPDEBUG if (i >= 0 && i < (Wrc.Right - Wrc.Left)) { if (*(Msl + i)) { c = *(sl + i); color[c]++; if (color[c] > max) { max = color[c]; maxp = c; } sum++; } } else SHOWDEBUG; #else if (*(Msl + i)) { c = *(sl + i); color[c]++; if (color[c] > max) { max = color[c]; maxp = c; } sum++; } #endif } } if (sum >= (wh)) { // Because of Irregular rect.... MosaicDraw8(Pattern, k, m, w, h, maxp); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->uBitmap->Width / mx; h = iMainImage->uBitmap->Height / my; Pattern->Create(mx * w + 1, my * h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { memset(color, 0, sizeof(color)); max = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < (iMainImage->uBitmap->Height)) { sl = iMainImage->uBitmap->GetScanLine(j); } else SHOWDEBUG; #else sl = iMainImage->uBitmap->GetScanLine(j); #endif for (i = k * w; i < (k + 1) * w; i++) { #ifdef TPDEBUG if (i >= 0 && i < (iMainImage->uBitmap->Width)) { c = *(sl + i); color[c] = color[c] + 1; if (color[c] > max) { max = color[c]; maxp = c; } } else SHOWDEBUG; #else c = *(sl + i); color[c] = color[c] + 1; if (color[c] > max) { max = color[c]; maxp = c; } #endif } } MosaicDraw8(Pattern, k, m, w, h, maxp); } } } } else { if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right - Wrc.Left) / mx; h = (Wrc.Bottom - Wrc.Top) / my; wh = w * h / 2; Pattern->Create(mx * w + 1, my * h + 1, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { red = green = blue = 0; sum = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < (Wrc.Right - Wrc.Left)) { sl = iMainImage->uBitmap->GetScanLine(j + Wrc.Top) + 3 * (Wrc.Left + k * w); Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = iMainImage->uBitmap->GetScanLine(j + Wrc.Top) + 3 * (Wrc.Left + k * w); Msl = WorkArea->Mask->GetScanLine(j); #endif for (i = k * w; i < (k + 1) * w; i++, sl += 3) { #ifdef TPDEBUG if (i >= 0 && i < (Wrc.Bottom - Wrc.Top)) { if (*(Msl + (i >> 3)) & (0x80 >> (i & 7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } } else SHOWDEBUG; #else if (*(Msl + (i >> 3)) & (0x80 >> (i & 7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } #endif } } if (sum > (wh)) { // Because of Irregular rect.... rgb[0].rgbRed = red / sum; rgb[0].rgbGreen = green / sum; rgb[0].rgbBlue = blue / sum; MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->uBitmap->Width / mx; h = iMainImage->uBitmap->Height / my; wh = w * h; Pattern->Create(mx * w + 1, my * h + 1, 24); for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { red = green = blue = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < iMainImage->uBitmap->Height) { sl = iMainImage->uBitmap->GetScanLine(j) + 3 * k * w; } else SHOWDEBUG; #else sl = iMainImage->uBitmap->GetScanLine(j) + 3 * k * w; #endif for (i = 0; i < w; i++, sl += 3) { #ifdef TPDEBUG if (i >= 0 && i < iMainImage->uBitmap->Width) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; } else SHOWDEBUG; #else GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; #endif } } rgb[0].rgbRed = Byte(blue / wh); rgb[0].rgbGreen = Byte(green / wh); rgb[0].rgbBlue = Byte(red / wh); MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } } iMainImage->uBitmap->StopScanLine(); END_LOG; return true; fail: if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); END_LOG; return false; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderMosaicMethod_layer (TUnionBitmap *Pattern, int mx, int my) { BEGIN_LOG(""); Byte max, maxp, *sl = NULL, *Msl = NULL; short color[256]; RGBQUAD rgb[256]; int i, j, k, m, w, h, wh, sum, red, green, blue; TRect Dst, Wrc, Re; COLORREF c; TUnionBitmap *Bitmap = NULL; // convert by celberus if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right - Wrc.Left) / mx; h = (Wrc.Bottom - Wrc.Top) / my; wh = w * h / 2; Pattern->Create(mx * w + 1, my * h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { memset(color, 0, sizeof(color)); sum = 0; max = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < (Wrc.Bottom - Wrc.Top)) { sl = Bitmap->GetScanLine(j + Wrc.Top) + Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j + Wrc.Top) + Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); #endif for (i = k * w; i < (k + 1) * w; i++) { #ifdef TPDEBUG if (i >= 0 && i < (Wrc.Right - Wrc.Left)) { if (*(Msl + i)) { c = *(sl + i); color[c]++; if (color[c] > max) { max = color[c]; maxp = c; } sum++; } } else SHOWDEBUG; #else if (*(Msl + i)) { c = *(sl + i); color[c]++; if (color[c] > max) { max = color[c]; maxp = c; } sum++; } #endif } } if (sum >= (wh)) { // Because of Irregular rect.... MosaicDraw8(Pattern, k, m, w, h, maxp); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->uBitmap->Width / mx; h = iMainImage->uBitmap->Height / my; Pattern->Create(mx * w + 1, my * h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { memset(color, 0, sizeof(color)); max = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < (iMainImage->uBitmap->Height)) { sl = Bitmap->GetScanLine(j); } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j); #endif for (i = k * w; i < (k + 1) * w; i++) { #ifdef TPDEBUG if (i >= 0 && i < (iMainImage->uBitmap->Width)) { c = *(sl + i); color[c] = color[c] + 1; if (color[c] > max) { max = color[c]; maxp = c; } } else SHOWDEBUG; #else c = *(sl + i); color[c] = color[c] + 1; if (color[c] > max) { max = color[c]; maxp = c; } #endif } } MosaicDraw8(Pattern, k, m, w, h, maxp); } } } } else { if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right - Wrc.Left) / mx; h = (Wrc.Bottom - Wrc.Top) / my; wh = w * h / 2; Pattern->Create(mx * w + 1, my * h + 1, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { red = green = blue = 0; sum = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < (Wrc.Right - Wrc.Left)) { sl = Bitmap->GetScanLine(j + Wrc.Top) + 3 * (Wrc.Left + k * w); Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j + Wrc.Top) + 3 * (Wrc.Left + k * w); Msl = WorkArea->Mask->GetScanLine(j); #endif for (i = k * w; i < (k + 1) * w; i++, sl += 3) { #ifdef TPDEBUG if (i >= 0 && i < (Wrc.Bottom - Wrc.Top)) { if (*(Msl + (i >> 3)) & (0x80 >> (i & 7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } } else SHOWDEBUG; #else if (*(Msl + (i >> 3)) & (0x80 >> (i & 7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } #endif } } if (sum > (wh)) { // Because of Irregular rect.... rgb[0].rgbRed = red / sum; rgb[0].rgbGreen = green / sum; rgb[0].rgbBlue = blue / sum; MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->uBitmap->Width / mx; h = iMainImage->uBitmap->Height / my; wh = w * h; Pattern->Create(mx * w + 1, my * h + 1, 24); for (m = 0; m < my; m++) { for (k = 0; k < mx; k++) { red = green = blue = 0; for (j = m * h; j < (m + 1) * h; j++) { #ifdef TPDEBUG if (j >= 0 && j < iMainImage->uBitmap->Height) { sl = Bitmap->GetScanLine(j) + 3 * k * w; } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j) + 3 * k * w; #endif for (i = 0; i < w; i++, sl += 3) { #ifdef TPDEBUG if (i >= 0 && i < iMainImage->uBitmap->Width) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; } else SHOWDEBUG; #else GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; #endif } } rgb[0].rgbRed = Byte(blue / wh); rgb[0].rgbGreen = Byte(green / wh); rgb[0].rgbBlue = Byte(red / wh); MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } } Bitmap->StopScanLine(); doDestroy(Bitmap) END_LOG; return true; fail: if (Bitmap) { if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); doDestroy(Bitmap) } END_LOG; return false; } // --------------------------------------------------------------------------- // Public Function // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintLineLocate(TObject *Sender, HDC formDC) { // HDC formDC; HBRUSH hOldBrush = NULL; HPEN hOldPen = NULL; int nDrawMode; int NOL = NumberOfLine; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = (HPEN)SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; POINT pt; POINT First; POINT Second; LineListData *line; for (int i = 0; i < NOL; i++) { line = (LineListData*)LineList->Items[i]; First = line->First; Second = line->Second; pt.x = iMainImage->BitmapToCanvasX(First.x); pt.y = iMainImage->BitmapToCanvasY(First.y); MoveToEx(formDC, pt.x, pt.y, NULL); pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); LineTo(formDC, pt.x, pt.y); } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } // --------------------------------------------------------------------------- void TMainImageForm::DrawLineLocate(POINT First, POINT Second, int NOL) { NumberOfLine = NOL; static RECT oldlines = Rect(0, 0, 0, 0); LineListData *line = NULL; if (NOL == 0) { // LineList->Clear(); ////// while (LineList->Count > 0) { line = (LineListData*)LineList->Last(); LineList->Remove(line); delete line; } iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle, &oldlines, false); } else { iMainImage->OnPaintLocate = PaintLineLocate; /////////////////by jeegeo static int cnt = 0; if (cnt == 0) { // LineList->Clear(); ////// while (LineList->Count > 0) { line = (LineListData*)LineList->Last(); LineList->Remove(line); delete line; } } line = new LineListData; cnt++; line->First = First; line->Second = Second; LineList->Add(line); if (NOL == cnt) { cnt = 0; line = (LineListData*)LineList->Items[0]; int minx, miny, maxx, maxy; minx = iMainImage->BitmapToCanvasX(min(line->First.x, line->Second.x)); maxx = iMainImage->BitmapToCanvasX(max(line->First.x, line->Second.x)); miny = iMainImage->BitmapToCanvasY(min(line->First.y, line->Second.y)); maxy = iMainImage->BitmapToCanvasY(max(line->First.y, line->Second.y)); for (int i = 1; i < NOL; i++) { line = (LineListData*)LineList->Items[i]; minx = min(minx, iMainImage->BitmapToCanvasX (min(line->First.x, line->Second.x))); maxx = max(maxx, iMainImage->BitmapToCanvasX (max(line->First.x, line->Second.x))); miny = min(miny, iMainImage->BitmapToCanvasY (min(line->First.y, line->Second.y))); maxy = max(maxy, iMainImage->BitmapToCanvasY (max(line->First.y, line->Second.y))); } RECT rc = { minx - 1, miny - 1, maxx + 1, maxy + 1 }; oldlines = rc; } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintFreeLineLocate (TObject *Sender, HDC formDC) { // HDC formDC; HBRUSH hOldBrush = NULL; HPEN hOldPen = NULL; int nDrawMode; // int NOL=NumberOfLine; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = (HPEN)SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; POINT pt; POINT First; POINT Second; LineListData *line = NULL; if (LineList->Count > 0) { line = (LineListData*)LineList->Items[0]; Second = line->Second; pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); MoveToEx(formDC, pt.x, pt.y, NULL); } for (int i = 1; i < LineList->Count; i++) { line = (LineListData*)LineList->Items[i]; First = line->First; Second = line->Second; pt.x = iMainImage->BitmapToCanvasX(First.x); pt.y = iMainImage->BitmapToCanvasY(First.y); MoveToEx(formDC, pt.x, pt.y, NULL); pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); LineTo(formDC, pt.x, pt.y); } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } // --------------------------------------------------------------------------- void TMainImageForm::DrawFreeLineLocate(POINT Second, int resetCount) { LineListData *line = NULL; static RECT oldlines = Rect(0, 0, 0, 0); static POINT First = Second; if (resetCount == 0) { First = Second; // LineList->Clear(); ////// while (LineList->Count > 0) { line = (LineListData*)LineList->Last(); LineList->Remove(line); delete line; } iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle, &oldlines, false); } else { iMainImage->OnPaintLocate = PaintFreeLineLocate; /////////////////by jeegeo LineListData *line = NULL; if (resetCount == -1 || resetCount == -2) { line = new LineListData; line->First = First; line->Second = Second; LineList->Add(line); First = Second; } else { while (LineList->Count > resetCount) { line = (LineListData*)LineList->Last(); LineList->Remove(line); delete line; } if (LineList->Count > 0) { // by embakum 080331 ¸®½ºÆ®¸¦ ´Ù ºñ¿ì°í, Last·Î Á¢±ÙÀ» ÇÏ´Â ¹®Á¦°¡ ÀÖ¾î ¼öÁ¤. First = ((LineListData*)LineList->Last())->Second; } else { First = Point(0, 0); } } if (LineList->Count != 0) { // by embakum 080331 ¸®½ºÆ®¸¦ ´Ù ºñ¿ì°í, Last·Î Á¢±ÙÀ» ÇÏ´Â ¹®Á¦°¡ ÀÖ¾î ¼öÁ¤. line = (LineListData*)LineList->Items[0]; int minx, miny, maxx, maxy; minx = iMainImage->BitmapToCanvasX(min(line->First.x, line->Second.x)); maxx = iMainImage->BitmapToCanvasX(max(line->First.x, line->Second.x)); miny = iMainImage->BitmapToCanvasY(min(line->First.y, line->Second.y)); maxy = iMainImage->BitmapToCanvasY(max(line->First.y, line->Second.y)); for (int i = 1; i < LineList->Count; i++) { line = (LineListData*)LineList->Items[i]; minx = min(minx, iMainImage->BitmapToCanvasX (min(line->First.x, line->Second.x))); maxx = max(maxx, iMainImage->BitmapToCanvasX (max(line->First.x, line->Second.x))); miny = min(miny, iMainImage->BitmapToCanvasY (min(line->First.y, line->Second.y))); maxy = max(maxy, iMainImage->BitmapToCanvasY (max(line->First.y, line->Second.y))); } RECT rc = { minx - 1, miny - 1, maxx + 1, maxy + 1 }; if (resetCount != -2) { } oldlines = rc; } } } // --------------------------------------------------------------------------- void TMainImageForm::DrawRectangleLocate(RECT rc, int NOR) { static RECT oldrc = Rect(0, 0, 0, 0); if (NOR == 0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle, &oldrc, false); } else { iMainImage->OnPaintLocate = PaintRectangleLocate; /////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left, rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left, rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top, rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top, rc.bottom)); oldrc = FloatingRect; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintRectangleLocate (TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush = NULL; HPEN hOldPen = NULL; int nDrawMode; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = (HPEN)SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; Rectangle(formDC, min(rc.left, rc.right) + 1, min(rc.top, rc.bottom) + 1, max (rc.left, rc.right), max(rc.top, rc.bottom)); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } // --------------------------------------------------------------------------- void TMainImageForm::DrawEllipseLocate(RECT rc, int NOE) { static RECT oldrc = Rect(0, 0, 0, 0); if (NOE == 0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle, &oldrc, false); } else { iMainImage->OnPaintLocate = PaintEllipseLocate; /////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left, rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left, rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top, rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top, rc.bottom)); oldrc = FloatingRect; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintEllipseLocate(TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush = NULL; HPEN hOldPen = NULL; int nDrawMode; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = (HPEN)SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; Ellipse(formDC, min(rc.left, rc.right) + 1, min(rc.top, rc.bottom) + 1, max (rc.left, rc.right), max(rc.top, rc.bottom)); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } // --------------------------------------------------------------------------- void TMainImageForm::DrawArcLocate(POINT center2, double LRadius2, double SRadius2, double angleS2, double angleE2, bool isFan2, bool isClosed2, int NOA) { //////isFanÀÌ trueÀ̸é fanÀ̰í falseÀ̸é tubeÀÌ´Ù center = center2; //////tube¿¡¼­´Â SRadius°¡ Æ©ºê ¾çÂÊ ³¡ÀÇ ¼±ºÐÀÇ ±æÀÌÀÌ´Ù LRadius = LRadius2; //////angleS´Â ½ÃÀæ°¢µµÀ̰í SRadius = SRadius2; //////angleE´Â ³¡°¢µµÀÌ´Ù angleS = angleS2; angleE = angleE2; isFan = isFan2; isClosed = isClosed2; RECT rc = Rect(center.x - LRadius - SRadius, center.y - LRadius - SRadius, center.x + LRadius + SRadius, center.y + LRadius + SRadius); static RECT oldrc = Rect(0, 0, 0, 0); if (NOA == 0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle, &oldrc, false); } else { iMainImage->OnPaintLocate = PaintArcLocate; /////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left, rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left, rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top, rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top, rc.bottom)); oldrc = FloatingRect; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintArcLocate(TObject *Sender, HDC formDC) /////by jeegeo { RECT rc, rr; POINT p, ps, pe; // HDC formDC; HBRUSH hOldBrush = NULL; HPEN hOldPen = NULL; int nDrawMode; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = (HPEN)SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; if (isFan) { rc = Rect(center.x - LRadius, center.y - LRadius, center.x + LRadius, center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x + cos(angleS) * LRadius, center.y - sin(angleS) * LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x + cos(angleE) * LRadius, center.y - sin(angleE) * LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC, rr.left, rr.top, rr.right, rr.bottom, ps.x, ps.y, pe.x, pe.y); rc = Rect(center.x - SRadius, center.y - SRadius, center.x + SRadius, center.y + SRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x + cos(angleS) * SRadius, center.y - sin(angleS) * SRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x + cos(angleE) * SRadius, center.y - sin(angleE) * SRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC, rr.left, rr.top, rr.right, rr.bottom, ps.x, ps.y, pe.x, pe.y); if (isClosed) { /////////Arc¸¦ ´Ý´Â ¼±ºÐÀ» ±×¸°´Ù p = Point(center.x + cos(angleS) * LRadius, center.y - sin(angleS) * LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC, p.x, p.y, NULL); p = Point(center.x + cos(angleS) * SRadius, center.y - sin(angleS) * SRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); LineTo(formDC, p.x, p.y); p = Point(center.x + cos(angleE) * LRadius, center.y - sin(angleE) * LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC, p.x, p.y, NULL); p = Point(center.x + cos(angleE) * SRadius, center.y - sin(angleE) * SRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); LineTo(formDC, p.x, p.y); } } else { rc = Rect(center.x - LRadius, center.y - LRadius, center.x + LRadius, center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x + cos(angleS) * LRadius, center.y - sin(angleS) * LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x + cos(angleE) * LRadius, center.y - sin(angleE) * LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC, rr.left, rr.top, rr.right, rr.bottom, ps.x, ps.y, pe.x, pe.y); double midAngle = (angleS + angleE) / 2.0; float ratio = (float)iMainImage->ZoomIn / (float)iMainImage->ZoomOut; POINT plus = Point(-SRadius * cos(midAngle) * ratio, SRadius * sin (midAngle) * ratio); rc = Rect(center.x - LRadius, center.y - LRadius, center.x + LRadius, center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x + cos(angleS) * LRadius, center.y - sin(angleS) * LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x + cos(angleE) * LRadius, center.y - sin(angleE) * LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC, rr.left + plus.x, rr.top + plus.y, rr.right + plus.x, rr.bottom + plus.y, ps.x + plus.x, ps.y + plus.y, pe.x + plus.x, pe.y + plus.y); if (isClosed) { /////////Arc¸¦ ´Ý´Â ¼±ºÐÀ» ±×¸°´Ù p = Point(center.x + cos(angleS) * LRadius, center.y - sin(angleS) * LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC, p.x, p.y, NULL); LineTo(formDC, p.x + plus.x, p.y + plus.y); p = Point(center.x + cos(angleE) * LRadius, center.y - sin(angleE) * LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC, p.x, p.y, NULL); LineTo(formDC, p.x + plus.x, p.y + plus.y); } } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintCrossLine(TObject *Sender, HDC formDC) { HPEN hOldPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; POINT cp = iMainImage->GetCrossPos(); RGBQUAD rgb; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = (HPEN)SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); MoveToEx(formDC, cp.x, 0 /* iMainImage->Parent->Top */ , NULL); LineTo(formDC, cp.x, iMainImage->Height /* iMainImage->Parent->Top + iMainImage->Parent->Height */ ); MoveToEx(formDC, 0 /* iMainImage->Parent->Left */ , cp.y, NULL); LineTo(formDC, iMainImage->Width /* iMainImage->Parent->Left + iMainImage->Parent->Width */ , cp.y); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintDirectly (HDC dcDst, int px, int py, int vw, int vh) { if (!isPaintDirectlyClean) { if (!isFirst) { if (iMainImage->OnPaintCursor) iMainImage->OnPaintCursor(iMainImage, dcDst, Pen.x, Pen.y); if (iMainImage->OnPaintCrossLine) iMainImage->OnPaintCrossLine(iMainImage, dcDst); } if (iMainImage->OnPaintIndexPoint) // By GreenFish iMainImage->OnPaintIndexPoint(iMainImage, dcDst); if (iMainImage->OnPaintZoom) iMainImage->OnPaintZoom(iMainImage, dcDst); if (iMainImage->OnPaintLocate) iMainImage->OnPaintLocate(iMainImage, dcDst); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - ±âÁؼ±À» ±×¸°´Ù - by monkman (2005.02.16) if (iMainImage->OnPaintVectorReflectIndexPoint) iMainImage->OnPaintVectorReflectIndexPoint(iMainImage, dcDst); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintDirectly2 (HDC dcDst, int px, int py, int vw, int vh) { if (!isPaintDirectlyClean) { if (!isFirst) { if (iMainImage->OnPaintCursor) iMainImage->OnPaintCursor(iMainImage, dcDst, Pen.x, Pen.y); if (iMainImage->OnPaintCrossLine) iMainImage->OnPaintCrossLine(iMainImage, dcDst); } if (iMainImage->OnPaintIndexPoint) // By GreenFish iMainImage->OnPaintIndexPoint(iMainImage, dcDst); if (N3DMappingForm && N3DMappingForm->isDrawGrid()) { // ±×¸®µå¸¦ ±×¸®´Â ¶§´Â.....PaintDirectly¿¡¼­ ±×¸±¶§.. } else { if (iMainImage->OnPaintZoom) iMainImage->OnPaintZoom(iMainImage, dcDst); } if (iMainImage->OnPaintLocate) iMainImage->OnPaintLocate(iMainImage, dcDst); // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - by monkman (2005.02.17) if (NVector->bVectorReflectionMode && iMainImage->OnPaintVectorReflectIndexPoint && NVector->ReflectionVH > 0 && VectorForm && (MainMenuForm->Item == T_VECTOR)) { // ±âÁؼ±À» ±×¸®¸ç Ä¿¼­¸¦ º¯°æÇÑ´Ù switch(NVector->ReflectionVH) { case 1: case 2: if (!NVector->ReflectionVIndex >= 0 || NVector->ReflectionHIndex >= 0) PaintVectorReflectIndexPoint(iMainImage, dcDst); break; case 3: // ¼öÁ÷ ±âÁؼ± ±×¸®´Â Áß if (!NVector->ReflectFirstIndex) PaintVectorCurrentReflectIndexPoint(); iMainImage->Cursor = crHSplit; break; case 4: // ¼öÆò ±âÁؼ± ±×¸®´Â Áß if (!NVector->ReflectFirstIndex) PaintVectorCurrentReflectIndexPoint(); iMainImage->Cursor = crVSplit; break; } } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintVectorModify(HDC dcDst, int px, int py, int vw, int vh) { if (MainImageForm == NULL) return; VecDraw->ModifyDraw(dcDst, px, py, vw, vh, this); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintVector (HDC dcDst, int px, int py, int vw, int vh) // By GreenFish { try { // this ¸¦ º¸³»´Â ÀÌÀ¯´Â Á¤È®ÇÑ ÇöÀçÀÇ MainImage¸¦ ÀνÄÇϱâ À§ÇÔÀÌ´Ù thx to k3dogs if (MainImageForm == NULL) return; if (px < 0 && py < 0) { // FullViewPaintÀÇ ½ÅÈ£ (Æí¹ýÀÌ´Ù..) // convert by celberus if (VectorForm) VecDraw->FullViewDraw(dcDst, -px - 1, -py - 1, vw, vh); // convert by celberus else VecDraw->FullViewBitmapToFullView(dcDst, -px - 1, -py - 1, vw, vh); // À§ÀÇ µÎ ¶óÀÎÀÌ ÁÖ¼®À¸·Î 󸮵Ǿî ÀÖ¾ú´Ù. ÀÌ·¸°Ô ÇÒ °æ¿ì FullViewBitmapToFullView() ÇÔ¼ö¿¡¼­ // BitBlt¸¦ ó¸®ÇÏ´Â if¹®¿¡ µé¾î°¡Áö ¾Ê¾Æ RepaintÀÇ È¿°ú°¡ ¾ø¾îÁö°Ô µÈ´Ù. ±×·¡¼­ ÀÌÀü ¹æ½ÄÀ¸·Î // º¯°æÇϱâ À§ÇØ ¾Æ·¡¸¦ ÁÖ¼®À¸·Î ó¸®Çϰí À§¿¡ ºÎºÐÀº ÁÖ¼®À» Ç®¾ú´Ù. by david 090122 // if (VectorForm) VecDraw->FullViewDraw(dcDst, -1, -1, vw, vh); // else VecDraw->FullViewBitmapToFullView(dcDst, -1, -1, vw, vh); } else { // Vector Speed - by monkman (2007.09.12) // if (VecDraw->NVector->bVectorMove) { // ĵ¹ö½º À̵¿½Ã Vector MoveDraw()·Î ±×¸®±â - by monkman (2008.10.17) // VecDraw->MoveDraw(dcDst, px, py, vw, vh, this); // // Vector RectPaint - by monkman (2008.11.13) // } // else { // if (MainForm->nVectorMode == 0) { // Quality // VecDraw->LineDraw(dcDst, px, py, vw, vh, this); // // Vector RectPaint - by monkman (2008.11.13) // } // else { // Speed // VecDraw->MoveDraw(dcDst, px, py, vw, vh, this); // // Vector RectPaint - by monkman (2008.11.13) // } // } VecDraw->LineDraw(dcDst, px, py, vw, vh, this); // For Ctrl + t 07.01.25 ------------------by maxleo21c if (MainMenuForm && MainMenuForm->Item == T_CTRLT) { MainMenuForm->CtrlTPaint(dcDst, px, py, this); return; } #ifdef TRIAL if (this->WaterMarkPaint) { int width = iMainImage->uBitmap->Width * iMainImage->ZoomIn / iMainImage->ZoomOut; int height = iMainImage->uBitmap->Height * iMainImage->ZoomIn / iMainImage->ZoomOut; PaintWaterMark(dcDst, px, py, width, height, iMainImage->ZoomIn, iMainImage->ZoomOut); } #endif //////////////////////////////////////////////////////// } } catch (...) { return; } } // --------------------------------------------------------------------------- // ÇÔ¼öÄÝ ÇÏ´Â ºÎºÐÀ» ÁÖ¼®À» ó¸®Çؼ­ ÀÌ Èû¼ö´Â ÇöÀç ºÒ·ÁÁöÁö ¾Ê´Â´Ù. // ÇÔ¼öÀÇ Á¸Àç ÀÌÀ¯¸¦ ¸ð¸£±â ¶§¹®¿¡ ³²°Ü µÎ¾ú´Ù. // ÁÖ¼® ó¸® ÀÌÀ¯´Â À̹ø ¾÷±×·¹À̵忡¼­ Vecdraw->bFirst¸¦ Æ÷ÀÎÅÍ·Î ¸¸µé¸é¼­ // Vecdraw->bFirst°¡ ÁÖ¼Ò¸¦ °¡Áö°í ÀÖ±â Àü¿¡ *VecDraw->bFirst(°ª)À» ¾Ë·Á°í // ÇÒ¶§ Äڵ尡µå¿¡¼­ °É¸®±â ¶§¹®ÀÌ´Ù. - by maxleo21c (05.06.04) void __fastcall TMainImageForm::InitCurveLine() { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDraw, VectorForm º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // º¯¼ö¸¦ VecDraw¿Í VectorFormÀÌ Æ÷ÀÎÅÍ º¯¼öµé°ú ¿¬°á ½ÃÄÑÁØ´Ù if (NVector->bFirst && NVector->bFirst) NVector->bFirst = true; // Curve¸¦ ±×¸±¶§ÀÇ ÀÜ»ó ¾ø¾Ö±â // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- int __fastcall TMainImageForm::GetLineListCount(void) { return LineList->Count; } // --------------------------------------------------------------------------- void TMainImageForm::ResetDraw(bool repaint) { LineListData *line = NULL; iMainImage->OnPaintLocate = NULL; while (LineList->Count > 0) { line = (LineListData*)LineList->Last(); LineList->Remove(line); delete line; } FloatingRect = Rect(0, 0, 0, 0); NumberOfLine = 0; center = Point(0, 0); SRadius = 0; LRadius = 0; angleS = 0; angleE = 0; isClosed = false; isFan = true; if (repaint) iMainImage->Repaint(); } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitForm(TPCanvasInfor &ci, WORD bpp, TGraphicFileFormat Index) { // convert by celberus // iMainImage->OnPaintLocate = PaintRectangleLocate;/////////////////by jeegeo BEGIN_LOG(""); PALETTEENTRY peEntry[256]; RGBQUAD rgb[256]; if (Palette == NULL || WorkArea == NULL) { SAVE_EXCEPTION(EC_MEMORY_LACK); END_LOG; return EC_MEMORY_LACK; } if (!Palette->LoadFromFile((DirectoryColor + "\\Textile.fcr").c_str())) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); for (int i = 3; i < 255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); Palette->SetNormal(255, 255, 255, 255); } if (!ResizePattern(ci, bpp)) { SAVE_EXCEPTION(EC_MEMORY_LACK); END_LOG; return EC_MEMORY_LACK; } if (Index == gffNON) { if (bpp == 8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); #ifdef TRIAL FileName = Format("Noname%d.ttex", OPENARRAY(TVarRec, (Number + 1))); gff = gffTEX_TRIAL; #else FileName = Format("Noname%d.tex", OPENARRAY(TVarRec, (Number + 1))); gff = gffTEX; #endif MaskPixel = 0x0F; PaletteForm->sbProtect->Enabled = true; } else { #ifdef TRIAL FileName = Format("Noname%d.ttfc", OPENARRAY(TVarRec, (Number + 1))); gff = gffTFC_TRIAL; #else FileName = Format("Noname%d.tfc", OPENARRAY(TVarRec, (Number + 1))); gff = gffTFC; #endif MaskPixel = 0x80; PaletteForm->sbProtect->Enabled = false; } } else { #ifdef NOTN3D #else if (Index == gffN3D) { FileName = Format("Noname%d.n3d", OPENARRAY(TVarRec, (Number + 1))); MaskPixel = 0x80; PaletteForm->sbProtect->Enabled = false; iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF (24)); // speed-test if (!new3d) new3d = new TN3D(iMainImage); N3DMappingForm->Visible = true; N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); LayerForm->Visible = false; } #endif gff = Index; } int zi, zo; if (bpp == 8) { // speed-test // 2003. 8 iMainImage->uBitmap->Activate(0, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); //speed-test iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8) , rgb); // speed-test FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (8), rgb); // speed-test } else { // speed-test // 2003. 8 iMainImage->uBitmap->Activate(0, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); //speed-test iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24) ); // speed-test FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (24)); // speed-test } /* iMainImage->uBitmap->FillRect(Rect(0, 0, CanvasInfor.Width, CanvasInfor.Height), PaletteForm->DIB256Palette->GetBGCOLORREF(iMainImage->uBitmap->BitsPerPixel)); if (bpp == 8) { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); } else { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); } */ // if (WindowState == wsNormal) { // Top = 0; // Left = 0; //// ClientWidth = MainForm->ClientWidth-267; // //ClientHeight = MainForm->ClientHeight-MainForm->StatusBar->Height // // -GetSystemMetrics(SM_CYSMCAPTION)-GetSystemMetrics(SM_CYMENU)+3-3;//-3 on XP // Width = MainForm->ClientWidth - MainMenuForm->Width - 4; // Height = MainForm->ClientHeight-MainForm->StatusBar->Height-4; // } // ºñÆ®¸ÊÀ» ÃʱâÈ­ÇÏ¿© º¤Å͸¸ »ç¿ëÇßÀ» °æ¿ì¿¡ ¹®Á¦°¡ ¹ß»ýÇÏÁö ¾Êµµ·Ï ¼öÁ¤ - by monkman (2011.04.26) iMainImage->uBitmap->FillRect(TRect(0, 0, ci.Width, ci.Height), PaletteForm->DIB256Palette->GetBGCOLORREF(bpp)); iMainImage->uBitmap->SetAllToModified(); resetClientSize(); SetCaption(); iMainImage->SetPosition(0, 0); PaletteForm->DIB256Palette->ChoiceIndex = 2; MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); // MainForm->shPenShape->Pen->Color = Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; // MainForm->shPenShape->Brush->Color = Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDraw, VectorForm º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // º¯¼ö¸¦ VecDraw¿Í VectorFormÀÌ Æ÷ÀÎÅÍ º¯¼öµé°ú ¿¬°á ½Ã۰í ÃʱâÈ­ ½ÃÄÑÁØ´Ù VecDraw->MappingVariable(this->NVector); if (VectorForm) VectorForm->MappingVariable(this->NVector); VecDraw->InitVariable(this->NVector); if (VectorForm) VectorForm->InitVariable(this->NVector); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- PaletteForm->UpdateForm(bpp); END_LOG; return EC_NONE; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitForm2(TPCanvasInfor &ci, WORD bpp, TGraphicFileFormat Index) { PALETTEENTRY peEntry[256]; RGBQUAD rgb[256]; if (Palette==NULL || WorkArea==NULL) return EC_MEMORY_LACK; if (!Palette->LoadFromFile((DirectoryColor+"\\Textile.fcr").c_str())) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); for (int i=3; i<255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); Palette->SetNormal(255, 255, 255, 255); } if (!ResizePattern(ci, bpp)) return EC_MEMORY_LACK; if(Index==gffNON){ if (bpp==8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); FileName = Format("Noname%d.tex", OPENARRAY(TVarRec, (Number+1))); MaskPixel = 0x0F; PaletteForm->sbProtect->Enabled = true; gff = gffTEX; } else { FileName = Format("Noname%d.tfc", OPENARRAY(TVarRec, (Number+1))); MaskPixel = 0x80; PaletteForm->sbProtect->Enabled = false; gff = gffTFC; } } else { gff = Index; } iMainImage->uBitmap->FillRect(Rect(0, 0, CanvasInfor.Width, CanvasInfor.Height), PaletteForm->DIB256Palette->GetBGCOLORREF(iMainImage->uBitmap->BitsPerPixel)); int zi, zo; if (bpp == 8) { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (8), rgb); // speed-test } else { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test } if (WindowState == wsNormal) { Top = 0; Left = 0; ClientWidth = ci.Width < MainForm->ClientWidth-267 ? ci.Width : MainForm->ClientWidth-267; ClientHeight = ci.Height < MainForm->ClientHeight-MainForm->StatusBar->Height-4 ? ci.Height : MainForm->ClientHeight-MainForm->StatusBar->Height-4; } SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); if (MainMenuForm->Item != T_COMBO && VectorForm) // added by maxleo21c 04/04/20 Panel->PopupMenu = VectorForm->VectorPopupMenu; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDraw, VectorForm º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // º¯¼ö¸¦ VecDraw¿Í VectorFormÀÌ Æ÷ÀÎÅÍ º¯¼öµé°ú ¿¬°á ½Ã۰í ÃʱâÈ­ ½ÃÄÑÁØ´Ù VecDraw->MappingVariable(MainImageForm->NVector); if (VectorForm) VectorForm->MappingVariable(MainImageForm->NVector); VecDraw->InitVariable(MainImageForm->NVector); if (VectorForm) VectorForm->InitVariable(MainImageForm->NVector); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- return EC_NONE; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile(String dn, String fn, TGraphicFileFormat ExtIndex, WORD bpp) { return InitFormFile(dn, fn, ExtIndex, bpp, false); } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormImage (TPCanvasInfor &ci, TUnionBitmap *newBitmap, int usedColor) { BEGIN_LOG(""); PALETTEENTRY peEntry[256]; RGBQUAD rgb[256]; if (Palette == NULL || WorkArea == NULL) { SAVE_EXCEPTION(EC_MEMORY_LACK); END_LOG; return EC_MEMORY_LACK; } newBitmap->GetColors(0, 256, rgb); int bpp = newBitmap->BitsPerPixel; if (!Palette->LoadFromFile((DirectoryColor + "\\Textile.fcr").c_str())) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); for (int i = 3; i < 255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); Palette->SetNormal(255, 255, 255, 255); } for (int i = 2; i < 2 + usedColor; i++) { Palette->SetNormal(i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue); } Palette->UseColor = usedColor + 1; if (!ResizePattern(ci, bpp)) { SAVE_EXCEPTION(EC_MEMORY_LACK); END_LOG; return EC_MEMORY_LACK; } Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); newBitmap->PutColors(0, 256, rgb); iMainImage->uBitmap->Copy(newBitmap, SRCCOPY); // if(Index==gffNON){ // if (bpp==8) { // Palette->ToRGBQUAD(rgb, 256); // iMainImage->uBitmap->PutColors(0, 256, rgb); #ifdef TRIAL FileName = Format("Noname%d.ttex", OPENARRAY(TVarRec, (Number + 1))); #else FileName = Format("Noname%d.tex", OPENARRAY(TVarRec, (Number + 1))); #endif MaskPixel = 0x0F; PaletteForm->sbProtect->Enabled = true; gff = gffTEX; /* } else { FileName = Format("Noname%d.tfc", OPENARRAY(TVarRec, (Number+1))); MaskPixel = 0x80; PaletteForm->sbProtect->Enabled = false; gff = gffTFC; } } else { #ifdef NOTN3D #else if(Index==gffN3D){ FileName = Format("Noname%d.n3d", OPENARRAY(TVarRec, (Number+1))); MaskPixel = 0x80; PaletteForm->sbProtect->Enabled = false; iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); //speed-test if(!new3d) new3d = new TN3D(iMainImage); N3DMappingForm->Visible = true; N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); LayerForm->Visible = false; } #endif gff = Index; } */ int zi, zo; if (bpp == 8) { // speed-test // 2003. 8 iMainImage->uBitmap->Activate(0, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); //speed-test iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8) , rgb); // speed-test FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (8), rgb); // speed-test } else { // speed-test iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24) ); // speed-test FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (24)); // speed-test } // if (WindowState == wsNormal) { // Top = 0; // Left = 0; // //ClientWidth = MainForm->ClientWidth-267; // Width = MainForm->ClientWidth - MainMenuForm->Width - 4; // Height = MainForm->ClientHeight-MainForm->StatusBar->Height-4; // } resetClientSize(); SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); END_LOG; return EC_NONE; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::LoadVectorFromFile (String fn, TGraphicFileFormat ExtIndex) { int pw, ph, sw, sh, x, y; TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; String ext = LowerCase(ExtractFileExt(fn)); if (Palette == NULL) return false; BEGIN_LOG(""); if ((hFile = CreateFile(fn.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainMenuForm->InitVectorForm(true); #ifdef TRIAL if (ExtIndex == gffVST_TRIAL) { if ((ec = VecDraw->LoadVector(hFile, Palette, tpfh, true)) != EC_NONE) goto fail; VecDraw->LoadVectorFromFile(hFile, true); } else { if ((ec = VecDraw->LoadVector(hFile, Palette, tpfh)) != EC_NONE) goto fail; VecDraw->LoadVectorFromFile(hFile); } #else if ((ec = VecDraw->LoadVector(hFile, Palette, tpfh)) != EC_NONE) goto fail; VecDraw->LoadVectorFromFile(hFile); #endif CloseHandle(hFile); // new3d->Rendering(); // iMainImage->Repaint(); // FullViewForm->InitForm(iMainImage); // LayerForm->InitForm(true); END_LOG; return true; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return false; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile_T3D (String directoryName, String fileName, TEXPIAFILEHEADER TPFileHeader, TGraphicFileFormat ExtIndex) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TUnionBitmap *tempUnionBitmap = NULL; TPException ec; int zoomIn, zoomOut; TGraphicFileFormat gff = ExtIndex; try { if ((tempUnionBitmap = new TUnionBitmap) == NULL) { SAVE_EXCEPTION(EC_MEMORY_LACK); throw EC_MEMORY_LACK; } // speed-test if (MainForm->T3D_Item) { if ((hFile = CreateFile(FullPathName(directoryName, fileName).c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { SAVE_EXCEPTION(EC_MEMORY_LACK); throw EC_MEMORY_LACK; } #ifdef TRIAL if (ExtIndex == gffT3D_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, Palette, TPFileHeader, tempUnionBitmap, gff, true, NULL, true)) != EC_NONE) throw ec; // convert by celberus } else { if ((ec = LoadFromTexpiaFile(hFile, Palette, TPFileHeader, tempUnionBitmap, gff)) != EC_NONE) throw ec; // convert by celberus } #else if ((ec = LoadFromTexpiaFile(hFile, Palette, TPFileHeader, tempUnionBitmap, gff)) != EC_NONE) throw ec; // convert by celberus #endif if (!ResizePattern(TPFileHeader.CanvasInfor, 24)) { SAVE_EXCEPTION(EC_MEMORY_LACK); throw EC_MEMORY_LACK; } FullViewForm->GetZoomRatio(iMainImage, zoomIn, zoomOut); // convert by celberus MaskPixel = 0x80; if (!iMainImage->uBitmap->Copy(tempUnionBitmap, SRCCOPY)) { SAVE_EXCEPTION(EC_RESOURCE_LACK); throw EC_RESOURCE_LACK; } // convert by celberus iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF (24)); DirName = directoryName; fileName.Delete(LastDelimiter(String("."), fileName), fileName.Length()); #ifdef TRIAL if (ExtIndex == gffT3D_TRIAL) fileName = fileName + String(".tt3d"); else fileName = fileName + String(".t3d"); #else fileName = fileName + String(".t3d"); #endif FileName = fileName; SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); PaletteForm->DIB256Palette->ChoiceIndex = 2; if (Data3D) delete Data3D; if ((Data3D = new TData3D) == NULL) { SAVE_EXCEPTION(EC_MEMORY_LACK); throw EC_MEMORY_LACK; } // if ((ec = MainMenuForm->LoadFrom3DFile(hFile, TPFileHeader, tb))!=EC_NONE) throw ec; if ((ec = MainMenuForm->LoadFrom3DFile(hFile, TPFileHeader, tempUnionBitmap)) != EC_NONE) throw ec; // convert by celberus CloseHandle(hFile); iMainImage->InitbmFullView(zoomIn, zoomOut, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // convert by celberus iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ if (iMainImage->Mask) MaskArea = true; delete tempUnionBitmap; } } catch(TPException & TPe) { if (tempUnionBitmap) { delete tempUnionBitmap; } if (hFile != INVALID_HANDLE_VALUE) { doDestroy(Data3D)CloseHandle(hFile); } END_LOG; return TPe; } END_LOG; return EC_NONE; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile_ToN3D (String fileName, TPCanvasInfor canvasInfor, WORD bitsPerPixel, bool layer) { BEGIN_LOG(""); TUnionBitmap *tempBitmap = NULL; int zoomIn, zoomOut; fileName.Delete(LastDelimiter(String("."), fileName), fileName.Length()); fileName = fileName + String(".n3d"); FileName = fileName; // if (!tb->Copy(iMainImage->uBitmap, SRCCOPY)) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } try { tempBitmap = new TUnionBitmap; if (layer) { iMainImage->FlattenVisibleLayer(); // 2003-11-24 by celberus n3d¿¡¼­ ·¹ÀÌ¾î ÆÄÀÏÀ» ÀÐÀ» ¶§´Â ¸ðµÎ barebody·Î.. } if (!tempBitmap->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { SAVE_EXCEPTION(EC_RESOURCE_LACK); throw EC_RESOURCE_LACK; } tempBitmap->Copy(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, iMainImage->uBitmap, 0, 0, SRCCOPY); if (bitsPerPixel != 24) { if (!ResizePattern(canvasInfor, 24)) { SAVE_EXCEPTION(EC_MEMORY_LACK); throw EC_MEMORY_LACK; } iMainImage->bmScreen->Create(iMainImage->bmScreen->Width, iMainImage->bmScreen->Height, 24); FullViewForm->GetZoomRatio(iMainImage, zoomIn, zoomOut); iMainImage->InitbmFullView(zoomIn, zoomOut, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); } MaskPixel = 0x80; iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24) ); PaletteForm->sbProtect->Enabled = false; if (!new3d) new3d = new TN3D(iMainImage); if (!iMainImage->uBitmap->Copy(tempBitmap, SRCCOPY)) { SAVE_EXCEPTION(EC_RESOURCE_LACK); throw EC_RESOURCE_LACK; } delete tempBitmap; tempBitmap = NULL; iMainImage->Deactivate(); // ·¹ÀÌ¾î ¾÷µ¥ÀÌÆ®¸¦ À§Çؼ­ Æí¹ýÀ¸·Î.. iMainImage->Activate(); N3DMappingForm->Visible = true; N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); LayerForm->Visible = false; SetCaption(); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); PaletteForm->DIB256Palette->ChoiceIndex = 2; } catch(TPException & TPe) { if (tempBitmap) { delete tempBitmap; } END_LOG; return TPe; } END_LOG; return EC_NONE; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::setPaletteData(RGBQUAD *rgb, bool shift) { iMainImage->uBitmap->GetColors(0, 256, rgb); Palette->SetNormal(0, 0, 0, 0); for (int i = 0; i < 250; i++) { if (shift) Palette->SetNormal(i + 2, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue); else Palette->SetNormal(i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue); } Palette->SetNormal(255, 255, 255, 255); Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::findUsedColor(bool shift) { bool colorUsed[256] = { false, }; BYTE *pLine; if (!iMainImage->uBitmap->StartScanLine()) { SAVE_EXCEPTION(EC_MEMORY_LACK); throw EC_MEMORY_LACK; } for (int y = 0; y < iMainImage->uBitmap->Height; y++) { pLine = iMainImage->uBitmap->GetScanLine(y); for (int x = 0; x < iMainImage->uBitmap->Width; x++, pLine++) { if (shift) * pLine += 2; colorUsed[*pLine] = true; } iMainImage->uBitmap->PutScanLine(y); } iMainImage->uBitmap->StopScanLine(); for (int i = 251; i >= 1; i--) { if (colorUsed[i] == true) { Palette->UseColor = i; break; } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::resetClientSize() { if (WindowState == wsNormal) { // ClientWidth = MainForm->ClientWidth-267; // ClientHeight = MainForm->ClientHeight-MainForm->StatusBar->Height // -GetSystemMetrics(SM_CYSMCAPTION)-GetSystemMetrics(SM_CYMENU)+3-3;//-3 on XP Width = MainForm->ClientWidth - MainMenuForm->Width - 4; if (MainForm->VCanvasTabItem->Checked == true) Height = MainForm->ClientHeight - MainForm->StatusBar->Height - MainForm->rztabctrlCanvas->Height - 4; else Height = MainForm->ClientHeight - MainForm->StatusBar->Height - 4; int screenWidth = iMainImage->uBitmap->Width + PanelVert->Width; int screenHeight = iMainImage->uBitmap->Height + PanelHorz->Height; if (sbRuler->Down) { screenWidth += Ruler->Thick; screenHeight += Ruler->Thick; } if (screenWidth < ClientWidth) ClientWidth = screenWidth; if (screenHeight < ClientHeight) ClientHeight = screenHeight; Top = 0; Left = 0; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ResizeCanvas(short dpi, int w, int h) { BEGIN_LOG(""); RGNXFORM XForm; HRGN rgn = NULL; double rx, ry; rx = (double)w / iMainImage->uBitmap->Width; ry = (double)h / iMainImage->uBitmap->Height; if (new3d) { new3d->Resize(w, h, true); } else { iMainImage->ResizeStretchLayer(w, h); } if (iMainImage->Mask) iMainImage->Mask->ResizeStretch(w, h); AllocLineMem(h); CanvasInfor.DotsPerInch = dpi; CanvasInfor.SetExtFileOption(); CanvasInfor.SetSize(cstFree, w, h); BITMAPHANDLE *bh = 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_GetBitmapRgnHandle(bh, &XForm, &rgn); WorkArea->SetMask(rgn); DeleteObject(rgn); } #ifndef N_3D if (MainForm->T3D_Item) { if (Data3D && new3d == NULL) { int btn = MessageDlg(IDS_MESSAGE_NEWMODEL, mtInformation, TMsgDlgButtons () << mbYes << mbNo, 0); if (btn == mrYes) { if (Data3D->Source->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { iMainImage->uBitmap->ConvertColorSpace(csHLS); Data3D->Source->Copy(iMainImage->uBitmap, SRCCOPY); iMainImage->uBitmap->ConvertColorSpace(csRGB); } else { SAVE_EXCEPTION(EC_MEMORY_LACK); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return; } } else { Data3D->Source->ResizeStretch(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); } Data3D->Resize(rx, ry); Data3D->waStart.x = Data3D->waStart.x * rx + 0.5; Data3D->waStart.y = Data3D->waStart.y * ry + 0.5; Data3D->waSize.x = Data3D->waSize.x * rx + 0.5; Data3D->waSize.y = Data3D->waSize.y * ry + 0.5; } } // need-conversion #endif int zi, zo; // convert by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); // convert by celberus iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (8), rgb); // convert by celberus iMainImage->isRepaintAll = true; // T3D¿¡¼­ resizeÇÒ ¶§ fullview°¡ ±î¸ÅÁö´Â ¹®Á¦ ¶§¹®¿¡.. by celberus UpdateImage(); ::RepaintColor(); ReviewStatusBar(); // Modify = false; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::EnlargeCanvas(int w, int h) { BEGIN_LOG(""); BITMAPHANDLE *bh; RGNXFORM XForm; HRGN rgn = NULL; RGBQUAD RGB[256]; // by celberus #ifdef TRIAL int A4Width = 1248, A4Height = 1760; if (w > A4Height && h > A4Height) { if (w > h) { w = 1760; h = 1248; } else { w = 1248; h = 1760; } } else if (w > A4Width && h > A4Height) { w = 1248; h = 1760; } else if (w > A4Height && h > A4Width) { w = 1760; h = 1248; } else if (w > A4Height) { w = 1760; } else if (h > A4Height) { h = 1760; } if (w > A4Width && h > A4Width) { if (w > h) { h = 1248; } else { w = 1248; } } #endif #ifndef N_3D if (MainForm->T3D_Item) { if (Data3D) { POINT max = Data3D->MaxGridPoint(); if (w < max.x || h < max.y) { MessageDlg(IDS_MESSAGE_INPUTVALUE, mtInformation, TMsgDlgButtons() << mbOK, 0); END_LOG; return; } } } #endif COLORREF bc = PaletteForm->DIB256Palette->GetBGCOLORREF (iMainImage->uBitmap->BitsPerPixel); CanvasInfor.SetSize(cstFree, w, h); if (new3d) { new3d->Resize(w, h, false); } else { iMainImage->ResizeLayer(w, h, bc); } bh = iMainImage->uBitmap->RgnBitmap->Handle; 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_GetBitmapRgnHandle(bh, &XForm, &rgn); WorkArea->SetMask(rgn); DeleteObject(rgn); } #ifndef N_3D if (MainForm->T3D_Item) { if (Data3D && new3d == NULL) { if (iMainImage->Mask) { iMainImage->Mask->Resize(w, h, clWhite); } int btn = MessageDlg(IDS_MESSAGE_NEWMODEL, mtInformation, TMsgDlgButtons () << mbYes << mbNo, 0); if (btn == mrYes) { if (Data3D->Source->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { iMainImage->uBitmap->ConvertColorSpace(csHLS); Data3D->Source->Copy(iMainImage->uBitmap, SRCCOPY); iMainImage->uBitmap->ConvertColorSpace(csRGB); } else { SAVE_EXCEPTION(EC_MEMORY_LACK); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return; } } else { Data3D->Source->Resize(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, bc); } } else { if (iMainImage->Mask) { iMainImage->Mask->Resize(w, h, 0); } } } #endif int zi, zo; // convert by celberus iMainImage->uBitmap->GetColors(0, 256, RGB); // by celberus ¹é±×¶ó¿îµå color¸¦ ¿ÏÀü °ËÁ¤»öÀ¸·Î ¹Ù²Ù°í enlargeÇÒ °æ¿ì ¹ß»ýÇÏ´Â ¿¡·¯ ¶§¹®¿¡.. FullViewForm->GetZoomRatio(iMainImage, zi, zo); // convert by celberus iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (8), RGB); // convert by celberus iMainImage->isRepaintAll = true; // T3D¿¡¼­ enlargeÇÒ ¶§ fullview°¡ ±î¸ÅÁö´Â ¹®Á¦ ¶§¹®¿¡.. by celberus UpdateImage(); ::RepaintColor(); AllocLineMem(h); ReviewStatusBar(); Modify = true; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::EnlargeCanvasInAutoRepeat() { BEGIN_LOG(""); int zi, zo; // convert by celberus RGBQUAD RGB[256]; // by celberus if (iMainImage->uBitmap->BitsPerPixel == 8) { iMainImage->uBitmap->GetColors(0, 256, RGB); // by celberus ¹é±×¶ó¿îµå color¸¦ ¿ÏÀü °ËÁ¤»öÀ¸·Î ¹Ù²Ù°í enlargeÇÒ °æ¿ì ¹ß»ýÇÏ´Â ¿¡·¯ ¶§¹®¿¡.. FullViewForm->GetZoomRatio(iMainImage, zi, zo); // convert by celberus iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (8), RGB); // convert by celberus } else { FullViewForm->GetZoomRatio(iMainImage, zi, zo); // convert by celberus iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (24)); // convert by celberus } // FullViewForm->FormResize(this); // for PFM by celberus UpdateImage(); // ::RepaintColor(); // for PFM by celberus AllocLineMem(iMainImage->uBitmap->Height); ReviewStatusBar(); // Modify = false; END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::ResizePattern (TPCanvasInfor &pi, int bpp, bool layer) { BEGIN_LOG(""); RGBQUAD rgb[256]; TPException ec = EC_NONE; if (pi.SizeType != cstFree) { pi.Width = pi.GetWidth(); pi.Height = pi.GetHeight(); } CanvasInfor = pi; CanvasInfor.SetExtFileOption(); Ruler->DPI = CanvasInfor.DotsPerInch; if (layer == false) { if (!iMainImage->uBitmap->Create(CanvasInfor.Width, CanvasInfor.Height, bpp) ) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if(WorkArea) {delete WorkArea; WorkArea = NULL;} } // if ((WorkArea = new TPWorkArea(&(iMainImage->uBitmap->RgnBitmap))) == NULL ) goto fail; //convert by celberus // ÆÄÀÏ ·ÎµåÇÒ¶§ RgnBitmapÀÇ Æ÷ÀÎÅͰªÀÌ ¹Ù²î¹Ç·Î workarea¸¦ ¸®¼ÂÇØÁÖ¾î¾ß ÇÑ´Ù. WorkArea->BitsPerPixel = bpp; // convert by celberus speed-test // RgnBitmapÀº bpp°¡ 1À̱⠶§¹®¿¡ WorkAreaÀÇ BitsperPixelÀ» ¿©±â¼­ ¹Ù²ãÁØ´Ù. if (!AllocLineMem(CanvasInfor.Height)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } ReviewStatusBar(); END_LOG; return true; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::InitMerge(String FullFileName, TGraphicFileFormat Index) { BEGIN_LOG(""); // ¾Æ·¡¿¡¼­ Set MainMenuForm->ItemÀ» ó¸®Çϴµ¥ ExitFormÀ» ÇÏÁö ¾ÊÀ¸¸é SetÀü¿¡ »ç¿ëÇÏ´ø ³»¿ëÀ» // Áö¿ì°Å³ª ³¡³»Áö ¾Ê±â ¶§¹®¿¡ ¸ÕÀú ExitFormÀ» ó¸®ÇÑ´Ù. Vector´Â VectorFormÀ» ±âÁØÀ¸·Î Çϴµ¥ // ExitFormÀ» ÇÏÁö ¾Ê°í ó¸®Çϸé MainMenuÀÇ Form Size¸¸ º¯°æµÇ°í VectorFormÀÌ »èÁ¦µÇÁö ¾Ê¾Æ // Copy, Paste¸¦ ½ÇÇàÇÒ ¶§ VecDrawÀÇ Copy, Paste°¡ ½ÇÇàµÇ´Â ¹®Á¦°¡ ¹ß»ýÇÑ´Ù. if (MainMenuForm->Item != T_NONE || MainMenuForm->Item != T_MERGE) { MainMenuForm->ExitForm(1); } int i, x, y, bg, UseColor; TPCanvasInfor ci; TRect r; RGBQUAD rgb[256]; Byte *pp = NULL, *mp = NULL, mm; bool undoSw = false; TPalette *TempPalette = NULL; COLORREF bgc, c; TPException ec = EC_NONE; // r = Rect(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); // if ((undoSw = UndoSave(UK_ALL, r)) == false) goto fail; if ((undoSw = UndoSave(UK_ALL, Rect(0, 0, 0, 0))) == false) goto fail; iMainImage->SubEnabled = true; if ((TempPalette = new TPalette) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } switch(FullViewForm->Super) { case sOff: if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = LoadToSelectImage(FullFileName, Index, TempBitmap, TempPalette, ci)) != EC_NONE) goto fail; TempBitmap->ResizeStretch(ci.Width, ci.Height, false); // By GreenFish if (iMainImage->Reflection && reflection) { if (TempBitmap->Width > reflection->BitmapWidth || TempBitmap->Height > reflection->BitmapHeight) { ec = EC_BIG_SIZE; goto fail; } } else { if (TempBitmap->Width > iMainImage->uBitmap->Width || TempBitmap->Height > iMainImage->uBitmap->Height) { ec = EC_BIG_SIZE; goto fail; } } if (iMainImage->uBitmap->BitsPerPixel == 8) { if (TempBitmap->BitsPerPixel != 8) { ec = EC_COLOR_OVERFLOW; goto fail; } bg = 0; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < TempBitmap->Height; y++) { pp = TempBitmap->GetScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if (*(pp + x) == 1) { bg = 1; goto next1; } } TempBitmap->PutScanLine(y); } next1: TempBitmap->StopScanLine(); SetOldUseColor(Palette->UseColor); // ¹Ø¿¡¼­ À§·Î ¿Å±è by celberus if (Palette->UseColor + TempPalette->UseColor - 2 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } UseColor = Palette->UseColor - 1 + bg; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < TempBitmap->Height; y++) { pp = TempBitmap->GetScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { *(pp + x) += UseColor; } TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); for (i = 2 - bg; i <= TempPalette->UseColor; i++) { Palette->ColorData[UseColor + i] = TempPalette->ColorData[i]; } // FOldUseColor = Palette->UseColor; // SetOldUseColor(Palette->UseColor); Palette->UseColor = UseColor + TempPalette->UseColor; if (Palette->UseColor > 251) Palette->UseColor = 251; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } iMainImage->SubMask->FillRect (Rect(0, 0, iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height), PALETTEINDEX(0)); } else { if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } iMainImage->SubMask->FillRect (Rect(0, 0, iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height), PALETTEINDEX(0)); } break; case sOverlap: case sNormal: case sGauze: if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = LoadToSelectImage(FullFileName, Index, TempBitmap, TempPalette, ci)) != EC_NONE) goto fail; //None °æ¿ì¿¡¸¸ 󸮰¡ µÇ¾îÁ® ÀÖ¾ú´Ù. ±×·¡¼­ Ãß°¡ÇÔ. //dpi¿¡ µû¶ó À̹ÌÁö »çÀÌÁ Á¶ÀýÇÏ´Â ÇÔ¼öÀÌ´Ù. by david 110513 TempBitmap->ResizeStretch(ci.Width, ci.Height, false); // By GreenFish if (TempBitmap->Width > iMainImage->uBitmap->Width || TempBitmap->Height > iMainImage->uBitmap->Height) { ec = EC_BIG_SIZE; goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { SetOldUseColor(Palette->UseColor); // by celberus ¿ø·¡ ¾ø¾úÀ½ if (TempBitmap->BitsPerPixel != 8) { ec = EC_COLOR_OVERFLOW; goto fail; } if (Palette->UseColor + TempPalette->UseColor - 2 >= 252) { ec = EC_COLOR_OVERFLOW; goto fail; } if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } UseColor = Palette->UseColor - 1; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < TempBitmap->Height; y++) { pp = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); for (x = 0; x < TempBitmap->Width; x++, pp++, mp++) { if (*pp < 2) { *pp = 0; *mp = 0xFF; } else { *pp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); } TempBitmap->StopScanLine(); TempMask->StopScanLine(); for (i = 2; i <= TempPalette->UseColor; i++) { Palette->ColorData[UseColor + i] = TempPalette->ColorData[i]; } Palette->UseColor = UseColor + TempPalette->UseColor; if (Palette->UseColor > 251) Palette->UseColor = 251; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); TempMask->PutColors(0, 256, rgb); if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (TempMask) delete TempMask; if ((TempMask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->BitsPerPixel == 8) { TempBitmap->GetColors(0, 256, rgb); if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < TempBitmap->Height; y++) { pp = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); for (x = 0; x < TempBitmap->Width; x++, pp++, mp++) { if (*pp < 2) { if (Index != gffBMP) { *pp = 0; *mp = 0xFF; } } else *mp = 0; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } else { bgc = TempPalette->Color[1]; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < TempBitmap->Height; y++) { pp = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); x = 0; *mp = 0; mm = 0x80; while (1) { GetPixel24(pp, c); if (c == bgc) { SetPixel24(pp, 0); *mp |= mm; } x++; if (x >= TempBitmap->Width) break; pp += 3; if (mm == 1) { mp++; *mp = 0; mm = 0x80; } else mm >>= 1; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1) ) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } break; } iMainImage->SubVisible = false; // by celberus Èæ¹é À̹ÌÁö ¹®Á¦ ¶§¹®¿¡ iMainImage->InitBackGround(0x01); PenManagerForm->SetColor(Palette); Center.x = iMainImage->SubBitmap->Width / 2; Center.y = iMainImage->SubBitmap->Height / 2; MainMenuForm->Item = T_MERGE; MainMenuForm->SubItem = 0; ::RepaintColor(); delete TempPalette; END_LOG; return true; fail: if (TempPalette) { if (TempBitmap) { doDestroy(TempMask)delete TempBitmap; TempBitmap = NULL; } delete TempPalette; } ExitMerge(); if (undoSw == true) { MainImageForm->Undo->UndoRead(); // MainImageForm->Undo->RemoveLast(); // 8.1¿¡¼­ ²À Áö¿ö! } EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ExitMerge() { BEGIN_LOG(""); iMainImage->SubEnabled = false; iMainImage->SubVisible = false; iMainImage->ExitBackGround(0x01); // if(iMainImage->uBitmap->BitsPerPixel!=24){ if (iMainImage->uBitmap->BitsPerPixel == 8) { Palette->UseColor = (FOldUseColor > 0) ? FOldUseColor : 1; PaletteForm->DIB256Palette->UseColor = FOldUseColor; // shin palette if (Palette->ColorCount < Palette->UseColor + 1) Palette->ColorCount = Palette->UseColor + 1; } doDestroy(TempBitmap)doDestroy(TempMask) if (VectorForm && VecDraw->NVector && VecDraw->NVector->bMergeMode) VecDraw->ExitMerge(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ExitIndex() { if ((HIndexSelected || VIndexSelected)) { // À̵¿Áß¿¡ ÀÚ Å¬¸¯½Ã À妽º Á¦°Å Ruler->Cursor = crDefault; HIndexSelected = false; VIndexSelected = false; HIM = VIM = NULL; iMainImage->Repaint(); IndexSW = false; } } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToFile(String dn, String fn, TGraphicFileFormat Index, TCompressMethod cm) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256], Btrgb[256]; TTexpiaBitmap *tag = NULL, *tb = NULL; HDC dcSrc = NULL, dcTmp = NULL; TPException ec = EC_NONE; bool layer; DWORD dwWrite; TUnionBitmap *ub = NULL, *BtTemp = NULL; // ºñÆ®¸Ê Àӽà ÀúÀå By GreenFish // convert by celberus TPLayer *lay = NULL; TPLayerImage *iTempImage; bool SaveVectorToBitmap = false; bool bAntialiasing = true; int Value = 0; // Å« »çÀÌÁî ºñÆ®¸ÊÀ» ÀúÀåÇÒ ¼ö ÀÖµµ·Ï ¼öÁ¤ - by monkman (2006.06.02) TUnionBitmap *ubSaveBitmap = NULL; BYTE *pSrc = NULL, *pDst = NULL; try { #ifdef TRIAL if (Index == gffTEX_TRIAL || Index == gffTFC_TRIAL) { #else if (Index == gffTEX || Index == gffTFC) { #endif if ((ec = SaveToTEXTFC(dn, fn, cm, TextileFileVersion)) != EC_NONE) goto fail; } #ifdef TRIAL else if (Index == gffVST_TRIAL) { if ((ec = SaveToVST(dn, fn, cm, TextileFileVersion)) != EC_NONE) goto fail; } #else else if (Index == gffVST) { if ((ec = SaveToVST(dn, fn, cm, TextileFileVersion)) != EC_NONE) goto fail; } else if (Index == gffVST10) { if ((ec = SaveToVST(dn, fn, cm, TextileFileVersion10)) != EC_NONE) goto fail; } #endif #ifdef TRIAL else if (Index == gffT3D_TRIAL) { #else else if (Index == gffT3D10) { if (MainForm->T3D_Item) { if ((ec = SaveToT3D(dn, fn, cm, TextileFileVersion10)) != EC_NONE) goto fail; } } else if (Index == gffT3D) { #endif if (MainForm->T3D_Item) { if ((ec = SaveToT3D(dn, fn, cm, TextileFileVersion)) != EC_NONE) goto fail; } } #ifdef NOTN3D #else else if (Index == gffN3D) { // N3D_jeegeo if (MainForm->T3D_Item) { if ((ec = SaveToN3D(dn, fn, cm)) != EC_NONE) goto fail; } } #endif #ifndef TRIAL else if (Index == gffTEX10 || Index == gffTFC10) { if ((ec = SaveToTEXTFC(dn, fn, cm, TextileFileVersion10)) != EC_NONE) goto fail; } #endif // else if (Index == gffOldTEX || Index == gffOldTFC) { // SaveToOldFile(dn, fn, Index, cm); // } else if (Index == gffSVG) { // for SVG - by maxleo21c (2006/06/17) if ((ec = SaveToSVG(dn, fn, Index)) != EC_NONE) goto fail; } else { if ((ec = SaveToAnotherFileFormat(dn, fn, Index)) != EC_NONE) goto fail; } // TFC formatÀÇ °æ¿ì EnvironmentÀÇ AutoSaveJpg°¡ CheckµÇ¾î ÀÖÀ¸¸é jpg formatÀ¸·Î Ãß°¡ ÀúÀå if (Index == gffTFC && MainForm->bAutoSaveJpg == true) { String sFileName = FullPathName(dn, fn); String jpgFileName = sFileName; String ext = ExtractFileExt(sFileName); jpgFileName.Delete(jpgFileName.Pos(ext), jpgFileName.Length()); jpgFileName = MainForm->FMOnFileName(jpgFileName, gffJPG); AdditionalSaveJpg(jpgFileName); } } catch(...) { SAVE_EXCEPTION(EC_NO_MESSAGE); goto fail; } if (!MainForm->WaSave && !MainForm->MoSave) { FileName = fn; DirName = dn; SetCaption(); gff = Index; // by jeegeo } // if (dn!=DirectoryItem) SetCaption(); // dn ÀÌ directoryItem°ú °°À¸¸é ¸ðƼºê ÀúÀåÀ̹ǷΠĸ¼Ç X Modify = false; // 2002.10.22. by lhskys ÀúÀå½Ã¿¡ ´Ù½Ã ÀúÀå ¹¯Áö ¾Ê±â. END_LOG; return EC_NONE; fail: if (ub) delete ub; if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; } if (ubSaveBitmap) delete ubSaveBitmap; if (dcSrc) iMainImage->uBitmap->DeleteDC(dcSrc); // speed-test if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToOldFile(String dn, String fn, TGraphicFileFormat Index, TCompressMethod cm) { /* BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256], Btrgb[256]; TTexpiaBitmap *tag = NULL, *tb = NULL; HDC dcTmp = NULL, dcDst = NULL; TPException ec = EC_NONE; bool layer; DWORD dwWrite; TTexpiaBitmap *BtTemp = NULL; // ºñÆ®¸Ê Àӽà ÀúÀå By GreenFish TUnionBitmap *ub = NULL; TPLayer *lay = NULL; try { if (Index == gffOldTEX || Index == gffOldTFC) { if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } tpfh.Version = TexVersion('P', 'T', TextileFileVersionOld); tpfh.CanvasInfor = CanvasInfor; tpfh.CanvasInfor.Width = iMainImage->uBitmap->Width; // abcdabcdabcd tpfh.CanvasInfor.Height = iMainImage->uBitmap->Height; // abcdabcdabcd tpfh.BitsPerPixel = iMainImage->uBitmap->BitsPerPixel; tpfh.Compress = cm; if (WorkArea->Mask) { src = WorkArea->Range; } if (iMainImage->LayerList->Count > 1) { // ·¹À̾î ÀÖÀ»¶§ if ((tb = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { iMainImage->uBitmap->GetColors(0, 256, rgb); if (!tb->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!tb->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (MainForm->MoSave == true) { // Motive save½Ã¿¡´Â ÇÑÀåÀÇ Layer¸¸ lay = (TPLayer*)iMainImage->LayerList->Items[iMainImage->Index]; if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } lay->LBitmap->UnionBitBlt(dcTmp, 0, 0, lay->LBitmap->Width, lay->LBitmap->Height, 0, 0, SRCCOPY, false); tb->DeleteDC(dcTmp); dcTmp = NULL; // tb->Copy(lay->LBitmap, SRCCOPY); } else { // ÀÏ¹Ý FileSave½Ã¿¡´Â Àü Layer¸¦ ÇÕÃļ­ ÀúÀå if ((ub = iMainImage->Composition()) == NULL) goto fail; if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ub->UnionBitBlt(dcTmp, 0, 0, ub->Width, ub->Height, 0, 0, SRCCOPY, false)) goto fail; tb->DeleteDC(dcTmp); dcTmp = NULL; delete ub; // if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // iMainImage->FullViewPaint(dcTmp, 1, 1); // tb->DeleteDC(dcTmp); dcTmp = NULL; } if (WorkArea->Mask) { tpfh.CanvasInfor.DotsPerInch = tpfh.CanvasInfor.DotsPerInch; tpfh.CanvasInfor.SetSize(cstFree, src.Right - src.Left, src.Bottom - src.Top); Byte *mp, *bp; // ºÎºÐ ÀúÀå½Ã ÀÛ¾÷±¸¿ª¸¸ ÀúÀåÇϵµ·Ï By GreenFish if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!tb->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (tb->BitsPerPixel == 8) { for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = tb->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(z); bp += src.left; for (int x = 0; x < src.right - src.left; x++, mp++) { if (*mp) { if (MainForm->WaSave) { TColor TempC = clBlack; // Palette->ColorData[0]->Color; *(bp + x) = TempC; // 0x00; //2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... } } else { if (MainForm->WaSave) { TColor TempW = clWhite; // Palette->ColorData[0]->Color; *(bp + x) = TempW; // 0x00; } else *(bp + x) = 1; } } tb->PutScanLine(y); } WorkArea->Mask->StopScanLine(); tb->StopScanLine(); } else { // Full Color TColor TempC = Palette->ColorData[1]->Color; for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = tb->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(z); bp += src.left * 3; for (int x = 0; x < src.right - src.left; x++, bp += 3) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { if (MainForm->WaSave) { TColor TempW = clWhite; *bp = clWhite; *(bp + 1) = clWhite; *(bp + 2) = clWhite; } else { *(bp + 2) = TempC & 0xFF; *(bp + 1) = (TempC >> 8) & 0xFF; *bp = (TempC >> 16) & 0xFF; } } else if (MainForm->WaSave) { // 2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... *bp = 0x00; *(bp + 1) = 0x00; *(bp + 2) = 0x00; } } tb->PutScanLine(y); } WorkArea->Mask->StopScanLine(); tb->StopScanLine(); } } else { src.Left = 0; src.Top = 0; src.Right = tb->Width; src.Bottom = tb->Height; } // ============= if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MakeTexpiaTag(tag, tb, src, 0); ////////////// if (!MainForm->MoSave && !MainForm->WaSave) { // ¸ðƼºê save½Ã¿¡´Â º¤ÅÍ Ç¥Çö X HDC dcTemp = NULL; if ((dcTemp = tag->CreateDC()) == NULL) goto fail; VecDraw->TagDraw(dcTemp, tag->Width, tag->Height, src, 2, NULL, tpfh.Version.Number); tag->DeleteDC(dcTemp); dcTemp = NULL; } //////// Vector Tag By GreenFIsh if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb, &WorkArea->Range) ) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } layer = true; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; if (WorkArea && WorkArea->Mask) { if (!iMainImage->SaveToLayerFile(hFile, WorkArea->Range, tpfh.Version.Number)) goto fail; } else { if (!iMainImage->SaveToLayerFile(hFile, tpfh.Version.Number)) goto fail; } delete tb; } else { // Layer ¾øÀ»¶§ if ((tb = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { iMainImage->uBitmap->GetColors(0, 256, rgb); if (!tb->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!tb->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } iMainImage->uBitmap->UnionBitBlt (dcTmp, 0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 0, 0, SRCCOPY, false); tb->DeleteDC(dcTmp); dcTmp = NULL; if (WorkArea->Mask) { tpfh.CanvasInfor.DotsPerInch = tpfh.CanvasInfor.DotsPerInch; tpfh.CanvasInfor.SetSize(cstFree, src.Right - src.Left, src.Bottom - src.Top); Byte *mp = NULL, *bp = NULL; // ºÎºÐ ÀúÀå½Ã ÀÛ¾÷±¸¿ª¸¸ ÀúÀåÇϵµ·Ï By GreenFish if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!tb->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = tb->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(z); bp += src.left; for (int x = 0; x < src.right - src.left; x++, mp++) { if (*mp) { if (MainForm->WaSave) { TColor TempC = clBlack; // Palette->ColorData[0]->Color; *(bp + x) = TempC; // 0x00; //2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... } } else { if (MainForm->WaSave) { TColor TempW = clWhite; // Palette->ColorData[0]->Color; *(bp + x) = TempW; // 0x00; } else *(bp + x) = 1; } } tb->PutScanLine(y); } WorkArea->Mask->StopScanLine(); tb->StopScanLine(); } else { // Full Color TColor TempC = Palette->Color[1]; for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = tb->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(z); bp += src.left * 3; for (int x = 0; x < src.right - src.left; x++, bp += 3) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { if (MainForm->WaSave) { TColor TempW = clWhite; *bp = clWhite; *(bp + 1) = clWhite; *(bp + 2) = clWhite; } else { *(bp + 2) = TempC & 0xFF; *(bp + 1) = (TempC >> 8) & 0xFF; *bp = (TempC >> 16) & 0xFF; } } else if (MainForm->WaSave) { // 2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... *bp = 0x00; *(bp + 1) = 0x00; *(bp + 2) = 0x00; } } tb->PutScanLine(y); } WorkArea->Mask->StopScanLine(); tb->StopScanLine(); } } else { src.Left = 0; src.Top = 0; src.Right = tb->Width; src.Bottom = tb->Height; } if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MakeTexpiaTag(tag, tb, src, 0); ////////////// if (!MainForm->MoSave && !MainForm->WaSave) { HDC dcTemp = NULL; if ((dcTemp = tag->CreateDC()) == NULL) goto fail; VecDraw->TagDraw(dcTemp, tag->Width, tag->Height, src, 2, NULL, tpfh.Version.Number); tag->DeleteDC(dcTemp); dcTemp = NULL; } //////// Vector Tag By GreenFish (MainImage¿¡ 4±ºµ¥°¡ ÀÖÀ½) if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb, &WorkArea->Range) ) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; delete tb; } if (!MainForm->MoSave && !MainForm->WaSave) if (!VecDraw->SaveToFile(hFile, NVector->DataList, 2, TextileFileVersion10, MainImageForm->Number)) { // Vector File Save~ ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } CloseHandle(hFile); if (tag) { delete tag; tag = NULL; } // if (dn!=DirectoryItem){ DirName = dn; FileName = fn;} // if (WorkArea->Mask) { caution qe ±»ÀÌ ÇÊ¿ä¾øÁÒ? // iMainImage->uBitmap->Copy(src.left,src.top,src.right-src.left,src.bottom-src.top,BtTemp,0,0,SRCCOPY); // BtTemp ¿¡ tb¸¦ º¸°ü // delete BtTemp; BtTemp = NULL; // º¸°üÇß´ø ºñÆ®¸ÊÀ» ´Ù½Ã tb·Î // } } } catch(...) { SAVE_EXCEPTION(EC_NO_MESSAGE); goto fail; } END_LOG; return EC_NONE; fail: if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; } if (ub) delete ub; if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; */ } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SubBitmapPosition(int X, int Y, bool paint) { // check initial condition strictly TPException ec = EC_NONE; if (!iMainImage) return; if (!iMainImage->uBitmap || !iMainImage->SubBitmap) return; // remove useless variables // bool undoSw = false; // TRect dst; // get sub-range area and the position paintrect = iMainImage->SubRange; POINT p = Point(X - Center.x, Y - Center.y); // set merge position as mouse moves if (!VecDraw) return; BEGIN_LOG(""); RECT vector_r = VecDraw->SetMergePosition(X, Y, paintrect, paint); // Vector¿¡¼­µµ Merge if (p.x < 0) p.x = 0; else if (p.x > iMainImage->uBitmap->Width - iMainImage->SubBitmap->Width) p.x = iMainImage->uBitmap->Width - iMainImage->SubBitmap->Width; // forbid SubBitmap to be out of iMainImage area (y-direction) if (p.y < 0) p.y = 0; else if (p.y > iMainImage->uBitmap->Height - iMainImage->SubBitmap->Height) p.y = iMainImage->uBitmap->Height - iMainImage->SubBitmap->Height; iMainImage->SubRange.left = p.x; iMainImage->SubRange.top = p.y; iMainImage->SubRange.right = p.x + iMainImage->SubBitmap->Width; iMainImage->SubRange.bottom = p.y + iMainImage->SubBitmap->Height; iMainImage->SubVisible = true; if (iMainImage->Reflection){ POINT rpt = reflection->FindOriginalPos(p.x, p.y); p.x = rpt.x; p.y = rpt.y; if (p.x < 0){ p.x = reflection->BitmapRange.left; } if (p.y < 0){ p.y = reflection->BitmapRange.top; } } // if TempBitmap exists, save the sub-image into Undo if (TempBitmap) { Undo->SaveData(iMainImage->SubRange); IsMerge(p); } // set rectangular area for drawing and paint it if (paint) { RECT r; r.left = min(vector_r.left, iMainImage->SubRange.left); r.top = min(vector_r.top, iMainImage->SubRange.top); r.right = max(vector_r.right, iMainImage->SubRange.right); r.bottom = max(vector_r.bottom, iMainImage->SubRange.bottom); if (iMainImage->Reflection){ RECT rt; if (reflection->ChangeRectPaintRange(r, rt)){ iMainImage->RectPaint(rt); } else { iMainImage->SubRange.left = -iMainImage->SubBitmap->Width; iMainImage->SubRange.top = -iMainImage->SubBitmap->Height; iMainImage->SubRange.right = -1; iMainImage->SubRange.bottom = -1; } } else { iMainImage->RectPaint(r); //k3dogs } //iMainImage->RectPaint(r); } END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- String __fastcall TMainImageForm::UnitName(TUnit unit) { if (unit == uDot) return "Dot"; else if (unit == uInch) return "Inch"; else if (unit == uCm) return "Cm"; else return ""; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::UnitChange(TUnit unit) { CurrentUnit = unit; Ruler->AUnit = CurrentUnit; if (CurrentUnit == uDot) sbUnit->Caption = String(IDS_UNIT) + " : Dot"; else if (CurrentUnit == uInch) sbUnit->Caption = String(IDS_UNIT) + " : Inch"; else if (CurrentUnit == uCm) sbUnit->Caption = String(IDS_UNIT) + " : Cm"; FullViewForm->UnitChange(); MainMenuForm->UnitChange(); if (LibraryForm) LibraryForm->UnitChange(); ReviewStatusBar(); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChange(int zi, int zo, POINT *ptScreen) { POINT ptClient; String sbZoom; if (zi != iMainImage->ZoomIn || zo != iMainImage->ZoomOut) { // º¤ÅÍ ÆíÁýµµÁß È®´ëÃà¼Ò¸¦ ÇÏ´Â °æ¿ì´Â bVectorModify¸¦ false·Î ÇØ¼­ FVecModifyBitmapÀ» º¯°æ½ÃÄÑÁÖ¾î¾ßÇÔ. if ((VectorForm && iMainImage->bVectorModify && (VectorForm->V_Item == M_O_EDIT || VectorForm->V_Item == M_O_PROPORTION || VectorForm->V_Item == M_O_ROTATION))) iMainImage->bVectorModify = false; iMainImage->isZoomChanged = true; // by celberus iMainImageChange(); if (ptScreen) { ptClient = iMainImage->ScreenToClient(*ptScreen); iMainImage->SetZoom(zi, zo, &ptClient); } else { iMainImage->SetZoom(zi, zo); } Ruler->Zoom = (double)zi / zo; FullViewForm->SetZoom(); } ShowZoomText(); // InitCurveLine(); // ÁÖ¼®À¸·Î ó¸® by maxleo21c (05.06.04) } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ShowZoomText() { String sbZoom; switch(iMainImage->ZoomIn) { case 1: switch(iMainImage->ZoomOut) { case 1: sbZoom = "Zoom : 1"; break; case 2: sbZoom = "Zoom : 1/2"; break; case 3: sbZoom = "Zoom : 1/3"; break; case 4: sbZoom = "Zoom : 1/4"; break; case 6: sbZoom = "Zoom : 1/6"; break; case 8: sbZoom = "Zoom : 1/8"; break; case 12: sbZoom = "Zoom : 1/12"; break; case 16: sbZoom = "Zoom : 1/16"; break; } break; case 2: switch(iMainImage->ZoomOut) { case 1: sbZoom = "Zoom : 2"; break; case 3: sbZoom = "Zoom : 2/3"; break; } break; case 3: switch(iMainImage->ZoomOut) { case 1: sbZoom = "Zoom : 3"; break; case 2: sbZoom = "Zoom : 3/2"; break; } break; case 4: sbZoom = "Zoom : 4"; break; case 6: sbZoom = "Zoom : 6"; break; case 8: sbZoom = "Zoom : 8"; break; case 12: sbZoom = "Zoom : 12"; break; case 16: sbZoom = "Zoom : 16"; break; } MainForm->StatusBar->Panels->Items[StatusBarZoom]->Text = sbZoom; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChangeIn(POINT ptScreen) { switch(iMainImage->ZoomIn) { case 1: switch(iMainImage->ZoomOut) { case 1: ZoomChange(2, 1, &ptScreen); break; case 2: ZoomChange(1, 1, &ptScreen); break; case 4: ZoomChange(1, 2, &ptScreen); break; case 8: ZoomChange(1, 4, &ptScreen); break; case 16: ZoomChange(1, 8, &ptScreen); break; } break; case 2: ZoomChange(4, 1, &ptScreen); break; case 4: ZoomChange(8, 1, &ptScreen); break; case 8: ZoomChange(16, 1, &ptScreen); break; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChangeOut(POINT ptScreen) { switch(iMainImage->ZoomIn) { case 1: switch(iMainImage->ZoomOut) { case 1: ZoomChange(1, 2, &ptScreen); break; case 2: ZoomChange(1, 4, &ptScreen); break; case 4: ZoomChange(1, 8, &ptScreen); break; case 8: ZoomChange(1, 16, &ptScreen); break; } break; case 2: ZoomChange(1, 1, &ptScreen); break; case 4: ZoomChange(2, 1, &ptScreen); break; case 8: ZoomChange(4, 1, &ptScreen); break; case 16: ZoomChange(8, 1, &ptScreen); break; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::set_hline(int x, int y, int len, COLORREF c) { if (x >= iMainImage->uBitmap->Width || y < 0 || y >= iMainImage->uBitmap->Height) return; if (iMainImage->Reflection && reflection) { if (x >= reflection->BitmapRange.right || y < reflection->BitmapRange.top || y >= reflection->BitmapRange.bottom) return; if (x < reflection->BitmapRange.left) { len -= (reflection->BitmapRange.left - x); x = reflection->BitmapRange.left; if (len <= 0) return; } else if (x + len >= reflection->BitmapRange.right) { len = reflection->BitmapRange.right - x; if (len <= 0) return; } } else { if (x < 0) { len += x; x = 0; if (len <= 0) return; } } if (x + len > iMainImage->uBitmap->Width) len = iMainImage->uBitmap->Width - x; Undo->SaveData(x, y, len); // by linuxjun if (iMainImage->LayerMask) { if (bProtect) if (!(iMainImage->BackGround->StartScanLine())) goto fail; if (FOnSetHLine) FOnSetHLine(x, y, len, c); } else if (FOnSetHLine) FOnSetHLine(x, y, len, c); return; fail: if (bProtect) iMainImage->BackGround->StopScanLine(); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLine8ColorNo (int x, int y, int len, COLORREF c) { Byte *bp = NULL, *mp = NULL, *lp = NULL, *gp = NULL; bp = iMainImage->uBitmap->GetScanLine(y, x, len); // if (iMainImage->LayerMask) { lp = iMainImage->LayerMask->GetScanLine(y, x, len); // if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y, x, len); // if (bProtect) { // gp = iMainImage->BackGround->GetScanLine(y); for (int i = 0; i < len; i++) { // if ((Palette->ColorData[gp[x + i]]->Protect == 0) && (mp[x + i] == 0)) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (mp[x + i] == 0) ) { bp[x + i] = c; lp[x + i] = 0; } } } else { for (int i = 0; i < len; i++) { if (mp[x + i] == 0) { bp[x + i] = c; lp[x + i] = 0; } } } } else { if (bProtect) { // gp = iMainImage->BackGround->GetScanLine(y); for (int i = 0; i < len; i++) { // if (Palette->ColorData[gp[x + i]]->Protect == 0) { if (Palette->ColorData[bp[x + i]]->Protect == 0) { bp[x + i] = c; lp[x + i] = 0; } } } else { memset(bp + x, c, len); memset(lp + x, 0, len); } } iMainImage->LayerMask->PutScanLine(y, x, len); // } else { if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y, x, len); // if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (mp[x + i] == 0) ) { bp[x + i] = c; } } } else { for (int i = 0; i < len; i++) { if (mp[x + i] == 0) bp[x + i] = c; } } } else { if (bProtect) { for (int i = 0; i < len; i++) { if (Palette->ColorData[bp[x + i]]->Protect == 0) { bp[x + i] = c; } } } else { memset(bp + x, c, len); } } } iMainImage->uBitmap->PutScanLine(y, x, len); // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLine8ColorYes (int x, int y, int len, COLORREF c) { Byte *bp = NULL, *mp = NULL, *lp = NULL, *gp = NULL; bp = iMainImage->uBitmap->GetScanLine(y, x, len); // if (iMainImage->LayerMask) { lp = iMainImage->LayerMask->GetScanLine(y, x, len); // gp = iMainImage->BackGround->GetScanLine(y); if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y, x, len); // if (bProtect) { for (int i = 0; i < len; i++) { // if ((Palette->ColorData[gp[x + i]]->Protect == 0) && (mp[x + i] == 0) //080408 layer¿¡¼­ »ç¿ëÇÑ »öÀ» Àç »ç¿ëÇÒ °æ¿ì »öº¸È£°¡ ¾ÈµÇ´Â // && (PenManagerForm->Selector->Number[gp[x + i]] != 255)) { //¹®Á¦¸¦ ¼öÁ¤Çϱâ À§Çؼ­ º¯°æ by david with hoochu if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (mp[x + i] == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; lp[x + i] = 0; } } } else { for (int i = 0; i < len; i++) { // if ((mp[x + i] == 0) && (PenManagerForm->Selector->Number[gp[x + i]] != 255)) { if ((mp[x + i] == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; lp[x + i] = 0; } } } } else { if (bProtect) { for (int i = 0; i < len; i++) { // if ((Palette->ColorData[gp[x + i]]->Protect == 0) && // (PenManagerForm->Selector->Number[gp[x + i]] != 255)) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; lp[x + i] = 0; } } } else { for (int i = 0; i < len; i++) { // if (PenManagerForm->Selector->Number[gp[x + i]] != 255) { if (PenManagerForm->Selector->Number[bp[x + i]] != 255) { bp[x + i] = c; lp[x + i] = 0; } } } } iMainImage->LayerMask->PutScanLine(y, x, len); // } else { if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y, x, len); // if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (mp[x + i] == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; } } } else { for (int i = 0; i < len; i++) { if ((mp[x + i] == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; } } } } else { if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; } } } else { for (int i = 0; i < len; i++) { if (PenManagerForm->Selector->Number[bp[x + i]] != 255) { bp[x + i] = c; } } } } } iMainImage->uBitmap->PutScanLine(y, x, len); // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLine24(int x, int y, int len, COLORREF c) { Byte *bp = NULL, *mp = NULL, *lp = NULL; bp = iMainImage->uBitmap->GetScanLine(y, x, len); // convert by celberus if (iMainImage->LayerMask) { lp = iMainImage->LayerMask->GetScanLine(y, x, len); // if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y, x, len); // for (int i = x; i < x + len; i++, bp += 3) { if ((mp[i >> 3] & (0x80 >> (i & 7))) == 0) { memset24(bp + 3 * x, c, 1); *(lp + (i >> 3)) &= ~(0x80 >> (i & 7)); } } } else { for (int i = x; i < x + len; i++, bp += 3) { memset24(bp + 3 * x, c, 1); *(lp + (i >> 3)) &= ~(0x80 >> (i & 7)); } } iMainImage->LayerMask->PutScanLine(y, x, len); // } else { if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y, x, len); // for (int i = x; i < x + len; i++, bp += 3) { if ((mp[i >> 3] & (0x80 >> (i & 7))) == 0) { memset24(bp + 3 * x, c, 1); } } } else { for (int i = x; i < x + len; i++, bp += 3) { memset24(bp + 3 * x, c, 1); } } } iMainImage->uBitmap->PutScanLine(y, x, len); // convert by celberus } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLineMask8 (int x, int y, int len, COLORREF c) { Byte *bp = NULL; bp = iMainImage->Mask->GetScanLine(y, x, len); // memset(bp + x, MaskPixel, len); iMainImage->Mask->PutScanLine(y, x, len); // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLineMask24 (int x, int y, int len, COLORREF c) { Byte *bp = NULL; bp = iMainImage->Mask->GetScanLine(y, x, len); // for (int i = x; i < x + len; i++) { bp[i >> 3] |= MaskPixel >> (i & 7); } iMainImage->Mask->PutScanLine(y, x, len); // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLineMaskDelete24 (int x, int y, int len, COLORREF c) { Byte *bp = NULL; bp = iMainImage->Mask->GetScanLine(y, x, len); // for (int i = x; i < x + len; i++) { bp[i >> 3] &= ~(0x80 >> (i & 7)); } iMainImage->Mask->PutScanLine(y, x, len); // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::dotted_pen(int x, int y, int cx, int cy, COLORREF c) { int i, PenType, ls, rs, len; double r, dx; PenType = PenManagerForm->Pen->Shape; len = PenManagerForm->Pen->Thick; r = len / 2.0; ls = (int)r; rs = len - ls; int xx = x, yy = y, ccx = cx, ccy = cy; if (iMainImage->Reflection && reflection) { POINT pt, ct; pt = reflection->FindOriginalPos(x, y); ct = reflection->FindOriginalPos(cx, cy); xx = pt.x; yy = pt.y; ccx = ct.x; ccy = ct.y; } if (PenType) { if (cy > yy) yy = yy - ls; if (cx < xx) xx = xx - ls; for (i = yy; i < yy + len; i++) set_hline(xx, i, len, c); } else { if (iMainImage->LayerMask) { if (!(iMainImage->LayerMask->StartScanLine())) goto fail; if (bProtect) if (!(iMainImage->BackGround->StartScanLine())) goto fail; } for (i = -ls; i < rs; i++) { dx = sqrt(r * r - i * i); set_hline(xx - dx, yy + i, 2 * dx, c); } if (iMainImage->LayerMask) { iMainImage->LayerMask->StopScanLine(); if (bProtect) iMainImage->BackGround->StopScanLine(); } } return; fail: if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); if (bProtect) iMainImage->BackGround->StopScanLine(); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::line_pen(int sx, int sy, int ex, int ey, COLORREF c, RECT *rect) { if (iMainImage->Reflection && reflection) { POINT st, et, pts, pte; if (sx < 0 && ex < 0) return; if (sy < 0 && ey < 0) return; if (sy < 0) sy = 0; if (ex < 0) ex = 0; if (ey < 0) ey = 0; st = reflection->FindOriginalPos(sx, sy); et = reflection->FindOriginalPos(ex, ey); if (sx == ex){ if (st.x < 0 && et.x < 0) return; if (st.y < 0 && et.y < 0) return; if (st.y < 0){ if (sy < ey) st.y = reflection->BitmapRange.top; else st.y = reflection->BitmapRange.bottom; } if (et.y < 0){ if (sy < ey) et.y = reflection->BitmapRange.bottom; else et.y = reflection->BitmapRange.top; } } if (sy == ey){ if (st.y < 0 && et.y < 0) return; if (st.x < 0 && et.x < 0) return; if (st.x < 0){ if (sx < ex) st.x = reflection->BitmapRange.left; else st.x = reflection->BitmapRange.right; } if (et.x < 0){ if (sx < ex) et.x = reflection->BitmapRange.right; else et.x = reflection->BitmapRange.left; } } DrawPen(st.x, st.y, et.x, et.y, c, rect); if (rect) { int dia = PenManagerForm->Pen->Thick; // lhskys draw ¿¡¼­ ÇÑÁ¡µÚ·Î ÇÒ¶§ Pen size°ªÀ» ÀÌ¿ë ±×¸®±â À§ÇØ... int ls = dia >> 1; int rs = dia - ls; rect->left = min(sx, ex) - ls; rect->top = min(sy, ey) - ls; rect->right = max(sx, ex) + rs; rect->bottom = max(sy, ey) + rs; } } else { DrawPen(sx, sy, ex, ey, c, rect); } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawPen(int sx, int sy, int ex, int ey, COLORREF c, RECT *rect) { int PenType, dia, ls, rs, w, h, sw, y, x, r, yyy; double d, r1, r2, xx, yy; TLineData ld; TPException ec = EC_NONE; PenType = PenManagerForm->Pen->Shape; dia = PenManagerForm->Pen->Thick; // lhskys draw ¿¡¼­ ÇÑÁ¡µÚ·Î ÇÒ¶§ Pen size°ªÀ» ÀÌ¿ë ±×¸®±â À§ÇØ... ls = dia >> 1; rs = dia - ls; w = iMainImage->uBitmap->Width; h = iMainImage->uBitmap->Height; for (y = 0; y < h; y++) { *(msx + y) = w; *(mex + y) = -1; } if (sy < ey) { ld.sy = sy; ld.ey = ey; ld.sx = sx; ld.ex = ex; } else { ld.sy = ey; ld.ey = sy; ld.sx = ex; ld.ex = sx; } if (ld.sy < 0) ld.sy = 0; else if (ld.sy > h) ld.sy = h; if (ld.ey < 0) ld.ey = 0; else if (ld.ey > h) ld.ey = h; r = PenType ? (ld.sx < ld.ex ? -(dia - 1) / 2 : ls) : 0; ld.psx1 = ld.sx - ls; ld.psy1 = ld.sy - r; ld.pex1 = ld.ex - ls; ld.pey1 = ld.ey - r; r = PenType ? (ld.sx < ld.ex ? ls : -(dia - 1) / 2) : 0; ld.psx2 = ld.sx + (dia - 1) / 2; ld.psy2 = ld.sy - r; ld.pex2 = ld.ex + (dia - 1) / 2; ld.pey2 = ld.ey - r; if (PenType || ld.ex - ld.sx == 0 || ld.ey - ld.sy == 0) { sw = 0; ld.d1 = ld.d2 = 0.0; ld.dx1 = ld.dx2 = ld.dy1 = ld.dy2 = 0.0; } else { sw = 1; ld.d1 = ld.d2 = (double)2.0 * h * h; d = fabs(atan((double)(ld.ex - ld.sx) / (ld.ey - ld.sy))); ld.dx1 = ld.sx - fabs(cos(d)) * ls; ld.dy1 = ld.sy + (ld.sx < ld.ex ? fabs(sin(d)) * ((dia - 1) / 2) : -fabs (sin(d)) * ls); ld.dx2 = ld.sx + fabs(cos(d)) * ((dia - 1) / 2); ld.dy2 = ld.sy - (ld.sx < ld.ex ? fabs(sin(d)) * ls : -fabs(sin(d)) * ((dia - 1) / 2)); } if (PenType) { if (dia & 1) { r1 = dia / 2.0; pos_in(ld, ld.sy, ld.sx - r1 + 1, ld.sx + r1, sw); pos_in(ld, ld.ey, ld.ex - r1 + 1, ld.ex + r1, 0); for (yyy = -r1; yyy <= r1; yyy++) { pos_in(ld, ld.sy + yyy, ld.sx - r1 + 1, ld.sx + r1, sw); pos_in(ld, ld.ey + yyy, ld.ex - r1 + 1, ld.ex + r1, 0); } } else { r1 = dia / 2.0; for (yy = 0.5; yy <= r1; yy += 1.0) { pos_in(ld, ld.sy - yy - 0.5, ld.sx - r1 + 0.5, ld.sx + r1 - 0.5, sw); pos_in(ld, ld.ey - yy - 0.5, ld.ex - r1 + 0.5, ld.ex + r1 - 0.5, 0); pos_in(ld, ld.sy + yy, ld.sx - r1 + 0.5, ld.sx + r1 - 0.5, sw); pos_in(ld, ld.ey + yy, ld.ex - r1 + 0.5, ld.ex + r1 - 0.5, 0); } } } else { if (dia & 1) { r1 = dia / 2.0; r2 = r1 * r1; pos_in(ld, ld.sy, ld.sx - r1 + 1, ld.sx + r1, sw); pos_in(ld, ld.ey, ld.ex - r1 + 1, ld.ex + r1, 0); for (yyy = -r1; yyy <= r1; yyy++) { xx = sqrt(fabs(r2 - yyy * yyy)); pos_in(ld, ld.sy + yyy, ld.sx - xx + 1, ld.sx + xx, sw); pos_in(ld, ld.ey + yyy, ld.ex - xx + 1, ld.ex + xx, 0); } } else { r1 = dia / 2.0; r2 = r1 * r1; for (yy = 0.5; yy <= r1; yy += 1.0) { xx = sqrt(r2 - yy * yy); pos_in(ld, ld.sy - yy - 0.5, ld.sx - xx + 0.5, ld.sx + xx - 0.5, sw); pos_in(ld, ld.ey - yy - 0.5, ld.ex - xx + 0.5, ld.ex + xx - 0.5, 0); pos_in(ld, ld.sy + yy, ld.sx - xx + 0.5, ld.sx + xx - 0.5, sw); pos_in(ld, ld.ey + yy, ld.ex - xx + 0.5, ld.ex + xx - 0.5, 0); } } } /** ************************************************************* */ /* ĵ¹ö½º »ó´Ü °æ°è¸é¿¡¼­ Line Drawing½Ã ¼±ÀÌ ¾ã¾ÆÁö´Â ¹®Á¦ ÇØ°á */ /** ************************************************************* */ if ((ey - r1) < 0 || (sy - r1) < 0) { // LineÀÇ ½ÃÀÛÁ¡À̳ª ³¡Á¡ÀÇ ºê·¯½¬°¡ »ó´Ü °æ°è¸é¿¡ °ÉÃÄÁö´Â °æ¿ì int swap = 0; // ½º¿Ò¿ë Àӽú¯¼ö double tansign = (sy - ey); // ±â¿ï±âÀÇ ºÎÈ£ ÆÇÁ¤º¯¼ö tansign = (ex - sx) > 0 ? tansign : -tansign; if (tansign == 0) { ld.psx1 = 0; ld.psy1 = 0; ld.pex1 = 0; ld.pey1 = 0; } else if (tansign > 0) { ld.psx1 = sx - (dia / 2) * abs(ey - sy) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); // ¹ÝÁö¸§ * Sin°ª ld.psy1 = sy - (dia / 2) * abs(ex - sx) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); // ¹ÝÁö¸§ * Cos°ª ld.pex1 = ex - (dia / 2) * abs(ey - sy) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); ld.pey1 = ey - (dia / 2) * abs(ex - sx) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); } else { ld.psx2 = sx + (dia / 2) * abs(ey - sy) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); ld.psy2 = sy - (dia / 2) * abs(ex - sx) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); ld.pex2 = ex + (dia / 2) * abs(ey - sy) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); ld.pey2 = ey - (dia / 2) * abs(ex - sx) / sqrt (abs(ex - sx) * abs(ex - sx) + abs(ey - sy) * abs(ey - sy)); } // ³¡Á¡ÀÌ »ó´Ü °æ°èºÎ¿¡ °ÉÄ¡´Â °æ¿ì ½ÃÀÛÁ¡°ú ³¡Á¡ÀÌ Á¤»óÀûÀ¸·Î ½º¿ÒµÇÁö ¾Ê´Â ¹®Á¦ ÇØ°á // peyÀÇ °ªÀÌ psyº¸´Ù ÀÛÀ» °æ¿ì µÎ Á¡ÀÇ °ªÀ» ½º¿ÒÇØ¼­ ½ÃÀÛÁ¡ÀÌ ÀÛÀº °ªÀ» °¡Áöµµ·Ï ÇÑ´Ù. // ±×·¯³ª, »ó´Ü °æ°è¸é¿¡ °ÉÄ¡´Â °æ¿ì´Â À§¿¡¼­¿Í °°ÀÌ ÀÛÁ¢ Æ÷ÀÎÆ® °ªÀ» Àâ¾ÆÁÖ¾ú±â ¶§¹®¿¡, // ÀϹÝÀûÀÎ ¹æ¹ýÀ¸·Î ½º¿ÒÀÌ µÇÁö ¾Ê¾Æ¼­ °­Á¦ÀûÀ¸·Î ½º¿ÒÀ» ÇØÁÖ¾ú´Ù. if ((ey - r1) < 0) { if (tansign >= 0) { swap = ld.psx1; ld.psx1 = ld.pex1; ld.pex1 = swap; swap = ld.psy1; ld.psy1 = ld.pey1; ld.pey1 = swap; } else { swap = ld.psx2; ld.psx2 = ld.pex2; ld.pex2 = swap; swap = ld.psy2; ld.psy2 = ld.pey2; ld.pey2 = swap; } } } // */ /** **************************************************************** 2007. 1. 10. By Altang. */ if (abs(ld.pex1 - ld.psx1) < abs(ld.pey1 - ld.psy1)) { d = (double)(ld.pex1 - ld.psx1) / (ld.pey1 - ld.psy1); for (y = ld.psy1; y <= ld.pey1; y++) { if (y >= 0 && y < h) * (msx + y) = d * (y - ld.psy1) + ld.psx1 + 0.5; } } else if (ld.psx1 - ld.pex1) { if (ld.pex1 < ld.psx1) { r = ld.psx1; ld.psx1 = ld.pex1; ld.pex1 = r; r = ld.psy1; ld.psy1 = ld.pey1; ld.pey1 = r; } d = (double)(ld.pey1 - ld.psy1) / (ld.pex1 - ld.psx1); for (x = ld.psx1; x <= ld.pex1; x++) { y = d * (x - ld.psx1) + ld.psy1 + 0.5; if (y >= 0 && y < h && x < *(msx + y)) * (msx + y) = x; } } if (abs(ld.pex2 - ld.psx2) < abs(ld.pey2 - ld.psy2)) { d = (double)(ld.pex2 - ld.psx2) / (ld.pey2 - ld.psy2); for (y = ld.psy2; y <= ld.pey2; y++) { if (y >= 0 && y < h) * (mex + y) = d * (y - ld.psy2) + ld.psx2 + 0.5; } } else if (ld.psx2 - ld.pex2) { if (ld.pex2 < ld.psx2) { r = ld.psx2; ld.psx2 = ld.pex2; ld.pex2 = r; r = ld.psy2; ld.psy2 = ld.pey2; ld.pey2 = r; } d = (double)(ld.pey2 - ld.psy2) / (ld.pex2 - ld.psx2); for (x = 0; x <= ld.pex2; x++) { y = d * (x - ld.psx2) + ld.psy2 + 0.5; if (y >= 0 && y < h && x > *(mex + y)) * (mex + y) = x; } } ld.sy -= ls; ld.ey += rs; if (!(iMainImage->uBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->LayerMask) { if (!(iMainImage->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (bProtect || PenManagerForm->acolor == 2) if (!(iMainImage->BackGround->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (iMainImage->Mask) { if (!(iMainImage->Mask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } for (y = ld.sy; y <= ld.ey; y++) { if (*(mex + y) >= 0 && *(msx + y) < w) { set_hline(*(msx + y), y, *(mex + y) - *(msx + y) + 1, c); } } if (iMainImage->LayerMask) { iMainImage->LayerMask->StopScanLine(); if (bProtect || PenManagerForm->acolor == 2) iMainImage->BackGround->StopScanLine(); } if (iMainImage->Mask) iMainImage->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); if (rect) { rect->left = min(sx, ex) - ls; rect->top = min(sy, ey) - ls; rect->right = max(sx, ex) + rs; rect->bottom = max(sy, ey) + rs; } return; fail: if (iMainImage->Mask) iMainImage->Mask->StopScanLine(); if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); if (bProtect || PenManagerForm->acolor == 2) iMainImage->BackGround->StopScanLine(); iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Reflection_DrawPen (int sx, int sy, int ex, int ey, COLORREF c, RECT *rect) { } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageChange() { FullViewForm->iMainImageChange(); MainMenuForm->iMainImageChange(this); // bmScreenResize(); // temp line } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::WorkAreaChange() { // MainForm->UpdateMenuItems() // È£ÃâÇÏ´Â ºÎºÐÀ» Àß ÆÇ´ÜÇÏ¿© ÁÖ¼®Ã³¸®Çϰí, // ÇÊ¿äÇÏ´Ù¸é WorkAreaChange()¸¦ È£ÃâÇÑ ÇÔ¼ö¿¡¼­ MainForm->UpdateMenuItems()¸¦ È£ÃâÇϵµ·Ï ¼öÁ¤ÇÑ´Ù // MainForm->UpdateMenuItems(NULL); PenManagerForm->WorkAreaChange(); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::WorkAreaReset(bool bUndo) { // MainForm->UpdateMenuItems() // È£ÃâÇÏ´Â ºÎºÐÀ» Àß ÆÇ´ÜÇÏ¿© ÁÖ¼®Ã³¸®Çϰí, // ÇÊ¿äÇÏ´Ù¸é WorkAreaReset()¸¦ È£ÃâÇÑ ÇÔ¼ö¿¡¼­ MainForm->UpdateMenuItems()¸¦ È£ÃâÇϵµ·Ï ¼öÁ¤ÇÑ´Ù WorkArea->Reset(bUndo); // MainForm->UpdateMenuItems(NULL); PenManagerForm->WorkAreaChange(); } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWholeColor(TChoiceColor *ChoiceColor) { BEGIN_LOG(""); int x, y; Byte *bp = NULL, *lp = NULL; int stx = 0, sty = 0, width = 0, height = 0; if (iMainImage->Reflection && MainImageForm->reflection) { stx = MainImageForm->reflection->BitmapRange.left; sty = MainImageForm->reflection->BitmapRange.top; width = MainImageForm->reflection->BitmapWidth; height = MainImageForm->reflection->BitmapHeight; } else { width = iMainImage->uBitmap->Width; height = iMainImage->uBitmap->Height; } if (!iMainImage->uBitmap->StartScanLine()) { END_LOG; return false; } if (iMainImage->LayerMask) { if (!iMainImage->LayerMask->StartScanLine()) { END_LOG; return false; } for (y = sty; y < height + sty; y++) { bp = iMainImage->uBitmap->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x = stx; x < width + stx; x++) { if (lp[x] == 0) ChoiceColor->Add(Palette, *(bp + x)); } } iMainImage->LayerMask->StopScanLine(); } else { for (y = sty; y < height + sty; y++) { bp = iMainImage->uBitmap->GetScanLine(y); for (x = stx; x < width + stx; x++) { ChoiceColor->Add(Palette, *(bp + x)); } } } iMainImage->uBitmap->StopScanLine(); END_LOG; return true; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWorkAreaColor (TChoiceColor *ChoiceColor, int *Code) // gabriel: added Code { BEGIN_LOG(""); Byte *mp = NULL, mm, *bp = NULL, *lp = NULL; int x, y; if (!WorkArea->Mask->StartScanLine()) goto fail; if (!iMainImage->uBitmap->StartScanLine()) goto fail; if (iMainImage->LayerMask) { if (!iMainImage->LayerMask->StartScanLine()) goto fail; if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y = WorkArea->Range.top; y < WorkArea->Range.bottom; y++) { bp = iMainImage->uBitmap->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y - WorkArea->Range.top); for (x = WorkArea->Range.left; x < WorkArea->Range.right; x++, mp++) { if (*mp && (lp[x] == 0)) { ChoiceColor->Add(Palette, *(bp + x)); if (Code) // gabriel if (Code[*(bp + x)] == -1) Code[*(bp + x)] = ChoiceColor->Count - 1; } } } } else { for (y = WorkArea->Range.top; y < WorkArea->Range.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y - WorkArea->Range.top); mm = 0x80; bp = iMainImage->uBitmap->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x = WorkArea->Range.left; x < WorkArea->Range.right; x++) { if (*mp & mm) { if ((*(lp + (x >> 3)) & (0x80 >> (x & 7))) == 0) ChoiceColor->Add(Palette, *(bp + x)); } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } } } iMainImage->LayerMask->StopScanLine(); } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y = WorkArea->Range.top; y < WorkArea->Range.bottom; y++) { bp = iMainImage->uBitmap->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y - WorkArea->Range.top); for (x = WorkArea->Range.left; x < WorkArea->Range.right; x++, mp++) { if (*mp) { ChoiceColor->Add(Palette, *(bp + x)); if (Code) // gabriel if (Code[*(bp + x)] == -1) Code[*(bp + x)] = ChoiceColor->Count - 1; } } } } else { for (y = WorkArea->Range.top; y < WorkArea->Range.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y - WorkArea->Range.top); mm = 0x80; bp = iMainImage->uBitmap->GetScanLine(y); for (x = WorkArea->Range.left; x < WorkArea->Range.right; x++) { if (*mp & mm) { ChoiceColor->Add(Palette, *(bp + x)); } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } } } } iMainImage->uBitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); END_LOG; return true; fail: if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); END_LOG; return false; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWholeBackGroundColor (TChoiceColor *ChoiceColor) { // convert by celberus BEGIN_LOG(""); int x, y; Byte *bp = NULL; TUnionBitmap *Bitmap = NULL; Bitmap = iMainImage->Composition(); if (Bitmap) { if (!Bitmap->StartScanLine()) { END_LOG; return false; } for (y = 0; y < Bitmap->Height; y++) { bp = Bitmap->GetScanLine(y); for (x = 0; x < Bitmap->Width; x++) { ChoiceColor->Add(Palette, *(bp + x)); } } Bitmap->StopScanLine(); doDestroy(Bitmap) } END_LOG; return true; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWorkAreaBackGroundColor (TChoiceColor *ChoiceColor) { // convert by celberus BEGIN_LOG(""); Byte *mp = NULL, mm, *bp = NULL; int x, y; TUnionBitmap *Bitmap = NULL; if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if (!WorkArea->Mask->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (Bitmap->BitsPerPixel == 8) { for (y = WorkArea->Range.top; y < WorkArea->Range.bottom; y++) { bp = Bitmap->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y - WorkArea->Range.top); for (x = WorkArea->Range.left; x < WorkArea->Range.right; x++, mp++) { if (*mp) ChoiceColor->Add(Palette, *(bp + x)); } } } else { for (y = WorkArea->Range.top; y < WorkArea->Range.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y - WorkArea->Range.top); mm = 0x80; bp = Bitmap->GetScanLine(y); for (x = WorkArea->Range.left; x < WorkArea->Range.right; x++) { if (*mp & mm) ChoiceColor->Add(Palette, *(bp + x)); if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } } } Bitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); doDestroy(Bitmap) END_LOG; return true; fail: if (Bitmap) { Bitmap->StopScanLine(); doDestroy(Bitmap) } WorkArea->Mask->StopScanLine(); END_LOG; return false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::UpdateImage() { TPoint Size; if (VectorForm) iMainImage->bVectorModify = false; Size.x = Panel->Width * iMainImage->ZoomOut / iMainImage->ZoomIn; Size.y = Panel->Height * iMainImage->ZoomOut / iMainImage->ZoomIn; if (iMainImage->Reflection && reflection) { int width = 0, height = 0; if (reflection->Direction == D_LR) { width = reflection->BitmapWidth * 2; height = reflection->BitmapHeight; } else { width = reflection->BitmapWidth; height = reflection->BitmapHeight * 2; } if (width < Size.x) sbHorz->Max = 0; else sbHorz->Max = width - Size.x; if (height < Size.y) sbVert->Max = 0; else sbVert->Max = height - Size.y; } else { if (iMainImage->uBitmap->Width < Size.x) sbHorz->Max = 0; else sbHorz->Max = iMainImage->uBitmap->Width - Size.x; if (iMainImage->uBitmap->Height < Size.y) sbVert->Max = 0; else sbVert->Max = iMainImage->uBitmap->Height - Size.y; } sbHorz->SmallChange = sbHorz->Max / 10; sbHorz->LargeChange = sbHorz->Max / 5; sbVert->SmallChange = sbVert->Max / 10; // SmallChange´Â Àüü »çÀÌÁîÀÇ 1/10 sbVert->LargeChange = sbVert->Max / 5; // LargeChange´Â Àüü »çÀÌÁîÀÇ 1/5 } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::EditCut() { if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } TCursor cursor; TPoint Size; TUnionBitmap *tlb = NULL, *tb = NULL; // convert by celberus int x, y; Byte *mp = NULL, mm, *pp = NULL, *lm = NULL; bool undoSw = false; COLORREF c; RECT r, rt; TPException ec = EC_NONE; if (MainMenuForm->UseEditFunction) { // For TextBoxEdit by maxleo21c (04.10.22) MainMenuForm->CutSelectedWordData(); return; } BEGIN_LOG(""); cursor = Screen->Cursor; Screen->Cursor = crHourGlass; c = PaletteForm->DIB256Palette->GetBGCOLORREF (iMainImage->uBitmap->BitsPerPixel); rt = MainImageForm->WorkArea->Range; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rt = MainImageForm->AutoRep_UndoRect(rt); if (WorkArea->Mask) { if ((undoSw = UndoSave(UK_ALL, rt)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = SaveToClipboard()) != EC_NONE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Size.x = WorkArea->Range.right - WorkArea->Range.left; Size.y = WorkArea->Range.bottom - WorkArea->Range.top; tb = iMainImage->uBitmap; tlb = iMainImage->LayerMask; if (!tb->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (tlb) { if (!tlb->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y = 0; y < Size.y; y++) { pp = tb->GetScanLine(WorkArea->Range.top + y) + WorkArea->Range.left; lm = tlb->GetScanLine(WorkArea->Range.top + y) + WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, mp++, lm++) { if (*mp) { *pp = c; *lm = 0xFF; } } tlb->PutScanLine(WorkArea->Range.top + y); tb->PutScanLine(WorkArea->Range.top + y); } } else { for (y = 0; y < Size.y; y++) { pp = tb->GetScanLine(WorkArea->Range.top + y) + 3 * WorkArea->Range.left; lm = tlb->GetScanLine(WorkArea->Range.top + y); mp = WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x = 0; x < Size.x; x++, pp += 3) { if (*mp & mm) { SetPixel24(pp, c); lm[(WorkArea->Range.left + x) >> 3] |= (0x80 >> ((WorkArea->Range.left + x) & 7)); // *lm |= mm; } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } tb->PutScanLine(WorkArea->Range.top + y); tlb->PutScanLine(WorkArea->Range.top + y); } } tlb->StopScanLine(); } else { if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { for (y = 0; y < Size.y; y++) { pp = tb->GetScanLine(WorkArea->Range.top + y) + WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, mp++) { if (*mp) * pp = c; } tb->PutScanLine(WorkArea->Range.top + y); } } else { for (y = 0; y < Size.y; y++) { pp = tb->GetScanLine(WorkArea->Range.top + y) + 3 * WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x = 0; x < Size.x; x++, pp += 3) { if (*mp & mm) { SetPixel24(pp, c); } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } tb->PutScanLine(WorkArea->Range.top + y); } } } tb->StopScanLine(); WorkArea->Mask->StopScanLine(); } else { r = Rect(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); if ((undoSw = UndoSave(UK_ALL, r)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = SaveToClipboard()) != EC_NONE) goto fail; iMainImage->uBitmap->FillRect(r, c); if (iMainImage->LayerMask) { if (iMainImage->uBitmap->BitsPerPixel == 8) iMainImage->LayerMask->FillRect(r, PALETTEINDEX(255)); else iMainImage->LayerMask->FillRect(r, clWhite); } } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); iMainImage->Repaint(); Screen->Cursor = cursor; END_LOG; return; fail: if (WorkArea->Mask) { WorkArea->Mask->StopScanLine(); tb->StopScanLine(); tlb->StopScanLine(); } if (undoSw == true) MainImageForm->Undo->RemoveLast(); Screen->Cursor = cursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::EditCopy() { if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } TCursor cursor; TPException ec; if (MainMenuForm->UseEditFunction) { // For TextBoxEdit by maxleo21c (04.10.19) MainMenuForm->CopySelectedWordData(); return; } BEGIN_LOG(""); cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if ((ec = SaveToClipboard()) != EC_NONE) EXCEPTION_MESSAGE_OK(ec); Screen->Cursor = cursor; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::EditPaste() { if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } RGBQUAD rgb[256]; int x, y; BITMAPHANDLE bh; HGLOBAL hMem = NULL; TClipboardInfo *cbi = NULL; HANDLE hBuffer = NULL; Byte *pBuffer = NULL, c; short color[256]; int colors; TPException ec = EC_NONE; bool undoSw = false, bClipboard = false; if (MainMenuForm->UseEditFunction) { // For TextBoxEdit by maxleo21c (04.10.19) char *ptr=NULL; if(IsClipboardFormatAvailable(CF_TEXT)){ OpenClipboard(hWnd); hMem=GetClipboardData(CF_TEXT); ptr=(char *)GlobalLock(hMem); MainMenuForm->PasteSelectedWordData(ptr); GlobalUnlock(hMem); CloseClipboard(); bClipboard=true; } else MainMenuForm->PasteSelectedWordData(); return; } // TCursor cursor = Screen->Cursor; // Screen->Cursor = crHourGlass; // MainMenuForm->ExitForm(1); // by celberus // 20050525 by lhskys with leo21c Æû Á¾·á½Ã ¿ÏȰÇϰÔ... // ExitForm(1)ÀÌ ºÒ·ÁÁú¶§ Ȥ½Ã ¸ð¸¦ Access¸¦ ¹æÁöÇϱâ À§Çؼ­ ÀÌ·¸°Ô ó¸® PostMessage(this->Handle, TPM_EDITPASTE, MainMenuForm->Item, 0); // =====================================//20050525 by lhskys with leo21c Á¾·áÇÑ ´ÙÀ½ Paste... /* TRect r = Rect(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); if ((undoSw = UndoSave(UK_ALL, Rect(0,0,0,0))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if ((undoSw = UndoSave(UK_ALL, r)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } memset(&bh, 0, sizeof(BITMAPHANDLE)); iMainImage->SubEnabled = true; iMainImage->SubVisible = false; // by celberus Èæ¹é À̹ÌÁö ¹®Á¦ ¶§¹®¿¡.. // if(iMainImage->uBitmap->BitsPerPixel!=24){ if(iMainImage->uBitmap->BitsPerPixel==8){ SetOldUseColor(Palette->UseColor); } if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } bClipboard = true; if (IsClipboardFormatAvailable(MainForm->ClipboardFormat)) { if ((hMem = GetClipboardData(MainForm->ClipboardFormat))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cbi = (TClipboardInfo *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cbi->Width<=iMainImage->uBitmap->Width && cbi->Height<=iMainImage->uBitmap->Height) { if (iMainImage->uBitmap->BitsPerPixel==8) { if (cbi->BitsPerPixel!=8) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((ec = ReadTexpiaFormat8To8(cbi))!=EC_NONE) goto fail; if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (cbi->BitsPerPixel==8) { if ((ec = ReadTexpiaFormat8To24(cbi))!=EC_NONE) goto fail; } else { if ((ec = ReadTexpiaFormat24To24(cbi))!=EC_NONE) goto fail; } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { ec = EC_BIG_SIZE; goto fail; } GlobalUnlock(hMem); } else { if (L_ClipboardReady()) { if (L_InitBitmap(&bh, 0, 0, iMainImage->uBitmap->BitsPerPixel)<1) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (L_CopyFromClipboard(MainForm->Handle, &bh)<1) { ec = EC_CLIPBOARD_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (bh.Width<=iMainImage->uBitmap->Width && bh.Height<=iMainImage->uBitmap->Height) { if (bh.ViewPerspective!=TOP_LEFT) if (L_ChangeBitmapViewPerspective(NULL, &bh, TOP_LEFT)<1) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (bh.BitsPerPixel<=8) { if (bh.BitsPerPixel!=8) { if (L_ColorResBitmap(&bh, &bh, 8, CRF_OPTIMIZEDPALETTE, NULL, NULL, 0, NULL, NULL)<1) { ec = EC_CAN_NOT_CONVERT; goto fail; } } L_AccessBitmap(&bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh.BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } colors = 0; memset(color, 0, 256*sizeof(short)); L_GetBitmapColors(&bh, 0, 256, rgb); for (y=0; yuBitmap->BitsPerPixel==8) { if (bh.BitsPerPixel!=8) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((ec = ReadGeneralFormat8To8(&bh, colors, color))!=EC_NONE) goto fail; if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (bh.BitsPerPixel==8) { if ((ec = ReadGeneralFormat8To24(&bh, colors, color))!=EC_NONE) goto fail; } else { if ((ec = ReadGeneralFormat24To24(&bh))!=EC_NONE) goto fail; } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { ec = EC_BIG_SIZE; goto fail; } L_FreeBitmap(&bh); } else {ec = EC_NO_CLIPBOARDDATA; goto fail;} // 2004-01-27 by celberus } CloseClipboard(); if (iMainImage->SubBitmap->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->SubBitmap->PutColors(0, 256, rgb); iMainImage->SubMask->PutColors(0, 256, rgb); } FullViewForm->stSuper->Enabled = false; iMainImage->InitBackGround(0x01); PenManagerForm->SetColor(Palette); Center.x = iMainImage->SubBitmap->Width/2; Center.y = iMainImage->SubBitmap->Height/2; MainMenuForm->Item = T_MERGE; if(StyleForm)StyleForm->Visible = false; MainMenuForm->SubItem = 0; ::RepaintColor(); Screen->Cursor = cursor; return; fail: if (undoSw) { if (bClipboard) { if (hBuffer) { if (pBuffer) GlobalUnlock(hBuffer); GlobalFree(hBuffer); } L_FreeBitmap(&bh); if (hMem) { if (cbi) GlobalUnlock(hMem); } ExitMerge(); CloseClipboard(); } MainImageForm->Undo->RemoveLast(); } Screen->Cursor = cursor; EXCEPTION_MESSAGE_OK(ec); */ // ==========//20050525 by lhskys with leo21c Á¾·áÇÑ ´ÙÀ½ Paste...TPMEditPaste ºÎºÐÀ¸·Î ³Ñ±è } // --------------------------------------------------------------------- // 20050525 by lhskys with leo21c Æû Á¾·á½Ã ¿ÏȰÇϰÔ... // ¿­·ÁÁø ÆûÀÌ ÀÖ´Â »óÅ¿¡¼­ KeydownÀ̺¥Æ®°¡ ¹ß»ýÇϴµ¥ ±× ÆûÀÌ deleteµÇ¼­ ¹ß»ýÇÒ¼ö // ÀÖ´Â Access¸¦ ¹æÁöÇϱâ À§Çؼ­ Message Queue¸¦ ÀÌ¿ëÇß´Ù. void TMainImageForm::TPMEditPaste(TMessage &msg) { RGBQUAD rgb[256]; int x, y; BITMAPHANDLE bh; HGLOBAL hMem = NULL; TClipboardInfo *cbi = NULL; HANDLE hBuffer = NULL; Byte *pBuffer = NULL, c; short color[256]; int colors; TPException ec = EC_NONE; bool undoSw = false, bClipboard = false; MainMenuForm->Item = msg.WParam; if (!MainMenuForm->ExitForm(1)) return; // if¹®À¸·Î º¯°æ by maxleo21c (05.06.27) BEGIN_LOG(""); TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; TRect r = Rect(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); if ((undoSw = UndoSave(UK_ALL, Rect(0, 0, 0, 0))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if ((undoSw = UndoSave(UK_ALL, r)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } memset(&bh, 0, sizeof(BITMAPHANDLE)); iMainImage->SubEnabled = true; iMainImage->SubVisible = false; // by celberus Èæ¹é À̹ÌÁö ¹®Á¦ ¶§¹®¿¡.. // if(iMainImage->uBitmap->BitsPerPixel!=24){ if (iMainImage->uBitmap->BitsPerPixel == 8) { SetOldUseColor(Palette->UseColor); } if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } bClipboard = true; if (IsClipboardFormatAvailable(MainForm->ClipboardFormat)) { if ((hMem = GetClipboardData(MainForm->ClipboardFormat)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cbi = (TClipboardInfo*)GlobalLock(hMem)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cbi->Width <= iMainImage->uBitmap->Width && cbi->Height <= iMainImage->uBitmap->Height) { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (cbi->BitsPerPixel != 8) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((ec = ReadTexpiaFormat8To8(cbi)) != EC_NONE) goto fail; if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (cbi->BitsPerPixel == 8) { if ((ec = ReadTexpiaFormat8To24(cbi)) != EC_NONE) goto fail; } else { if ((ec = ReadTexpiaFormat24To24(cbi)) != EC_NONE) goto fail; } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { ec = EC_BIG_SIZE; goto fail; } GlobalUnlock(hMem); } else { if (L_ClipboardReady()) { if (L_InitBitmap(&bh, sizeof(BITMAPHANDLE), 0, 0, iMainImage->uBitmap->BitsPerPixel) < 1) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (L_CopyFromClipboard(MainForm->Handle, &bh, sizeof(BITMAPHANDLE)) < 1) { ec = EC_CLIPBOARD_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (bh.Width <= iMainImage->uBitmap->Width && bh.Height <= iMainImage->uBitmap->Height) { if (bh.ViewPerspective != TOP_LEFT) if (L_ChangeBitmapViewPerspective(NULL, &bh, sizeof(BITMAPHANDLE), TOP_LEFT) < 1) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (bh.BitsPerPixel <= 8) { if (bh.BitsPerPixel != 8) { if (L_ColorResBitmap(&bh, &bh, sizeof(BITMAPHANDLE), 8, CRF_OPTIMIZEDPALETTE, NULL, NULL, 0, NULL, NULL) < 1) { ec = EC_CAN_NOT_CONVERT; goto fail; } } L_AccessBitmap(&bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh.BytesPerLine)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((pBuffer = (Byte*)GlobalLock(hBuffer)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } colors = 0; memset(color, 0, 256 * sizeof(short)); L_GetBitmapColors(&bh, 0, 256, rgb); for (y = 0; y < bh.Height; y++) { L_GetBitmapRow(&bh, pBuffer, y, bh.BytesPerLine); for (x = 0; x < bh.Width; x++) { c = *(pBuffer + x); if (color[c] == 0) { color[c] = colors + 1; colors++; } } } GlobalUnlock(hBuffer); GlobalFree(hBuffer); hBuffer = NULL; L_ReleaseBitmap(&bh); } else { if (bh.BitsPerPixel != 24) { if (L_ColorResBitmap(&bh, &bh, sizeof(BITMAPHANDLE), 24, CRF_BYTEORDERBGR, NULL, NULL, 0, NULL, NULL) < 1) { ec = EC_CAN_NOT_CONVERT; goto fail; } } } if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bh.BitsPerPixel != 8) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((ec = ReadGeneralFormat8To8(&bh, colors, color)) != EC_NONE) goto fail; if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (bh.BitsPerPixel == 8) { if ((ec = ReadGeneralFormat8To24(&bh, colors, color)) != EC_NONE) goto fail; } else { if ((ec = ReadGeneralFormat24To24(&bh)) != EC_NONE) goto fail; } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { ec = EC_BIG_SIZE; goto fail; } L_FreeBitmap(&bh); } else { ec = EC_NO_CLIPBOARDDATA; goto fail; } // 2004-01-27 by celberus } CloseClipboard(); if (iMainImage->SubBitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->SubBitmap->PutColors(0, 256, rgb); iMainImage->SubMask->PutColors(0, 256, rgb); } iMainImage->InitBackGround(0x01); PenManagerForm->SetColor(Palette); Center.x = iMainImage->SubBitmap->Width / 2; Center.y = iMainImage->SubBitmap->Height / 2; MainMenuForm->Item = T_MERGE; if (StyleForm) StyleForm->Visible = false; MainMenuForm->SubItem = 0; ::RepaintColor(); Screen->Cursor = cursor; END_LOG; return; fail: if (undoSw) { if (bClipboard) { if (hBuffer) { if (pBuffer) GlobalUnlock(hBuffer); GlobalFree(hBuffer); } L_FreeBitmap(&bh); if (hMem) { if (cbi) GlobalUnlock(hMem); } ExitMerge(); CloseClipboard(); } // MainImageForm->Undo->RemoveLast(); } Screen->Cursor = cursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; } // -------------------------------------------------------------------------- TCaptureData *__fastcall TMainImageForm::MakeCapture(bool bWorkArea) { BEGIN_LOG(""); TCaptureData *cd = NULL; if ((cd = new TCaptureData) == NULL) goto fail; cd->IsWorkArea = bWorkArea; // À̹ÌÁö ĸÃÄÇÏÁö ¾Ê°í, ÀÛ¾÷±¸¿ªÀ¸·Î ÀâÀº À̹ÌÁöÀÇ °æ¿ì - by monkman (2010.10.04) cd->Range = WorkArea->Range; if ((cd->Bitmap = new TUnionBitmap) == NULL) goto fail; // convert by celberus if (!cd->Bitmap->Create(cd->Range.Right - cd->Range.Left, cd->Range.Bottom - cd->Range.Top, iMainImage->uBitmap->BitsPerPixel)) goto fail; if (!cd->Bitmap->CopyFromRect(iMainImage->uBitmap, cd->Range.Left, cd->Range.Top, SRCCOPY)) goto fail; // if(!iMainImage->uBitmap->CopyToTexpia(cd->Bitmap, 0, 0, cd->Bitmap->Width, cd->Bitmap->Height, // cd->Range.Left, cd->Range.Top, SRCCOPY)) goto fail; // convert by celberus if ((cd->Mask = new TUnionBitmap) == NULL) goto fail; // convert by celberus if (!cd->Mask->Create(cd->Range.Right - cd->Range.Left, cd->Range.Bottom - cd->Range.Top, WorkArea->Mask->BitsPerPixel)) goto fail; if (!cd->Mask->Copy(WorkArea->Mask, SRCCOPY)) goto fail; END_LOG; return cd; fail: if (cd) delete cd; END_LOG; return NULL; } // --------------------------------------------------------------------- TCaptureData *__fastcall TMainImageForm::MakeCapture(TUnionBitmap *uBitmap) { BEGIN_LOG(""); TCaptureData *cd = NULL; if ((cd = new TCaptureData) == NULL) goto fail; cd->IsWorkArea = false; // À̹ÌÁö ĸÃÄÇÏÁö ¾Ê°í, ÀÛ¾÷±¸¿ªÀ¸·Î ÀâÀº À̹ÌÁöÀÇ °æ¿ì - by monkman (2010.10.04) cd->Range = TRect(0, 0, uBitmap->Width, uBitmap->Height); if ((cd->Bitmap = new TUnionBitmap) == NULL) goto fail; // convert by celberus //24bit¿¡¼­¸¸ »ç¿ëÇϱ⠶§¹®¿¡ ¾Æ·¡¿Í °°ÀÌ Ã³¸®ÇÔ if (!cd->Bitmap->Create(cd->Range.Right - cd->Range.Left, cd->Range.Bottom - cd->Range.Top, 24)) goto fail; if (!cd->Bitmap->CopyFromRect(uBitmap, cd->Range.Left, cd->Range.Top, SRCCOPY)) goto fail; if ((cd->Mask = new TUnionBitmap) == NULL) goto fail; // convert by celberus //24bit¿¡¼­¸¸ »ç¿ëÇϱ⠶§¹®¿¡ ¾Æ·¡¿Í °°ÀÌ Ã³¸®ÇÔ if (!cd->Mask->Create(cd->Range.Right - cd->Range.Left, cd->Range.Bottom - cd->Range.Top, 1)) goto fail; cd->Mask->FillRect(cd->Range, clBlack); END_LOG; return cd; fail: if (cd) delete cd; END_LOG; return NULL; } // --------------------------------------------------------------------- bool __fastcall TMainImageForm::InitOverlap(void) { if (iMainImage->uBitmap->BitsPerPixel > 8) { overlapdata = (Byte*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 252 * 252 * 3); // ½ÇÁ¦ÀûÀ¸·Î ǮĮ¶ó¿¡¼­´Â ¾²ÀÌÁö ¾Ê´Âµí.. } else { overlapdata = (Byte*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 252 * 252); } return overlapdata != NULL; } // --------------------------------------------------------------------- void __fastcall TMainImageForm::ExitOverlap(void) { // if (iMainImage->uBitmap->BitsPerPixel==8) { if (overlapdata) { HeapFree(GetProcessHeap(), 0, overlapdata); overlapdata = NULL; } // } } // --------------------------------------------------------------------- COLORREF __fastcall TMainImageForm::Overlap(COLORREF base, COLORREF cover) { int point, density = FullViewForm->OverlapDensity; Byte usecolor; RGBQUAD rgb[256]; // , *rgbPoint=NULL, *rgbBase=NULL, *rgbCover=NULL; if (iMainImage->uBitmap->BitsPerPixel == 8) { if (base && cover) { if (base == cover) return base; else { usecolor = PaletteForm->DIB256Palette->UseColor; if (usecolor >= 251) return 0xFF; if (overlapdata[base * 252 + cover]) return overlapdata[base * 252 + cover]; point = usecolor + 1; PaletteForm->DIB256Palette->UseColor = point; overlapdata[base * 252 + cover] = overlapdata[cover * 252 + base] = point; RGBQUAD rgbPoint = Palette->ColorData[point]->RGB; RGBQUAD rgbBase = Palette->ColorData[base]->RGB; RGBQUAD rgbCover = Palette->ColorData[cover]->RGB; rgbPoint.rgbRed = (rgbBase.rgbRed * (63 - density) + rgbCover.rgbRed * density) / 63; rgbPoint.rgbGreen = (rgbBase.rgbGreen * (63 - density) + rgbCover.rgbGreen * density) / 63; rgbPoint.rgbBlue = (rgbBase.rgbBlue * (63 - density) + rgbCover.rgbBlue * density) / 63; Palette->ColorData[point]->RGB = rgbPoint; PaletteForm->DIB256Palette->SetPalette(Palette); Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); return point; } } else if (base) return base; else return cover; } else { if (base == cover) return base; else { rgb[0] = TColorToRGB((TColor)base); rgb[1] = TColorToRGB((TColor)cover); rgb[2].rgbRed = (rgb[0].rgbRed * (63 - density) + rgb[1].rgbRed * density) / 63; rgb[2].rgbGreen = (rgb[0].rgbGreen * (63 - density) + rgb[1].rgbGreen * density) / 63; rgb[2].rgbBlue = (rgb[0].rgbBlue * (63 - density) + rgb[1].rgbBlue * density) / 63; return RGBToTColor(rgb[2]); } } } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderNoMethod (TUnionBitmap *Pattern, TSize r, int len, int item) // convert by celberus { BEGIN_LOG(""); int width, height; TSize s; RECT Src; RGBQUAD rgb[256]; TUnionBitmap *Bitmap = NULL; // by celberus if (WorkArea->Mask) { Src = WorkArea->Range; } else { Src = Rect(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); } s.cx = Src.right - Src.left; s.cy = Src.bottom - Src.top; width = s.cx * r.cx; height = s.cy * r.cy; if (iMainImage->uBitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); Pattern->Create(width, height, 8, rgb); } else { Pattern->Create(width, height, 24); } Pattern->FillRect(Rect(0, 0, width, height), clWhite); if (iMainImage->LayerList->Count > 1) { if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if (!Repeat_Method(Pattern, r, s, Src, len, item, Bitmap)) goto fail; delete Bitmap; Bitmap = NULL; } else { if (!Repeat_Method(Pattern, r, s, Src, len, item, iMainImage->uBitmap)) goto fail; } END_LOG; return true; fail: if (Bitmap) delete Bitmap; END_LOG; return false; } // ---------------------------------------------------------------------------- by k3dogs(20001015) ±×¸®µå¸¦ Pattern¿¡ ±×¸°´Ù. void __fastcall TMainImageForm::PrintGrid(TUnionBitmap *Pattern, TSize r, TColor GridColor, TGrid Grid, int GridMark, TColor GridMarkColor) { // convert by celberus int i; double gapx = 0, gapy = 0, width, height; RECT Src; HDC dcDst = NULL; HPEN hPen = NULL; HPEN hOldPen = NULL; switch(Grid.Unit) { case 1: Grid.X *= CanvasInfor.DotsPerInch; Grid.Y *= CanvasInfor.DotsPerInch; break; case 2: Grid.X *= CanvasInfor.DotsPerInch / 2.54; Grid.Y *= CanvasInfor.DotsPerInch / 2.54; break; } for (int n = 0; n < Pattern->CountX * Pattern->CountY; n++) // convert by celberus { if (Grid.X > 5 && Grid.Y > 5) { // ±×¸®µå °£°Ý Á¦ÇÑ. if (WorkArea->Mask) { Src = WorkArea->Range; } else { Src = Rect(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height); } width = (Src.right - Src.left) * r.cx; height = (Src.bottom - Src.top) * r.cy; dcDst = Pattern->CreateDC(n); hPen = CreatePen(psSolid, 1, GridColor); hOldPen = (HPEN)SelectObject(dcDst, hPen); gapx = 0; gapy = 0; for (i = 0; i <= Floor(iMainImage->uBitmap->Width / Grid.X); i++) { if ((GridMark > 0) && (i % GridMark == 0)) { if (hPen) { DeleteObject(hPen); hPen = NULL; } hPen = CreatePen(psSolid, 1, GridMarkColor); SelectObject(dcDst, hPen); } if (WorkArea->Mask) { if ((WorkArea->Range.left <= gapx) && (gapx <= WorkArea->Range.right) ) { MoveToEx(dcDst, gapx - WorkArea->Range.left - Pattern->uRect[0][n] .left, 0, NULL); // convert by celberus LineTo(dcDst, gapx - WorkArea->Range.left - Pattern->uRect[0][n] .left, height - Pattern->uRect[0][n].top); // convert by celberus } } else { if ( /* (WorkArea->Range.left <= gapx) && */ (gapx <= iMainImage->uBitmap->Width)) { MoveToEx(dcDst, gapx - Pattern->uRect[0][n].left, 0, NULL); // convert by celberus LineTo(dcDst, gapx - Pattern->uRect[0][n].left, height - Pattern->uRect[0][n].top); // convert by celberus } } if ((GridMark > 0) && (i % GridMark == 0)) { if (hPen) { DeleteObject(hPen); hPen = NULL; } hPen = CreatePen(psSolid, 1, GridColor); SelectObject(dcDst, hPen); } gapx += Grid.X; } for (i = 0; i <= Floor(iMainImage->uBitmap->Height / Grid.Y); i++) { if ((GridMark > 0) && (i % GridMark == 0)) { if (hPen) { DeleteObject(hPen); hPen = NULL; } hPen = CreatePen(psSolid, 1, GridMarkColor); SelectObject(dcDst, hPen); } if (WorkArea->Mask) { if ((WorkArea->Range.top <= gapy) && (gapy <= WorkArea->Range.bottom) ) { MoveToEx(dcDst, 0, gapy - WorkArea->Range.top - Pattern->uRect[0][n] .top, NULL); // convert by celberus LineTo(dcDst, width - Pattern->uRect[0][n].left, gapy - WorkArea->Range.top - Pattern->uRect[0][n].top); // convert by celberus } } else { if ( /* (WorkArea->Range.top <= gapy) && */ (gapy <= iMainImage->uBitmap->Height)) { MoveToEx(dcDst, 0, gapy - Pattern->uRect[0][n].top, NULL); // convert by celberus LineTo(dcDst, width - Pattern->uRect[0][n].left, gapy - Pattern->uRect[0][n].top); // convert by celberus } } if ((GridMark > 0) && (i % GridMark == 0)) { if (hPen) { DeleteObject(hPen); hPen = NULL; } hPen = CreatePen(psSolid, 1, GridColor); SelectObject(dcDst, hPen); } gapy += Grid.Y; } SelectObject(dcDst, hOldPen); hOldPen = NULL; if (hPen) { DeleteObject(hPen); hPen = NULL; } Pattern->DeleteDC(dcDst, n); dcDst = NULL; } } } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderYesMethod (TUnionBitmap *Pattern, double ColorChipZoom) { // convert by celberus BEGIN_LOG(""); bool result; if (iMainImage->LayerList->Count > 1) { result = HeaderYesMethod_layer(Pattern, ColorChipZoom); } else { result = HeaderYesMethod_none(Pattern, ColorChipZoom); } END_LOG; return result; } // ---------------------------------------------------------------------------- ///Ãâ·ÂÁß¿¡¼­ color chip Ãâ·Â °ü·ÃÇÏ¿© ó¸®ÇÏ´Â ÇÔ¼ö 080325 int __fastcall TMainImageForm::ComboHeaderUsedColorMethod (TUnionBitmap *Pattern, bool Yes, double zoom, TSize &colorChipArea) // modified by smallpotato 2007.05.02 // color name ´ÙÁß line Ãâ·Â °ü·ÃÀ¸·Î ¶Ç ¼öÁ¤ 2008.03.11 by smallpotato { BEGIN_LOG(""); TChoiceColor *ChoiceColor = NULL; int i, row, column, width, height; short tab; TSize chip_size, chip_count, page_margin, chip_gap, chip_period, chip_name_area; String NameStr = "", Rgbvalue, strColorValue1 = "", strColorValue2 = "", strColorValue3 = "", delimiter = " "; RGBQUAD rgb[256]; TRect BitRect, StrRect; TCanvas *ca = NULL; TTexpiaBitmap *tempBitmap = NULL, *stretchBitmap = NULL; // by celberus TRect tempRect; // by celberus HDC tempDC, stretchDC; // by celberus int patternW, patternH; int printLOGPIXELSX = GetDeviceCaps(Printer()->Handle, LOGPIXELSX); int printLOGPIXELSY = GetDeviceCaps(Printer()->Handle, LOGPIXELSY); if ((ChoiceColor = new TChoiceColor) == NULL) goto fail; if (iMainImage->LayerList->Count > 1) { if (WorkArea->Mask) SearchWorkAreaBackGroundColor(ChoiceColor); else SearchWholeBackGroundColor(ChoiceColor); } else { if (WorkArea->Mask) SearchWorkAreaColor(ChoiceColor); else SearchWholeColor(ChoiceColor); } zoom /= 100; width = GetDeviceCaps(Printer()->Handle, HORZRES) * 160 / printLOGPIXELSX; // 160dpi À϶§ÀÇ print width height = GetDeviceCaps(Printer()->Handle, VERTRES) * 160 / printLOGPIXELSY; patternW = width * CanvasInfor.DotsPerInch / 160; if (MainImageForm->iMainImage->uBitmap->Width > patternW) { patternW = MainImageForm->iMainImage->uBitmap->Width; width = patternW * 160 / CanvasInfor.DotsPerInch; } if (Yes) { // ComboBoxYesMethod¿¡¼­ »ç¿ë ÇÒ °ª chip_size.cx = 90 * zoom; chip_size.cy = 50 * zoom; } else { // UsedColorMethod¿¡¼­ »ç¿ë ÇÒ °ª chip_size.cx = 110 * zoom; chip_size.cy = 100 * zoom; } page_margin.cx = 44 * zoom; page_margin.cy = 30 * zoom; chip_name_area.cx = chip_size.cx; chip_name_area.cy = 20 * zoom; chip_gap.cx = 10 * zoom; chip_gap.cy = chip_name_area.cy; chip_period.cx = chip_size.cx + chip_gap.cx; chip_period.cy = chip_size.cy + chip_gap.cy; chip_count.cx = (width - page_margin.cx) / chip_period.cx; // Pattern Height Á¤Çϱâ if (chip_count.cx == 0) return -1; chip_count.cy = 1 + ChoiceColor->Count / chip_count.cx; height = chip_count.cy * chip_period.cy + page_margin.cy * 2; /* patternH = height * CanvasInfor.DotsPerInch / 160; //width * CanvasInfor.DotsPerInch / 160 ´Â ĵ¹ö½º dpi¿¡ »ó´ë width patternW = width * CanvasInfor.DotsPerInch / 160; if (MainImageForm->iMainImage->uBitmap->Width > patternW) { patternW = MainImageForm->iMainImage->uBitmap->Width; } */ colorChipArea.cx = width * CanvasInfor.DotsPerInch / 160; // patternW; colorChipArea.cy = height * CanvasInfor.DotsPerInch / 160; // patternH; if (!Pattern) { return 0; } Pattern->Create(colorChipArea.cx, colorChipArea.cy, iMainImage->uBitmap->BitsPerPixel, iMainImage->uBitmap->RGB); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); tempBitmap = new TTexpiaBitmap; // by celberus if (!tempBitmap) goto fail; if (tempBitmap->Create(500, 200, iMainImage->uBitmap->BitsPerPixel, iMainImage->uBitmap->RGB) == NULL) goto fail; // by celberus ÀÓÀÇÀÇ °ª stretchBitmap = new TTexpiaBitmap; if (!stretchBitmap) goto fail; if (stretchBitmap->Create(500 * zoom * CanvasInfor.DotsPerInch / 160, 200 * zoom * CanvasInfor.DotsPerInch / 160, iMainImage->uBitmap->BitsPerPixel, iMainImage->uBitmap->RGB) == NULL) goto fail; tempBitmap->FillRect(Rect(0, 0, tempBitmap->Width, tempBitmap->Height), clWhite); ca = tempBitmap->CreateCanvas(); // by celberus if (!ca) goto fail; ca->Font->Size = 10 * zoom; stretchDC = stretchBitmap->CreateDC(); for (i = 0, column = 0; i < ChoiceColor->Count; i++, column++) { if (i % chip_count.cx == 0) { row = i / chip_count.cx; column = 0; } NameStr = ""; StrRect = Rect(page_margin.cx + column * chip_period.cx, page_margin.cy + chip_size.cy + row * chip_period.cy, page_margin.cx + column * chip_period.cx + chip_name_area.cx, page_margin.cy + chip_size.cy + row * chip_period.cy + chip_name_area.cy); tempRect.left = 0; tempRect.right = StrRect.right - StrRect.left; // tempRect.top = 0; tempRect.bottom = StrRect.bottom - StrRect.top; // ca->Brush->Color = clWhite; if (RGBnum == false) { if ((ChoiceColor->ColorMap[i]->Kind & 0x400F) >= 0x4000) { switch(ChoiceColor->ColorMap[i]->Kind & 0x000F) { case 0: case 1: case 2: // ÀÌ ºÎºÐÀÌ Æ÷ÇԵǾî ÀÖÁö ¾Ê¾Ò´Ù. ÀÌÀ¯°¡ ÀÖÀ» °Í °°Àºµ¥....080408 ¿ä±¸·Î Ãß°¡ case 3: case 4: case 6: // Pantone coloe 080324 NameStr = ChoiceColor->ColorMap[i]->ColorName; Rgbvalue = Format("%d - %d - %d", OPENARRAY (TVarRec, (ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue))); break; } } else { switch(ChoiceColor->ColorMap[i]->Kind & 0x0FFF) { case 0: if (ChoiceColor->ColorMap[i]->Page == 0) NameStr = Format("%d - %d - %d", OPENARRAY (TVarRec, (255 - ChoiceColor->ColorMap[i]->RGB.rgbRed, 255 - ChoiceColor->ColorMap[i] ->RGB.rgbGreen, 255 - ChoiceColor->ColorMap[i]->RGB.rgbBlue))); else NameStr = PrinterColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 1: case 2: NameStr = "Special Color"; break; case 3: NameStr = StandardColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 4: NameStr = TextileColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 6: // Pantone coloe 080408 // NameStr = ChoiceColor->ColorMap[i]->PantoneColor; NameStr = (char*)ChoiceColor->ColorMap[i] ->additionalColorData->GetData(TAG_PANTONE_COLOR); break; } } } else if (RGBnum == true) { NameStr = Format("%d - %d - %d", OPENARRAY (TVarRec, (ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue))); } if (NameStr != "") { ca->Font->Color = clBlack; int lastfontsize = ca->Font->Size; ca->Font->Size = 9 * zoom; int string_line_count = ca->TextWidth(NameStr) / chip_name_area.cx + 1; if (string_line_count == 1) { tab = (chip_name_area.cx - ca->TextWidth(NameStr)) / 2; ca->TextRect(tempRect, tab, 2, NameStr); } else { chip_size.cy -= (chip_name_area.cy * (string_line_count - 1)); StrRect.top -= (chip_name_area.cy * (string_line_count - 1)); int char_index, start_index = 0, start_line = 0; for (char_index = 1; char_index < NameStr.Length(); ++char_index) { if (ca->TextWidth(NameStr.SubString(start_index, char_index - start_index)) > chip_name_area.cx) { ca->TextRect(tempRect, 0, start_line * chip_name_area.cy + 2, NameStr.SubString(start_index, char_index - start_index - 1)); tempRect.bottom += chip_name_area.cy; tempRect.top += chip_name_area.cy; start_index = char_index; ++start_line; } } ca->TextRect(tempRect, 0, start_line * chip_name_area.cy + 2, NameStr.SubString(start_index, char_index - start_index + 1)); } ca->Font->Size = lastfontsize; } else { tab = (chip_name_area.cx - ca->TextWidth (strColorValue1 + delimiter + strColorValue2 + delimiter + strColorValue3)) / 2; // Adjust Center if (tab < 0) tab = 0; // ¿©±â¼­ºÎÅÍ color code¸¦ ½á³Ö´Â ºÎºÐ ca->Font->Color = clRed; ca->TextRect(tempRect, tab, 2, strColorValue1); // by smallpotato 2007.05.02 tab += ca->TextWidth(strColorValue1 + delimiter); tempRect.Left = tab; ca->Font->Color = clGreen; ca->TextRect(tempRect, tab, 2, strColorValue2); // by smallpotato 2007.05.02 tab += ca->TextWidth(strColorValue2 + delimiter); tempRect.Left = tab; ca->Font->Color = clBlue; ca->TextRect(tempRect, tab, 2, strColorValue3); // by smallpotato 2007.05.02 } BitRect = Rect((page_margin.cx + column * chip_period.cx) * CanvasInfor.DotsPerInch / 160, (page_margin.cy + row * chip_period.cy) * CanvasInfor.DotsPerInch / 160, (page_margin.cx + column * chip_period.cx + chip_size.cx) * CanvasInfor.DotsPerInch / 160, (page_margin.cy + row * chip_period.cy + chip_size.cy) * CanvasInfor.DotsPerInch / 160); if (iMainImage->uBitmap->BitsPerPixel == 24) { PrintColorChip24(Pattern, BitRect, ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue); } else { PrintColorChip8(Pattern, BitRect, ChoiceColor->Code[i]); } chip_size.cy = chip_period.cy - chip_name_area.cy; SetStretchBltMode(stretchDC, COLORONCOLOR); StretchBlt(stretchDC, 0, 0, (StrRect.right - StrRect.left) * CanvasInfor.DotsPerInch / 160, (StrRect.bottom - StrRect.top) * CanvasInfor.DotsPerInch / 160, ca->Handle, 0, 0, StrRect.right - StrRect.left, StrRect.bottom - StrRect.top, SRCCOPY); Pattern->UnionBitBlt (stretchDC, StrRect.left * CanvasInfor.DotsPerInch / 160, StrRect.top * CanvasInfor.DotsPerInch / 160, (StrRect.right - StrRect.left) * CanvasInfor.DotsPerInch / 160, (StrRect.bottom - StrRect.top) * CanvasInfor.DotsPerInch / 160, 0, 0, SRCCOPY, true); // by celberus BitBlt(ca->Handle, 0, 0, tempRect.right, tempRect.bottom, NULL, 0, 0, WHITENESS); // ÇϳªÇϳª¾¿ Âï¾îÁÜ } tempBitmap->DeleteCanvas(ca); stretchBitmap->DeleteDC(stretchDC); delete ChoiceColor; delete tempBitmap; // by celberus delete stretchBitmap; END_LOG; return 0; fail: if (ChoiceColor) delete ChoiceColor; END_LOG; return-1; } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderMosaicMethod (TUnionBitmap *Pattern, int mx, int my) { BEGIN_LOG(""); bool result; if (iMainImage->LayerList->Count > 1) { result = HeaderMosaicMethod_layer(Pattern, mx, my); } else { result = HeaderMosaicMethod_none(Pattern, mx, my); } END_LOG; return result; } // ---------------------------------------------------------------------------- bool __fastcall TMainImageForm::UndoSave(int k, RECT r) // by linuxjun Undo_Method { BEGIN_LOG(""); Modify = true; if (FullViewForm->Super == sOverlap) { //FullViewForm->ExitOverlapChange(); doDestroy(OverlapBitmap) doDestroy(OverlapBack) FullViewForm->OverlapBitmap = NULL; FullViewForm->OverlapBack = NULL; } // return Undo->Save(k, r, bSave); bool rtn = Undo->UndoSave(k, r); END_LOG; return rtn; // by linuxjun Undo_Method } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::UndoSave(int k) // by linuxjun Undo_Method { BEGIN_LOG(""); Modify = true; if (FullViewForm->Super == sOverlap) { //FullViewForm->ExitOverlapChange(); doDestroy(OverlapBitmap) doDestroy(OverlapBack) FullViewForm->OverlapBitmap = NULL; FullViewForm->OverlapBack = NULL; } bool rtn = Undo->UndoSave(k); END_LOG; return rtn; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PenChange(void) { // MainImageForm Á¦°Å½Ã¿¡ ¸Þ¸ð¸® Á¢±Ù ¿À·ù¹ß»ýÇØ¼­ Ãß°¡ if (MainImageForm == NULL) return; BEGIN_LOG(""); PenManagerForm->rzckColorSelect->Enabled = iMainImage->uBitmap->BitsPerPixel == 8; PenManagerForm->ColorPanel->Enabled = iMainImage->uBitmap->BitsPerPixel == 8; PenManagerForm->numedEGrade->Enabled = iMainImage->uBitmap->BitsPerPixel == 8; if (MainMenuForm->Item == T_NONE) { if (PenManagerForm->Type == PT_MASK) { if (iMainImage->uBitmap->BitsPerPixel == 8) { OnSetHLine = SetHLineMask8; if (PenManagerForm->rzckDelete->Checked) { MaskPixel = 0x00; } else { MaskPixel = 0x0F; } } else { if (PenManagerForm->rzckDelete->Checked) { OnSetHLine = SetHLineMaskDelete24; MaskPixel = 0x00; } else { OnSetHLine = SetHLineMask24; MaskPixel = 0x80; } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (PenManagerForm->Type == PT_WATER) { PenManagerForm->Type == PT_NORMAL; PenManagerForm->sbNormal->Down = true; PenManagerForm->PenSelectClick(PenManagerForm->sbNormal); PenManagerForm->sbWater->Enabled = false; } else { PenManagerForm->sbWater->Enabled = false; } if (PenManagerForm->acolor == 2) { OnSetHLine = SetHLine8ColorYes; } else { OnSetHLine = SetHLine8ColorNo; } } else { PenManagerForm->sbWater->Enabled = true; OnSetHLine = SetHLine24; } } } else if (MainMenuForm->Item == T_DRAW || MainMenuForm->Item == T_3D) { if (PenManagerForm->Type == PT_MASK) { if (iMainImage->uBitmap->BitsPerPixel == 8) { OnSetHLine = SetHLineMask8; if (PenManagerForm->rzckDelete->Checked) { MaskPixel = 0x00; } else { MaskPixel = 0x0F; } } else { if (PenManagerForm->rzckDelete->Checked) { OnSetHLine = SetHLineMaskDelete24; MaskPixel = 0x00; } else { OnSetHLine = SetHLineMask24; MaskPixel = 0x80; } } } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { OnSetHLine = SetHLine8ColorNo; } else { OnSetHLine = SetHLine24; } } } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer50ms() { // } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer200ms() { if (CurrentUnit == uDot) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format ("%d : %d", OPENARRAY(TVarRec, ((int)CursorPosition.x, (int)CursorPosition.y))); } else if (CurrentUnit == uInch) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format ("%f : %f", OPENARRAY(TVarRec, ((double)CursorPosition.x / CanvasInfor.DotsPerInch, (double)CursorPosition.y / CanvasInfor.DotsPerInch))); } else if (CurrentUnit == uCm) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format ("%f : %f", OPENARRAY(TVarRec, (2.54 * CursorPosition.x / CanvasInfor.DotsPerInch, 2.54 * CursorPosition.y / CanvasInfor.DotsPerInch))); } if (sbRuler->Down) Ruler->PositionBar(CursorPosition); if (iMainImage->OnPaintIndexPoint) { // GreenFish HDC dcDst = iMainImage->Canvas->Handle; iMainImage->OnPaintIndexPoint(iMainImage, dcDst); } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - ±âÁؼ±À» ±×¸°´Ù - by monkman (2005.02.16) if (iMainImage->OnPaintVectorReflectIndexPoint) { HDC dcDst = iMainImage->Canvas->Handle; iMainImage->OnPaintVectorReflectIndexPoint(iMainImage, dcDst); } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer1000ms() { // static int i=0; /* if (!BtnClick) */ if (iMainImage && WorkArea) iMainImage->OutlineBitmapRgn(WorkArea->bComplex); // if(i==0&&Active&&iMainImage->CrossLine)iMainImage->Repaint(); // if(i==2)i=0; // i++; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::TimerAutoSave() { String msg, fn, ext; TGraphicFileFormat gff; if (iMainImage->uBitmap->BitsPerPixel == 8) { #ifdef TRIAL gff = gffTEX_TRIAL; ext = String(".ttex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors Trial File (*.ttex)|*.ttex"); #else gff = gffTEX; ext = String(".tex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.tex)|*.tex"); #endif } else { #ifndef N_3D if (MainForm->T3D_Item) { if (MainMenuForm->Item == T_3D) { #ifdef TRIAL gff = gffT3D_TRIAL; ext = String(".tt3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D Trial File (*.tt3d)|*.tt3d"); #else gff = gffT3D; ext = String(".t3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D File (*.t3d)|*.t3d"); #endif } else { #ifdef TRIAL gff = gffTFC_TRIAL; ext = String(".ttfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors Trial File (*.ttfc)|*.ttfc"); #else gff = gffTFC; ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); #endif } } else { #ifdef TRIAL gff = gffTFC_TRIAL; ext = String(".ttfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors Trial File (*.ttfc)|*.ttfc"); #else gff = gffTFC; ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); #endif } #else gff = gffTFC; ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); #endif } if (initsave) { TIniFile *IniFile = new TIniFile(AppDataItem + "\\Main.ini"); if (IniFile) { MainForm->SaveDialog->InitialDir = IniFile->ReadString ("FileManager", "DirectoryName", "C:\\"); delete IniFile; } if (MainForm->SaveDialog->Execute() == mrOk) { fn = MainForm->SaveDialog->FileName; if (LowerCase(ExtractFileExt(fn)) != ext) fn += ext; DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); AutoSaveForm = new TAutoSaveForm(NULL); AutoSaveForm->Visible = true; AutoSaveForm->Update(); AutoSaveToFile(DirName, FileName, gff, MainForm->CompressMethod); delete AutoSaveForm; initsave = false; } } else { AutoSaveForm = new TAutoSaveForm(NULL); AutoSaveForm->Visible = true; AutoSaveForm->Update(); AutoSaveToFile(DirName, FileName, gff, MainForm->CompressMethod); delete AutoSaveForm; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ApplyEnvironment() { TIniFile *IniFile = new TIniFile(AppDataItem + "\\status.ini"); if (IniFile) { WorkArea->undoMax = IniFile->ReadInteger("Window", "MaxUndo", 5); delete IniFile; } } // --------------------------------------------------------------------- void __fastcall TMainImageForm::ReadyToArrowKeyDown(bool IsDown) { sbHorz->Enabled = IsDown; sbVert->Enabled = IsDown; FullViewForm->tbOverlap->Enabled = IsDown; FullViewForm->TrackBar->Enabled = IsDown; } // --------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange() { BEGIN_LOG(""); if (iMainImage->LayerMask) { OverlapChange_layer(); } else { OverlapChange_none(); } END_LOG; } // --------------------------------------------------------------------- void __fastcall TMainImageForm::ChangeLayer() { BEGIN_LOG(""); MainMenuForm->ExitForm(); BackGroundSettingForChangeLayer(); END_LOG; /* if (bProtect) { iMainImage->ExitBackGround(0x10); iMainImage->InitBackGround(0x10); } if (PenManagerForm->acolor == 2) { iMainImage->ExitBackGround(0x20); iMainImage->InitBackGround(0x20); } if (PenManagerForm->Type == PT_WATER) { iMainImage->ExitBackGround(0x04); iMainImage->InitBackGround(0x04); } */ } void __fastcall TMainImageForm::BackGroundSettingForChangeLayer() { if (bProtect) { iMainImage->ExitBackGround(0x10); iMainImage->InitBackGround(0x10); } if (PenManagerForm->acolor == 2) { iMainImage->ExitBackGround(0x20); iMainImage->InitBackGround(0x20); } if (PenManagerForm->Type == PT_WATER) { iMainImage->ExitBackGround(0x04); iMainImage->InitBackGround(0x04); } } // --------------------------------------------------------------------- void __fastcall TMainImageForm::RegionMouseDown(int X, int Y) { BEGIN_LOG(""); TransformRegionKind = RegionMethod(X, Y); if (TransformRegionKind) { bRegionDown = true; region = WorkArea->Range; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::RegionMouseMove(int X, int Y) { TPItemImage *Image = iMainImage; Image->SetCrossPos(Point(X, Y)); int hw, hh; TSize size; if (bRegionDown) { if (bRegionDraw) DrawRectangleLocate(region); if (TransformRegionKind == 5) { size.cx = WorkArea->Range.right - WorkArea->Range.left; size.cy = WorkArea->Range.bottom - WorkArea->Range.top; hw = size.cx / 2.0; hh = size.cy / 2.0; region.left = X - hw; if (region.left < 0) region.left = 0; if (region.left + size.cx > iMainImage->uBitmap->Width) region.left = iMainImage->uBitmap->Width - size.cx; region.right = region.left + size.cx; region.top = Y - hh; if (region.top < 0) region.top = 0; if (region.top + size.cy > iMainImage->uBitmap->Height) region.top = iMainImage->uBitmap->Height - size.cy; region.bottom = region.top + size.cy; } else { switch(TransformRegionKind) { case 1: region.left = X; region.top = Y; break; case 2: region.right = X + 1; region.top = Y; break; case 3: region.left = X; region.bottom = Y + 1; break; case 4: region.right = X + 1; region.bottom = Y + 1; } } DrawRectangleLocate(region); bRegionDraw = true; } int kind = RegionMethod(X, Y); if (kind == 5) iMainImage->Cursor = crHandPoint; else if (kind && kind < 5) iMainImage->Cursor = crCross; else iMainImage->Cursor = crDefault; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::RegionMouseUp(int X, int Y) { if (bRegionDown) { if (bRegionDraw) DrawRectangleLocate(region); WorkArea->Transform(region); bRegionDown = false; bRegionDraw = false; DrawRectangleLocate(region, 0); ::RepaintImage(); } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::RegionChange() { bRegionDown = false; bRegionDraw = false; DrawRectangleLocate(region, 0); TransformRegionKind = 0; iMainImage->Repaint(); } // --------------------------------------------------------------------------- int __fastcall TMainImageForm::RegionMethod(int X, int Y) { RECT r = WorkArea->Range; if (bRegionDown == false) { if (X > r.left - 5 && X < r.left + 5) { if (Y > r.top - 5 && Y < r.top + 5) return 1; else if (Y > r.bottom - 5 && Y < r.bottom + 5) return 3; } else if (X > r.right - 5 && X < r.right + 5) { if (Y > r.top - 5 && Y < r.top + 5) return 2; else if (Y > r.bottom - 5 && Y < r.bottom + 5) return 4; } else if (PtInRect(&r, Point(X, Y))) return 5; } return 0; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomForKeyDown(int Key) // added by qe È®´ëÃà¼Ò ´ÜÃàŰ { WORD wKey; TShiftState Shift; // bool IsEditMode = false; // if(TextForm) IsEditMode |= TextForm->Edit->Enabled; // if(StyleForm) IsEditMode |= StyleForm->EditPara->Enabled; // if(APMenuForm&&APTableForm->Visible) IsEditMode |= APTableForm->APTableView; // if(N3DMappingForm) IsEditMode |= N3DMappingForm->edName->Focused(); // if(PaletteForm) IsEditMode |= PaletteForm->PanelLibrary->Visible; // if(NewGroupingForm) IsEditMode |= NewGroupingForm->Visible; // if(VectorForm && VectorForm->UseComboBoxForText) return; //for TextBox by maxleo21c (04.11.03) // if(ComboMenu) IsEditMode |= ComboMenu->Visible; // added by maxleo21c (05.03.08) if (MainMenuForm && MainMenuForm->Item == T_CTRLT) { // 07.02.12 by maxleo21 if (MainMenuForm->CtrlTMouseState()) return; } // Æ÷ÀÎÆ® ÀúÀå ÆíÁýâÀÇ PaintBox(Á¤È®ÇÏ°Ô ¸»Çϸé btnPaintBoxFocus)¿¡ Æ÷Ä¿½º°¡ // ÀÖÀ» °æ¿ì ĵ¹ö½º È®´ëÃà¼ÒÀÇ A/S ´ÜÃà۰¡ Æ÷ÀÎÆ® ÀúÀå ÆíÁýâÀ¸·Î °¡µµ·Ï ÇÑ´Ù. - by monkman (2011.03.31) if (DataTransForm && DataTransForm->Visible && DataTransForm->btnPaintBoxFocus->Focused()) { wKey = Key; Shift.Clear(); DataTransForm->btnPaintBoxFocusKeyDown(NULL, wKey, Shift); return; } // if(!IsEditMode){ int Ratio = 0; if (Key == 'A') { // 'a' or 'A' Key = 0; switch(iMainImage->ZoomIn) { // ÇöÀçÀÇ È®´ë, Ãà¼ÒµÈ ºñÀ²Àº ¾Ë¾Æ³»¾î case 1: switch(iMainImage->ZoomOut) { // ºñÀ²¿¡ µû¶ó ratio¶ó´Â º¯¼ö¿¡ Àû´çÇÑ °ªÀ» case 1: Ratio = 302; break; // ÀԷ½Ã۰í, ±×°ÍÀº parameter·Î ÇÏ´Â ÇÔ¼ö(RatioZoom) case 2: Ratio = 203; break; // ¸¦ È£ÃâÇÑ´Ù. case 3: Ratio = 102; break; case 4: Ratio = 103; break; // ¼öÁ¤ By GreenFish (Áܴܰè È®Àå) case 6: Ratio = 104; break; case 8: Ratio = 106; break; case 12: Ratio = 108; break; case 16: Ratio = 112; break; } break; case 2: switch(iMainImage->ZoomOut) { case 1: Ratio = 301; break; case 3: Ratio = 101; break; } break; case 3: switch(iMainImage->ZoomOut) { case 1: Ratio = 401; break; case 2: Ratio = 201; break; } break; case 4: Ratio = 601; break; case 6: Ratio = 801; break; case 8: Ratio = 1201; break; case 12: Ratio = 1601; break; default: return; } // ¼Óµµ °³¼±À» À§ÇØ ¿òÁ÷ÀÏ °æ¿ì (GDI·Î ±×¸°´Ù - ¿ÀºêÁ§Æ® À̵¿, ĵ¹ö½º À̵¿ µîÀ» À̵¿ÇÒ ¶§) - by monkman (2005.07.11) TList *DataList = form->V_DATA; if (VecDraw->NVector) VecDraw->NVector->bVectorMove = true; RatioZoom(Ratio); // GDI+·Î ±×¸®µµ·Ï µ¹·Á³õ´Â´Ù - by monkman (2008.10.20) tmVectorMoveDraw->Enabled = true; } if (Key == 'S') { // 's' or 'S' Key = 0; switch(iMainImage->ZoomIn) { case 1: switch(iMainImage->ZoomOut) { case 1: Ratio = 203; break; case 2: Ratio = 103; break; case 3: Ratio = 104; break; case 4: Ratio = 106; break; case 6: Ratio = 108; break; case 8: Ratio = 112; break; case 12: Ratio = 116; break; default: return; } break; case 2: switch(iMainImage->ZoomOut) { case 1: Ratio = 302; break; case 3: Ratio = 102; break; } break; case 3: switch(iMainImage->ZoomOut) { case 1: Ratio = 201; break; case 2: Ratio = 101; break; } break; case 4: Ratio = 301; break; case 6: Ratio = 401; break; case 8: Ratio = 601; break; case 12: Ratio = 801; break; case 16: Ratio = 1201; break; default: return; } // ¼Óµµ °³¼±À» À§ÇØ ¿òÁ÷ÀÏ °æ¿ì (GDI·Î ±×¸°´Ù - ¿ÀºêÁ§Æ® À̵¿, ĵ¹ö½º À̵¿ µîÀ» À̵¿ÇÒ ¶§) - by monkman (2005.07.11) TList *DataList = form->V_DATA; if (VecDraw->NVector) VecDraw->NVector->bVectorMove = true; RatioZoom(Ratio); // GDI+·Î ±×¸®µµ·Ï µ¹·Á³õ´Â´Ù - by monkman (2008.10.20) tmVectorMoveDraw->Enabled = true; } // } if (MainMenuForm && MainMenuForm->Item == T_CTRLT) { // 07.02.12 by maxleo21 TShiftState Shift; if (!MainMenuForm->CtrlTMouseState()) MainMenuForm->iMainImageKeyDown(this, 'S', Shift); } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::RatioZoom(int r) // by qe and GreenFish { int a, b; a = r / 100; b = r % 100; GetCursorPos(&ptScreen); // ¸¶¿ì½º Ä¿¼­ÀÇ À§Ä¡¸¦ ÀԷ¹޴´Ù. ZoomChange(a, b, &ptScreen); /* switch (r){ //È®´ëµÉ ºñÀ² case 116 : ZoomChange(1, 16, &ptScreen); break; case 18 : ZoomChange(1, 8, &ptScreen); break; case 14 : ZoomChange(1, 4, &ptScreen); break; case 12 : ZoomChange(1, 2, &ptScreen); break; case 1 : ZoomChange(1, 1, &ptScreen); break; case 2 : ZoomChange(2, 1, &ptScreen); break; case 4 : ZoomChange(4, 1, &ptScreen); break; case 8 : ZoomChange(8, 1, &ptScreen); break; case 16 : ZoomChange(16, 1, &ptScreen); break; default : return; } */ } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoRepUpdateMenu(bool bExitForm) { if (bExitForm) { MainMenuForm->ARExitForm(); } else { MainMenuForm->AutoRepUpdateItem(); } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ARViewExitForm() { if (AutoRepViewForm) { AutoRepViewForm->WriteIniFile(); doDestroy(AutoRepViewForm) // Error } sbAutoRepView->Down = false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::RedrawingRepeat (bool MaskBmp, bool repaint, bool Draw) { BEGIN_LOG(""); POINT sp, ep; HRGN rgn = NULL; THistoryData *ud = NULL; ud = Undo->GetLast(); if (Draw) { if (MaskBmp == false && ud && ud->getUndoKind() == UK_MASK && MainMenuForm->Item == T_UNDO && UndoForm && UndoForm->bPenUndoUse) { MaskBmp = true; } // ========================================= Delete WorkArea for BitBlt if (WorkArea->Mask) { // ¾î´À ¼±Åà ¿µ¿ªÀÌ ÀÖÀ¸¸é ±× ºÎºÐ¸¸ BitBlt°¡ µÈ´Ù. WorkArea->ResetRegion(iMainImage, &rgn); } // ========================================== if (ARTItem == AREPEAT_NORMAL) { // Normal NormalDrawing(MaskBmp); } else if (ARTItem == AREPEAT_HDVER) { // Half Drop Ver. HDVERDrawing(MaskBmp); } else if (ARTItem == AREPEAT_HDHOR) { // Half Drop Hor. HDHORDrawing(MaskBmp); } if (rgn) { WorkArea->SetRegion(rgn); DeleteObject(rgn); } // if PenUndo ÁßÀ̳Ä? if (UndoForm) { if (UndoForm->bPenUndoUse) { MainImageForm->iMainImage->uBitmap->PartialUndo->LoadAutoRepeatPenUndo (); if (MaskBmp) MainImageForm->iMainImage->Mask->PartialUndo->LoadAutoRepeatPenUndo(); } } //////////// } if (repaint) iMainImage->Repaint(); if (AutoRepViewForm) AutoRepViewForm->ReDrawImage(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawARepeatArea (TObject *Sender, HDC hDC, int X, int Y) { TPItemImage *Image = (TPItemImage*)Sender; int sx, sy, ex, ey; HBRUSH hOldBrush = NULL; COLORREF clOldBk; HPEN hPen = NULL, hOldPen = NULL; sx = Image->BitmapToCanvasX(arwindow.s.x) - X; sy = Image->BitmapToCanvasY(arwindow.s.y) - Y; ex = Image->BitmapToCanvasX(arwindow.e.x) - X; ey = Image->BitmapToCanvasY(arwindow.e.y) - Y; hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH)); clOldBk = SetBkColor(hDC, clWhite); hPen = CreatePen(PS_DASHDOT, 1, clBlack); hOldPen = (HPEN)SelectObject(hDC, hPen); Rectangle(hDC, sx, sy, ex, ey); SelectObject(hDC, hOldPen); DeleteObject(hPen); SetBkColor(hDC, clOldBk); SelectObject(hDC, hOldBrush); } // --------------------------------------------------------------------------- RECT __fastcall TMainImageForm::AutoRep_UndoRect(RECT rt) { int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; RECT art, rect; art = Rect(arwindow.s.x - arwindow.size.x / 2 - ARWidthR, arwindow.s.y - arwindow.size.y / 2 - ARHeightR, arwindow.e.x + arwindow.size.x / 2, arwindow.e.y + arwindow.size.y / 2); UnionRect(&rect, &rt, &art); return rect; } // --------------------------------------------------------------------------- RECT __fastcall TMainImageForm::AutoRep_UndoRect() { int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; RECT art, rect; art = Rect(arwindow.s.x - arwindow.size.x / 2 - ARWidthR, arwindow.s.y - arwindow.size.y / 2 - ARHeightR, arwindow.e.x + arwindow.size.x / 2, arwindow.e.y + arwindow.size.y / 2); return art; } // --------------------------------------------------------------------- /// ĵ¹ö½º À§ÀÇ ¸¶¿ì½º Ä¿¼­¸¦ ±×¸®´Â ÇÔ¼ö /** * SRCNOT ¹æ½ÄÀ¸·Î Ä¿¼­¸¦ ±×·Á¼­, ±âÁ¸ Ä¿¼­´Â ÀÚµ¿À¸·Î Áö¿öÁö°í ³Ñ¾î°¡µµ·Ï ÀÛ¼ºµÈ ÇÔ¼öÀÌ´Ù. * ÇÑ ¹ø ±×¸° Æ÷ÀÎÅ͸¦ ±â¾ïÇÏ¿© Áö¿ìµµ·Ï Çϱâ À§ÇØ, oldX, oldY, oldBasicThick, oldShape ¶ó´Â * º¯¼ö¸¦ »ç¿ëÇÑ´Ù. */ // 2007.03.05. diekun void __fastcall TMainImageForm::PaintPenLocate (TObject *Sender, HDC formDC, int X, int Y) { // diekun.2007.01.05. °°Àº À§Ä¡¿¡´Â ²À µÎ¹ø¾¿ µé¾î°£´Ù´Â °ÍÀ» ¿ø¸®·Î ÀÚ±¹³²´Â ¿¡·¯ °íÃÆÀ½. static int oldX = -1, oldY = -1; static int oldBasicThick, oldShape; int drawingThick, drawingShape; if (oldX == X && oldY == Y) { drawingThick = oldBasicThick; drawingShape = oldShape; } else { drawingThick = PenManagerForm->Pen->BasicThick; drawingShape = PenManagerForm->Pen->Shape; } HBRUSH hOldBrush = NULL; HPEN hOldPen = NULL, hPen = NULL; int nDrawMode; int ls, rs, left, top, right, bottom; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); hPen = CreatePen(PS_SOLID, 1, clWhite); hOldPen = (HPEN)SelectObject(formDC, hPen); nDrawMode = GetROP2(formDC); SetROP2(formDC, R2_NOT); ls = drawingThick >> 1; rs = drawingThick - ls; double ratio = iMainImage->ZoomIn / (double)iMainImage->ZoomOut; // gabriel if (drawingThick * ratio > 5) { left = X - ls * ratio; top = Y - ls * ratio; right = X + rs * ratio + 1; bottom = Y + rs * ratio + 1; if (drawingShape) Rectangle(formDC, left, top, right, bottom); else Ellipse(formDC, left, top, right, bottom); } MoveToEx(formDC, X, Y - 15, NULL); LineTo(formDC, X, Y + 15); MoveToEx(formDC, X - 15, Y, NULL); LineTo(formDC, X + 15, Y); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); DeleteObject(hPen); // oldº¯¼ö ó¸® oldX = X; oldY = Y; oldBasicThick = drawingThick; oldShape = drawingShape; } // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // External Function // --------------------------------------------------------------------- void __fastcall RepaintImage() { RGBQUAD rgb[256]; if (MainImageForm) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { MainImageForm->ApplyPalette(); } MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); //shin vector LayerForm->InitForm(); } } // --------------------------------------------------------------------- void __fastcall RepaintColor() { RGBQUAD rgb[256]; if (MainImageForm) { if (MainMenuForm && MainMenuForm->Item == T_COMBO && ComboMenu && !ComboMenu->isLoad) { // added by maxleo21c (05.02.15) return; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { MainImageForm->ApplyPalette(); } MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); PaletteForm->InitForm(MainImageForm->Palette); LayerForm->InitForm(); PenManagerForm->SetColor(MainImageForm->Palette); ColorLibraryForm->View(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) { if (AutoRepViewForm) AutoRepViewForm->ReDrawImage(); } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetMaskShow(bool Value) { if (iMainImage->MaskEnabled != Value) { iMainImage->MaskEnabled = Value; sbMaskShow->Down = Value; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::IsMerge(POINT p) { BEGIN_LOG(""); TUnionBitmap* Bitmap = iMainImage->uBitmap; // convert by celberus TPException ec = EC_NONE; /* switch (iMainImage->IsBackGround()) { case 0: Bitmap = iMainImage->uBitmap; break; case 1: Bitmap = iMainImage->BackGround; break; // case 1: Bitmap = iMainImage->uBitmap; break; // convert by celberus FBackgroundÀÇ È°¿ë¿©ºÎ? default : { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } */ if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->SubBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->SubMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (FullViewForm->Super == sGauze) { if (TempMask) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_TempMask_Gauze8(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_TempMask_Gauze24(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Gauze24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_TempMask_Gauze8(Bitmap, p.x, p.y); else Merge_TempMask_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_TempMask_Gauze24(Bitmap, p.x, p.y); else Merge_TempMask_Gauze24(Bitmap, p.x, p.y); } } TempMask->StopScanLine(); } else { if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_Gauze8(Bitmap, p.x, p.y); else Merge_Mask_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_Gauze24(Bitmap, p.x, p.y); else Merge_Mask_Gauze24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_Gauze8(Bitmap, p.x, p.y); else Merge_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_TempMask_Gauze24(Bitmap, p.x, p.y); else Merge_Gauze24(Bitmap, p.x, p.y); } } } } else { if (TempMask) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_TempMask_Default8(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Default8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_TempMask_Default24(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Default24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_TempMask_Default8(Bitmap, p.x, p.y); else Merge_TempMask_Default8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_TempMask_Default24(Bitmap, p.x, p.y); else Merge_TempMask_Default24(Bitmap, p.x, p.y); } } TempMask->StopScanLine(); } else { if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_Default8(Bitmap, p.x, p.y); else Merge_Mask_Default8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_Default24(Bitmap, p.x, p.y); else Merge_Mask_Default24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_Default8(Bitmap, p.x, p.y); else Merge_Default8(p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_Default24(Bitmap, p.x, p.y); // k3dogs <- Merge_Temp8_TempMask_Default24(Bitmap, p.x, p.y) else Merge_Default24(p.x, p.y); } } } } iMainImage->SubMask->StopScanLine(); iMainImage->SubBitmap->StopScanLine(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); END_LOG; return; fail: iMainImage->Mask->StopScanLine(); iMainImage->SubMask->StopScanLine(); iMainImage->SubBitmap->StopScanLine(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); // need-conversion FBackGround´Â TexpiaBitmapÀ̰í uBitmapÀº UnionBitmap END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem(int X, int Y) { BEGIN_LOG(""); switch(iMainImage->IsBackGround()) { case 0: if (!OpenItem_none(X, Y)) goto fail; break; case 1: if (!OpenItem_layer(X, Y)) goto fail; break; default: goto fail; } END_LOG; return true; fail: END_LOG; return false; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintCurrentIndexPoint(void) { // By GreenFish ÇöÀç À妽º Æ÷ÀÎÆ® ±×¸®±â iMainImage->OnPaintCursor = NULL; HDC formDC = NULL; formDC = iMainImage->Canvas->Handle; HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; POINT cp = iMainImage->GetCrossPos(); RGBQUAD rgb; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); if (!IndexColor) IndexColor = clBlack; hPen = CreatePen(psSolid, 1, IndexColor); hOldPen = (HPEN)SelectObject(formDC, hPen); SetROP2(formDC, R2_NOT); if (Ruler->Cursor == crHSplit) { MoveToEx(formDC, cp.x, iMainImage->Parent->Top - 25, NULL); LineTo(formDC, cp.x, iMainImage->Parent->Top + iMainImage->Parent->Height); } else if (Ruler->Cursor == crVSplit) { MoveToEx(formDC, iMainImage->Parent->Left - 25, cp.y, NULL); LineTo(formDC, iMainImage->Parent->Left + iMainImage->Parent->Width, cp.y); } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); DeleteObject(hPen); hPen = NULL; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintIndexPoint(TObject *Sender, HDC dcMemV) { // ±×·ÁÁ® ÀÖ´Â À妽º Æ÷ÀÎÆ® ±×¸®±â By GreenFish HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; RGBQUAD rgb; hOldBrush = (HBRUSH)SelectObject(dcMemV, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(dcMemV); if (!IndexColor) IndexColor = clBlack; hPen = CreatePen(psSolid, 1, IndexColor); hOldPen = (HPEN)SelectObject(dcMemV, hPen); // »ö±ò ¹Ù²Ü¶§ »ç¿ë SetROP2(dcMemV, R2_COPYPEN); for (int i = 0; i < VI; i++) { MoveToEx(dcMemV, (VIndex[i] - sbHorz->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut, iMainImage->Parent->Top - 25, NULL); LineTo(dcMemV, (VIndex[i] - sbHorz->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut, iMainImage->Parent->Top + iMainImage->Parent->Height); } for (int j = 0; j < HI; j++) { MoveToEx(dcMemV, iMainImage->Parent->Left - 25, (HIndex[j] - sbVert->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut, NULL); LineTo(dcMemV, iMainImage->Parent->Left + iMainImage->Parent->Width, (HIndex[j] - sbVert->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut); } SetROP2(dcMemV, nDrawMode); SelectObject(dcMemV, hOldBrush); SelectObject(dcMemV, hOldPen); hOldPen = NULL; DeleteObject(hPen); hPen = NULL; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintVectorCurrentReflectIndexPoint() { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - by monkman(2005.02.16) // ¹ÝÀü °Å¿ï ±âÁؼ± À妽º Æ÷ÀÎÆ® ±×¸®±â (±×¸®´Â Áß) iMainImage->OnPaintCursor = NULL; HDC formDC = NULL; formDC = iMainImage->Canvas->Handle; HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; RGBQUAD rgb; POINT cp = iMainImage->GetReflectionPos(); hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); if (!IndexColor) IndexColor = clBlack; hPen = CreatePen(psDashDotDot, 1, IndexColor); hOldPen = (HPEN)SelectObject(formDC, hPen); SetROP2(formDC, R2_NOT); switch(NVector->ReflectionVH) { case 3: // ¼öÁ÷ ±âÁؼ± ±×¸®±â MoveToEx(formDC, cp.x, iMainImage->Parent->Top - 25, NULL); LineTo(formDC, cp.x, iMainImage->Parent->Top + iMainImage->Parent->Height); break; case 4: // ¼öÆò ±âÁؼ± ±×¸®±â MoveToEx(formDC, iMainImage->Parent->Left - 25, cp.y, NULL); LineTo(formDC, iMainImage->Parent->Left + iMainImage->Parent->Width, cp.y); break; } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); DeleteObject(hPen); hPen = NULL; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintVectorReflectIndexPoint (TObject *Sender, HDC dcMemV) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É °ü·Ã - by monkman(2005.02.16) // ¹ÝÀü °Å¿ï ±âÁؼ± À妽º Æ÷ÀÎÆ® ±×¸®±â HPEN hOldPen = NULL, hPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; RGBQUAD rgb; hOldBrush = (HBRUSH)SelectObject(dcMemV, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(dcMemV); if (!IndexColor) IndexColor = clBlack; hPen = CreatePen(psDashDotDot, 1, IndexColor); hOldPen = (HPEN)SelectObject(dcMemV, hPen); // »ö±ò ¹Ù²Ü¶§ »ç¿ë SetROP2(dcMemV, R2_COPYPEN); switch(NVector->ReflectionVH) { case 0: // ¾Æ¹«°Íµµ ±×¸®Áö ¾Ê´Â´Ù break; case 1: // ¼öÁ÷ ±âÁؼ± ±×¸®±â if (NVector->ReflectionVIndex > 0) { MoveToEx(dcMemV, (NVector->ReflectionVIndex - sbHorz->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut, iMainImage->Parent->Top - 25, NULL); LineTo(dcMemV, (NVector->ReflectionVIndex - sbHorz->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut, iMainImage->Parent->Top + iMainImage->Parent->Height); } break; case 2: // ¼öÆò ±âÁؼ± ±×¸®±â if (NVector->ReflectionHIndex > 0) { MoveToEx(dcMemV, iMainImage->Parent->Left - 25, (NVector->ReflectionHIndex - sbVert->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut, NULL); LineTo(dcMemV, iMainImage->Parent->Left + iMainImage->Parent->Width, (NVector->ReflectionHIndex - sbVert->Position) * iMainImage->ZoomIn / iMainImage->ZoomOut); } break; } SetROP2(dcMemV, nDrawMode); SelectObject(dcMemV, hOldBrush); SelectObject(dcMemV, hOldPen); hOldPen = NULL; DeleteObject(hPen); hPen = NULL; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::RulerMouseDown (TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - ¹ÝÀü °Å¿ï Æû´Ý±â - by monkman (2005.02.24) if (VectorForm) { if (!VectorForm->ExitReflectionMirror()) return; } // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (MainMenuForm->Item != T_INDEX) MainMenuForm->ExitForm(1); if (Button != mbLeft) return; if (X < 24 && Y < 24) { // ¸ð¼­¸® Ŭ¸¯½Ã Visible on/off Visible1Click(this); return; } // if ((HIM || VIM)) { // À̵¿Áß¿¡ ÀÚ Å¬¸¯½Ã À妽º Á¦°Å if ((HIndexSelected || VIndexSelected)) { // À̵¿Áß¿¡ ÀÚ Å¬¸¯½Ã À妽º Á¦°Å Ruler->Cursor = crDefault; HIndexSelected = false; VIndexSelected = false; HIM = VIM = NULL; iMainImage->Repaint(); IndexSW = false; return; } else { if (false == Visible1->Checked) return; // by celberus visible false¸é À妽º ¹Ù ½ÇÇà¾ÈµÇ°Ô HIM = VIM = NULL; IndexSW = true; } if ((X < 24 && VI >= 20) || (Y < 24 && HI >= 20)) return; // 20°³ ³Ñ¾î°¡¸é ±×¸¸! if (X < 24) { Ruler->Cursor = crHSplit; // By GreenFish VIndexSelected = true; } if (Y < 24) { Ruler->Cursor = crVSplit; // ÀÛ¾÷Áß HIndexSelected = true; } sbCrossLine->Enabled = false; // Å©·Î½º¶óÀÎ »ç¿ëºÒ°¡ iMainImage->OnPaintIndexPoint = PaintIndexPoint; Visible1->Checked = true; FirstIndex = true; // ù¶óÀÎÀÇ Áߺ¹ ¹æÁö if (sbCrossLine->Down) { sbCrossLine->Down = false; iMainImage->Cross = false; iMainImage->CrossLine = false; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Visible1Click(TObject *Sender) { // Index ¼û±â±â/º¸À̱â if (Visible1->Checked == true) { Visible1->Checked = false; iMainImage->OnPaintIndexPoint = NULL; iMainImage->Repaint(); } else { Visible1->Checked = true; iMainImage->OnPaintIndexPoint = PaintIndexPoint; } isPaintDirectlyClean = false; PaintDirectly(iMainImage->Canvas->Handle, iMainImage->Parent->Left, iMainImage->Parent->Top, iMainImage->Parent->Width, iMainImage->Parent->Height); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::IndexLock1Click(TObject *Sender) { if (IndexLock1->Checked) { IndexLock1->Checked = false; } else { IndexLock1->Checked = true; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::N2Click(TObject *Sender) // Index ÃʱâÈ­ { VI = 0; HI = 0; iMainImage->Repaint(); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::N1Click(TObject *Sender) // Index »ö¹Ù²Ù±â { if (ColorIndex->Execute()) IndexColor = ColorIndex->Color; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ReopenMove(int X, int Y) // 2001.6.5. by lhskys ÀÛ¾÷±¸¿ª save { #ifdef TEXSTYLIST int x, y; COLORREF bgc, c; TPItemImage *Image = iMainImage; Screen->Cursor = crHandPoint; X = X - Image->SubBitmap->Width / 2.0; Y = Y - Image->SubBitmap->Height / 2.0; if (X < 0 && Y < 0) { X = 0; Y = 0; } else if (X < 0 && Y + Image->SubBitmap->Height > Image->uBitmap->Height) { X = 0; Y = Image->uBitmap->Height - Image->SubBitmap->Height; } else if (X + Image->SubBitmap->Width > Image->uBitmap->Width && Y < 0) { X = Image->uBitmap->Width - Image->SubBitmap->Width; Y = 0; } else if (X + Image->SubBitmap->Width > Image->uBitmap->Width && Y + Image->SubBitmap->Height > Image->uBitmap->Height) { X = Image->uBitmap->Width - Image->SubBitmap->Width; Y = Image->uBitmap->Height - Image->SubBitmap->Height; } else if (X < 0) { X = 0; } else if (X + Image->SubBitmap->Width > Image->uBitmap->Width) { X = Image->uBitmap->Width - Image->SubBitmap->Width; } else if (Y < 0) { Y = 0; } else if (Y + Image->SubBitmap->Height > Image->uBitmap->Height) { Y = Image->uBitmap->Height - Image->SubBitmap->Height; } Image->SubRange.left = X; MoveRect.s.x = X; MoveRect.e.x = MoveRect.s.x + MoveRect.size.x; Image->SubRange.top = Y; MoveRect.s.y = Y; MoveRect.e.y = MoveRect.s.y + MoveRect.size.y; Image->SubVisible = true; Image->SetCrossPos(Point(X, Y)); if (X < 0) X = 0; else if (X > Image->uBitmap->Width - Image->SubBitmap->Width) X = Image->uBitmap->Width - Image->SubBitmap->Width; if (Y < 0) Y = 0; if (Y > Image->uBitmap->Height - Image->SubBitmap->Height) Y = Image->uBitmap->Height - Image->SubBitmap->Height; if (Image->SubRange.left < X) { paintrect.left = Image->SubRange.left; paintrect.right = X + Image->SubBitmap->Width; } else { paintrect.left = X; paintrect.right = Image->SubRange.left + Image->SubBitmap->Width; } if (paintrect.right > Image->uBitmap->Width) paintrect.right = Image->uBitmap->Width; if (Image->SubRange.top < Y) { paintrect.top = Image->SubRange.top; paintrect.bottom = Y + Image->SubBitmap->Height; } else { paintrect.top = Y; paintrect.bottom = Image->SubRange.top + Image->SubBitmap->Height; } if (paintrect.bottom > Image->uBitmap->Height) paintrect.bottom = Image->uBitmap->Height; iMainImage->Repaint(); return; #endif } // ----------------------------------------------------------------------------- bool __fastcall TMainImageForm::WLoadFile(String FullFileName, TGraphicFileFormat Index) // 2001.8.29 by lhskys ÀÛ¾÷±¸¿ª save¿¡¼­ { BEGIN_LOG(""); // SubBitmapÀÇ Å©±â¸¦ ÃøÁ¤. TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; TPalette *TempPalette = NULL; TGraphicFileFormat gff; if (TempBitmap) delete TempBitmap; if ((TempBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((TempPalette = new TPalette) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((hFile = CreateFile(FullFileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } gff = FindExtension(ExtractFileExt(FullFileName)); if ((ec = LoadFromTexpiaFile(hFile, TempPalette, tpfh, TempBitmap, gff)) != EC_NONE) goto fail; waWidth = tpfh.CanvasInfor.Width; waHeight = tpfh.CanvasInfor.Height; CloseHandle(hFile); delete TempBitmap; // by celberus delete TempPalette; // by celberus TempBitmap = NULL; TempPalette = NULL; END_LOG; return true; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); EXCEPTION_MESSAGE_OK(ec); END_LOG; return ec; } // ----------------------------------------------------------------------------- COLORREF __fastcall TMainImageForm::GetBGColor(int BPP) { COLORREF bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(BPP); return bgc; } // ----------------------------------------------------------------------------- void __fastcall TMainImageForm::SetFont() { SetSmallFont(Font); SetSmallFont(TempLabel->Font); SetSmallFont(sbUnit->Font); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::MHdivDrawing1(bool MaskBmp) { BEGIN_LOG(""); int hw, hh; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dsp, spp1, spp2, spp3; hw = arwindow.size.x / 2; hh = arwindow.size.y / 2; dsp = Point(arwindow.s.x, arwindow.s.y); spp1 = Point(arwindow.e.x, arwindow.s.y + MHdiv); spp2 = Point(arwindow.e.x, arwindow.e.y + MHdiv); spp3 = Point(arwindow.s.x, arwindow.e.y); AR_VDrawing(MaskBmp, hw, hh - MHdiv, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x, arwindow.s.y + hh - MHdiv); spp1 = Point(arwindow.e.x, arwindow.s.y - hh - ARHeightR); spp2 = Point(arwindow.e.x, arwindow.e.y - hh - ARHeightR); spp3 = Point(arwindow.s.x, arwindow.e.y + hh - MHdiv); AR_VDrawing(MaskBmp, hw, MHdiv, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x, arwindow.s.y + hh); spp1 = Point(arwindow.s.x, arwindow.s.y - hh - ARHeightR); spp2 = Point(arwindow.e.x, arwindow.s.y - hh + MHdiv - ARHeightR); spp3 = Point(arwindow.e.x, arwindow.e.y - hh + MHdiv - ARHeightR); AR_VDrawing(MaskBmp, hw, hh + ARHeightR, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x + hw, arwindow.s.y); spp1 = Point(arwindow.s.x + hw, arwindow.e.y); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y - MHdiv); spp3 = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y - MHdiv); AR_VDrawing(MaskBmp, hw + ARWidthR, hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x + hw, arwindow.s.y + hh); spp1 = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y + hh - MHdiv); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y + hh - MHdiv); spp3 = Point(arwindow.s.x + hw, arwindow.s.y - hh - ARHeightR); AR_VDrawing(MaskBmp, hw + ARWidthR, MHdiv, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x + hw, arwindow.s.y + hh + MHdiv); spp1 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y + hh); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y - hh - ARHeightR); spp3 = Point(arwindow.s.x + hw, arwindow.s.y - hh + MHdiv - ARHeightR); AR_VDrawing(MaskBmp, hw + ARWidthR, hh - MHdiv + ARHeightR, dsp, spp1, spp2, spp3); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::MHdivDrawing2(bool MaskBmp) { BEGIN_LOG(""); int hw, hh; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dsp, spp1, spp2, spp3; hw = arwindow.size.x / 2; hh = arwindow.size.y / 2; dsp = Point(arwindow.s.x, arwindow.s.y); // Left - Top spp1 = Point(arwindow.e.x, arwindow.s.y - hh - ARHeightR); spp2 = Point(arwindow.e.x, arwindow.e.y - hh - ARHeightR); spp3 = Point(arwindow.s.x, arwindow.e.y); AR_VDrawing(MaskBmp, hw, hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.e.x - hw - ARWidthR, arwindow.s.y); // Right - Top spp1 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y - hh - ARHeightR); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y - hh - ARHeightR); spp3 = Point(arwindow.e.x - hw - ARWidthR, arwindow.e.y); AR_VDrawing(MaskBmp, hw + ARWidthR, hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x, arwindow.e.y - hh - ARHeightR); // Left - Bottom spp1 = Point(arwindow.s.x, arwindow.s.y - hh - ARHeightR); spp2 = Point(arwindow.e.x, arwindow.s.y - ARHeightR); spp3 = Point(arwindow.e.x, arwindow.e.y - ARHeightR); AR_VDrawing(MaskBmp, hw, hh + ARHeightR, dsp, spp1, spp2, spp3); dsp = Point(arwindow.e.x - hw - ARWidthR, arwindow.e.y - hh - ARHeightR); // Right - Bottom spp1 = Point(arwindow.e.x - hw - ARWidthR, arwindow.s.y - hh - ARHeightR); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y - ARHeightR); spp3 = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y - ARHeightR); AR_VDrawing(MaskBmp, hw + ARWidthR, hh + ARHeightR, dsp, spp1, spp2, spp3); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::MHdivDrawing3(bool MaskBmp) { BEGIN_LOG(""); int hw, hh; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dsp, spp1, spp2, spp3; hw = arwindow.size.x / 2; hh = arwindow.size.y / 2; dsp = Point(arwindow.s.x, arwindow.s.y); spp1 = Point(arwindow.e.x, arwindow.s.y + MHdiv - 2 * hh - ARHeightR); spp2 = Point(arwindow.e.x, arwindow.s.y + MHdiv); spp3 = Point(arwindow.s.x, arwindow.e.y); AR_VDrawing(MaskBmp, hw, hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x, arwindow.s.y + hh); spp1 = Point(arwindow.s.x, arwindow.s.y - hh - ARHeightR); spp2 = Point(arwindow.e.x, arwindow.s.y + MHdiv - hh - ARHeightR); spp3 = Point(arwindow.e.x, arwindow.e.y + MHdiv - hh - ARHeightR); AR_VDrawing(MaskBmp, hw, 2 * hh - MHdiv + ARHeightR, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x, arwindow.e.y + hh - MHdiv); spp1 = Point(arwindow.s.x, arwindow.s.y + hh - MHdiv); spp2 = Point(arwindow.e.x, arwindow.s.y - hh - ARHeightR); spp3 = Point(arwindow.e.x, arwindow.e.y - hh - ARHeightR); AR_VDrawing(MaskBmp, hw, MHdiv - hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x + hw, arwindow.s.y); spp1 = Point(arwindow.s.x + hw, arwindow.e.y); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y + 2 * hh - MHdiv + ARHeightR); spp3 = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y - MHdiv); AR_VDrawing(MaskBmp, hw + ARWidthR, MHdiv - hh - ARHeightR, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x + hw, arwindow.s.y + MHdiv - hh - ARHeightR); spp1 = Point(arwindow.s.x + hw, arwindow.e.y + MHdiv - hh - ARHeightR); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y + hh); spp3 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y - hh - ARHeightR); AR_VDrawing(MaskBmp, hw + ARWidthR, 2 * hh - MHdiv + ARHeightR, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x + hw, arwindow.s.y + hh); spp1 = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y + hh - MHdiv); spp2 = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y + hh - MHdiv); spp3 = Point(arwindow.s.x + hw, arwindow.s.y - hh - ARHeightR); AR_VDrawing(MaskBmp, hw + ARWidthR, hh + ARHeightR, dsp, spp1, spp2, spp3); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::MWdivDrawing1(bool MaskBmp) { BEGIN_LOG(""); int w, h, hh, hw; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dp, sp; w = arwindow.size.x; h = arwindow.size.y; hw = w / 2; hh = h / 2; TCursor old_cursor; old_cursor = Screen->Cursor; Screen->Cursor = crHourGlass; dp = Point(arwindow.s.x, arwindow.s.y); sp = Point(arwindow.s.x + MWdiv, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp, hw - MWdiv); dp = Point(arwindow.s.x + hw - MWdiv, arwindow.s.y); sp = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp, MWdiv); dp = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y); sp = Point(arwindow.s.x - hw + MWdiv - ARWidthR, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp, hw + ARWidthR); dp = Point(arwindow.s.x - MWdiv, arwindow.s.y - hh - ARHeightR); sp = Point(arwindow.s.x, arwindow.s.y + hh); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, hw); dp = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y - hh - ARHeightR); sp = Point(arwindow.s.x - hw + MWdiv - ARWidthR, arwindow.s.y + hh); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, hw - MWdiv + ARWidthR); dp = Point(arwindow.s.x + hw - MWdiv, arwindow.s.y - hh - ARHeightR); sp = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y + hh); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, MWdiv); Screen->Cursor = old_cursor; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::MWdivDrawing2(bool MaskBmp) { BEGIN_LOG(""); TCursor old_cursor; old_cursor = Screen->Cursor; Screen->Cursor = crHourGlass; int w, h; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dp, sp; w = arwindow.size.x; h = arwindow.size.y; dp = Point(arwindow.s.x, arwindow.s.y); // Left - Top sp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp, w / 2); dp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.s.y); // Right - Top sp = Point(arwindow.s.x - ARWidthR, arwindow.e.y); AR_NHBDrawing(MaskBmp, w, h, dp, sp, w / 2 + ARWidthR); dp = Point(arwindow.s.x, arwindow.e.y - h / 2 - ARHeightR); // Left - Bottom sp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.s.y - h / 2 - ARHeightR); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, w / 2); dp = Point(arwindow.s.x - w / 2 - ARWidthR, arwindow.e.y - h / 2 - ARHeightR); // Right - Bottom sp = Point(arwindow.s.x - ARWidthR, arwindow.s.y - h / 2 - ARHeightR); AR_NHBDrawing(MaskBmp, w, h + ARHeightR, dp, sp, w / 2 + ARWidthR); Screen->Cursor = old_cursor; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::MWdivDrawing3(bool MaskBmp) { BEGIN_LOG(""); int w, h, hh, hw; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dp, sp; w = arwindow.size.x; h = arwindow.size.y; hw = w / 2; hh = h / 2; TCursor old_cursor; old_cursor = Screen->Cursor; Screen->Cursor = crHourGlass; dp = Point(arwindow.s.x, arwindow.s.y); sp = Point(arwindow.s.x - 2 * hw + MWdiv - ARWidthR, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp, hw); dp = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y); sp = Point(arwindow.s.x - hw + MWdiv - ARWidthR, arwindow.e.y); // AR_NHADrawing(MaskBmp, w, h, dp, sp, 2*hw-MWdiv+ARHeightR); AR_NHADrawing(MaskBmp, w, h, dp, sp, 2 * hw - MWdiv + ARWidthR); dp = Point(arwindow.s.x + hw - MWdiv, arwindow.s.y); sp = Point(arwindow.s.x - hw - ARWidthR, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp, MWdiv - hw); dp = Point(arwindow.e.x - MWdiv, arwindow.s.y - hh - ARHeightR); sp = Point(arwindow.s.x, arwindow.s.y + hh); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, MWdiv - hw - ARWidthR); dp = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y - hh - ARHeightR); sp = Point(arwindow.s.x + MWdiv - hw - ARWidthR, arwindow.s.y + hh); // AR_NHADrawing(MaskBmp, w, h+ARHeightR, dp, sp, 2*hw-MWdiv+ARHeightR); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, 2 * hw - MWdiv + ARWidthR); dp = Point(arwindow.s.x + hw - MWdiv, arwindow.s.y - hh - ARHeightR); sp = Point(arwindow.s.x - hw - ARWidthR, arwindow.s.y + hh); AR_NHADrawing(MaskBmp, w, h + ARHeightR, dp, sp, hw + ARWidthR); Screen->Cursor = old_cursor; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SubBitmapPositionMC(int X, int Y, bool paint) { BEGIN_LOG(""); TRect dst; RECT r; POINT p = Point(X - MainImageForm->iMainImage->SubBitmap->Width / 2.0, Y - MainImageForm->iMainImage->SubBitmap->Height / 2.0); paintrect = iMainImage->SubRange; // VecDraw->SetMergePosition(X, Y, paintrect, paint); // Vector¿¡¼­µµ Merge if (p.x < 0) p.x = 0; else if (p.x > iMainImage->uBitmap->Width - iMainImage->SubBitmap->Width) p.x = iMainImage->uBitmap->Width - iMainImage->SubBitmap->Width; iMainImage->SubRange.left = p.x; if (p.y < 0) p.y = 0; else if (p.y > iMainImage->uBitmap->Height - iMainImage->SubBitmap->Height) p.y = iMainImage->uBitmap->Height - iMainImage->SubBitmap->Height; iMainImage->SubRange.top = p.y; iMainImage->SubRange.right = p.x + iMainImage->SubBitmap->Width; iMainImage->SubRange.bottom = p.y + iMainImage->SubBitmap->Height; iMainImage->SubVisible = true; if (TempBitmap) IsMerge(p); if (paint) { r.left = paintrect.left < iMainImage->SubRange.left ? paintrect.left : iMainImage->SubRange.left; r.top = paintrect.top < iMainImage->SubRange.top ? paintrect.top : iMainImage->SubRange.top; r.right = paintrect.right > iMainImage->SubRange.right ? paintrect.right : iMainImage->SubRange.right; r.bottom = paintrect.bottom > iMainImage->SubRange.bottom ? paintrect.bottom : iMainImage->SubRange.bottom; iMainImage->RectPaint(r); } END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoSaveAs() { BEGIN_LOG(""); String msg, fn, ext; TGraphicFileFormat gff; if (iMainImage->uBitmap->BitsPerPixel == 8) { #ifdef TRIAL gff = gffTEX_TRIAL; ext = String(".ttex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors Trial File (*.ttex)|*.ttex"); #else gff = gffTEX; ext = String(".tex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.tex)|*.tex"); #endif } else { #ifndef N_3D if (MainForm->T3D_Item) { if (MainMenuForm->Item == T_3D) { #ifdef TRIAL gff = gffT3D_TRIAL; ext = String(".tt3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D Trial File (*.)|*.tt3d"); #else gff = gffT3D; ext = String(".t3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D File (*.t3d)|*.t3d"); #endif } else { #ifdef TRIAL gff = gffTFC_TRIAL; ext = String(".ttfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors Trial File (*.ttfc)|*.ttfc"); #else gff = gffTFC; ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); #endif } } else { #ifdef TRIAL gff = gffTFC_TRIAL; ext = String(".ttfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors Trial File (*.ttfc)|*.ttfc"); #else gff = gffTFC; ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); #endif } #else gff = gffTFC; ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); #endif } MainForm->SaveDialog->InitialDir = String("C:\\"); fn = String("texprobackup") + ext + String(".back"); DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); AutoSaveForm = new TAutoSaveForm(NULL); AutoSaveForm->Update(); AutoSaveToFile(DirName, FileName, gff, MainForm->CompressMethod); END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoSavebackupTimer(TObject *Sender) { /* if (MainImageForm) { // AutoSaveAs(); } */ } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FormMouseWheel (TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled) { if (!this->Active) return; if (VecDraw->SpreadStep == 2) { return; } if (!MainForm->MotiveLoad->Checked) iMainImage->SetPosition(iMainImage->PositionX, iMainImage->PositionY - WheelDelta); /* ************** Âü°í »çÇ× **************** ******** ¸¶¿ì½º À̺¥Æ® ******** int zDelta; POINT p; if(Msg.message==WM_MOUSEWHEEL){ // if()return; GetCursorPos(&p); if(PtInRect(&(this->ClientRect),this->ScreenToClient(p))){ // Msg ¸¦ È®ÀÎÇϸé ÈÙÀÇ Á¤º¸¸¦ ¾Ë¼ö ÀÖ½À´Ï´Ù. zDelta = GET_WHEEL_DELTA_WPARAM(Msg.wParam); iMainImage->SetPosition(iMainImage->PositionX, iMainImage->PositionY-zDelta); } } */ } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::UndoBtnExec() { // MainImageForm->Undo->UndoRead(); //by linuxjun Undo_Method // Undo->UndoRead(true); //by linuxjun Undo_Method BEGIN_LOG(""); Undo->UndoRead(false); // by linuxjun Undo_Method //ReadFile if (PaletteForm->DIB256Palette->ChoiceIndex > MainImageForm->Palette->UseColor) PaletteForm->DIB256Palette->ChoiceIndex = MainImageForm->Palette->UseColor; //FullViewForm->ExitOverlapChange(); doDestroy(OverlapBitmap) doDestroy(OverlapBack) if (FullViewForm) { FullViewForm->OverlapBitmap = NULL; FullViewForm->OverlapBack = NULL; } ::RepaintColor(); // MainImageForm->WorkAreaChange(); WorkAreaChange(); MainForm->UpdateMenuItems(MainImageForm); // WorkAreaChange() ³»ºÎ ±¸Á¶ º¯°æÀ¸·Î Ãß°¡ - by monkman (2010.03.17) PenManagerForm->ResetClientHeight(); // PenManagerForm->SinglePanel->Visible = false; // PenManagerForm->AirPanel->Visible = false; // PenManagerForm->btnUp->Visible = false; // PenManagerForm->btnDown->Visible = true; END_LOG; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::RedoBtnExec() { BEGIN_LOG(""); // MainImageForm->RedoRead(); //by linuxjun Undo_Method Undo->RedoRead(); // by linuxjun Undo_Method // Undo->RedoRead(); // UndoCount++; // Edit2->Text = UndoCount; if (PaletteForm->DIB256Palette->ChoiceIndex > MainImageForm->Palette->UseColor) PaletteForm->DIB256Palette->ChoiceIndex = MainImageForm->Palette->UseColor; //FullViewForm->ExitOverlapChange(); doDestroy(OverlapBitmap) doDestroy(OverlapBack) if (FullViewForm) { FullViewForm->OverlapBitmap = NULL; FullViewForm->OverlapBack = NULL; } ::RepaintColor(); // MainImageForm->WorkAreaChange(); WorkAreaChange(); MainForm->UpdateMenuItems(MainImageForm); // WorkAreaChange() ³»ºÎ ±¸Á¶ º¯°æÀ¸·Î Ãß°¡ - by monkman (2010.03.17) END_LOG; } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::CorrectPaletteIndex() { BEGIN_LOG(""); BYTE *dp = NULL; int x, y; int index = FindBlackColorIndex(); if (!iMainImage->uBitmap->StartScanLine()) goto fail; for (y = 0; y < iMainImage->uBitmap->Height; y++) { dp = iMainImage->uBitmap->GetScanLine(y); for (x = 0; x < iMainImage->uBitmap->Width; x++, dp++) { if (*dp == 0) * dp = index; } iMainImage->uBitmap->PutScanLine(y); } iMainImage->uBitmap->StopScanLine(); END_LOG; return true; fail: iMainImage->uBitmap->StopScanLine(); END_LOG; return false; } // --------------------------------------------------------------------------- int __fastcall TMainImageForm::FindBlackColorIndex() { BEGIN_LOG(""); RGBQUAD rgb[256]; int i, index; iMainImage->uBitmap->GetColors(0, 256, rgb); for (i = 2; i < 252; i++) { if (rgb[i].rgbRed == '\0' && rgb[i].rgbGreen == '\0' && rgb[i] .rgbBlue == '\0') { END_LOG; return i; } } if (Palette->UseColor > 250) index = Palette->UseColor; else { index = Palette->UseColor + 1; PaletteForm->DIB256Palette->UseColor++; } Palette->SetNormal(index, 0, 0, 0); END_LOG; return index; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetOldUseColor(int oldusecolor) { FOldUseColor = oldusecolor; return; } // --------------------------------------------------------------------------- int __fastcall TMainImageForm::GetOldUseColor() { return FOldUseColor; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::Templine_pen(int sx, int sy, int ex, int ey, COLORREF c, RECT *rect) { int PenType, dia, ls, rs, w, h, sw, y, x, r, yyy; double d, r1, r2, xx, yy, ratio; TLineData ld; int oldY; TPException ec = EC_NONE; PenType = PenManagerForm->Pen->Shape; dia = PenManagerForm->Pen->Thick; // lhskys draw ¿¡¼­ ÇÑÁ¡µÚ·Î ÇÒ¶§ Pen size°ªÀ» ÀÌ¿ë ±×¸®±â À§ÇØ... ls = dia >> 1; rs = dia - ls; w = iMainImage->uBitmap->Width; h = iMainImage->uBitmap->Height; for (y = 0; y < h; y++) { *(msx + y) = w; *(mex + y) = -1; } if (sy < ey) { ld.sy = sy; ld.ey = ey; ld.sx = sx; ld.ex = ex; } else { ld.sy = ey; ld.ey = sy; ld.sx = ex; ld.ex = sx; } if (ld.sy < 0) ld.sy = 0; else if (ld.sy > h) ld.sy = h; if (ld.ey < 0) ld.ey = 0; else if (ld.ey > h) ld.ey = h; r = PenType != 0 ? (ld.sx < ld.ex ? -(dia - 1) / 2 : ls) : 0; ld.psx1 = ld.sx - ls; ld.psy1 = ld.sy - r; ld.pex1 = ld.ex - ls; ld.pey1 = ld.ey - r; r = PenType != 0 ? (ld.sx < ld.ex ? ls : -(dia - 1) / 2) : 0; ld.psx2 = ld.sx + (dia - 1) / 2; ld.psy2 = ld.sy - r; ld.pex2 = ld.ex + (dia - 1) / 2; ld.pey2 = ld.ey - r; if (PenType || ld.ex - ld.sx == 0 || ld.ey - ld.sy == 0) { sw = 0; ld.d1 = ld.d2 = 0.0; ld.dx1 = ld.dx2 = ld.dy1 = ld.dy2 = 0.0; } else { sw = 1; ld.d1 = ld.d2 = (double)2.0 * h * h; d = fabs(atan((double)(ld.ex - ld.sx) / (ld.ey - ld.sy))); ld.dx1 = ld.sx - fabs(cos(d)) * ls; ld.dy1 = ld.sy + (ld.sx < ld.ex ? fabs(sin(d)) * ((dia - 1) / 2) : -fabs (sin(d)) * ls); ld.dx2 = ld.sx + fabs(cos(d)) * ((dia - 1) / 2); ld.dy2 = ld.sy - (ld.sx < ld.ex ? fabs(sin(d)) * ls : -fabs(sin(d)) * ((dia - 1) / 2)); } if (PenType != 0) { if (dia & 1) { r1 = dia / 2.0; pos_in(ld, ld.sy, ld.sx - r1 + 1, ld.sx + r1, sw); pos_in(ld, ld.ey, ld.ex - r1 + 1, ld.ex + r1, 0); for (yyy = -r1; yyy <= r1; yyy++) { pos_in(ld, ld.sy + yyy, ld.sx - r1 + 1, ld.sx + r1, sw); pos_in(ld, ld.ey + yyy, ld.ex - r1 + 1, ld.ex + r1, 0); } } else { r1 = dia / 2.0; for (yy = 0.5; yy <= r1; yy += 1.0) { pos_in(ld, ld.sy - yy - 0.5, ld.sx - r1 + 0.5, ld.sx + r1 - 0.5, sw); pos_in(ld, ld.ey - yy - 0.5, ld.ex - r1 + 0.5, ld.ex + r1 - 0.5, 0); pos_in(ld, ld.sy + yy, ld.sx - r1 + 0.5, ld.sx + r1 - 0.5, sw); pos_in(ld, ld.ey + yy, ld.ex - r1 + 0.5, ld.ex + r1 - 0.5, 0); } } } else { if (dia & 1) { r1 = dia / 2.0; r2 = r1 * r1; pos_in(ld, ld.sy, ld.sx - r1 + 1, ld.sx + r1, sw); pos_in(ld, ld.ey, ld.ex - r1 + 1, ld.ex + r1, 0); for (yyy = -r1; yyy <= r1; yyy++) { xx = sqrt(fabs(r2 - yyy * yyy)); pos_in(ld, ld.sy + yyy, ld.sx - xx + 1, ld.sx + xx, sw); pos_in(ld, ld.ey + yyy, ld.ex - xx + 1, ld.ex + xx, 0); } } else { r1 = dia / 2.0; r2 = r1 * r1; for (yy = 0.5; yy <= r1; yy += 1.0) { xx = sqrt(r2 - yy * yy); pos_in(ld, ld.sy - yy - 0.5, ld.sx - xx + 0.5, ld.sx + xx - 0.5, sw); pos_in(ld, ld.ey - yy - 0.5, ld.ex - xx + 0.5, ld.ex + xx - 0.5, 0); pos_in(ld, ld.sy + yy, ld.sx - xx + 0.5, ld.sx + xx - 0.5, sw); pos_in(ld, ld.ey + yy, ld.ex - xx + 0.5, ld.ex + xx - 0.5, 0); } } } if (abs(ld.pex1 - ld.psx1) < abs(ld.pey1 - ld.psy1)) { d = (double)(ld.pex1 - ld.psx1) / (ld.pey1 - ld.psy1); for (y = ld.psy1; y <= ld.pey1; y++) { if (y >= 0 && y < h) * (msx + y) = d * (y - ld.psy1) + ld.psx1 + 0.5; } } else if (ld.psx1 - ld.pex1) { if (ld.pex1 < ld.psx1) { r = ld.psx1; ld.psx1 = ld.pex1; ld.pex1 = r; r = ld.psy1; ld.psy1 = ld.pey1; ld.pey1 = r; } d = (double)(ld.pey1 - ld.psy1) / (ld.pex1 - ld.psx1); for (x = ld.psx1; x <= ld.pex1; x++) { y = d * (x - ld.psx1) + ld.psy1 + 0.5; if (y >= 0 && y < h && x < *(msx + y)) * (msx + y) = x; } } if (abs(ld.pex2 - ld.psx2) < abs(ld.pey2 - ld.psy2)) { d = (double)(ld.pex2 - ld.psx2) / (ld.pey2 - ld.psy2); for (y = ld.psy2; y <= ld.pey2; y++) { if (y >= 0 && y < h) * (mex + y) = d * (y - ld.psy2) + ld.psx2 + 0.5; } } else if (ld.psx2 - ld.pex2) { if (ld.pex2 < ld.psx2) { r = ld.psx2; ld.psx2 = ld.pex2; ld.pex2 = r; r = ld.psy2; ld.psy2 = ld.pey2; ld.pey2 = r; } d = (double)(ld.pey2 - ld.psy2) / (ld.pex2 - ld.psx2); for (x = 0; x <= ld.pex2; x++) { y = d * (x - ld.psx2) + ld.psy2 + 0.5; if (y >= 0 && y < h && x > *(mex + y)) * (mex + y) = x; } } ld.sy -= ls; ld.ey += rs; if (!(iMainImage->uBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->LayerMask) { if (!(iMainImage->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (bProtect || PenManagerForm->acolor == 2) if (!(iMainImage->BackGround->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (iMainImage->Mask) { if (!(iMainImage->Mask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (!iMainImage->bmScreen->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus ratio = (double)iMainImage->ZoomIn / iMainImage->ZoomOut; // by celberus int tsx, tex, tsy, tey, oy, screenLength; oldY = -1; if (iMainImage->ZoomOut == 3 && iMainImage->ZoomIn == 2) { tsy = (double)(ld.sy - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5; // temp start y tey = (ld.ey - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut; for (y = tsy; y <= tey; y++) { oy = iMainImage->PositionY + (double) y * iMainImage->ZoomOut / iMainImage->ZoomIn + 0.5; // 2/3 map: 0123456... -> 0235689.. if (*(mex + oy) >= 0 && *(msx + oy) < w) { tsx = (double)(*(msx + oy) - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5; // temp start x 2/3 map: 012345678... -> 011233455... tex = (*(mex + oy) - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut; // tsx´Â ¹Ý¿Ã¸² ¾ÈÇϴ°ÍÀÌ ¸Â´Â °è»ê¹ýÀÌ´Ù. 2/3 map: 012345678... -> 001223445... tex = (*(mex + oy) - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut; // tsx´Â ¹Ý¿Ã¸² ¾ÈÇϴ°ÍÀÌ ¸Â´Â °è»ê¹ýÀÌ´Ù. 2/3 map: 012345678... -> 001223445... set_temphline(tsx, y, tex - tsx + 1, c); } } } else if ((iMainImage->ZoomOut == 3 || iMainImage->ZoomOut == 2) && iMainImage->ZoomIn == 1) { tsy = (ld.sy - iMainImage->PositionY) / iMainImage->ZoomOut; // temp start y tey = (ld.ey - iMainImage->PositionY) / iMainImage->ZoomOut; for (y = tsy; y <= tey; y++) { oy = (int)((double)(y + 0.5) * iMainImage->ZoomOut + iMainImage->PositionY) / 2 * 2 + 1; if (*(mex + oy) >= 0 && *(msx + oy) < w) { tsx = (*(msx + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; // temp start x if ((int)((double)(tsx + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 2 * 2 + 1 < *(msx + oy)) tsx++; tex = (*(mex + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; if ((int)((double)(tex + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 2 * 2 + 1 > *(mex + oy)) tex--; set_temphline(tsx, y, tex - tsx + 1, c); } } } else if ((iMainImage->ZoomOut == 4 || iMainImage->ZoomOut == 6) && iMainImage->ZoomIn == 1) { tsy = (ld.sy - iMainImage->PositionY) / iMainImage->ZoomOut; // temp start y tey = (ld.ey - iMainImage->PositionY) / iMainImage->ZoomOut; for (y = tsy; y <= tey; y++) { oy = (int)((double)(y + 0.5) * iMainImage->ZoomOut + iMainImage->PositionY) / 4 * 4 + 3; if (*(mex + oy) >= 0 && *(msx + oy) < w) { tsx = (*(msx + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; // temp start x if ((int)((double)(tsx + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 4 * 4 + 3 < *(msx + oy)) tsx++; tex = (*(mex + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; if ((int)((double)(tex + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 4 * 4 + 3 > *(mex + oy)) tex--; set_temphline(tsx, y, tex - tsx + 1, c); } } } else if ((iMainImage->ZoomOut == 8 || iMainImage->ZoomOut == 12) && iMainImage->ZoomIn == 1) { tsy = (ld.sy - iMainImage->PositionY) / iMainImage->ZoomOut; // temp start y tey = (ld.ey - iMainImage->PositionY) / iMainImage->ZoomOut; for (y = tsy; y <= tey; y++) { oy = (int)((double)(y + 0.5) * iMainImage->ZoomOut + iMainImage->PositionY) / 8 * 8 + 7; if (*(mex + oy) >= 0 && *(msx + oy) < w) { tsx = (*(msx + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; // temp start x if ((int)((double)(tsx + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 8 * 8 + 7 < *(msx + oy)) tsx++; tex = (*(mex + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; if ((int)((double)(tex + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 8 * 8 + 7 > *(mex + oy)) tex--; set_temphline(tsx, y, tex - tsx + 1, c); } } } else if ((iMainImage->ZoomOut == 16) && iMainImage->ZoomIn == 1) { tsy = (ld.sy - iMainImage->PositionY) / iMainImage->ZoomOut; // temp start y tey = (ld.ey - iMainImage->PositionY) / iMainImage->ZoomOut; for (y = tsy; y <= tey; y++) { oy = (int)((double)(y + 0.5) * iMainImage->ZoomOut + iMainImage->PositionY) / 16 * 16 + 15; if (*(mex + oy) >= 0 && *(msx + oy) < w) { tsx = (*(msx + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; // temp start x if ((int)((double)(tsx + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 16 * 16 + 15 < *(msx + oy)) tsx++; tex = (*(mex + oy) - iMainImage->PositionX) / iMainImage->ZoomOut; if ((int)((double)(tex + 0.5) * iMainImage->ZoomOut + iMainImage->PositionX) / 16 * 16 + 15 > *(mex + oy)) tex--; set_temphline(tsx, y, tex - tsx + 1, c); } } } else if ((iMainImage->ZoomOut == 2) && iMainImage->ZoomIn == 3) { tsy = (ld.sy - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut; // temp start y tey = (ld.ey - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut; for (y = tsy; y <= tey; y++) { oy = (int)((double)y * iMainImage->ZoomOut / iMainImage->ZoomIn + 0.5 + iMainImage->PositionY); if (*(mex + oy) >= 0 && *(msx + oy) < w) { tsx = (double)(*(msx + oy) - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut; // temp start x tex = (double)(*(mex + oy) + 1 - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut; set_temphline(tsx, y, tex - tsx, c); } } /* tsy = (double)(ld.sy - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5; // temp start y tey = (ld.ey - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut; for (y = tsy; y <= tey; y++) { oy = iMainImage->PositionY + (double)y * iMainImage->ZoomOut / iMainImage->ZoomIn + 0.5; // 2/3 map: 0123456... -> 0235689.. if (*(mex + oy)>=0 && *(msx + oy)PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5; // temp start x 2/3 map: 012345678... -> 011233455... // if ((iMainImage->PositionX + tsx * iMainImage->ZoomOut / iMainImage->ZoomIn) < *(msx + oy)) tsx++; // if ((iMainImage->PositionX + (tsx - 1) * iMainImage->ZoomOut / iMainImage->ZoomIn) >= *(msx + oy)) tsx--; tex = (*(mex + oy) - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut; // tsx´Â ¹Ý¿Ã¸² ¾ÈÇϴ°ÍÀÌ ¸Â´Â °è»ê¹ýÀÌ´Ù. 2/3 map: 012345678... -> 001223445... // screenLength = (double)(*(mex + oy) - *(msx + oy) + 1) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5; // if ((iMainImage->PositionX + tex * iMainImage->ZoomOut / iMainImage->ZoomIn) < *(mex + oy) + 1) tex++; set_temphline(tsx, y, tex - tsx + 1, c); // set_temphline(tex - screenLength + 1, y, screenLength, c); } } */ } else { tsy = (ld.sy - iMainImage->PositionY) * iMainImage->ZoomIn; // temp start y tey = (ld.ey - iMainImage->PositionY) * iMainImage->ZoomIn; for (y = tsy; y <= tey; y++) { oy = (int)((double)y / iMainImage->ZoomIn + iMainImage->PositionY); if (*(mex + oy) >= 0 && *(msx + oy) < w) { tsx = (double)(*(msx + oy) - iMainImage->PositionX) * iMainImage->ZoomIn; // temp start x tex = (double)(*(mex + oy) + 1 - iMainImage->PositionX) * iMainImage->ZoomIn; set_temphline(tsx, y, tex - tsx, c); } } } /* for (y = ld.sy; y <= ld.ey; y++) { if (oldY == y * ratio + 0.5) continue; oldY = y * ratio + 0.5; if (*(mex + y)>=0 && *(msx + y)bmScreen->StopScanLine(); // by celberus /* for (y=ld.sy; y<=ld.ey; y++) { if (*(mex + y)>=0 && *(msx + y)LayerMask) { iMainImage->LayerMask->StopScanLine(); if (bProtect || PenManagerForm->acolor == 2) iMainImage->BackGround->StopScanLine(); } if (iMainImage->Mask) iMainImage->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); if (rect) { rect->left = min(sx, ex) - ls - 5; rect->top = min(sy, ey) - ls - 5; rect->right = max(sx, ex) + rs + 5; rect->bottom = max(sy, ey) + rs + 5; } return; fail: if (iMainImage->Mask) iMainImage->Mask->StopScanLine(); if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); if (bProtect || PenManagerForm->acolor == 2) iMainImage->BackGround->StopScanLine(); iMainImage->uBitmap->StopScanLine(); iMainImage->bmScreen->StopScanLine(); // by celberus EXCEPTION_MESSAGE_OK(ec); /* int PenType, dia, ls, rs, w, h, sw, y, x, r, yyy, leftBound, rightBound, drawingThick, startX, endX, startY, endY; double d, r1, r2, xx, yy, ratio; TLineData ld; PenType = PenManagerForm->Pen->Shape; dia = PenManagerForm->Pen->Thick; //lhskys draw ¿¡¼­ ÇÑÁ¡µÚ·Î ÇÒ¶§ Pen size°ªÀ» ÀÌ¿ë ±×¸®±â À§ÇØ... ls = dia>>1; rs = dia-ls; w = iMainImage->bmScreen->Width; h = iMainImage->bmScreen->Height; ratio = (double)iMainImage->ZoomIn / iMainImage->ZoomOut; startX = iMainImage->BitmapToCanvasX(sx); startY = iMainImage->BitmapToCanvasY(sy); endX = iMainImage->BitmapToCanvasX(ex); endY = iMainImage->BitmapToCanvasY(ey); drawingThick = ratio * dia; if (drawingThick < 1) drawingThick = 1; leftBound = drawingThick>>1; rightBound = drawingThick-leftBound; for (y=0; yh) ld.sy = h; if (ld.ey<0) ld.ey = 0; else if (ld.ey>h) ld.ey = h; r = PenType ? (ld.sx=0 && y=0 && y=0 && y=0 && y*(tex + y)) *(tex + y) = x; } } ld.sy -= leftBound; ld.ey += rightBound; for (y=ld.sy; y<=ld.ey; y++) { if (*(tex + y)>=0 && *(tsx + y)left = min(sx, ex) - ls; rect->top = min(sy, ey) - ls; rect->right = max(sx, ex) + rs; rect->bottom = max(sy, ey) + rs; } return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } // --------------------------------------------------------------------------- /* void __fastcall TMainImageForm::temppos_in(TLineData &ld, int by, int bsx, int bex, int ch) { pos_in(ld, by, bsx, bex, ch); return; double d; // if ((by>=0) && (bybmScreen->Height)) { if ((by>=0) && (byuBitmap->Height)) { if (*(tsx+by)>bsx) { if (ch) { d = (ld.dx1 - bsx) * (ld.dx1 - bsx) + (ld.dy1 - by) * (ld.dy1 - by); if (d= iMainImage->uBitmap->Width || y < 0 || y >= iMainImage->uBitmap->Height) return; if (x < 0) { len += x; x = 0; if (len <= 0) return; } if (x + len > iMainImage->uBitmap->Width) len = iMainImage->uBitmap->Width-x; // Undo->SaveData(x,y,len); //by linuxjun /* if (iMainImage->LayerMask) { if (bProtect) if (!(iMainImage->BackGround->StartScanLine())) goto fail; if (FOnSetHLine) FOnSetHLine(x, y, len, c); }else if (FOnSetHLine) FOnSetHLine(x, y, len, c); */ /* double ratio = (double)iMainImage->ZoomIn / iMainImage->ZoomOut; // by celberus int sx, ex, screenLength; // sx = iMainImage->BitmapToCanvasX(x); sx = (double)(x - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5; // screenLength = iMainImage->BitmapToCanvasX(x + len) - sx; ex = (double)(x + len - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5; screenLength = ex - sx; bp = iMainImage->bmScreen->GetScanLine((y - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5); if (iMainImage->uBitmap->BitsPerPixel == 8) { memset(bp + sx, c, screenLength); } else if (iMainImage->uBitmap->BitsPerPixel == 24) { for (int i = sx; i < sx + screenLength; i++, bp += 3) { memset24(bp+3*x, c, 1); } } // iMainImage->bmScreen->PutScanLine(iMainImage->BitmapToCanvasY(y)); iMainImage->bmScreen->PutScanLine((y - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut + 0.5); return; fail: if (bProtect) iMainImage->BackGround->StopScanLine(); */ if (len <= 0) return; Byte *bp = NULL; if (x >= iMainImage->bmScreen->Width || y < 0 || y >= iMainImage->bmScreen->Height) return; if (x < 0) { len += x; x = 0; if (len <= 0) return; } if (x + len > iMainImage->bmScreen->Width) len = iMainImage->bmScreen->Width - x; // if (!iMainImage->bmScreen->StartScanLine()) goto fail; bp = iMainImage->bmScreen->GetScanLine(y); if (iMainImage->uBitmap->BitsPerPixel == 8) { memset(bp + x, c, len); } else if (iMainImage->uBitmap->BitsPerPixel == 24) { for (int i = x; i < x + len; i++, bp += 3) { memset24(bp + 3 * x, c, 1); } } iMainImage->bmScreen->PutScanLine(y); // iMainImage->bmScreen->StopScanLine(); fail: // iMainImage->bmScreen->StopScanLine(); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SaveToCurrentFile() { BEGIN_LOG(""); TPException ec = EC_NONE; String ext, fn; switch(gff) { #ifdef TRIAL case gffTEX_TRIAL: { ext = String(".ttex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.ttex)|*.ttex"); break; } case gffTFC_TRIAL: { ext = String(".ttfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.ttfc)|*.ttfc"); break; } #else case gffTEX: { ext = String(".tex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.tex)|*.tex"); break; } case gffTFC: { ext = String(".tfc"); MainForm->SaveDialog->Filter = String( "Texpro Textile Full Colors File (*.tfc)|*.tfc"); break; } #endif #ifndef N_3D #ifdef TRIAL case gffT3D_TRIAL: { ext = String(".tt3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D File (*.tt3d)|*.tt3d"); break; } #else case gffT3D: { ext = String(".t3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile 3D File (*.t3d)|*.t3d"); break; } #endif #ifdef NOTN3D #else case gffN3D: { ext = String(".n3d"); MainForm->SaveDialog->Filter = String( "Texpro Textile New 3D File (*.n3d)|*.n3d"); break; } #endif #endif #ifdef TRIAL default: { ext = String(".ttex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.tex)|*.tex"); break; } #else case gffBMP: case gffJPG: case gffPCT: case gffPCX: case gffPNG: case gffPSD: case gffRAS: case gffTGA: case gffTIF: case gffEPS: case gffDXF: case gffSVG: { if (gff == gffBMP) ext = String(".bmp"); else if (gff == gffJPG) ext = String(".jpg"); else if (gff == gffPCT) ext = String(".pct"); else if (gff == gffPCX) ext = String(".pcx"); else if (gff == gffPNG) ext = String(".png"); else if (gff == gffPSD) ext = String(".psd"); else if (gff == gffRAS) ext = String(".ras"); else if (gff == gffTGA) ext = String(".tga"); else if (gff == gffTIF) ext = String(".tif"); else if (gff == gffEPS) ext = String(".eps"); else if (gff == gffDXF) ext = String(".dxf"); else if (gff == gffSVG) ext = String(".svg"); String fileExtension = ExtractFileExt(FileName); if (LowerCase(fileExtension) == String(".tfc") || LowerCase (fileExtension) == String(".tex")) { FileName.Delete(FileName.Pos(fileExtension), FileName.Length()); FileName = MainForm->FMOnFileName(FileName, gff); } break; } default: { ext = String(".tex"); MainForm->SaveDialog->Filter = String( "Texpro Textile 256 Colors File (*.tex)|*.tex"); break; } #endif } if (FileName == Format("Noname%d%s", OPENARRAY(TVarRec, (Number + 1, ext)))) { TIniFile *IniFile = new TIniFile(AppDataItem + "\\Main.ini"); if (IniFile) { MainForm->SaveDialog->InitialDir = IniFile->ReadString ("FileManager", "DirectoryName", "C:\\"); delete IniFile; } if (MainForm->SaveDialog->Execute()) { fn = MainForm->SaveDialog->FileName; if (fn.SubString(fn.LastDelimiter("."), fn.Length()) != ext) { fn = fn + ext; } DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); ec = SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); } } else { if (WorkArea && WorkArea->Mask != NULL) { if (Application->MessageBox(IDS_MESSAGE_ONLYWORKREGIONSAVE.c_str(), L"Save", MB_OKCANCEL) == IDOK) { MakeBackupFile(DirName, FileName); ec = SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); } } else { MakeBackupFile(DirName, FileName); ec = SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); } } if (ec != EC_NONE) { EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } END_LOG; } // --------------------------------------------------------------------------- /* void __fastcall TMainImageForm::bmScreenResize() { if (!iMainImage->uBitmap) return; int sy = iMainImage->PositionY; int h = iMainImage->Height*iMainImage->ZoomOut/iMainImage->ZoomIn; if (h>iMainImage->uBitmap->Height-sy) h = iMainImage->uBitmap->Height-sy; if (iMainImage->ZoomOut>1) { h -= h%iMainImage->ZoomOut; } h = h*iMainImage->ZoomIn/iMainImage->ZoomOut; AllocTempLineMem(h); return; } */ // --------------------------------------------------------------------------- __fastcall RepeatDraw::RepeatDraw() { // initRect(); arLineItr = NULL; } // --------------------------------------------------------------------------- __fastcall RepeatDraw::~RepeatDraw() { if (arLineItr) delete arLineItr; } // --------------------------------------------------------------------------- void __fastcall RepeatDraw::setLoopArea (int left, int top, int right, int bottom) { loopArea.left = left; loopArea.top = top; loopArea.right = right; loopArea.bottom = bottom; loopWidth = loopArea.right - loopArea.left; } // --------------------------------------------------------------------------- void __fastcall RepeatDraw::copyValue() { // BEGIN_LOG(""); arLineItr->copyValue(); // END_LOG; } // --------------------------------------------------------------------------- __fastcall NormalRepeatDraw::NormalRepeatDraw (TWindowData *arwindow, RECT wholeAreaRect) { BEGIN_LOG(""); arArea.left = arwindow->s.x; arArea.right = arwindow->s.x + arwindow->size.x; arArea.top = arwindow->s.y; arArea.bottom = arwindow->s.y + arwindow->size.y; wholeArea = wholeAreaRect; initDividedRect(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::initDividedRect() { // Àüü ¿µ¿ªÀ» ÀÚµ¿¹Ýº¹ °æ°è¸¦ ±âÁØÀ¸·Î 9Á¶°¢À¸·Î ³ª´«´Ù. dividedRect[0] = Rect(wholeArea.left, wholeArea.top, arArea.left, arArea.top); // |00|1111|22| |DD|CCDD|CC| dividedRect[1] = Rect(arArea.left, wholeArea.top, arArea.right, arArea.top); // |00|1111|22| |DD|CCDD|CC| dividedRect[2] = Rect(arArea.right, wholeArea.top, wholeArea.right, arArea.top); // |33|4444|55| |BB|AABB|AA| dividedRect[3] = Rect(wholeArea.left, arArea.top, arArea.left, arArea.bottom); // |33|4444|55| |BB|AABB|AA| dividedRect[4] = Rect(arArea.left, arArea.top, arArea.right, arArea.bottom); // |33|4444|55| |DD|CCDD|CC| dividedRect[5] = Rect(arArea.right, arArea.top, wholeArea.right, arArea.bottom); // |33|4444|55| |DD|CCDD|CC| dividedRect[6] = Rect(wholeArea.left, arArea.bottom, arArea.left, wholeArea.bottom); // |66|7777|88| |BB|AABB|BB| dividedRect[7] = Rect(arArea.left, arArea.bottom, arArea.right, wholeArea.bottom); // |66|7777|88| |DD|CCDD|CC| dividedRect[8] = Rect(arArea.right, arArea.bottom, wholeArea.right, wholeArea.bottom); } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::initItr(TPLayerImage *theImage, bool MaskBmp) { if (MaskBmp) { if (theImage->uBitmap->BitsPerPixel == 8) { arLineItr = (ARLineItr*)new ARLineItr_8_Mask(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_24_Mask(theImage); } } else { if (theImage->uBitmap->BitsPerPixel == 8) { if (theImage->LayerMask) { arLineItr = (ARLineItr*)new ARLineItr_8_Layer(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_8(theImage); } } else { if (theImage->LayerMask) { arLineItr = (ARLineItr*)new ARLineItr_24_Layer(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_24(theImage); } } } } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::initPoint() { BEGIN_LOG(""); pointCenter = Point(loopArea.left, loopArea.top); pointLR = Point(loopArea.left + arArea.right - arArea.left, loopArea.top); pointTB = Point(loopArea.left, loopArea.top + arArea.bottom - arArea.top); pointTBLR = Point(loopArea.left + arArea.right - arArea.left, loopArea.top + arArea.bottom - arArea.top); if (pointTB.y >= wholeArea.bottom) { pointTB.y = wholeArea.top + pointTB.y - wholeArea.bottom; pointTBLR.y = wholeArea.top + pointTBLR.y - wholeArea.bottom; } if (pointLR.x >= wholeArea.right) { pointLR.x = wholeArea.left + pointLR.x - wholeArea.right; pointTBLR.x = wholeArea.left + pointTBLR.x - wholeArea.right; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::initPointX() { BEGIN_LOG(""); pointCenter.x = loopArea.left; pointLR.x = loopArea.left + arArea.right - arArea.left; pointTB.x = loopArea.left; pointTBLR.x = loopArea.left + arArea.right - arArea.left; if (pointLR.x >= wholeArea.right) { // ³¡À» ³Ñ¾î°¡¸é pointLR.x = wholeArea.left + pointLR.x - wholeArea.right; pointTBLR.x = wholeArea.left + pointTBLR.x - wholeArea.right; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::getScanLine() { arLineItr->getLine(pointCenter.y, pointCenter.x, loopArea.right - loopArea.left, 0); arLineItr->setPointer(pointCenter.x, 0, POINTER_CENTER); if (loopArea.right + arArea.right - arArea.left > wholeArea.right) { if (loopArea.left + arArea.right - arArea.left > wholeArea.right) { arLineItr->getLine(pointCenter.y, wholeArea.left + loopArea.left + arArea.right - arArea.left - wholeArea.right, loopArea.right - loopArea.left, 0); } else { arLineItr->getLine(pointCenter.y, pointLR.x, wholeArea.right - arArea.right + arArea.left - loopArea.left, 0); arLineItr->getLine(pointCenter.y, wholeArea.left, arArea.right - arArea.left + loopArea.right - wholeArea.right, 0); } } else { arLineItr->getLine(pointCenter.y, pointLR.x, loopArea.right - loopArea.left, 0); } arLineItr->setPointer(pointLR.x, 0, POINTER_LR); arLineItr->getLine(pointTB.y, pointCenter.x, loopArea.right - loopArea.left, 1); arLineItr->setPointer(pointCenter.x, 1, POINTER_TB); if (loopArea.right + arArea.right - arArea.left > wholeArea.right) { if (loopArea.left + arArea.right - arArea.left > wholeArea.right) { arLineItr->getLine(pointTB.y, wholeArea.left + loopArea.left + arArea.right - arArea.left - wholeArea.right, loopArea.right - loopArea.left, 1); } else { arLineItr->getLine(pointTB.y, pointLR.x, wholeArea.right - arArea.right + arArea.left - loopArea.left, 1); arLineItr->getLine(pointTB.y, wholeArea.left, arArea.right - arArea.left + loopArea.right - wholeArea.right, 1); } } else { arLineItr->getLine(pointTB.y, pointLR.x, loopArea.right - loopArea.left, 1); } arLineItr->setPointer(pointTBLR.x, 1, POINTER_TBLR); } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::putScanLine() { arLineItr->putLine(pointCenter.y, pointCenter.x, loopArea.right - loopArea.left, 0); if (loopArea.right + arArea.right - arArea.left > wholeArea.right) { if (loopArea.left + arArea.right - arArea.left > wholeArea.right) { arLineItr->putLine(pointCenter.y, wholeArea.left + loopArea.left + arArea.right - arArea.left - wholeArea.right, loopArea.right - loopArea.left, 0); } else { arLineItr->putLine(pointCenter.y, pointLR.x, wholeArea.right - arArea.right + arArea.left - loopArea.left, 0); arLineItr->putLine(pointCenter.y, wholeArea.left, arArea.right - arArea.left + loopArea.right - wholeArea.right, 0); } } else { arLineItr->putLine(pointCenter.y, pointLR.x, loopArea.right - loopArea.left, 0); } arLineItr->putLine(pointTB.y, pointCenter.x, loopArea.right - loopArea.left, 1); if (loopArea.right + arArea.right - arArea.left > wholeArea.right) { if (loopArea.left + arArea.right - arArea.left > wholeArea.right) { arLineItr->putLine(pointTB.y, wholeArea.left + loopArea.left + arArea.right - arArea.left - wholeArea.right, loopArea.right - loopArea.left, 1); } else { arLineItr->putLine(pointTB.y, pointLR.x, wholeArea.right - arArea.right + arArea.left - loopArea.left, 1); arLineItr->putLine(pointTB.y, wholeArea.left, arArea.right - arArea.left + loopArea.right - wholeArea.right, 1); } } else { arLineItr->putLine(pointTB.y, pointLR.x, loopArea.right - loopArea.left, 1); } } // --------------------------------------------------------------------------- RECT __fastcall NormalRepeatDraw::transToCenter(RECT srcRect) { BEGIN_LOG(""); int lengthX, lengthY; RECT transformRect; lengthX = srcRect.left - arArea.left; if (lengthX < arArea.left) lengthX = lengthX + (arArea.right - arArea.left); transformRect.left = arArea.left + lengthX % (arArea.right - arArea.left); transformRect.right = transformRect.left + srcRect.right - srcRect.left; lengthY = srcRect.top - arArea.top; if (lengthY < arArea.top) lengthY = lengthY + (arArea.bottom - arArea.top); transformRect.top = arArea.top + lengthY % (arArea.bottom - arArea.top); transformRect.bottom = transformRect.top + srcRect.bottom - srcRect.top; END_LOG; return transformRect; } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::proceedPoint() { // BEGIN_LOG(""); pointCenter.x++; pointLR.x++; // pointTB.x++; // pointTBLR.x++; arLineItr->proceedPointer(); if (pointLR.x == wholeArea.right) { // ³¡À» ³Ñ¾î°¡¸é pointLR.x = wholeArea.left; // pointTBLR.x = wholeArea.left; arLineItr->setPointer(pointLR.x, 0, POINTER_LR); arLineItr->setPointer(pointLR.x, 1, POINTER_TBLR); } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall NormalRepeatDraw::proceedPointY() { BEGIN_LOG(""); pointCenter.y++; pointLR.y++; pointTB.y++; pointTBLR.y++; if (pointTB.y == wholeArea.bottom) { // ³¡À» ³Ñ¾î°¡¸é pointTB.y = wholeArea.top; pointTBLR.y = wholeArea.top; } END_LOG; } // --------------------------------------------------------------------------- // ----------- class WdivRepeatDraw 2004-02-24 by celberus --------------- __fastcall WdivRepeatDraw::WdivRepeatDraw (TWindowData *arwindow, RECT wholeAreaRect, int wdiv) { BEGIN_LOG(""); MWdiv = wdiv; arArea.left = arwindow->s.x; arArea.right = arwindow->s.x + arwindow->size.x; arArea.top = arwindow->s.y; arArea.bottom = arwindow->s.y + arwindow->size.y; ARWidth = arArea.right - arArea.left; wholeArea = wholeAreaRect; initDividedRect(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::initDividedRect() { // Àüü ¿µ¿ªÀ» ÀÚµ¿¹Ýº¹ °æ°è¸¦ ±âÁØÀ¸·Î 9Á¶°¢À¸·Î ³ª´«´Ù. if (MWdiv <= (arArea.right - arArea.left) / 2) { dividedRect[0] = Rect(wholeArea.left, wholeArea.top, arArea.left - MWdiv, arArea.top); // |0|1111|222| |D|CCDD|CCD| dividedRect[1] = Rect(arArea.left - MWdiv, wholeArea.top, arArea.right - MWdiv, arArea.top); // |0|1111|222| |D|CCDD|CCD| dividedRect[2] = Rect(arArea.right - MWdiv, wholeArea.top, wholeArea.right, arArea.top); // |33|4444|55| |BB|AABB|AA| dividedRect[3] = Rect(wholeArea.left, arArea.top, arArea.left, arArea.bottom); // |33|4444|55| |BB|AABB|AA| dividedRect[4] = Rect(arArea.left, arArea.top, arArea.right, arArea.bottom); // |33|4444|55| |DD|CCDD|CC| dividedRect[5] = Rect(arArea.right, arArea.top, wholeArea.right, arArea.bottom); // |33|4444|55| |DD|CCDD|CC| dividedRect[6] = Rect(wholeArea.left, arArea.bottom, arArea.left + MWdiv, wholeArea.bottom); // |666|7777|8| |BBB|AABB|A| dividedRect[7] = Rect(arArea.left + MWdiv, arArea.bottom, arArea.right + MWdiv, wholeArea.bottom); // |666|7777|8| |BBB|AABB|A| dividedRect[8] = Rect(arArea.right + MWdiv, arArea.bottom, wholeArea.right, wholeArea.bottom); } else { int LWdiv = ARWidth - MWdiv; dividedRect[0] = Rect(wholeArea.left, wholeArea.top, arArea.left + LWdiv, arArea.top); // |000|1111|2| |CDD|CCDD|C| dividedRect[1] = Rect(arArea.left + LWdiv, wholeArea.top, arArea.right + LWdiv, arArea.top); // |000|1111|2| |CDD|CCDD|C| dividedRect[2] = Rect(arArea.right + LWdiv, wholeArea.top, wholeArea.right, arArea.top); // |33|4444|55| |BB|AABB|AA| dividedRect[3] = Rect(wholeArea.left, arArea.top, arArea.left, arArea.bottom); // |33|4444|55| |BB|AABB|AA| dividedRect[4] = Rect(arArea.left, arArea.top, arArea.right, arArea.bottom); // |33|4444|55| |DD|CCDD|CC| dividedRect[5] = Rect(arArea.right, arArea.top, wholeArea.right, arArea.bottom); // |33|4444|55| |DD|CCDD|CC| dividedRect[6] = Rect(wholeArea.left, arArea.bottom, arArea.left - LWdiv, wholeArea.bottom); // |6|7777|888| |B|AABB|AAB| dividedRect[7] = Rect(arArea.left - LWdiv, arArea.bottom, arArea.right - LWdiv, wholeArea.bottom); // |6|7777|888| |B|AABB|AAB| dividedRect[8] = Rect(arArea.right - LWdiv, arArea.bottom, wholeArea.right, wholeArea.bottom); } } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::initItr(TPLayerImage *theImage, bool MaskBmp) // normal°ú µ¿ÀÏ { if (MaskBmp) { if (theImage->uBitmap->BitsPerPixel == 8) { arLineItr = (ARLineItr*)new ARLineItr_8_Mask(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_24_Mask(theImage); } } else { if (theImage->uBitmap->BitsPerPixel == 8) { if (theImage->LayerMask) { arLineItr = (ARLineItr*)new ARLineItr_8_Layer(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_8(theImage); } } else { if (theImage->LayerMask) { arLineItr = (ARLineItr*)new ARLineItr_24_Layer(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_24(theImage); } } } } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::initPoint() /* TODO : initPointY ¿Í initPointX·Î ºÐ¸®½ÃŰÀÚ */ { initPointY(); initPointX(); } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::initPointX() { BEGIN_LOG(""); int oddcheck = 0; pointCenter.x = loopArea.left; // °¡·Î ºÐÇÒÁß 50% À̵¿½Ã 1px ¾î±ß³ª°Ô ±×·ÁÁö´Â ¿À·ù ¼öÁ¤ (ÁÂÃøÀ¸·Î 1pxÀ̵¿) by Altang 2007. 1. 8. if (ARWidth % 2 && MWdiv == ARWidth / 2 && pointCenter.y >= wholeArea.top + (wholeArea.bottom - wholeArea.top) / 2) oddcheck = -1; pointLR.x = loopArea.left + ARWidth; if (pointTB.y > pointCenter.y) { pointTB.x = loopArea.left + MWdiv + oddcheck; pointTBLR.x = loopArea.left + arArea.right - arArea.left + MWdiv + oddcheck; } else { pointTB.x = loopArea.left - MWdiv + oddcheck; pointTBLR.x = loopArea.left + arArea.right - arArea.left - MWdiv + oddcheck; } if (pointTB.x >= wholeArea.right) { pointTB.x = wholeArea.left + pointTB.x - wholeArea.right; } if (pointLR.x >= wholeArea.right) { // ³¡À» ³Ñ¾î°¡¸é pointLR.x = wholeArea.left + pointLR.x - wholeArea.right; } if (pointTBLR.x >= wholeArea.right) { pointTBLR.x = wholeArea.left + pointTBLR.x - wholeArea.right; } if (pointTB.x < wholeArea.left) { pointTB.x = wholeArea.right + pointTB.x - wholeArea.left; } if (pointLR.x < wholeArea.left) { // ³¡À» ³Ñ¾î°¡¸é pointLR.x = wholeArea.right + pointLR.x - wholeArea.left; } if (pointTBLR.x < wholeArea.left) { pointTBLR.x = wholeArea.right + pointTBLR.x - wholeArea.left; } oddcheck = 0; END_LOG; } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::initPointY() { BEGIN_LOG(""); pointCenter.y = loopArea.top; pointLR.y = loopArea.top; pointTB.y = loopArea.top + arArea.bottom - arArea.top; pointTBLR.y = loopArea.top + arArea.bottom - arArea.top; if (pointTB.y >= wholeArea.bottom) { pointTB.y = wholeArea.top + pointTB.y - wholeArea.bottom; pointTBLR.y = wholeArea.top + pointTBLR.y - wholeArea.bottom; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::getScanLine() { arLineItr->getLine(pointCenter.y, pointCenter.x, loopArea.right - loopArea.left, 0); arLineItr->setPointer(pointCenter.x, 0, POINTER_CENTER); if (pointLR.x + loopWidth > wholeArea.right) { arLineItr->getLine(pointLR.y, pointLR.x, wholeArea.right - pointLR.x, 0); arLineItr->getLine(pointLR.y, wholeArea.left, pointLR.x + loopWidth - wholeArea.right, 0); } else { arLineItr->getLine(pointLR.y, pointLR.x, loopWidth, 0); } arLineItr->setPointer(pointLR.x, 0, POINTER_LR); if (pointTB.x + loopWidth > wholeArea.right) { arLineItr->getLine(pointTB.y, pointTB.x, wholeArea.right - pointTB.x, 1); arLineItr->getLine(pointTB.y, wholeArea.left, pointTB.x + loopWidth - wholeArea.right, 1); } else { arLineItr->getLine(pointTB.y, pointTB.x, loopWidth, 1); } arLineItr->setPointer(pointTB.x, 1, POINTER_TB); if (pointTBLR.x + loopWidth > wholeArea.right) { arLineItr->getLine(pointTBLR.y, pointTBLR.x, wholeArea.right - pointTBLR.x, 1); arLineItr->getLine(pointTBLR.y, wholeArea.left, pointTBLR.x + loopWidth - wholeArea.right, 1); } else { arLineItr->getLine(pointTBLR.y, pointTBLR.x, loopWidth, 1); } arLineItr->setPointer(pointTBLR.x, 1, POINTER_TBLR); } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::putScanLine() { pointTB.x++; pointTBLR.x++; arLineItr->putLine(pointCenter.y, pointCenter.x, loopArea.right - loopArea.left, 0); if (pointLR.x + loopWidth > wholeArea.right) { arLineItr->putLine(pointLR.y, pointLR.x, wholeArea.right - pointLR.x, 0); arLineItr->putLine(pointLR.y, wholeArea.left, pointLR.x + loopWidth - wholeArea.right, 0); } else { arLineItr->putLine(pointLR.y, pointLR.x, loopWidth, 0); } if (pointTB.x + loopWidth > wholeArea.right) { arLineItr->putLine(pointTB.y, pointTB.x, wholeArea.right - pointTB.x, 1); arLineItr->putLine(pointTB.y, wholeArea.left, pointTB.x + loopWidth - wholeArea.right, 1); } else { arLineItr->putLine(pointTB.y, pointTB.x, loopWidth, 1); } if (pointTBLR.x + loopWidth > wholeArea.right) { arLineItr->putLine(pointTBLR.y, pointTBLR.x, wholeArea.right - pointTBLR.x, 1); arLineItr->putLine(pointTBLR.y, wholeArea.left, pointTBLR.x + loopWidth - wholeArea.right, 1); } else { arLineItr->putLine(pointTBLR.y, pointTBLR.x, loopWidth, 1); } } // --------------------------------------------------------------------------- RECT __fastcall WdivRepeatDraw::transToCenter(RECT srcRect) { BEGIN_LOG(""); int lengthX, lengthY; RECT transformRect; if (srcRect.top >= arArea.bottom) { srcRect.left -= MWdiv; srcRect.right -= MWdiv; } else if (srcRect.bottom <= arArea.top) { srcRect.left += MWdiv; srcRect.right += MWdiv; } if (srcRect.left < 0) { srcRect.left = srcRect.left + wholeArea.right - wholeArea.left; srcRect.right = srcRect.right + wholeArea.right - wholeArea.left; } else if (srcRect.right > wholeArea.right) { srcRect.left = srcRect.left - wholeArea.right + wholeArea.left; srcRect.right = srcRect.right - wholeArea.right + wholeArea.left; } lengthX = srcRect.left - arArea.left; if (lengthX < arArea.left) lengthX = lengthX + (arArea.right - arArea.left); transformRect.left = arArea.left + lengthX % (arArea.right - arArea.left); transformRect.right = transformRect.left + srcRect.right - srcRect.left; lengthY = srcRect.top - arArea.top; if (lengthY < arArea.top) lengthY = lengthY + (arArea.bottom - arArea.top); transformRect.top = arArea.top + lengthY % (arArea.bottom - arArea.top); transformRect.bottom = transformRect.top + srcRect.bottom - srcRect.top; END_LOG; return transformRect; } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::proceedPoint() { // BEGIN_LOG(""); pointCenter.x++; pointLR.x++; pointTB.x++; pointTBLR.x++; arLineItr->proceedPointer(); if (pointLR.x == wholeArea.right) { // ³¡À» ³Ñ¾î°¡¸é pointLR.x = wholeArea.left; arLineItr->setPointer(pointLR.x, 0, POINTER_LR); } if (pointTB.x == wholeArea.right) { pointTB.x = wholeArea.left; arLineItr->setPointer(pointTB.x, 1, POINTER_TB); } if (pointTBLR.x == wholeArea.right) { pointTBLR.x = wholeArea.left; arLineItr->setPointer(pointTBLR.x, 1, POINTER_TBLR); } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall WdivRepeatDraw::proceedPointY() { BEGIN_LOG(""); pointCenter.y++; pointLR.y++; pointTB.y++; pointTBLR.y++; if (pointTB.y == wholeArea.bottom) { // ³¡À» ³Ñ¾î°¡¸é pointTB.y = wholeArea.top; pointTBLR.y = wholeArea.top; } END_LOG; } // --------------------------------------------------------------------------- // ----------- class HivRepeatDraw 2004-02-24 by celberus --------------- __fastcall HdivRepeatDraw::HdivRepeatDraw (TWindowData *arwindow, RECT wholeAreaRect, int hdiv) { BEGIN_LOG(""); MHdiv = hdiv; arArea.left = arwindow->s.x; arArea.right = arwindow->s.x + arwindow->size.x; arArea.top = arwindow->s.y; arArea.bottom = arwindow->s.y + arwindow->size.y; ARWidth = arArea.right - arArea.left; ARHeight = arArea.bottom - arArea.top; wholeArea = wholeAreaRect; initDividedRect(); END_LOG; } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::initDividedRect() { // Àüü ¿µ¿ªÀ» ÀÚµ¿¹Ýº¹ °æ°è¸¦ ±âÁØÀ¸·Î 9Á¶°¢À¸·Î ³ª´«´Ù. if (MHdiv <= (arArea.bottom - arArea.top) / 2) { dividedRect[0] = Rect(wholeArea.left, wholeArea.top, arArea.left, arArea.top - MHdiv); // |00|1111|22| |DD|CCDD|AA| dividedRect[1] = Rect(arArea.left, wholeArea.top, arArea.right, arArea.top); // |33|1111|22| |BB|CCDD|CC| dividedRect[2] = Rect(arArea.right, wholeArea.top, wholeArea.right, arArea.top + MHdiv); // |33|4444|22| |BB|AABB|CC| dividedRect[3] = Rect(wholeArea.left, arArea.top - MHdiv, arArea.left, arArea.bottom - MHdiv); // |33|4444|55| |DD|AABB|AA| dividedRect[4] = Rect(arArea.left, arArea.top, arArea.right, arArea.bottom); // |33|4444|55| |DD|CCDD|AA| dividedRect[5] = Rect(arArea.right, arArea.top + MHdiv, wholeArea.right, arArea.bottom + MHdiv); // |66|4444|55| |BB|CCDD|CC| dividedRect[6] = Rect(wholeArea.left, arArea.bottom - MHdiv, arArea.left, wholeArea.bottom); // |66|7777|55| |BB|AABB|CC| dividedRect[7] = Rect(arArea.left, arArea.bottom, arArea.right, wholeArea.bottom); // |66|7777|88| |DD|AABB|AA| dividedRect[8] = Rect(arArea.right, arArea.bottom + MHdiv, wholeArea.right, wholeArea.bottom); } else { int LHdiv = ARHeight - MHdiv; dividedRect[0] = Rect(wholeArea.left, wholeArea.top, arArea.left, arArea.top + LHdiv); // |00|1111|22| |BB|CCDD|CC| dividedRect[1] = Rect(arArea.left, wholeArea.top, arArea.right, arArea.top); // |00|1111|55| |DD|CCDD|AA| dividedRect[2] = Rect(arArea.right, wholeArea.top, wholeArea.right, arArea.top - LHdiv); // |00|4444|55| |DD|AABB|AA| dividedRect[3] = Rect(wholeArea.left, arArea.top + LHdiv, arArea.left, arArea.bottom + LHdiv); // |33|4444|55| |BB|AABB|CC| dividedRect[4] = Rect(arArea.left, arArea.top, arArea.right, arArea.bottom); // |33|4444|55| |BB|CCDD|CC| dividedRect[5] = Rect(arArea.right, arArea.top - LHdiv, wholeArea.right, arArea.bottom - LHdiv); // |33|4444|88| |DD|CCDD|AA| dividedRect[6] = Rect(wholeArea.left, arArea.bottom + LHdiv, arArea.left, wholeArea.bottom); // |33|7777|88| |DD|AABB|AA| dividedRect[7] = Rect(arArea.left, arArea.bottom, arArea.right, wholeArea.bottom); // |66|7777|88| |BB|AABB|CC| dividedRect[8] = Rect(arArea.right, arArea.bottom - LHdiv, wholeArea.right, wholeArea.bottom); } } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::initItr(TPLayerImage *theImage, bool MaskBmp) // normal°ú µ¿ÀÏ { if (MaskBmp) { if (theImage->uBitmap->BitsPerPixel == 8) { arLineItr = (ARLineItr*)new ARLineItr_8_Mask(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_24_Mask(theImage); } } else { if (theImage->uBitmap->BitsPerPixel == 8) { if (theImage->LayerMask) { arLineItr = (ARLineItr*)new ARLineItr_8_Layer(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_8(theImage); } } else { if (theImage->LayerMask) { arLineItr = (ARLineItr*)new ARLineItr_24_Layer(theImage); } else { arLineItr = (ARLineItr*)new ARLineItr_24(theImage); } } } } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::initPoint() /* TODO : initPointY ¿Í initPointX·Î ºÐ¸®½ÃŰÀÚ */ { initPointX(); initPointY(); } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::initPointX() { BEGIN_LOG(""); pointCenter.x = loopArea.left; pointLR.x = loopArea.left + arArea.right - arArea.left; pointTB.x = loopArea.left; pointTBLR.x = loopArea.left + arArea.right - arArea.left; if (pointLR.x >= wholeArea.right) { // ³¡À» ³Ñ¾î°¡¸é pointLR.x = wholeArea.left + pointLR.x - wholeArea.right; pointTBLR.x = wholeArea.left + pointTBLR.x - wholeArea.right; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::initPointY() { BEGIN_LOG(""); // int oddcheck = 0; pointCenter.y = loopArea.top; // if(ARHeight%2 && MHdiv==ARWidth/2) oddcheck = -1; pointTB.y = loopArea.top + ARHeight; if (pointLR.x > pointCenter.x) { pointLR.y = loopArea.top + MHdiv; pointTBLR.y = loopArea.top + arArea.bottom - arArea.top + MHdiv; } else { pointLR.y = loopArea.top - MHdiv; pointTBLR.y = loopArea.top + arArea.bottom - arArea.top - MHdiv; } if (pointLR.y >= wholeArea.bottom) { pointLR.y = wholeArea.top + pointLR.y - wholeArea.bottom; } if (pointTB.y >= wholeArea.bottom) { // ³¡À» ³Ñ¾î°¡¸é pointTB.y = wholeArea.top + pointTB.y - wholeArea.bottom; } if (pointTBLR.y >= wholeArea.bottom) { pointTBLR.y = wholeArea.top + pointTBLR.y - wholeArea.bottom; } if (pointLR.y < wholeArea.top) { pointLR.y = wholeArea.bottom + pointLR.y - wholeArea.top; } if (pointTB.y < wholeArea.top) { // ³¡À» ³Ñ¾î°¡¸é pointTB.y = wholeArea.bottom + pointTB.y - wholeArea.top; } if (pointTBLR.y < wholeArea.top) { pointTBLR.y = wholeArea.bottom + pointTBLR.y - wholeArea.top; } END_LOG; } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::getScanLine() { arLineItr->getLine(pointCenter.y, pointCenter.x, loopArea.right - loopArea.left, 0); arLineItr->setPointer(pointCenter.x, 0, POINTER_CENTER); if (pointLR.x + loopWidth > wholeArea.right) { arLineItr->getLine(pointLR.y, pointLR.x, wholeArea.right - pointLR.x, 1); // arLineItr->getLine(pointLR.y, wholeArea.left, pointLR.x + loopWidth - wholeArea.right, 1); } else { arLineItr->getLine(pointLR.y, pointLR.x, loopWidth, 1); } arLineItr->setPointer(pointLR.x, 1, POINTER_LR); arLineItr->getLine(pointTB.y, pointCenter.x, loopArea.right - loopArea.left, 2); arLineItr->setPointer(pointTB.x, 2, POINTER_TB); if (pointTBLR.x + loopWidth > wholeArea.right) { arLineItr->getLine(pointTBLR.y, pointTBLR.x, wholeArea.right - pointTBLR.x, 3); // arLineItr->getLine(pointTBLR.y, wholeArea.left, pointTBLR.x + loopWidth - wholeArea.right, 3); } else { arLineItr->getLine(pointTBLR.y, pointTBLR.x, loopWidth, 3); } arLineItr->setPointer(pointTBLR.x, 3, POINTER_TBLR); } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::putScanLine() { arLineItr->putLine(pointCenter.y, pointCenter.x, loopArea.right - loopArea.left, 0); if (pointLR.x + loopWidth > wholeArea.right) { // arLineItr->putLine(pointLR.y, pointLR.x, wholeArea.right - pointLR.x, 1); arLineItr->putLine(pointLR.y, wholeArea.left, pointLR.x + loopWidth - wholeArea.right, 1); } else if (pointLR.x + loopWidth < wholeArea.right) { // °°À»¶§´Â putLine ÇÒ Çʿ䰡 ¾ø´Ù. (xÁÂÇ¥°¡ ³Ñ¾î°¥ ¶§ ÇØÁØ´Ù) arLineItr->putLine(pointLR.y, pointLR.x, loopWidth, 1); } arLineItr->putLine(pointTB.y, pointCenter.x, loopArea.right - loopArea.left, 2); if (pointTBLR.x + loopWidth > wholeArea.right) { // arLineItr->putLine(pointTBLR.y, pointTBLR.x, wholeArea.right - pointTBLR.x, 3); arLineItr->putLine(pointTBLR.y, wholeArea.left, pointTBLR.x + loopWidth - wholeArea.right, 3); } else if (pointLR.x + loopWidth < wholeArea.right) { // °°À»¶§´Â putLine ÇÒ Çʿ䰡 ¾ø´Ù. (xÁÂÇ¥°¡ ³Ñ¾î°¥ ¶§ ÇØÁØ´Ù) arLineItr->putLine(pointTBLR.y, pointTBLR.x, loopWidth, 3); } } // --------------------------------------------------------------------------- RECT __fastcall HdivRepeatDraw::transToCenter(RECT srcRect) { BEGIN_LOG(""); int lengthX, lengthY; RECT transformRect; if (srcRect.left >= arArea.right) { srcRect.top -= MHdiv; srcRect.bottom -= MHdiv; } else if (srcRect.right <= arArea.left) { srcRect.top += MHdiv; srcRect.bottom += MHdiv; } if (srcRect.top < 0) { srcRect.top = srcRect.top + wholeArea.bottom - wholeArea.top; srcRect.bottom = srcRect.bottom + wholeArea.bottom - wholeArea.top; } else if (srcRect.bottom > wholeArea.bottom) { srcRect.top = srcRect.top - wholeArea.bottom + wholeArea.top; srcRect.bottom = srcRect.bottom - wholeArea.bottom + wholeArea.top; } lengthX = srcRect.left - arArea.left; if (lengthX < arArea.left) lengthX = lengthX + (arArea.right - arArea.left); transformRect.left = arArea.left + lengthX % (arArea.right - arArea.left); transformRect.right = transformRect.left + srcRect.right - srcRect.left; lengthY = srcRect.top - arArea.top; if (lengthY < arArea.top) lengthY = lengthY + (arArea.bottom - arArea.top); transformRect.top = arArea.top + lengthY % (arArea.bottom - arArea.top); transformRect.bottom = transformRect.top + srcRect.bottom - srcRect.top; END_LOG; return transformRect; } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::proceedPoint() { // BEGIN_LOG(""); pointCenter.x++; pointLR.x++; pointTB.x++; pointTBLR.x++; arLineItr->proceedPointer(); if (pointLR.x == wholeArea.right) { // ³¡À» ³Ñ¾î°¡¸é // xÁÂÇ¥°¡ ³Ñ¾î°¡¸é y ÁÂÇ¥µµ °°ÀÌ ¹Ù²î´Âµ¥ scanlineµîÀÇ ¹®Á¦·Î x°ªÀ» Àá±ñ¹Ù²Ù´Â Æí¹ýÀ» »ç¿ëÇÏ¿´´Ù. pointLR.x = loopArea.left + arArea.right - arArea.left; pointTBLR.x = loopArea.left + arArea.right - arArea.left; if (pointLR.x >= wholeArea.right) { pointLR.x = wholeArea.left + pointLR.x - wholeArea.right; pointTBLR.x = wholeArea.left + pointTBLR.x - wholeArea.right; } arLineItr->putLine(pointLR.y, pointLR.x, wholeArea.right - pointLR.x, 1); pointLR.y = pointLR.y - 2 * MHdiv; if (pointLR.y < wholeArea.top) { pointLR.y = wholeArea.bottom + pointLR.y - wholeArea.top; } arLineItr->getLine(pointLR.y, wholeArea.left, pointLR.x + loopWidth - wholeArea.right, 1); pointLR.x = wholeArea.left; arLineItr->setPointer(pointLR.x, 1, POINTER_LR); arLineItr->putLine(pointTBLR.y, pointTBLR.x, wholeArea.right - pointTBLR.x, 3); pointTBLR.y = pointTBLR.y - 2 * MHdiv; if (pointTBLR.y < wholeArea.top) { pointTBLR.y = wholeArea.bottom + pointTBLR.y - wholeArea.top; } arLineItr->getLine(pointTBLR.y, wholeArea.left, pointTBLR.x + loopWidth - wholeArea.right, 3); pointTBLR.x = wholeArea.left; arLineItr->setPointer(pointTBLR.x, 3, POINTER_TBLR); } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall HdivRepeatDraw::proceedPointY() { BEGIN_LOG(""); pointCenter.y++; // pointLR.y++; pointTB.y++; // pointTBLR.y++; if (pointLR.x > pointCenter.x) { pointLR.y = pointCenter.y + MHdiv; pointTBLR.y = pointTB.y + MHdiv; } else { pointLR.y = pointCenter.y - MHdiv; pointTBLR.y = pointTB.y - MHdiv; } if (pointLR.y >= wholeArea.bottom) { pointLR.y = wholeArea.top + pointLR.y - wholeArea.bottom; } if (pointTB.y >= wholeArea.bottom) { // ³¡À» ³Ñ¾î°¡¸é pointTB.y = wholeArea.top + pointTB.y - wholeArea.bottom; } if (pointTBLR.y >= wholeArea.bottom) { pointTBLR.y = wholeArea.top + pointTBLR.y - wholeArea.bottom; } if (pointLR.y < wholeArea.top) { pointLR.y = wholeArea.bottom + pointLR.y - wholeArea.top; } if (pointTB.y < wholeArea.top) { // ³¡À» ³Ñ¾î°¡¸é pointTB.y = wholeArea.bottom + pointTB.y - wholeArea.top; } if (pointTBLR.y < wholeArea.top) { pointTBLR.y = wholeArea.bottom + pointTBLR.y - wholeArea.top; } END_LOG; } // --------------------------------------------------------------------------- // ----------- class ARLineItr 2004-02-19 by celberus --------------- __fastcall ARLineItr::ARLineItr(TPLayerImage *theImage) { Image = theImage; } // --------------------------------------------------------------------------- // ----------- class ARLineItr_8 2004-02-19 by celberus --------------- void __fastcall ARLineItr_8::getLine(int y, int x, int length, int lineNumber) { pLine[lineNumber] = Image->uBitmap->GetScanLineN(y, x, length, lineNumber); pUndoLine[lineNumber] = Image->uBitmap->GetUndoScanLineN (y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8::putLine(int y, int x, int length, int lineNumber) { Image->uBitmap->PutDiffScanLineN(y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8::setPointer (int x, int lineNumber, int pointerNumber) { // BEGIN_LOG(""); pData[pointerNumber] = pLine[lineNumber] + x; pUndoData[pointerNumber] = pUndoLine[lineNumber] + x; // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8::copyValue() { // BEGIN_LOG(""); if (*pData[POINTER_CENTER] != *pUndoData[POINTER_CENTER]) { *pData[POINTER_TB] = *pData[POINTER_LR] = *pData[POINTER_TBLR] = *pData [POINTER_CENTER]; } else if (*pData[POINTER_TB] != *pUndoData[POINTER_TB]) { *pData[POINTER_LR] = *pData[POINTER_TBLR] = *pData[POINTER_CENTER] = *pData [POINTER_TB]; } else if (*pData[POINTER_LR] != *pUndoData[POINTER_LR]) { *pData[POINTER_TBLR] = *pData[POINTER_CENTER] = *pData[POINTER_TB] = *pData [POINTER_LR]; } else if (*pData[POINTER_TBLR] != *pUndoData[POINTER_TBLR]) { *pData[POINTER_CENTER] = *pData[POINTER_TB] = *pData[POINTER_LR] = *pData [POINTER_TBLR]; } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8::proceedPointer() { // BEGIN_LOG(""); pData[0]++; pData[1]++; pData[2]++; pData[3]++; pUndoData[0]++; pUndoData[1]++; pUndoData[2]++; pUndoData[3]++; // END_LOG; } // --------------------------------------------------------------------------- // ----------- class ARLineItr_8_Layer 2004-02-20 by celberus --------------- void __fastcall ARLineItr_8_Layer::getLine (int y, int x, int length, int lineNumber) { pLine[lineNumber] = Image->uBitmap->GetScanLineN(y, x, length, lineNumber); pUndoLine[lineNumber] = Image->uBitmap->GetUndoScanLineN (y, x, length, lineNumber); pLayerLine[lineNumber] = Image->LayerMask->GetScanLineN (y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Layer::putLine (int y, int x, int length, int lineNumber) { Image->uBitmap->PutDiffScanLineN(y, x, length, lineNumber); Image->LayerMask->PutDiffScanLineN(y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Layer::setPointer (int x, int lineNumber, int pointerNumber) { // BEGIN_LOG(""); pData[pointerNumber] = pLine[lineNumber] + x; pUndoData[pointerNumber] = pUndoLine[lineNumber] + x; pLayerData[pointerNumber] = pLayerLine[lineNumber] + x; // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Layer::copyValue() { // BEGIN_LOG(""); if (*pData[POINTER_CENTER] != *pUndoData[POINTER_CENTER]) { *pData[POINTER_TB] = *pData[POINTER_LR] = *pData[POINTER_TBLR] = *pData [POINTER_CENTER]; *pLayerData[POINTER_TB] = *pLayerData[POINTER_LR] = *pLayerData [POINTER_TBLR] = *pLayerData[POINTER_CENTER]; } else if (*pData[POINTER_TB] != *pUndoData[POINTER_TB]) { *pData[POINTER_LR] = *pData[POINTER_TBLR] = *pData[POINTER_CENTER] = *pData [POINTER_TB]; *pLayerData[POINTER_LR] = *pLayerData[POINTER_TBLR] = *pLayerData [POINTER_CENTER] = *pLayerData[POINTER_TB]; } else if (*pData[POINTER_LR] != *pUndoData[POINTER_LR]) { *pData[POINTER_TBLR] = *pData[POINTER_CENTER] = *pData[POINTER_TB] = *pData [POINTER_LR]; *pLayerData[POINTER_TBLR] = *pLayerData[POINTER_CENTER] = *pLayerData [POINTER_TB] = *pLayerData[POINTER_LR]; } else if (*pData[POINTER_TBLR] != *pUndoData[POINTER_TBLR]) { *pData[POINTER_CENTER] = *pData[POINTER_TB] = *pData[POINTER_LR] = *pData [POINTER_TBLR]; *pLayerData[POINTER_CENTER] = *pLayerData[POINTER_TB] = *pLayerData [POINTER_LR] = *pLayerData[POINTER_TBLR]; } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Layer::proceedPointer() { BEGIN_LOG(""); pData[0]++; pData[1]++; pData[2]++; pData[3]++; pUndoData[0]++; pUndoData[1]++; pUndoData[2]++; pUndoData[3]++; pLayerData[0]++; pLayerData[1]++; pLayerData[2]++; pLayerData[3]++; END_LOG; } // --------------------------------------------------------------------------- // ----------- class ARLineItr_24 2004-02-20 by celberus --------------- void __fastcall ARLineItr_24::getLine(int y, int x, int length, int lineNumber) { pLine[lineNumber] = Image->uBitmap->GetScanLineN(y, x, length, lineNumber); pUndoLine[lineNumber] = Image->uBitmap->GetUndoScanLineN (y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24::putLine(int y, int x, int length, int lineNumber) { Image->uBitmap->PutDiffScanLineN(y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24::setPointer (int x, int lineNumber, int pointerNumber) { // BEGIN_LOG(""); pData[pointerNumber] = pLine[lineNumber] + 3 * x; pUndoData[pointerNumber] = pUndoLine[lineNumber] + 3 * x; // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24::copyValue() { // BEGIN_LOG(""); if (pData[POINTER_CENTER][0] != pUndoData[POINTER_CENTER][0] || pData [POINTER_CENTER][1] != pUndoData[POINTER_CENTER][1] || pData[POINTER_CENTER][2] != pUndoData[POINTER_CENTER][2]) { pData[POINTER_TB][0] = pData[POINTER_LR][0] = pData[POINTER_TBLR][0] = pData [POINTER_CENTER][0]; pData[POINTER_TB][1] = pData[POINTER_LR][1] = pData[POINTER_TBLR][1] = pData [POINTER_CENTER][1]; pData[POINTER_TB][2] = pData[POINTER_LR][2] = pData[POINTER_TBLR][2] = pData [POINTER_CENTER][2]; } else if (pData[POINTER_TB][0] != pUndoData[POINTER_TB][0] || pData[POINTER_TB] [1] != pUndoData[POINTER_TB][1] || pData[POINTER_TB][2] != pUndoData [POINTER_TB][2]) { pData[POINTER_LR][0] = pData[POINTER_TBLR][0] = pData[POINTER_CENTER][0] = pData[POINTER_TB][0]; pData[POINTER_LR][1] = pData[POINTER_TBLR][1] = pData[POINTER_CENTER][1] = pData[POINTER_TB][1]; pData[POINTER_LR][2] = pData[POINTER_TBLR][2] = pData[POINTER_CENTER][2] = pData[POINTER_TB][2]; } else if (pData[POINTER_LR][0] != pUndoData[POINTER_LR][0] || pData[POINTER_LR] [1] != pUndoData[POINTER_LR][1] || pData[POINTER_LR][2] != pUndoData [POINTER_LR][2]) { pData[POINTER_TBLR][0] = pData[POINTER_CENTER][0] = pData[POINTER_TB][0] = pData[POINTER_LR][0]; pData[POINTER_TBLR][1] = pData[POINTER_CENTER][1] = pData[POINTER_TB][1] = pData[POINTER_LR][1]; pData[POINTER_TBLR][2] = pData[POINTER_CENTER][2] = pData[POINTER_TB][2] = pData[POINTER_LR][2]; } else if (pData[POINTER_TBLR][0] != pUndoData[POINTER_TBLR][0] || pData [POINTER_TBLR][1] != pUndoData[POINTER_TBLR][1] || pData[POINTER_TBLR][2] != pUndoData[POINTER_TBLR][2]) { pData[POINTER_CENTER][0] = pData[POINTER_TB][0] = pData[POINTER_LR][0] = pData[POINTER_TBLR][0]; pData[POINTER_CENTER][1] = pData[POINTER_TB][1] = pData[POINTER_LR][1] = pData[POINTER_TBLR][1]; pData[POINTER_CENTER][2] = pData[POINTER_TB][2] = pData[POINTER_LR][2] = pData[POINTER_TBLR][2]; } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24::proceedPointer() { pData[0] += 3; pData[1] += 3; pData[2] += 3; pData[3] += 3; pUndoData[0] += 3; pUndoData[1] += 3; pUndoData[2] += 3; pUndoData[3] += 3; } // --------------------------------------------------------------------------- // ----------- class ARLineItr_24_Layer 2004-02-20 by celberus --------------- void __fastcall ARLineItr_24_Layer::getLine (int y, int x, int length, int lineNumber) { pLine[lineNumber] = Image->uBitmap->GetScanLineN(y, x, length, lineNumber); pUndoLine[lineNumber] = Image->uBitmap->GetUndoScanLineN (y, x, length, lineNumber); pLayerLine[lineNumber] = Image->LayerMask->GetScanLineN (y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Layer::putLine (int y, int x, int length, int lineNumber) { Image->uBitmap->PutDiffScanLineN(y, x, length, lineNumber); Image->LayerMask->PutDiffScanLineN(y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Layer::setPointer (int x, int lineNumber, int pointerNumber) { // BEGIN_LOG(""); pData[pointerNumber] = pLine[lineNumber] + 3 * x; pUndoData[pointerNumber] = pUndoLine[lineNumber] + 3 * x; layerMaskPos[pointerNumber] = x; // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Layer::copyValue() { // BEGIN_LOG(""); if (pData[POINTER_CENTER][0] != pUndoData[POINTER_CENTER][0] || pData [POINTER_CENTER][1] != pUndoData[POINTER_CENTER][1] || pData[POINTER_CENTER][2] != pUndoData[POINTER_CENTER][2]) { pData[POINTER_TB][0] = pData[POINTER_LR][0] = pData[POINTER_TBLR][0] = pData [POINTER_CENTER][0]; pData[POINTER_TB][1] = pData[POINTER_LR][1] = pData[POINTER_TBLR][1] = pData [POINTER_CENTER][1]; pData[POINTER_TB][2] = pData[POINTER_LR][2] = pData[POINTER_TBLR][2] = pData [POINTER_CENTER][2]; if (*(pLayerLine[0] + (layerMaskPos[POINTER_CENTER] >> 3)) & (0x80 >> (layerMaskPos[POINTER_CENTER] & 7))) { *(pLayerLine[1] + (layerMaskPos[POINTER_TB] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_TB] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_LR] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_LR] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TBLR] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_TBLR] & 7)); } else { *(pLayerLine[1] + (layerMaskPos[POINTER_TB] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_TB] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_LR] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_LR] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TBLR] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_TBLR] & 7)); } } else if (pData[POINTER_TB][0] != pUndoData[POINTER_TB][0] || pData[POINTER_TB] [1] != pUndoData[POINTER_TB][1] || pData[POINTER_TB][2] != pUndoData [POINTER_TB][2]) { pData[POINTER_LR][0] = pData[POINTER_TBLR][0] = pData[POINTER_CENTER][0] = pData[POINTER_TB][0]; pData[POINTER_LR][1] = pData[POINTER_TBLR][1] = pData[POINTER_CENTER][1] = pData[POINTER_TB][1]; pData[POINTER_LR][2] = pData[POINTER_TBLR][2] = pData[POINTER_CENTER][2] = pData[POINTER_TB][2]; if (*(pLayerLine[1] + (layerMaskPos[POINTER_TB] >> 3)) & (0x80 >> (layerMaskPos[POINTER_TB] & 7))) { *(pLayerLine[0] + (layerMaskPos[POINTER_LR] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_LR] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TBLR] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_TBLR] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_CENTER] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_CENTER] & 7)); } else { *(pLayerLine[0] + (layerMaskPos[POINTER_LR] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_LR] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TBLR] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_TBLR] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_CENTER] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_CENTER] & 7)); } } else if (pData[POINTER_LR][0] != pUndoData[POINTER_LR][0] || pData[POINTER_LR] [1] != pUndoData[POINTER_LR][1] || pData[POINTER_LR][2] != pUndoData [POINTER_LR][2]) { pData[POINTER_TBLR][0] = pData[POINTER_CENTER][0] = pData[POINTER_TB][0] = pData[POINTER_LR][0]; pData[POINTER_TBLR][1] = pData[POINTER_CENTER][1] = pData[POINTER_TB][1] = pData[POINTER_LR][1]; pData[POINTER_TBLR][2] = pData[POINTER_CENTER][2] = pData[POINTER_TB][2] = pData[POINTER_LR][2]; if (*(pLayerLine[0] + (layerMaskPos[POINTER_LR] >> 3)) & (0x80 >> (layerMaskPos[POINTER_LR] & 7))) { *(pLayerLine[1] + (layerMaskPos[POINTER_TBLR] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_TBLR] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_CENTER] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_CENTER] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TB] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_TB] & 7)); } else { *(pLayerLine[1] + (layerMaskPos[POINTER_TBLR] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_TBLR] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_CENTER] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_CENTER] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TB] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_TB] & 7)); } } else if (pData[POINTER_TBLR][0] != pUndoData[POINTER_TBLR][0] || pData [POINTER_TBLR][1] != pUndoData[POINTER_TBLR][1] || pData[POINTER_TBLR][2] != pUndoData[POINTER_TBLR][2]) { pData[POINTER_CENTER][0] = pData[POINTER_TB][0] = pData[POINTER_LR][0] = pData[POINTER_TBLR][0]; pData[POINTER_CENTER][1] = pData[POINTER_TB][1] = pData[POINTER_LR][1] = pData[POINTER_TBLR][1]; pData[POINTER_CENTER][2] = pData[POINTER_TB][2] = pData[POINTER_LR][2] = pData[POINTER_TBLR][2]; if (*(pLayerLine[1] + (layerMaskPos[POINTER_TBLR] >> 3)) & (0x80 >> (layerMaskPos[POINTER_TBLR] & 7))) { *(pLayerLine[0] + (layerMaskPos[POINTER_CENTER] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_CENTER] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TB] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_TB] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_LR] >> 3)) |= (0x80 >> (layerMaskPos[POINTER_LR] & 7)); } else { *(pLayerLine[0] + (layerMaskPos[POINTER_CENTER] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_CENTER] & 7)); *(pLayerLine[1] + (layerMaskPos[POINTER_TB] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_TB] & 7)); *(pLayerLine[0] + (layerMaskPos[POINTER_LR] >> 3)) &= ~ (0x80 >> (layerMaskPos[POINTER_LR] & 7)); } } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Layer::proceedPointer() { BEGIN_LOG(""); pData[0] += 3; pData[1] += 3; pData[2] += 3; pData[3] += 3; pUndoData[0] += 3; pUndoData[1] += 3; pUndoData[2] += 3; pUndoData[3] += 3; layerMaskPos[0]++; layerMaskPos[1]++; layerMaskPos[2]++; layerMaskPos[3]++; END_LOG; } // --------------------------------------------------------------------------- // ----------- class ARLineItr_8_Mask 2004-02-19 by celberus --------------- void __fastcall ARLineItr_8_Mask::getLine (int y, int x, int length, int lineNumber) { pLine[lineNumber] = Image->Mask->GetScanLineN(y, x, length, lineNumber); pUndoLine[lineNumber] = Image->Mask->GetUndoScanLineN (y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Mask::putLine (int y, int x, int length, int lineNumber) { Image->Mask->PutDiffScanLineN(y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Mask::setPointer (int x, int lineNumber, int pointerNumber) { pData[pointerNumber] = pLine[lineNumber] + x; pUndoData[pointerNumber] = pUndoLine[lineNumber] + x; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Mask::copyValue() { // BEGIN_LOG(""); if (*pData[POINTER_CENTER] != *pUndoData[POINTER_CENTER]) { *pData[POINTER_TB] = *pData[POINTER_LR] = *pData[POINTER_TBLR] = *pData [POINTER_CENTER]; } else if (*pData[POINTER_TB] != *pUndoData[POINTER_TB]) { *pData[POINTER_LR] = *pData[POINTER_TBLR] = *pData[POINTER_CENTER] = *pData [POINTER_TB]; } else if (*pData[POINTER_LR] != *pUndoData[POINTER_LR]) { *pData[POINTER_TBLR] = *pData[POINTER_CENTER] = *pData[POINTER_TB] = *pData [POINTER_LR]; } else if (*pData[POINTER_TBLR] != *pUndoData[POINTER_TBLR]) { *pData[POINTER_CENTER] = *pData[POINTER_TB] = *pData[POINTER_LR] = *pData [POINTER_TBLR]; } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_8_Mask::proceedPointer() { pData[0]++; pData[1]++; pData[2]++; pData[3]++; pUndoData[0]++; pUndoData[1]++; pUndoData[2]++; pUndoData[3]++; } // --------------------------------------------------------------------------- // ----------- class ARLineItr_24_Mask 2004-02-24 by celberus --------------- void __fastcall ARLineItr_24_Mask::getLine (int y, int x, int length, int lineNumber) { pLine[lineNumber] = Image->Mask->GetScanLineN(y, x, length, lineNumber); pUndoLine[lineNumber] = Image->Mask->GetUndoScanLineN (y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Mask::putLine (int y, int x, int length, int lineNumber) { Image->Mask->PutDiffScanLineN(y, x, length, lineNumber); } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Mask::setPointer (int x, int lineNumber, int pointerNumber) { MaskPos[pointerNumber] = x; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Mask::copyValue() { // BEGIN_LOG(""); if ((*(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) & (0x80 >> (MaskPos[POINTER_CENTER] & 7))) ^ (*(pUndoLine[0] + (MaskPos[POINTER_CENTER] >> 3)) & (0x80 >> (MaskPos[POINTER_CENTER] & 7)))) { if (*(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) & (0x80 >> (MaskPos[POINTER_CENTER] & 7))) { *(pLine[1] + (MaskPos[POINTER_TB] >> 3)) |= (0x80 >> (MaskPos[POINTER_TB] & 7)); *(pLine[0] + (MaskPos[POINTER_LR] >> 3)) |= (0x80 >> (MaskPos[POINTER_LR] & 7)); *(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) |= (0x80 >> (MaskPos[POINTER_TBLR] & 7)); } else { *(pLine[1] + (MaskPos[POINTER_TB] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_TB] & 7)); *(pLine[0] + (MaskPos[POINTER_LR] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_LR] & 7)); *(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_TBLR] & 7)); } } else if ((*(pLine[1] + (MaskPos[POINTER_TB] >> 3)) & (0x80 >> (MaskPos[POINTER_TB] & 7))) ^ (*(pUndoLine[1] + (MaskPos[POINTER_TB] >> 3)) & (0x80 >> (MaskPos[POINTER_TB] & 7)))) { if (*(pLine[1] + (MaskPos[POINTER_TB] >> 3)) & (0x80 >> (MaskPos[POINTER_TB] & 7))) { *(pLine[0] + (MaskPos[POINTER_LR] >> 3)) |= (0x80 >> (MaskPos[POINTER_LR] & 7)); *(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) |= (0x80 >> (MaskPos[POINTER_TBLR] & 7)); *(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) |= (0x80 >> (MaskPos[POINTER_CENTER] & 7)); } else { *(pLine[0] + (MaskPos[POINTER_LR] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_LR] & 7)); *(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_TBLR] & 7)); *(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_CENTER] & 7)); } } else if ((*(pLine[0] + (MaskPos[POINTER_LR] >> 3)) & (0x80 >> (MaskPos[POINTER_LR] & 7))) ^ (*(pUndoLine[0] + (MaskPos[POINTER_LR] >> 3)) & (0x80 >> (MaskPos[POINTER_LR] & 7)))) { if (*(pLine[0] + (MaskPos[POINTER_LR] >> 3)) & (0x80 >> (MaskPos[POINTER_LR] & 7))) { *(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) |= (0x80 >> (MaskPos[POINTER_TBLR] & 7)); *(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) |= (0x80 >> (MaskPos[POINTER_CENTER] & 7)); *(pLine[1] + (MaskPos[POINTER_TB] >> 3)) |= (0x80 >> (MaskPos[POINTER_TB] & 7)); } else { *(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_TBLR] & 7)); *(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_CENTER] & 7)); *(pLine[1] + (MaskPos[POINTER_TB] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_TB] & 7)); } } else if ((*(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) & (0x80 >> (MaskPos[POINTER_TBLR] & 7))) ^ (*(pUndoLine[1] + (MaskPos[POINTER_TBLR] >> 3)) & (0x80 >> (MaskPos[POINTER_TBLR] & 7)))) { if (*(pLine[1] + (MaskPos[POINTER_TBLR] >> 3)) & (0x80 >> (MaskPos[POINTER_TBLR] & 7))) { *(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) |= (0x80 >> (MaskPos[POINTER_CENTER] & 7)); *(pLine[1] + (MaskPos[POINTER_TB] >> 3)) |= (0x80 >> (MaskPos[POINTER_TB] & 7)); *(pLine[0] + (MaskPos[POINTER_LR] >> 3)) |= (0x80 >> (MaskPos[POINTER_LR] & 7)); } else { *(pLine[0] + (MaskPos[POINTER_CENTER] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_CENTER] & 7)); *(pLine[1] + (MaskPos[POINTER_TB] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_TB] & 7)); *(pLine[0] + (MaskPos[POINTER_LR] >> 3)) &= ~ (0x80 >> (MaskPos[POINTER_LR] & 7)); } } // END_LOG; } // --------------------------------------------------------------------------- void __fastcall ARLineItr_24_Mask::proceedPointer() { MaskPos[0]++; MaskPos[1]++; MaskPos[2]++; MaskPos[3]++; } // --------------------------------------------------------------------------- // Fot TextBox by maxleo21c (04.10.30) // ¸¸µç ÀÌÀ¯: FullViewForm°ú ¿¬°áÇÒ ¼ö ÀÖ´Â ÇÔ¼ö¸¦ ¸¸µé±â À§Çؼ­ void __fastcall TMainImageForm::SetCaretPositionForTextBox() { if (this->Active) { if (VectorForm) { if (VectorForm->sbNewTextEdit->Down) { VectorForm->CaretPozChange(); // SetFocusedControl(this);// ¹öưÀ» Ŭ¸¯ÇÏ¸é ±×°÷¿¡ Æ÷Ä¿½º°¡ À־ "¹æÇâŰ"°¡ // // 󸮵ÇÁö ¾Ê´Â ¹®Á¦¸¦ ÇØ°áÇϱâ À§Çؼ­ »ç¿ë // tempRadioButton->SetFocus(); } } } } // --------------------------------------------------------------------------- bool __fastcall TMainImageForm::CanUseMouseWheelInVectorForm() { if (VectorForm && VectorForm->sbNewTextEdit->Down) return VectorForm->UseComboBoxForText; else return false; } // --------------------------------------------------------------------------- String __fastcall TMainImageForm::returnSize(int dx, int dy) { String str; if (CurrentUnit == uInch) { str = Format("%f x %f", OPENARRAY (TVarRec, ((fabs(dx) + 1) / CanvasInfor.DotsPerInch, (fabs(dy) + 1) / CanvasInfor.DotsPerInch))); } else if (CurrentUnit == uCm) { str = Format("%f x %f", OPENARRAY(TVarRec, (2.54 * (fabs(dx) + 1) / CanvasInfor.DotsPerInch, 2.54 * (fabs(dy) + 1) / CanvasInfor.DotsPerInch))); } else { str = Format("%d x %d", OPENARRAY(TVarRec, (abs(dx) + 1, abs(dy) + 1))); } return str; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbVerticalClick(TObject *Sender) { MainImageForm = this; if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } if (VectorForm) { switch(sbVertical->Tag) { case 0: // óÀ½ Çѹø // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - °¡·Î ±âÁØ ¼±À» ¼±ÅÃ- by monkman (2005.02.25) NVector->ReflectionVH = 3; this->iMainImage->OnPaintVectorReflectIndexPoint = this->PaintVectorReflectIndexPoint; NVector->ReflectFirstIndex = true; // ù¶óÀÎÀÇ Áߺ¹ ¹æÁö // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- sbVertical->Tag = 1; sbVertical->Down = true; sbVertical->Hint = IDS_ENDREFLECTION; sbHorizontal->Tag = 2; sbHorizontal->Down = false; sbHorizontal->Hint = IDS_HORIZONTALREFLECTION; sbLock->Tag = 1; sbLock->Down = true; sbLock->Enabled = true; sbLock->Hint = IDS_RELEASEAXIS; NVector->bReflectionGuideLineLock = true; VectorForm->InitReflectionMirror(); break; case 1: // ¹ÝÀü °Å¿ï Á¾·á if (VectorForm) { if (VectorForm->ExitReflectionMirror()) { // Á¾·á°¡ µÇ¾úÀ» °æ¿ì sbVertical->Tag = 0; sbVertical->Down = false; sbVertical->Hint = IDS_VERTICALREFLECTION; sbHorizontal->Tag = 0; sbHorizontal->Down = false; sbHorizontal->Hint = IDS_HORIZONTALREFLECTION; sbLock->Tag = 0; sbLock->Down = false; sbLock->Enabled = false; sbLock->Hint = IDS_FIXAXIS; } else { // Á¾·á°¡ µÇÁö ¾Ê¾ÒÀ» °æ¿ì sbVertical->Tag = 1; sbVertical->Down = true; sbVertical->Hint = IDS_ENDREFLECTION; sbHorizontal->Tag = 2; sbHorizontal->Down = false; sbHorizontal->Hint = IDS_HORIZONTALREFLECTION; sbLock->Enabled = true; } } break; case 2: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - °¡·Î ±âÁØ ¼±À» ¼±ÅÃ- by monkman (2005.02.25) NVector->ReflectionVH = 3; this->iMainImage->OnPaintVectorReflectIndexPoint = this->PaintVectorReflectIndexPoint; NVector->ReflectFirstIndex = true; // ù¶óÀÎÀÇ Áߺ¹ ¹æÁö // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- sbVertical->Tag = 1; sbVertical->Down = true; sbVertical->Hint = IDS_VERTICALREFLECTION; sbHorizontal->Tag = 2; sbHorizontal->Down = false; sbHorizontal->Hint = IDS_HORIZONTALREFLECTION; sbLock->Enabled = true; break; } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbHorizontalClick(TObject *Sender) { MainImageForm = this; if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } switch(sbHorizontal->Tag) { case 0: // óÀ½ Çѹø // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - °¡·Î ±âÁØ ¼±À» ¼±ÅÃ- by monkman (2005.02.25) NVector->ReflectionVH = 4; this->iMainImage->OnPaintVectorReflectIndexPoint = this->PaintVectorReflectIndexPoint; NVector->ReflectFirstIndex = true; // ù¶óÀÎÀÇ Áߺ¹ ¹æÁö // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- sbVertical->Tag = 2; sbVertical->Down = false; sbVertical->Hint = IDS_VERTICALREFLECTION; sbHorizontal->Tag = 1; sbHorizontal->Down = true; sbHorizontal->Hint = IDS_ENDREFLECTION; sbLock->Tag = 1; sbLock->Down = true; sbLock->Enabled = true; sbLock->Hint = IDS_RELEASEAXIS; NVector->bReflectionGuideLineLock = true; VectorForm->InitReflectionMirror(); break; case 1: // ¹ÝÀü °Å¿ï Á¾·á if (VectorForm) { if (VectorForm->ExitReflectionMirror()) { // Á¾·á°¡ µÇ¾úÀ» °æ¿ì sbVertical->Tag = 0; sbVertical->Down = false; sbVertical->Hint = IDS_VERTICALREFLECTION; sbHorizontal->Tag = 0; sbHorizontal->Down = false; sbHorizontal->Hint = IDS_HORIZONTALREFLECTION; sbLock->Down = false; sbLock->Tag = 0; sbLock->Enabled = false; sbLock->Hint = IDS_FIXAXIS; } else { // Á¾·á°¡ µÇÁö ¾Ê¾ÒÀ» °æ¿ì sbVertical->Tag = 2; sbVertical->Down = false; sbVertical->Hint = IDS_VERTICALREFLECTION; sbHorizontal->Tag = 1; sbHorizontal->Down = true; sbHorizontal->Hint = IDS_ENDREFLECTION; sbLock->Enabled = true; } } break; case 2: // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ¹ÝÀü °Å¿ï ±â´É - °¡·Î ±âÁØ ¼±À» ¼±ÅÃ- by monkman (2005.02.25) NVector->ReflectionVH = 4; this->iMainImage->OnPaintVectorReflectIndexPoint = this->PaintVectorReflectIndexPoint; NVector->ReflectFirstIndex = true; // ù¶óÀÎÀÇ Áߺ¹ ¹æÁö // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- sbVertical->Tag = 2; sbVertical->Down = false; sbVertical->Hint = IDS_VERTICALREFLECTION; sbHorizontal->Tag = 1; sbHorizontal->Down = true; sbHorizontal->Hint = IDS_ENDREFLECTION; sbLock->Enabled = true; break; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::sbLockClick(TObject *Sender) { MainImageForm = this; if (bShortcutForEnlarge) { // added by maxleo21c(05.04.15) TempLabel->Visible = false; bShortcutForEnlarge = false; } switch(sbLock->Tag) { case 0: // °íÁ¤ NVector->bReflectionGuideLineLock = true; sbLock->Tag = 1; sbLock->Down = true; sbLock->Hint = IDS_RELEASEAXIS; break; case 1: // ÇØÁ¦ NVector->bReflectionGuideLineLock = false; sbLock->Tag = 0; sbLock->Down = false; sbLock->Hint = IDS_FIXAXIS; break; } } // --------------------------------------------------------------------------- // FullView¿¡¼­ Èæ¹éÀ¸·Î ³ª¿À´Â ¹®Á¦¶§¹®¿¡ ¾î¿¼ö ¾øÀÌ ¸¸µé¾ú´Ù. ¸í½ÄÀÌ¿¡°Ô ¹®ÀÇ ÇÊ¿ä // added by maxleo21c (05.07.29) void __fastcall TMainImageForm::FullViewUpdate() { iMainImage->Repaint(); // todo : ¡Ù¡Ù ¼Óµµ °³¼± - by monkman (2005.07.20) VecDraw->FullViewBitmapDraw(-1, -1, -1, -1); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::OnColorChange(int index) { RGBQUAD rgb[256]; Palette->ToRGBQUAD(rgb, 256); iMainImage->ColorChange(PaletteForm->DIB256Palette->ChoiceIndex, rgb); // by celberus iMainImage->isColorChanged = true; // by celberus VecDraw->ColorChange(PaletteForm->DIB256Palette->ChoiceIndex, rgb); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ApplyPalette() { RGBQUAD rgb[256]; Palette->ToRGBQUAD(rgb, 256); iMainImage->ChangeRGBColors(rgb); VecDraw->ChangeRGBColors(rgb); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::tmVectorMoveDrawTimer(TObject *Sender) { // ¸¶¿ì½º·Î ĵ¹ö½ºÀÇ À§Ä¡¸¦ º¯°æÇÏ´Ù 1ÃÊ µ¿¾È ¿òÁ÷ÀÓÀÌ ¾øÀ» °æ¿ì ´Ù½Ã ±×¸² - by monkman (2008.10.20) if (VecDraw->NVector && VecDraw->NVector->bVectorMove) { VecDraw->NVector->bVectorMove = false; if (MainForm->nVectorMode == 0/* && MainMenuForm->Item == T_VECTOR*/) { // Quality iMainImage->Repaint(); } } tmVectorMoveDraw->Enabled = false; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile(String dn, String fn, TGraphicFileFormat ExtIndex, WORD bpp, bool changeFileFormat) { BEGIN_LOG(""); int zi, zo; // speed-test RGBQUAD rgb[256]; TPCanvasInfor ci; TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; bool layer = false; HANDLE hFile = INVALID_HANDLE_VALUE; String ext = LowerCase(ExtractFileExt(fn)); TGraphicFileFormat RealIndex = FindExtension(ext); TCursor cur; float m; int A4Width = 0, A4Height = 0; // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ĵ¹ö½º¿¡ µ¶¸³ÀûÀ̾î¾ß ÇÏ´Â VecDraw, VectorForm º¯¼ö¸¦ MainImageFormÀ¸·Î À̵¿ - by monkman (2005.03.08) // º¯¼ö¸¦ VecDraw¿Í VectorFormÀÌ Æ÷ÀÎÅÍ º¯¼öµé°ú ¿¬°á ½Ã۰í ÃʱâÈ­ ½ÃÄÑÁØ´Ù VecDraw->MappingVariable(this->NVector); if (VectorForm) VectorForm->MappingVariable(this->NVector); VecDraw->InitVariable(this->NVector); if (VectorForm) VectorForm->InitVariable(this->NVector); // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- if (ExtIndex == gffALL) { ExtIndex = RealIndex; } #ifdef NOTN3D if (ExtIndex == gffT3D #ifdef TRIAL || ExtIndex == gffT3D_TRIAL #endif ) { if (MainForm->T3D_Item == false) { END_LOG; return false; } } #else if (ExtIndex == gffN3D || ExtIndex == gffT3D) { if (MainForm->T3D_Item == false) { END_LOG; return false; } } #endif if (Palette == NULL || WorkArea == NULL) { END_LOG; return false; } #if !defined(N_3D) if (ExtIndex == gffT3D #ifdef TRIAL || ExtIndex == gffT3D_TRIAL #endif ) { if ((ec = LoadFromT3D(dn, fn, ExtIndex)) != EC_NONE) goto fail; } else if (ExtIndex == gffDXF) { // DXF Æ÷¸Ë ·Îµå // DXF ·Îµù½Ã ÇØ»óµµ Á¶Àý if ((ec = LoadFromDXF(dn, fn)) != EC_NONE) goto fail; } else if (ExtIndex == gffVST #ifdef TRIAL || ExtIndex == gffVST_TRIAL #endif ) { if ((ec = LoadFromVST(dn, fn, ExtIndex)) != EC_NONE) goto fail; } else if (ExtIndex == gffSVG) { // for SVG format file if ((ec = LoadFromSVG(dn, fn)) != EC_NONE) goto fail; } else { if (ExtIndex == gffTEX || ExtIndex == gffTFC #ifdef TRIAL || ExtIndex == gffTEX_TRIAL || ExtIndex == gffTFC_TRIAL #endif ) { if ((ec = LoadFromTEXTFC(FullPathName(dn, fn), ExtIndex, ci, layer, bpp)) != EC_NONE) goto fail; } else if (ExtIndex == gffWEA || ExtIndex == gffWAV || ExtIndex == gffKNT //|| ExtIndex == gffPIL #ifdef TRIAL || ExtIndex == gffWEA_TRIAL || ExtIndex == gffKNT_TRIAL #endif ) { if ((ec = LoadFromWeaveKnitPile(FullPathName(dn, fn), ExtIndex, ci, layer, bpp)) != EC_NONE) goto fail; } #ifndef NOTN3D else if (ExtIndex == gffN3D) { if ((ec = LoadFromN3D(FullPathName(dn, fn), ci, layer, bpp)) != EC_NONE) goto fail; } #endif else { if ((ec = LoadFromAnotherFileFormat(FullPathName(dn, fn), ci, layer, bpp) ) != EC_NONE) goto fail; } if (bpp == 8) { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF (8), rgb); MaskPixel = 0x0F; } else { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF (24)); MaskPixel = 0x80; } resetClientSize(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); PaletteForm->DIB256Palette->ChoiceIndex = 2; } #else ////////////////////////////////////////////////////////////////////////////// if (ExtIndex == gffTEX || ExtIndex == gffTFC #ifdef TRIAL || ExtIndex == gffTEX_TRIAL || ExtIndex == gffTFC_TRIAL #endif ) { if ((ec = LoadFromTEXTFC(FullPathName(dn, fn), ExtIndex, ci, layer, bpp)) != EC_NONE) goto fail; } else if (ExtIndex == gffWEA || ExtIndex == gffWAV || ExtIndex == gffKNT || ExtIndex == gffPIL #ifdef TRIAL || ExtIndex == gffWEA_TRIAL || ExtIndex == gffKNT_TRIAL #endif ) { if ((ec = LoadFromWeaveKnitPile(FullPathName(dn, fn), ExtIndex, ci, layer, bpp)) != EC_NONE) goto fail; } else if (ExtIndex == gffN3D) { if ((ec = LoadFromN3D(FullPathName(dn, fn), ci, layer, bpp)) != EC_NONE) goto fail; } else { if ((ec = LoadFromAnotherFileFormat(FullPathName(dn, fn), ci, layer, bpp)) != EC_NONE) goto fail; } if (bpp == 8) { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8) , rgb); MaskPixel = 0x0F; } else { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24) ); MaskPixel = 0x80; } resetClientSize(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); PaletteForm->DIB256Palette->ChoiceIndex = 2; #endif ////////////////////////////////////////////////////////////////////////////// if (changeFileFormat) { if (bpp == 8 || bpp == 16) { fn.Delete(LastDelimiter(String("."), fn), fn.Length()); #ifdef TRIAL fn = fn + String(".ttex"); #else fn = fn + String(".tex"); #endif #ifndef NOTN3D } else if (ExtIndex == gffN3D) { // N3D_jeegeo fn.Delete(LastDelimiter(String("."), fn), fn.Length()); fn = fn + String(".n3d"); #endif } else { fn.Delete(LastDelimiter(String("."), fn), fn.Length()); #ifdef TRIAL fn = fn + String(".ttfc"); #else fn = fn + String(".tfc"); #endif } } DirName = dn; FileName = fn; SetCaption(); #ifndef NOTN3D if (MainForm->ReadN3D == true && RealIndex != gffN3D) { // *.tex //*.tfc µîÀ» n3d·Î ÀоîµéÀ̱â À§Çؼ­ //N3D_jeegeo ec = InitFormFile_ToN3D(fn, ci, bpp, layer); if (ec != EC_NONE) goto fail; gff = gffN3D; } else { if (false == changeFileFormat) { gff = ExtIndex; // by jeegeo } else { if (bpp == 8 || bpp == 16) { #ifdef TRIAL gff = gffTEX_TRIAL; #else gff = gffTEX; #endif } else { #ifdef TRIAL gff = gffTFC_TRIAL; #else gff = gffTFC; #endif } } } #else if (false == changeFileFormat) { gff = ExtIndex; // by jeegeo } else { if (bpp == 8 || bpp == 16) { #ifdef TRIAL gff = gffTEX_TRIAL; #else gff = gffTEX; #endif } else { #ifdef TRIAL gff = gffTFC_TRIAL; #else gff = gffTFC; #endif } } #endif #ifdef TRIAL cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((iMainImage->uBitmap->Width > 1760 || iMainImage->uBitmap->Height > 1760) || (iMainImage->uBitmap->Width > 1248 && iMainImage->uBitmap->Height > 1248) ) { if (iMainImage->uBitmap->Width > iMainImage->uBitmap->Height) { A4Width = 1760; A4Height = 1248; } else { A4Width = 1248; A4Height = 1760; } m = Math::Min(A4Width / (float)iMainImage->uBitmap->Width, A4Height / (float)iMainImage->uBitmap->Height); Current_DPI = 160; ResizeCanvas(160, iMainImage->uBitmap->Width * m, iMainImage->uBitmap->Height * m); if (ExtIndex == gffT3D || ExtIndex == gffT3D_TRIAL) { if (MainForm->T3D_Item) { if (MainImageForm->Data3D->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } Screen->Cursor = cur; } #endif END_LOG; return EC_NONE; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromT3D(String dn, String fn, TGraphicFileFormat ExtIndex) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; ec = InitFormFile_T3D(dn, fn, tpfh, ExtIndex); // refactoring by celberus if (ec != EC_NONE) goto fail; if (MainForm->T3D_Item) { resetClientSize(); } END_LOG; return ec; fail: END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromDXF(String dn, String fn) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; int zi, zo; if (!FileExists(FullPathName(dn, fn))) { ec = EC_FILE_NOT_EXIST; SAVE_EXCEPTION(ec); goto fail; } MainMenuForm->InitVectorForm(true); tpfh.Version = TexVersion('P', 'T', TextileFileVersion); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; tpfh.Compress = cmZLib; if ((ec = VecDraw->LoadExternalVector(FullPathName(dn, fn), Palette, tpfh, NULL)) != EC_NONE) goto fail; if (!ResizePattern(tpfh.CanvasInfor, tpfh.BitsPerPixel, false)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (tpfh.BitsPerPixel)); iMainImage->uBitmap->SetAllToModified(); resetClientSize(); END_LOG; return ec; fail: END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromVST(String dn, String fn, TGraphicFileFormat ExtIndex) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; int zi, zo; if (!FileExists(FullPathName(dn, fn))) { ec = EC_FILE_NOT_EXIST; SAVE_EXCEPTION(ec); goto fail; } if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainMenuForm->InitVectorForm(true); #ifdef TRIAL if (ExtIndex == gffVST_TRIAL) { if ((ec = VecDraw->LoadVector(hFile, Palette, tpfh, true)) != EC_NONE) goto fail; VecDraw->LoadVectorFromFile(hFile, true); } else { if ((ec = VecDraw->LoadVector(hFile, Palette, tpfh)) != EC_NONE) goto fail; VecDraw->LoadVectorFromFile(hFile); } #else if ((ec = VecDraw->LoadVector(hFile, Palette, tpfh)) != EC_NONE) goto fail; VecDraw->LoadVectorFromFile(hFile); #endif if (!ResizePattern(tpfh.CanvasInfor, tpfh.BitsPerPixel, false)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (tpfh.BitsPerPixel)); iMainImage->uBitmap->SetAllToModified(); resetClientSize(); CloseHandle(hFile); END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromSVG(String dn, String fn) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; PALETTEENTRY peEntry[256]; HANDLE hFile = INVALID_HANDLE_VALUE; int zi, zo; if (!FileExists(FullPathName(dn, fn))) { ec = EC_FILE_NOT_EXIST; SAVE_EXCEPTION(ec); goto fail; } MainMenuForm->InitVectorForm(true); tpfh.Version = TexVersion('P', 'T', 240); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; tpfh.Compress = cmZLib; if (!VecDraw->LoadFromSVGFile(dn, fn, tpfh, CurrentUnit, NULL)) { // added for SVG by maxleo21c(06.03.17) ec = EC_FILE_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } if (!Palette->LoadFromFile((DirectoryColor + "\\Textile.fcr").c_str())) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); for (int i = 3; i < 255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); Palette->SetNormal(255, 255, 255, 255); } if (!ResizePattern(tpfh.CanvasInfor, tpfh.BitsPerPixel, false)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF (tpfh.BitsPerPixel)); iMainImage->uBitmap->SetAllToModified(); resetClientSize(); CloseHandle(hFile); END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromTEXTFC (String FileName, TGraphicFileFormat ExtIndex, TPCanvasInfor &ci, bool &layer, WORD bpp) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; PALETTEENTRY peEntry[256]; DWORD dwRead; bool vector; int zi, zo; HANDLE hFile = INVALID_HANDLE_VALUE; TUnionBitmap *pBitmap = iMainImage->uBitmap; TGraphicFileFormat gff = ExtIndex; if (ExtIndex == gffTEX || ExtIndex == gffTFC #ifdef TRIAL || ExtIndex == gffTEX_TRIAL || ExtIndex == gffTFC_TRIAL #endif ) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TRIAL if (ExtIndex == gffTEX_TRIAL || ExtIndex == gffTFC_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, Palette, tpfh, pBitmap, gff, true, NULL, true)) != EC_NONE) goto fail; } else { if ((ec = LoadFromTexpiaFile(hFile, Palette, tpfh, pBitmap, gff)) != EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, Palette, tpfh, pBitmap, gff)) != EC_NONE) goto fail; #endif ci = tpfh.CanvasInfor; if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number >= 230) { if (!ReadFile(hFile, &layer, sizeof(bool), &dwRead, NULL)) goto fail; if (layer) { if (bpp == pBitmap->BitsPerPixel) { if (bpp == 8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->LoadFromLayerFile(hFile, tpfh.Version.Number, rgb); } else { iMainImage->LoadFromLayerFile(hFile, tpfh.Version.Number); } LayerCNT = iMainImage->Index + 1; } else { layer = false; } } if (tpfh.Version.Number >= 240) { if (!ReadFile(hFile, &vector, sizeof(bool), &dwRead, NULL)) goto fail; if (vector) VecDraw->LoadFromFile(hFile); // By GreenFish Vector File Load (8.1) } } CloseHandle(hFile); } #ifdef TRIAL ci.DotsPerInch = 160; #endif if (!ResizePattern(ci, bpp, true)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test if (layer == false) { if (bpp == 8) { if (iMainImage->uBitmap->BitsPerPixel == 8) { if (ExtIndex == gffTEX || ExtIndex == gffTFC || ExtIndex == gffWEA || ExtIndex == gffWAV || ExtIndex == gffKNT //|| ExtIndex == gffPIL #ifdef TRIAL || ExtIndex == gffTEX_TRIAL || ExtIndex == gffTFC_TRIAL || ExtIndex == gffWEA_TRIAL || ExtIndex == gffKNT_TRIAL #endif ) { } else { findUsedColor(true); // ¸ðµç pixel °ª¿¡ +2À» ÇØÁØ´Ù. } } else { iMainImage->uBitmap->ColorResolution (8, CRF_OPTIMIZEDPALETTE, NULL, 250); try { setPaletteData(rgb, true); } catch(TPException TPe) { ec = TPe; goto fail; } findUsedColor(true); } Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { // bpp == 24 if (iMainImage->uBitmap->BitsPerPixel != 24) { iMainImage->uBitmap->ColorResolution (24, CRF_OPTIMIZEDPALETTE, NULL, 256); } // 24bpp¿¡¼­ ÇØ´ç UnionBitmapÀÌ blankÀ̸鼭 ÆÈ·¹Æ®°¡ ¸Á°¡Á®¼­ ¹é±×¶ó¿îµå »öÀÌ °ËÀº»öÀÏ °æ¿ì - by monkman (2010.10.05) if (Palette->Color[BackgroundIndex] == 0x000000) { if (!Palette->LoadFromFile((DirectoryColor + "\\Textile.fcr").c_str())) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); for (int i = 3; i < 255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); Palette->SetNormal(255, 255, 255, 255); } // ±âº» ÆÈ·¹Æ®¸¦ °¡Á®¿Í¼­ ¹é±×¶ó¿îµå»öÀ» ¼³Á¤ÇÑ´Ù Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); } iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } } else { // layer == true if (bpp == 8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { // 24bpp¿¡¼­ ÇØ´ç UnionBitmapÀÌ blankÀ̸鼭 ÆÈ·¹Æ®°¡ ¸Á°¡Á®¼­ ¹é±×¶ó¿îµå »öÀÌ °ËÀº»öÀÏ °æ¿ì - by monkman (2010.10.05) if (Palette->Color[BackgroundIndex] == 0x000000) { if (!Palette->LoadFromFile((DirectoryColor + "\\Textile.fcr").c_str())) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); for (int i = 3; i < 255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); Palette->SetNormal(255, 255, 255, 255); } // ±âº» ÆÈ·¹Æ®¸¦ °¡Á®¿Í¼­ ¹é±×¶ó¿îµå»öÀ» ¼³Á¤ÇÑ´Ù Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); } iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } // LayerÀϰæ¿ì¿¡ iMainImage->LoadFromLayerFile¿¡¼­ ¸ðµç°Å ´ÙÇØ¿ä.... } END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromN3D (String FileName, TPCanvasInfor &ci, bool &layer, WORD bpp) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; bool vector; int zi, zo; if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!new3d) new3d = new TN3D(iMainImage); if ((ec = new3d->LoadFromFile(hFile, Palette, tpfh)) != EC_NONE) goto fail; N3DMappingForm->Visible = true; N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); LayerForm->Visible = false; if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && tpfh.Version.Number >= 230) { if (tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } // 090527 upper version ec = EC_NONE; } else { ec = EC_FILE_NOT_OPEN; SAVE_EXCEPTION(ec); goto fail; } ci = tpfh.CanvasInfor; UserColorLibForm->ThisFileHasUserColor(Palette); layer = true; if (tpfh.Version.Number >= 240) { // 240ÀÌ»óÀ϶§¸¸ vector if (!ReadFile(hFile, &vector, sizeof(bool), &dwRead, NULL)) goto fail; // if (vector) VecDraw->LoadFromFile(hFile);// By GreenFish Vector File Load if (vector) { VecDraw->LoadFromFile(hFile); // By GreenFish Vector File Load // if (!VecDraw->LoadFromFile(hFile)) {ec = EC_NO_MESSAGE; goto fail;} } } CloseHandle(hFile); #ifdef TRIAL ci.DotsPerInch = 160; #endif if (!ResizePattern(ci, bpp, true)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test if (layer == false) { if (bpp == 8) { if (iMainImage->uBitmap->BitsPerPixel == 8) { findUsedColor(true); // ¸ðµç pixel °ª¿¡ +2À» ÇØÁØ´Ù. } else { iMainImage->uBitmap->ColorResolution (8, CRF_OPTIMIZEDPALETTE, NULL, 250); try { setPaletteData(rgb, true); } catch(TPException TPe) { ec = TPe; goto fail; } findUsedColor(true); } Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { // bpp == 24 if (iMainImage->uBitmap->BitsPerPixel != 24) { iMainImage->uBitmap->ColorResolution (24, CRF_OPTIMIZEDPALETTE, NULL, 256); } iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } } else { // layer == true if (bpp == 8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } // LayerÀϰæ¿ì¿¡ iMainImage->LoadFromLayerFile¿¡¼­ ¸ðµç°Å ´ÙÇØ¿ä.... } END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromWeaveKnitPile (String FileName, TGraphicFileFormat ExtIndex, TPCanvasInfor &ci, bool &layer, WORD bpp) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; TUnionBitmap *pBitmap = iMainImage->uBitmap; DWORD dwRead; bool vector; int zi, zo; TGraphicFileFormat gff = ExtIndex; if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef TRIAL if (ExtIndex == gffWEA_TRIAL || ExtIndex == gffKNT_TRIAL) { if ((ec = LoadFromTexpiaFile(hFile, Palette, tpfh, pBitmap, gff, false, NULL, true)) != EC_NONE) goto fail; } else { if ((ec = LoadFromTexpiaFile(hFile, Palette, tpfh, pBitmap, gff, false) ) != EC_NONE) goto fail; } #else if ((ec = LoadFromTexpiaFile(hFile, Palette, tpfh, pBitmap, gff, false)) != EC_NONE) goto fail; #endif UserColorLibForm->ThisFileHasUserColor(Palette); ci = tpfh.CanvasInfor; CloseHandle(hFile); #ifdef TRIAL ci.DotsPerInch = 160; #endif if (!ResizePattern(ci, bpp, true)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test if (layer == false) { if (bpp == 8) { if (iMainImage->uBitmap->BitsPerPixel == 8) { findUsedColor(true); // ¸ðµç pixel °ª¿¡ +2À» ÇØÁØ´Ù. } else { iMainImage->uBitmap->ColorResolution (8, CRF_OPTIMIZEDPALETTE, NULL, 250); try { setPaletteData(rgb, true); } catch(TPException TPe) { ec = TPe; goto fail; } findUsedColor(true); } Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { // bpp == 24 if (iMainImage->uBitmap->BitsPerPixel != 24) { iMainImage->uBitmap->ColorResolution (24, CRF_OPTIMIZEDPALETTE, NULL, 256); } iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } } else { // layer == true if (bpp == 8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } // LayerÀϰæ¿ì¿¡ iMainImage->LoadFromLayerFile¿¡¼­ ¸ðµç°Å ´ÙÇØ¿ä.... } END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromAnotherFileFormat (String FileName, TPCanvasInfor &ci, bool &layer, WORD bpp) { BEGIN_LOG(""); TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; bool vector; int zi, zo; String Directorycolorpath = DirectoryColor+"\\textile.fcr"; TUnionBitmap *pBitmap = iMainImage->uBitmap; if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } ci.DotsPerInch = pBitmap->DotsPerInch; // By GreenFish ci.SetSize(cstFree, pBitmap->Width, pBitmap->Height); if (pBitmap->BitsPerPixel == 8) { pBitmap->GetColors(0, 256, rgb); Palette->SetNormal(0, 0, 0, 0); for (int x = 0; x < 250; x++) { Palette->SetNormal(x + 2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } Palette->SetNormal(255, 255, 255, 255); } #ifdef TRIAL ci.DotsPerInch = 160; #endif if (!ResizePattern(ci, bpp, true)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test if (layer == false) { if (bpp == 8) { if (iMainImage->uBitmap->BitsPerPixel == 8) { findUsedColor(true); // ¸ðµç pixel °ª¿¡ +2À» ÇØÁØ´Ù. } else { iMainImage->uBitmap->ColorResolution (8, CRF_OPTIMIZEDPALETTE, NULL, 250); try { setPaletteData(rgb, true); } catch(TPException TPe) { ec = TPe; goto fail; } findUsedColor(true); } Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { // bpp == 24 if (iMainImage->uBitmap->BitsPerPixel != 24) { iMainImage->uBitmap->ColorResolution (24, CRF_OPTIMIZEDPALETTE, NULL, 256); } PaletteForm->DIB256Palette->LoadFromFile(Directorycolorpath.c_str()); MainImageForm->iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } } else { // layer == true if (bpp == 8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->uBitmap->PutColors(0, 256, rgb); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } else { PaletteForm->DIB256Palette->LoadFromFile(Directorycolorpath.c_str()); MainImageForm->iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); iMainImage->InitbmFullView (zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); // speed-test iMainImage->uBitmap->SetAllToModified(); // convert by celberus fullview º¸¿©ÁÖ±â À§ÇØ } // LayerÀϰæ¿ì¿¡ iMainImage->LoadFromLayerFile¿¡¼­ ¸ðµç°Å ´ÙÇØ¿ä.... } END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToTEXTFC(String dn, String fn, TCompressMethod cm, Word version) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256], Btrgb[256]; TUnionBitmap *ub = NULL, *BtTemp = NULL; // ºñÆ®¸Ê Àӽà ÀúÀå By GreenFish // convert by celberus TPLayer *lay = NULL; bool layer; DWORD dwWrite; TTexpiaBitmap *tag = NULL; // 10.0 ÀÌÇÏ·Î ÀúÀåÇÒ ¶§ VectorÀÇ DataList¸¦ °Ë»çÇÏ¿© ¿ÀºêÁ§Æ®°¡ 1024°¡ ³Ñ´Â °æ¿ì ÀúÀåÇÏÁö ¾Ê´Â´Ù - by monkman (2011.04.29) if (version <= 300 && !MainForm->MoSave && !MainForm->WaSave) { if (0 < VecDraw->CheckObjectPoint1024(MainImageForm, 2, false)) { MessageDlg(IDS_MESSAGE_VECTOROBJECTPOINTS1024, mtError, TMsgDlgButtons() << mbOK, 0); return ec; } } if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } tpfh.Version = TexVersion('P', 'T', version); tpfh.CanvasInfor = CanvasInfor; tpfh.CanvasInfor.Width = iMainImage->uBitmap->Width; // abcdabcdabcd tpfh.CanvasInfor.Height = iMainImage->uBitmap->Height; // abcdabcdabcd tpfh.BitsPerPixel = iMainImage->uBitmap->BitsPerPixel; tpfh.Compress = cm; if (WorkArea->Mask) { src = WorkArea->Range; if ((BtTemp = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } iMainImage->uBitmap->GetColors(0, 256, Btrgb); if (!BtTemp->Create(src.right - src.left, src.bottom - src.top, iMainImage->uBitmap->BitsPerPixel, Btrgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } BtTemp->Copy(0, 0, src.right - src.left, src.bottom - src.top, iMainImage->uBitmap, src.left, src.top, SRCCOPY); // BtTemp ¿¡ ub¸¦ º¸°ü } if (iMainImage->LayerList->Count > 1) { // ·¹À̾î ÀÖÀ»¶§ if (MainForm->MoSave == true) { // Motive save½Ã¿¡´Â ÇÑÀåÀÇ Layer¸¸ if ((ub = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { iMainImage->uBitmap->GetColors(0, 256, rgb); if (!ub->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!ub->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } lay = (TPLayer*)iMainImage->LayerList->Items[iMainImage->Index]; ub->Copy(lay->LBitmap, SRCCOPY); } else { // ÀÏ¹Ý FileSave½Ã¿¡´Â Àü Layer¸¦ ÇÕÃļ­ ÀúÀå if ((ub = iMainImage->Composition()) == NULL) goto fail; } if (WorkArea->Mask) { tpfh.CanvasInfor.DotsPerInch = tpfh.CanvasInfor.DotsPerInch; tpfh.CanvasInfor.SetSize(cstFree, src.Right - src.Left, src.Bottom - src.Top); Byte *mp, *bp; // ºÎºÐ ÀúÀå½Ã ÀÛ¾÷±¸¿ª¸¸ ÀúÀåÇϵµ·Ï By GreenFish if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ub->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (ub->BitsPerPixel == 8) { for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = ub->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(z); bp += src.left; for (int x = 0; x < src.right - src.left; x++, mp++) { if (*mp) { if (MainForm->WaSave) { TColor TempC = clBlack; // Palette->ColorData[0]->Color; *(bp + x) = TempC; // 0x00; //2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... } } else { if (MainForm->WaSave) { TColor TempW = clWhite; // Palette->ColorData[0]->Color; *(bp + x) = TempW; // 0x00; } else *(bp + x) = 1; } } ub->PutScanLine(y); } WorkArea->Mask->StopScanLine(); ub->StopScanLine(); } else { // Full Color TColor TempC = Palette->ColorData[1]->Color; for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = ub->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(z); bp += src.left * 3; for (int x = 0; x < src.right - src.left; x++, bp += 3) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { if (MainForm->WaSave) { TColor TempW = clWhite; *bp = clWhite; *(bp + 1) = clWhite; *(bp + 2) = clWhite; } else { *(bp + 2) = TempC & 0xFF; *(bp + 1) = (TempC >> 8) & 0xFF; *bp = (TempC >> 16) & 0xFF; } } else if (MainForm->WaSave) { // 2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... *bp = 0x00; *(bp + 1) = 0x00; *(bp + 2) = 0x00; } } ub->PutScanLine(y); } WorkArea->Mask->StopScanLine(); ub->StopScanLine(); } } else { src.Left = 0; src.Top = 0; src.Right = ub->Width; src.Bottom = ub->Height; } // ============= if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MakeTexpiaTag(tag, ub, src, 0); ////////////// if (!MainForm->MoSave && !MainForm->WaSave) { // ¸ðƼºê save½Ã¿¡´Â º¤ÅÍ Ç¥Çö X work area save¿¡¼­µµ.. by celberus HDC dcTemp = NULL; if ((dcTemp = tag->CreateDC()) == NULL) goto fail; VecDraw->TagDraw(dcTemp, tag->Width, tag->Height, src, 2, NULL, tpfh.Version.Number); tag->DeleteDC(dcTemp); dcTemp = NULL; } //////// Vector Tag By GreenFIsh if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, ub, &WorkArea->Range)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, ub)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } if (MainForm->MoSave || MainForm->WaSave) { // layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; } else { layer = true; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; if (WorkArea && WorkArea->Mask) { if (!iMainImage->SaveToLayerFile(hFile, WorkArea->Range, version)) goto fail; } else { if (!iMainImage->SaveToLayerFile(hFile, version)) goto fail; } } if (ub) { delete ub; ub = NULL; } } else { // Layer ¾øÀ»¶§ if (WorkArea->Mask) { tpfh.CanvasInfor.DotsPerInch = tpfh.CanvasInfor.DotsPerInch; tpfh.CanvasInfor.SetSize(cstFree, src.Right - src.Left, src.Bottom - src.Top); Byte *mp = NULL, *bp = NULL; // ºÎºÐ ÀúÀå½Ã ÀÛ¾÷±¸¿ª ¾ÈÂʸ¸ ÀúÀåÇϵµ·Ï By GreenFish if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = iMainImage->uBitmap->GetScanLine(y); // mp = WorkArea->Mask->GetScanLine(z); bp += src.left; for (int x = 0; x < src.right - src.left; x++, mp++) { if (*mp) { if (MainForm->WaSave) { // TColor TempC = clBlack;//Palette->ColorData[0]->Color; *(bp + x) = clBlack; // TempC;//0x00; //2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... } } else { if (MainForm->WaSave) { // TColor TempW = clWhite;//Palette->ColorData[0]->Color; *(bp + x) = clWhite; // TempW;//0x00; } else *(bp + x) = 1; } } iMainImage->uBitmap->PutScanLine(y); } WorkArea->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } else { // Full Color TColor TempC = Palette->Color[1]; for (int y = src.top, z = 0; y < src.bottom; y++, z++) { bp = iMainImage->uBitmap->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(z); bp += src.left * 3; for (int x = 0; x < src.right - src.left; x++, bp += 3) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { if (MainForm->WaSave) { TColor TempW = clWhite; *bp = clWhite; *(bp + 1) = clWhite; *(bp + 2) = clWhite; } else { *(bp + 2) = TempC & 0xFF; *(bp + 1) = (TempC >> 8) & 0xFF; *bp = (TempC >> 16) & 0xFF; } } else if (MainForm->WaSave) { // 2001.8.23 by lhskys ÀÛ¾÷±¸¿ªsave º¸À̰Ô... *bp = 0x00; *(bp + 1) = 0x00; *(bp + 2) = 0x00; } } iMainImage->uBitmap->PutScanLine(y); } WorkArea->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } } else { src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; } if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MakeTexpiaTag(tag, iMainImage->uBitmap, src); if (!MainForm->MoSave && !MainForm->WaSave) { HDC dcTemp = NULL; if ((dcTemp = tag->CreateDC()) == NULL) goto fail; VecDraw->TagDraw(dcTemp, tag->Width, tag->Height, src, 2, NULL, tpfh.Version.Number); tag->DeleteDC(dcTemp); dcTemp = NULL; } //////// Vector Tag By GreenFish (MainImage¿¡ 4±ºµ¥°¡ ÀÖÀ½) if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->uBitmap, &WorkArea->Range)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->uBitmap)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; } if (!MainForm->MoSave && !MainForm->WaSave) { if (!VecDraw->SaveToFile(hFile, NVector->DataList, 2, tpfh.Version.Number, MainImageForm->Number)) { // Vector File Save~ ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; if (tag) { delete tag; tag = NULL; } // if (dn!=DirectoryItem){ DirName = dn; FileName = fn;} if (WorkArea->Mask) { iMainImage->uBitmap->Copy(src.left, src.top, src.right - src.left, src.bottom - src.top, BtTemp, 0, 0, SRCCOPY); // BtTemp ¿¡ ub¸¦ º¸°ü delete BtTemp; BtTemp = NULL; // º¸°üÇß´ø ºñÆ®¸ÊÀ» ´Ù½Ã tb·Î } END_LOG; return ec; fail: if (ub) delete ub; if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToVST(String dn, String fn, TCompressMethod cm, Word version) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; TEXPIAFILEHEADER tpfh; DWORD dwWrite; TRect src; int method = 1; if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } memset(&tpfh, 0, sizeof(tpfh)); tpfh.Version = TexVersion('P', 'T', version); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; tpfh.Compress = cm; // 090805 by maxleo21c // ÀÛ¾÷ ±¸¿ªÀÌ ÀÖÀ» °æ¿ì CanvasÀüü°¡ ¾Æ´Ñ ÀÛ¾÷±¸¿ª¿¡ ´ëÇÑ Á¤º¸¸¸ ÀúÀåÇØ¾ß Çϱ⠶§¹®¿¡ // ¾Æ·¡¿Í °°ÀÌ Ã³¸®ÇÏ¿´À½. // Style_F.cppÀÇ º¤ÅÍ ½ºÅ¸ÀÏ ÆÄÀÏÀ» FULLÀü¿ëÀ¸·Î VSTÆÄÀÏÀ» ÀÌ¿ëÇϱ⠶§¹®¿¡ VSTÆÄÀÏ ¹öÀüÀÌ // º¯°æµÉ °æ¿ì TStyleForm::LoadToMainImage()ÇÔ¼ö¸¦ È®ÀÎÇØ¼­ ¼öÁ¤ÇØ¾ß ÇÔ. if (WorkArea->Mask) { src = WorkArea->Range; tpfh.CanvasInfor.SetSize(cstFree, src.Right - src.Left, src.Bottom - src.Top); } // StyleÀÇ Full µµ½ÄÈ­´Â VST·Î ÀúÀåµÈ´Ù. // Styleµµ½ÄÈ­´Â ÀÛ¾÷±¸¿ªÀ» ¹þ¾î´Â º¤ÅÍ¿Í patternÀ» ÀúÀåÇÏÁö ¾Ê´Â´Ù. method = 1; if (StyleForm && StyleForm->Visible) method = 4 + 32; if ((ec = VecDraw->SaveVectorTag(hFile, Palette, tpfh, method)) != EC_NONE) goto fail; method = 2; if (StyleForm && StyleForm->Visible) method = 4 + 32; if (!VecDraw->SaveVectorToFile(hFile, method, version)) { // Vector File Save~ ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToT3D(String dn, String fn, TCompressMethod cm, Word version) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; TEXPIAFILEHEADER tpfh; DWORD dwWrite; TTexpiaBitmap *tag = NULL; TRect src; if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } tpfh.Version = TexVersion('P', 'T', version); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; tpfh.Compress = cm; src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = MainMenuForm->SaveTo3DFile(hFile, tpfh, tag, iMainImage->uBitmap)) != EC_NONE) goto fail; CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; if (tag) { delete tag; tag = NULL; } END_LOG; return ec; fail: if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToN3D(String dn, String fn, TCompressMethod cm) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; TEXPIAFILEHEADER tpfh; if (FileExists(FullPathName(dn, fn))) { if (FileExists(FullPathName(dn, fn) + String(".bak"))) { DeleteFile((FullPathName(dn, fn) + String(".bak")).c_str()); } RenameFile(FullPathName(dn, fn), FullPathName(dn, fn) + ".bak"); // ¹é¾÷ È­ÀÏ ¸¸µê } if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } tpfh.Version = TexVersion('P', 'T', TextileFileVersion); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; // iMainImage->uBitmap->BitsPerPixel; tpfh.Compress = cmZLib; // cm; // ¿ë·®ÀÌ Å©¹Ç·Î ±âº» ¾ÐÃàÇÔ if (N3DMappingForm == NULL || new3d == NULL) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } if ((ec = new3d->SaveToFile(hFile, Palette, tpfh)) != EC_NONE) goto fail; if (!VecDraw->SaveToFile(hFile, NVector->DataList, 2, tpfh.Version.Number, MainImageForm->Number)) { // Vector File Save~ ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToSVG(String dn, String fn, TGraphicFileFormat Index) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; #ifdef SK_SMART String fileExtension, tempDirectory, fullLocalPath; DWORD hgetfile; #endif if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; SAVE_EXCEPTION(ec); goto fail; } if (!VecDraw->SaveVectorToSVGFile(hFile, Index, 2, dn, fn)) { // Vector File Save~ ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); goto fail; } CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; #ifdef SK_SMART // (07.01.18) SK¿ëÀ¸·Î SVGÀúÀåÇÑÈÄ ÀÚµ¿À¸·ÎJPEGÀúÀåµÇµµ·Ï ¸¸µê // PostMessage(this->Handle, TPM_AUTOSAVEJPEG, 0, 0); // message·Î ¸ðµÎ ó¸®ÇÏ·Á°í ÇßÁö¸¸ File ¿­¸° ÆÄÀÏÀ̸§À» À¯ÁöÇϰí ÀúÀåÇÏ´Â ÆÄÀÏÀ̸§¸¸ // ÀúÀåÇÒ ´ç½Ã¿¡¸¸ °¡Áö°í Àֱ⠶§¹®¿¡ message·Î ó¸®ÇÏ¸é ÆÄÀÏ À̸§ÀÌ ÀúÀåÇÒ ¶§ ÁöÁ¤ÇÑ //À̸§À» °¡ÁöÁö ¸øÇÏ´Â ¹®Á¦°¡ À־ Á÷Á¢ Ãß°¡Çß´Ù. 070706 fileExtension = ExtractFileExt(fn); fn = fn.Delete(fn.Pos(fileExtension), fn.Length()); fn = MainForm->FMOnFileName(fn, gffJPG); if (dn.SubString(dn.Length(), 1)=="\\") tempDirectory = dn + "JPEG\\"; else tempDirectory = dn + "\\JPEG\\"; hgetfile = GetFileAttributes(tempDirectory.c_str() ); if (hgetfile==0xFFFFFFFF) {//µð·ºÅ丮°¡ Á¸ÀçÇÏÁö ¾Ê´Ù¸é~ CreateDirectory(tempDirectory.c_str(), NULL); SetFileAttributes(tempDirectory.c_str(),FILE_ATTRIBUTE_HIDDEN); } if (fn.c_str()[0] == '_') { fn = fn.SubString(2, fn.Length()-1); } fullLocalPath = tempDirectory + fn; SaveToFile(fullLocalPath); #endif END_LOG; return ec; fail: if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; } // --------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToAnotherFileFormat (String dn, String fn, TGraphicFileFormat Index) { BEGIN_LOG(""); HANDLE hFile = INVALID_HANDLE_VALUE; TPException ec = EC_NONE; TUnionBitmap *ubSaveBitmap = NULL; TRect src; bool bAntialiasing = true; int Value = 0; bool SaveVectorToBitmap = false; TUnionBitmap *ub = NULL; // ºñÆ®¸Ê Àӽà ÀúÀå By GreenFish // convert by celberus TTexpiaBitmap *tb = NULL; HDC dcTmp = NULL; BYTE *pSrc = NULL, *pDst = NULL; unsigned short Resolution = CanvasInfor.DotsPerInch; if (WorkArea->Mask) { src = WorkArea->Range; } else { src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; } if (V_DATA->Count > 0) { // Vector´Â ÀúÀåÀÌ µÇÁö ¾Ê´Â´Ù´Â ¸Þ¼¼Áö ¹Ú½º by maxleo21c bAntialiasing = VecDraw->IsAntialiasing(); if (bAntialiasing) { Value = RasterizeDialogFunc(true, true); if (Value == 1) { NVector->bCancelAntialiasing = true; SaveVectorToBitmap = true; } else if (Value == 2) { NVector->bCancelAntialiasing = false; SaveVectorToBitmap = true; } else { // ¿¡·¯ ¸Þ½ÃÁö ³ªÁö ¾Êµµ·Ï Çϱâ À§Çؼ­ fail¿¡ ÀÖ´Â ¼Ò½º¸¦ ¿Å±è.. - by monkman (2005.05.07) if (ub) { delete ub; ub = NULL; } if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; END_LOG; return EC_NONE; } } } else { Value = RasterizeDialogFunc(false, true); if (Value == 1) { NVector->bCancelAntialiasing = true; SaveVectorToBitmap = true; } else { // ¿¡·¯ ¸Þ½ÃÁö ³ªÁö ¾Êµµ·Ï Çϱâ À§Çؼ­ fail¿¡ ÀÖ´Â ¼Ò½º¸¦ ¿Å±è.. - by monkman (2005.05.07) if (ub) { delete ub; ub = NULL; } if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; END_LOG; return EC_NONE; } } } } // Å« »çÀÌÁî ºñÆ®¸ÊÀÇ °æ¿ì DC°¡ ¸¸µé¾îÁöÁö ¾Ê´Â´Ù. ºñÆ®µ¥ÀÌÅ͸¸ º¹»çÇϵµ·Ï ÇÑ´Ù. // ºñÆ®¿¬»êÀ̹ǷΠ256ÀÌ´ø FullColor´ø »ó°üÀÌ ¾ø´Ù. - by monkman (2006.06.02) // if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } int nBitmapByte = iMainImage->uBitmap->BitsPerPixel / 8; if ((ubSaveBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (iMainImage->uBitmap->BitsPerPixel == 8) { iMainImage->uBitmap->GetColors(0, 256, rgb); if (!ubSaveBitmap->Create(src.Right - src.Left, src.Bottom - src.Top, iMainImage->uBitmap->BitsPerPixel, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!ubSaveBitmap->Create(src.Right - src.Left, src.Bottom - src.Top, iMainImage->uBitmap->BitsPerPixel)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (iMainImage->LayerList->Count > 1) { if ((ub = iMainImage->Composition()) == NULL) goto fail; // Å« »çÀÌÁî ºñÆ®¸ÊÀÇ °æ¿ì DC°¡ ¸¸µé¾îÁöÁö ¾Ê´Â´Ù. ºñÆ®µ¥ÀÌÅ͸¸ º¹»çÇϵµ·Ï ÇÑ´Ù. // ºñÆ®¿¬»êÀ̹ǷΠ256ÀÌ´ø FullColor´ø »ó°üÀÌ ¾ø´Ù. - by monkman (2006.06.02) // ub->UnionBitBlt(dcDst, 0, 0, tb->Width, tb->Height, src.Left, src.Top, SRCCOPY, false); if (!ub->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ubSaveBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (int nSrcY = src.top, nDstY = 0; nSrcY < src.bottom && nDstY < ubSaveBitmap->Height; nSrcY++, nDstY++) { pSrc = ub->GetScanLine(nSrcY); pSrc += (src.left * nBitmapByte); pDst = ubSaveBitmap->GetScanLine(nDstY); memcpy(pDst, pSrc, (src.right - src.left) * nBitmapByte); ubSaveBitmap->PutScanLine(nDstY); } ubSaveBitmap->StopScanLine(); ub->StopScanLine(); delete ub; ub = NULL; } else { // Å« »çÀÌÁî ºñÆ®¸ÊÀÇ °æ¿ì DC°¡ ¸¸µé¾îÁöÁö ¾Ê´Â´Ù. ºñÆ®µ¥ÀÌÅ͸¸ º¹»çÇϵµ·Ï ÇÑ´Ù. // ºñÆ®¿¬»êÀ̹ǷΠ256ÀÌ´ø FullColor´ø »ó°üÀÌ ¾ø´Ù. - by monkman (2006.06.02) // iMainImage->uBitmap->UnionBitBlt(dcDst, 0, 0, tb->Width, tb->Height, src.Left, src.Top, SRCCOPY, false); if (!ubSaveBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (int nSrcY = src.top, nDstY = 0; nSrcY < src.bottom && nDstY < ubSaveBitmap->Height; nSrcY++, nDstY++) { pSrc = iMainImage->uBitmap->GetScanLine(nSrcY); pSrc += (src.left * nBitmapByte); pDst = ubSaveBitmap->GetScanLine(nDstY); memcpy(pDst, pSrc, (src.right - src.left) * nBitmapByte); ubSaveBitmap->PutScanLine(nDstY); } iMainImage->uBitmap->StopScanLine(); ubSaveBitmap->StopScanLine(); } if (SaveVectorToBitmap) { // Vector´Â ÀúÀåÀÌ µÇÁö ¾Ê´Â´Ù´Â ¸Þ¼¼Áö ¹Ú½º by maxleo21c // Å« »çÀÌÁî ºñÆ®¸ÊÀÇ °æ¿ì DC°¡ ¸¸µé¾îÁöÁö ¾Ê´Â´Ù. ºñÆ®µ¥ÀÌÅ͸¸ º¹»çÇϵµ·Ï ÇÑ´Ù. // ºñÆ®¿¬»êÀ̹ǷΠ256ÀÌ´ø FullColor´ø »ó°üÀÌ ¾ø´Ù. - by monkman (2006.06.02) // VecDraw->ConvertToBitmap(this, dcDst, src.left, src.top, false, false); // ÀúÀåµÉ ÆÄÀÏÀ» ºñÆ®¸ÊÀ¸·Î ÀúÀå HDC dcDst = NULL; int countX = ubSaveBitmap->CountX; int countY = ubSaveBitmap->CountY; for (int n = 0; n < countX * countY; n++) { dcDst = ubSaveBitmap->CreateDC(n); // VecDraw->ConvertRectToBitmap (dcDst, src.left + ubSaveBitmap->uRect[0][n].left, src.top + ubSaveBitmap->uRect[0][n].top, src.left + ubSaveBitmap->uRect [0][n].right, src.top + ubSaveBitmap->uRect[0][n].bottom); // ubSaveBitmap->Table[0][n].blank = false; // º¤ÅͰ¡ ±×·ÁÁöÁö ¾Ê¾Ò´ø ºÎºÐÀ» ÇöÀç·Î¼­´Â ¾Ë ¼ö ¾ø¾î ÀüºÎ ºñÆ®¸ÊÈ­ µÈ°É·Î.. ubSaveBitmap->DeleteDC(dcDst, n); // convert by celberus dcDst = NULL; } } switch(Index) { case gffBMP: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_BMP)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_BMP, Resolution)) goto fail; break; case gffTIF: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_TIF)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_TIF, Resolution)) goto fail; break; case gffJPG: if ((ec = SaveToJPEG(ubSaveBitmap, FullPathName(dn, fn))) != EC_NONE) goto fail; break; case gffPCT: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PCT)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PCT, Resolution)) goto fail; break; case gffPCX: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PCX)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PCX, Resolution)) goto fail; break; case gffPNG: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PNG)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PNG, Resolution)) goto fail; break; case gffPSD: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PSD)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_PSD, Resolution)) goto fail; break; case gffRAS: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_RAS)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_RAS, Resolution)) goto fail; break; case gffTGA: // if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_TGA)) goto fail; if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_TGA, Resolution)) goto fail; break; case gffEPS: if (iMainImage->uBitmap->BitsPerPixel == 24) ShowMessage(IDS_MESSAGE_NOTEPSATFULLCOROL); // else if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_EPS)) goto fail; else if (!ubSaveBitmap->SaveToFile(FullPathName(dn, fn), FILE_EPS, Resolution)) goto fail; break; default: goto fail; } if (ubSaveBitmap) { delete ubSaveBitmap; ubSaveBitmap = NULL; } END_LOG; return ec; fail: if (ub) delete ub; if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; } if (ubSaveBitmap) delete ubSaveBitmap; if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); DeleteFile(FullPathName(dn, fn).c_str()); // shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); } END_LOG; return ec; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintCrossLineKey (TObject *Sender, HDC formDC, POINT cp) // Key Down½Ã ±×¸®µå µÇ°Ô Çϱâ À§ÇØ Àӽà by tmddn85 { HPEN hOldPen = NULL; HBRUSH hOldBrush = NULL; int nDrawMode; // POINT cp=iMainImage->GetCrossPos(); RGBQUAD rgb; hOldBrush = (HBRUSH)SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = (HPEN)SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); MoveToEx(formDC, cp.x, 0, NULL); LineTo(formDC, cp.x, iMainImage->Height); MoveToEx(formDC, 0, cp.y, NULL); LineTo(formDC, iMainImage->Width, cp.y); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::SetModify(bool value) { if (FModify != value) { FModify = value; MainForm->UpdateCanvasTab(dynamic_cast(this), FileName, Modify); } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::FullFittingImage() { // Number of ratio cases int NumberOfRatio = 17; // Results from dividing ZoomIn by ZoomOut // ( 116 , 112, 108, 106, 104, 103, 102, 203, 101, 302, 201, 301, 401, 601, 801, 1201, 1601 } float Ratio[17] = { 0.06, 0.08, 0.125, 0.16, 0.25, 0.33, 0.5, 0.66, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 12.0, 16.0 }; // First, find ratio of MainImageForm and Bitmap float ImageRatio_Width = (float) this->iMainImage->Width / this->iMainImage->uBitmap->Width; float ImageRatio_Height = (float) this->iMainImage->Height / this->iMainImage->uBitmap->Height; // Select bigger one because we should multiply inverse of it float ImageRatio = (ImageRatio_Width >= ImageRatio_Height) ? ImageRatio_Width : ImageRatio_Height; // Member variable of determining which one is close to ratio cases float diff = 1000; // Find adequate index of ratio cases int Zoom_Index = -1; // Final ratio index int FullFit_Ratio = 0; for (int i = 0; i < NumberOfRatio; i++) { if (diff >= sqrt((ImageRatio - Ratio[i]) * (ImageRatio - Ratio[i]))) { diff = sqrt((ImageRatio - Ratio[i]) * (ImageRatio - Ratio[i])); // find the nearest one Zoom_Index = i; } } // if the nearest one is smaller than selected raio, we should decrease index one if (ImageRatio < Ratio[Zoom_Index] && Zoom_Index > 0) { Zoom_Index--; } if (Zoom_Index >= 0) { // link index to real Zoom Value switch(Zoom_Index) { case 0: FullFit_Ratio = 116; break; case 1: FullFit_Ratio = 112; break; case 2: FullFit_Ratio = 108; break; case 3: FullFit_Ratio = 106; break; case 4: FullFit_Ratio = 104; break; case 5: FullFit_Ratio = 103; break; case 6: FullFit_Ratio = 102; break; case 7: FullFit_Ratio = 203; break; case 8: FullFit_Ratio = 101; break; case 9: FullFit_Ratio = 302; break; case 10: FullFit_Ratio = 201; break; case 11: FullFit_Ratio = 301; break; case 12: FullFit_Ratio = 401; break; case 13: FullFit_Ratio = 601; break; case 14: FullFit_Ratio = 801; break; case 15: FullFit_Ratio = 1201; break; case 16: FullFit_Ratio = 1601; break; default: break; } } // call ratio zoom function RatioZoom(FullFit_Ratio); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::CreateReflection (RECT range, TypeDirection direction, bool getHalf, TLRB getImageDirection, TLRB useDirection) { CreateReflectionObject(range, direction, getHalf, getImageDirection, useDirection); TWorkAreaMenu::WindowOff(); if (reflection) { ReflectionBackupRect = range; iMainImage->ReflectionRange = reflection->BitmapRange; iMainImage->ReflectionMode = direction; iMainImage->OnReflectionPaint = ReflectionPaint; iMainImage->OnReflectionRectPaint = ReflectionRectPaint; iMainImage->OnReflectionGridPaint = ReflectionGridPaint; iMainImage->Reflection = true; iMainImage->ReflectionGridVisible = true; // MainForm->miWaterPen->Enabled = false; // MainForm->miAirBrushPen2->Enabled = false; if (LayerForm) LayerForm->Enabled = false; //MainMenuForm->ReflectionMenuEnabled(false); MainMenuForm->UpdateItem(); UpdateImage(); } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::DeleteReflection() { iMainImage->ReflectionGridVisible = false; iMainImage->Reflection = false; iMainImage->OnReflectionPaint = NULL; iMainImage->OnReflectionRectPaint = NULL; iMainImage->OnReflectionGridPaint = NULL; DeleteReflectionObject(); if (LayerForm && LayerForm->Enabled == false) LayerForm->Enabled = true; MainMenuForm->ReflectionMenuEnabled(true); // MainMenuForm->UpdateItem(); UpdateImage(); iMainImage->isRepaintAll = true; iMainImage->Repaint(); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::CancelReflection() { if (reflection) { iMainImage->uBitmap->CopyToRect(ReflectionBackupRect.left, ReflectionBackupRect.top, reflection->BackupBitmap, SRCCOPY); if (iMainImage->LayerMask) { iMainImage->LayerMask->CopyToRect(ReflectionBackupRect.left, ReflectionBackupRect.top, reflection->BackupMask, SRCCOPY); } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::CreateReflectionObject (RECT range, TypeDirection direction, bool getHalf, TLRB getImageDirection, TLRB useDirection) { DeleteReflectionObject(); reflection = new TReflection(); reflection->SetReflection(iMainImage->uBitmap, iMainImage->LayerMask, range, direction, getHalf, getImageDirection, useDirection); reflection->backupPositionX = iMainImage->PositionX; reflection->backupPositionY = iMainImage->PositionY; reflection->BackupUndoCount = Undo->GetListCount()+1; } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::DeleteReflectionObject() { if (reflection) { delete reflection; reflection = NULL; } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ApplyReflection() { bool applyMerge = true; if (reflection->DstRange.left >= 0 && reflection->DstRange.top >= 0 && reflection->DstRange.right <= iMainImage->uBitmap->Width && reflection->DstRange.bottom <= iMainImage->uBitmap->Height) { applyMerge = false; } if (!applyMerge) { UndoSave(UK_ALL, reflection->DstRange); reflection->Apply(iMainImage->uBitmap, iMainImage->LayerMask); } else { if (ReflectionForm) { ReflectionForm->Merge = true; iMainImage->SubEnabled = true; reflection->ApplyMerge(iMainImage->SubBitmap, iMainImage->SubMask); iMainImage->SubVisible = true; Center.x = iMainImage->SubBitmap->Width / 2; Center.y = iMainImage->SubBitmap->Height / 2; MainImageForm->iMainImage->InitBackGround(0x01); } } } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ReflectionPaint (RECT Range, TTexpiaBitmap *ScreenBitmap, int PositionX, int PositionY, double dZoom) { reflection->HScroll = PositionX; reflection->VScroll = PositionY; reflection->Zoom = dZoom; reflection->PaintScreen(ScreenBitmap); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ReflectionRectPaint (RECT rtARRange, HDC dcViewRect, int nViewWidth, int nViewHeight, int nViewBitsPerPixel, double dZoom, RECT rtRealRect, bool bShowOnly) { reflection->RectPaintScreen(rtARRange, dcViewRect, nViewWidth, nViewHeight, nViewBitsPerPixel, dZoom, rtRealRect, bShowOnly); } // --------------------------------------------------------------------------- void __fastcall TMainImageForm::ReflectionGridPaint (HDC dcMemV, RECT Range, int PositionX, int PositionY, double dZoom) { reflection->ReflectionGridPaint(dcMemV, Range, PositionX, PositionY, dZoom); } // --------------------------------------------------------------------------- // TFC formatÀÇ °æ¿ì EnvironmentÀÇ AutoSaveJpg°¡ CheckµÇ¾î ÀÖÀ» ¶§ ÀÚµ¿À¸·Î jpg Ãß°¡ ÀúÀå. TPException __fastcall TMainImageForm::AdditionalSaveJpg(String path) { HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; TTexpiaBitmap *tb = NULL, *tt = NULL; HDC dcDst = NULL, dcTmp = NULL; TPException ec = EC_NONE; DWORD dwWrite; if (WorkArea->Mask) { src = WorkArea->Range; } else { src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; } if (V_DATA->Count > 0) { // Environment¿¡¼­ ¼³Á¤ÇÑ Anti-Alias ¼³Á¤À» »ç¿ë NVector->bCancelAntialiasing = !MainForm->bVectorAntiAlias; } if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!tb->Create(src.Right-src.Left, src.Bottom-src.Top, iMainImage->uBitmap->BitsPerPixel)) { ec = EC_MEMORY_LACK; goto fail; } if ((tt = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!tt->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, iMainImage->uBitmap->BitsPerPixel)) { ec = EC_MEMORY_LACK; goto fail; } // if (!tt->Copy(iMainImage->uBitmap, SRCCOPY)) { if (!iMainImage->uBitmap->CopyToTexpia(tt, 0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 0, 0, SRCCOPY)){ ec = EC_MEMORY_LACK; goto fail; } dcDst = tb->CreateDC(); dcTmp = tt->CreateDC(); VecDraw->ConvertToBitmap(this, dcTmp, false); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0, 0, src.right-src.left , src.bottom-src.top, dcTmp, src.left, src.top, src.right-src.left, src.bottom-src.top, SRCCOPY); //jpg ÀúÀåÇÏ´Â ºÎºÐÀ¸·Î ¿É¼ÇÀº ¹«¼Õ½ÇÀÌ´Ù. //nFormat = FILE_JFIF; QFactor = 2; if(!tb->SaveToFile(path, FILE_JFIF, 2, CanvasInfor.DotsPerInch)) ec = EC_FILE_NOT_WRITE;; if (tb) { if (dcDst) tb->DeleteDC(dcDst); delete tb; } if (tt) { if (dcTmp) tt->DeleteDC(dcTmp); delete tt; } return EC_NONE; fail: if (tb) { if (dcDst) tb->DeleteDC(dcDst); delete tb; } if (tt) { if (dcTmp) tt->DeleteDC(dcTmp); delete tt; } if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; return ec; } //--------------------------------------------------------------------------- /* SK SMART E - FOCUS SYSTEM */ /* SK Web service¿Í ¿¬µ¿Çϱâ À§ÇØ ÇÊ¿äÇÑ ºÎºÐ */ //--------------------------------------------------------------------------- #ifdef SK_SMART //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile(String dn, String fn, TGraphicFileFormat ExtIndex, WORD bpp, ParsedURL myURL, ParsedURL targetURL) { sourceInternetURL = myURL; targetInternetURL = targetURL; return InitFormFile(dn, fn, ExtIndex, bpp); } //--------------------------------------------------------------------------- // (07.01.18) SK¿ëÀ¸·Î SVGÀúÀåÇÑÈÄ ÀÚµ¿À¸·ÎJPEGÀúÀåµÇµµ·Ï ¸¸µê void TMainImageForm::TPMAutoSaveJpeg(TMessage &msg) { String tDirName, tFileName, fullLocalPath; tDirName = DirName; tFileName = FileName; String fileExtension = ExtractFileExt(FileName); FileName = FileName.Delete(FileName.Pos(fileExtension), FileName.Length()); FileName = MainForm->FMOnFileName(MainImageForm->FileName, gffJPG); String tempDirectory; if (DirName.SubString(DirName.Length(), 1)=="\\") tempDirectory = DirName + "JPEG\\"; else tempDirectory = DirName + "\\JPEG\\"; DWORD hgetfile = GetFileAttributes(tempDirectory.c_str() ); if (hgetfile==0xFFFFFFFF) {//µð·ºÅ丮°¡ Á¸ÀçÇÏÁö ¾Ê´Ù¸é~ CreateDirectory(tempDirectory.c_str(), NULL); SetFileAttributes(tempDirectory.c_str(),FILE_ATTRIBUTE_HIDDEN); } fullLocalPath = tempDirectory + FileName; SaveToFile(fullLocalPath); DirName = tDirName; FileName = tFileName; } //--------------------------------------------------------------------------- // SKÀü¿ëÀ¸·Î JPG¸¦ ¹«¼Õ½Ç·Î ¹«Á¶°Ç ÀúÀåÇÏ´Â ºÎºÐ - by maxleo21c (06.11.29) TPException __fastcall TMainImageForm::SaveToFile(String fullLocalPath) { HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; TTexpiaBitmap *tb = NULL, *tt = NULL; HDC dcDst = NULL, dcTmp = NULL; TPException ec = EC_NONE; DWORD dwWrite; bool SaveVectorToBitmap = false; if (WorkArea->Mask) { src = WorkArea->Range; } else { src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; } if (V_DATA->Count > 0) { // Vector´Â ÀúÀåÀÌ µÇÁö ¾Ê´Â´Ù´Â ¸Þ¼¼Áö ¹Ú½º by maxleo21c //bCancelAntialiasing = false; SaveVectorToBitmap=true; } if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!tb->Create(src.Right-src.Left, src.Bottom-src.Top, iMainImage->uBitmap->BitsPerPixel)) { ec = EC_MEMORY_LACK; goto fail; } if ((tt = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!tt->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, iMainImage->uBitmap->BitsPerPixel)) { ec = EC_MEMORY_LACK; goto fail; } if (tb->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); tb->PutColors(0, 256, rgb); tt->PutColors(0, 256, rgb); } if (!iMainImage->uBitmap->CopyToTexpia(tt, 0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 0, 0, SRCCOPY)) { ec = EC_MEMORY_LACK; goto fail; } dcDst = tb->CreateDC(); dcTmp = tt->CreateDC(); VecDraw->ConvertToBitmap(this, dcTmp, false); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0, 0, src.right-src.left , src.bottom-src.top, dcTmp, src.left, src.top, src.right-src.left, src.bottom-src.top, SRCCOPY); //jpg ÀúÀåÇÏ´Â ºÎºÐÀ¸·Î ¿É¼ÇÀº ¹«¼Õ½ÇÀÌ´Ù. //nFormat = FILE_JFIF; QFactor = 2; if(!tb->SaveToFile(fullLocalPath, FILE_JFIF, 2, CanvasInfor.DotsPerInch)) ec = EC_FILE_NOT_WRITE;; if (tb) { if (dcDst) tb->DeleteDC(dcDst); delete tb; } if (tt) { if (dcTmp) tt->DeleteDC(dcTmp); delete tt; } return EC_NONE; fail: if (tb) { if (dcDst) tb->DeleteDC(dcDst); delete tb; } if (tt) { if (dcTmp) tt->DeleteDC(dcTmp); delete tt; } if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; return ec; } #endif //--------------------------------------------------------------------------- void __fastcall TMainImageForm::TimerForSKTimer(TObject *Sender) { #ifdef SK_SMART if (targetInternetURL.myString.Length() > 0 && bWebConnected) { HANDLE hPipe = NULL; hPipe=CreateFile(L"\\\\.\\pipe\\YoungWoo_TexSeries", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (hPipe==INVALID_HANDLE_VALUE) { bWebConnected = false; targetInternetURL.myString=""; Application->MessageBox(IDS_MI_SK_MSG2_1.c_str(), L"Network Message", MB_OK); } if (hPipe) CloseHandle(hPipe); hPipe = NULL; } #endif } //---------------------------------------------------------------------------