//--------------------------------------------------------------------------- #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" #ifndef ACADEMY #include "UserColor_F.h" #endif #include "Autosave.h" #include "Repeat_F.h" #include "Window.h" #include "Windowlib_F.h" #include "VecDraw.h" // By GreenFish ÀÛ¾÷Áß #include "Vector_F.h" #include "N3DMapping.h" #include "N3DPattern.h" //--------------------------------------------------------------------------- #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] //--------------------------------------------------------------------------- TMainImageForm *MainImageForm; int MainImageCount = 0; //--------------------------------------------------------------------------- __fastcall TMainImageForm::TMainImageForm(TComponent* Owner) : TForm(Owner) { Number = MainImageCount; MainImageCount++; memsize = 0; hMemLine = NULL; msx = NULL; BtnClick = false; DownState = false; bProtect = false; bMaskArea = false; bDrawPen = true; ALLClose = false; // MainMenu ´ÝÇôµµ Filemanager´Â »ç¿ë °¡´ÉÇÏ°Ô WATEMP = false; iMainImage->OnPaintDirectly=PaintDirectly; iMainImage->OnPaintVector = PaintVector; iMainImage->OnPaintCursor=NULL; iMainImage->OnPaintCrossLine=NULL; iMainImage->OnPaintZoom=NULL; iMainImage->OnPaintLocate=NULL; isPaintDirectlyClean=false; isFirst=true; LineList = new TList; DrawORStitch=false; bOnImage = false; MouseState = 0; gff = gffNON; new3d = NULL; //================================ //2001.4.11. by lhskys congi¿¡¼­ unit ³Ö±â // CurrentUnit = uCm; TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); int UNITS, unit; if (TUnits == "uCm")UNITS = 0; else if (TUnits == "uInch")UNITS = 1; else UNITS = 2; IniFile->WriteInteger("MainImage", "Unit", UNITS); //================================= //======================================== 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; // TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { unit = IniFile->ReadInteger("MainImage", "Unit", 0); if (unit == 0) { sbUnit->Caption = AnsiString(IDS_UNIT) + " : Cm"; UnitChange(uCm); } else if (unit == 1) { sbUnit->Caption = AnsiString(IDS_UNIT) + " : Inch"; UnitChange(uInch); } else { sbUnit->Caption = AnsiString(IDS_UNIT) + " : Dot"; UnitChange(uDot); } delete IniFile; } //======================================== 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; #ifndef ACADEMY #ifndef N_3D Data3D = NULL; #endif #endif } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormActivate(TObject *Sender) { if (MainImageForm!=this) { if (MainImageForm) { MainImageForm->iMainImage->Deactivate(); if(MainImageForm->new3d){ for(int i=0;inew3d->ListOf3CP->Count;i++){ T3CP *t3cp = (T3CP *)MainImageForm->new3d->ListOf3CP->Items[i]; t3cp->Deactivate(); } } } iMainImage->Activate(); if (MainImageForm) { #ifndef ACADEMY if (MainImageForm->AutoRepeat && (LayerCNT == ARLayerCnt)) { if (AutoRepViewForm) { MainImageForm->sbAutoRepView->Down = false; ARViewExitForm(); } } #endif } MainMenuForm->ExitForm(1); MainImageForm = this; PenManagerForm->InitPenForm(); } Undo->Set(iMainImage, Palette, WorkArea); //by linuxjun for Undo_Method FullViewForm->InitForm(iMainImage); PaletteForm->InitForm(Palette); //ÆÈ·¹Æ® ÁÖ¼Ò ¾÷µ¥ÀÌÆ® PaletteForm->UpdateForm(iMainImage->uBitmap->BitsPerPixel); #ifndef ACADEMY LayerForm->InitForm(); #endif ReviewStatusBar(); ReleaseCapture(); ShowZoomText(); //================================================= for Auto Repeat by kjs #ifndef ACADEMY if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) { MainMenuForm->AutoRepUpdateItem(); } //================================================== if(N3DMappingForm) { N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); } if(N3DPatternForm) { N3DPatternForm->UpdateAll(); } #endif iMainImage->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormClose(TObject *Sender, TCloseAction &Action) { delete LineList; Action = caFree; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormCloseQuery(TObject *Sender, bool &CanClose) { AnsiString msg, fn, ext, cmfn, cmfn2; TCursor cur; char *s; int FileNameLength, last1, last2, last3, last4; char FileIndex1, FileIndex2, FileIndex3, FileIndex4; TPException ec = EC_NONE; switch(gff){ case gffTEX: { ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; break; } case gffTFC: { ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; break; } #ifndef ACADEMY #ifndef N_3D case gffT3D: { ext = ".t3d"; MainForm->SaveDialog->Filter = "Texpro Textile 3D File (*.t3d)|*.t3d"; break; } #ifdef NOTN3D #else case gffN3D: { ext = ".n3d"; MainForm->SaveDialog->Filter = "Texpro Textile New 3D File (*.n3d)|*.n3d"; break; } #endif #endif #endif default: { ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; break; } } if (MainForm->MDIChildCount == 1){ //lhskys ALLClose = true; // MainMenu ´ÝÇôµµ Filemanager´Â »ç¿ë °¡´ÉÇÏ°Ô if (TexWork){ if (TexWork->Modify ){ AnsiString msg; if(TexWork->OpenDialog1->FileName!= "")msg = TexWork->OpenDialog1->FileName; else msg = "Noname.fst"; int Btn = MessageDlg(IDS_MESSAGE_SAVECHANGE + " " + msg, mtWarning, TMsgDlgButtons()<tbSaveClick(this); } TexWork->Modify = false; } TexWork->FormCloseQuery(this,true); } } MainMenuForm->ExitForm(1); 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()) { //=============================================================== FileNameLength = MainForm->SaveDialog->FileName.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = ext[1]; FileIndex2 = ext[2]; FileIndex3 = ext[3]; FileIndex4 = ext[4]; if((FileIndex1 == MainForm->SaveDialog->FileName[last1]) &&(FileIndex2 == MainForm->SaveDialog->FileName[last2]) && (FileIndex3 == MainForm->SaveDialog->FileName[last3]) &&(FileIndex4 == MainForm->SaveDialog->FileName[last4])){ s = "PASS"; }else s=NULL; }else s=NULL; //=============================================================== // s = AnsiStrScan(MainForm->SaveDialog->FileName.c_str(), '.'); if (s==NULL) fn = MainForm->SaveDialog->FileName+ext; else fn = MainForm->SaveDialog->FileName; DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); CanClose = true; } } 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; } } else { CanClose = true; } if (CanClose) { PaletteForm->DIB256Palette->ChoiceIndex = 2; if (FileExists(DirName + "\\" + FileName)) { FileHistory->InsertHistory(DirName, ExtractFileName(FileName), 1, iMainImage->uBitmap->BitsPerPixel); } //====================================================== for Auto Repeat by kjs #ifndef ACADEMY if (AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) { AutoRepUpdateMenu(true); AutoRepeat = false; if (AutoRepViewForm) ARViewExitForm(); } #endif //====================================================== } 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 ProtectCard->Check(); #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; #ifndef ACADEMY AutoRepViewForm = NULL; #endif //====================================== MainImageForm = this; CanvasInfor.DotsPerInch = 160; CanvasInfor.SetExtFileOption(); ApplyEnvironment(); Panel->PopupMenu = MainMenuForm->PopupMenu1; iMainImage->Cursor = crPen; ZoomChange(1, 1); PaletteForm->InitForm(Palette); PenManagerForm->InitPenForm(); ReviewStatusBar(); initsave = true; if ((Undo = new TUndo)==NULL) { goto fail; } //by linuxjun Undo-Method return; fail: ::doDestroy(Palette); ::doDestroy(WorkArea); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormDestroy(TObject *Sender) { MainMenuForm->ExitForm(1); iMainImage->OnPaintZoom = NULL; #ifndef ACADEMY #ifndef N_3D ::doDestroy(new3d); ::doDestroy(Data3D); LayerForm->Visible = false; #endif #endif DelLineMem(); ::doDestroy(Palette); ::doDestroy(WorkArea); FullViewForm->InitForm(NULL); ::doDestroy(Undo); //by linuxjun for Undo MainImageForm = NULL; if (ALLClose) MainMenuForm->CloseMainMenuItem(); // MainMenu ´ÝÇôµµ Filemanager´Â »ç¿ë °¡´ÉÇÏ°Ô if(N3DMappingForm) { N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { MainMenuForm->iMainImageKeyDown(this, Key); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormKeyPress(TObject *Sender, char &Key) { #ifndef ACADEMY bool NotWork = false; //qe TexWork°¡ ¿­·ÁÀÖÁö ¾Ê°Å³ª Minimized µÇ¾úÀ»¶§¸¸ A,S ´ÜÃàŰ ½ÇÇàµÇµµ·Ï if(TexWork){ if(TexWork->WindowState == wsMinimized){ NotWork = true; }else { NotWork = false; } }else { NotWork = true; } if((Key == 65 || Key == 97 || Key == 83 || Key == 115)&& NotWork) //È®´ëÃà¼Ò iMainImageKeyDown(Key); #else if(Key == 65 || Key == 97 || Key == 83 || Key == 115) iMainImageKeyDown(Key); //È®´ëÃà¼Ò ´ÜÃàŰ·Î #endif MainMenuForm->iMainImageKeyPress(this, Key); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { MainMenuForm->iMainImageKeyUp(this, Key); } //--------------------------------------------------------------------------- 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 iMainImage->SetPosition(); FullViewForm->SetSize(); } //--------------------------------------------------------------------------- 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); } MainMenuForm->iMainImageMouseEnter(this); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseLeave(TObject *Sender) { isFirst=true; /* 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(); iMainImage->Repaint(); MainMenuForm->iMainImageMouseLeave(this); iMainImage->Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { 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 && XuBitmap->Width && Y>=0 && YuBitmap->Height) { DownState = true; if (Shift.Contains(ssCtrl) && Button==mbLeft) { MouseState = 1; iMainImage->Cursor = crHandPoint; ptFirst = Point(X, Y); } else { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft && MainMenuForm->Item!=T_VECTOR)) { c = iMainImage->uBitmap->GetPixelColor(X, Y); 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 = 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); BtnClick = true; } } } } } } } // GreenFish (Index Point) if (Ruler->Cursor==crHSplit || Ruler->Cursor==crVSplit) { 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°¡ À妽º Æ÷ÀÎÆ® ±×¸®±âÀÇ ÁöÇ¥ÀÌ´Ù iMainImage->OnPaintCursor = PaintPenLocate; MainMenuForm->Item = T_NONE; sbCrossLine->Enabled = true; } if (iMainImage->OnPaintIndexPoint && (HIM || VIM)) { if (VIM) { Ruler->Cursor=crHSplit; VIndex[VIM-1] = -10; }else { Ruler->Cursor=crVSplit; HIndex[HIM-1] = -10; } FirstIndex = true; iMainImage->Repaint(); } // if (MainForm->MotiveFileName != "") { // MainForm->MotiveLoadClick (this); // } isPaintDirectlyClean=false; PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseMove(TObject *Sender, TShiftState Shift, int X, int 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); return; } 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) { iMainImage->OnPaintCursor = PaintPenLocate; MainMenuForm->Item = T_NONE; VIM = NULL; HIM = NULL; for (int i=0; i VIndex[i]-3) { iMainImage->OnPaintCursor = NULL; iMainImage->Cursor = crHandPoint; VIM = i+1; // Vertical Index Move function MainMenuForm->Item = T_INDEX; break; } } for (int j=0; j HIndex[j]- 3) { iMainImage->OnPaintCursor = NULL; iMainImage->Cursor = crHandPoint; VIM = NULL; // °ãÃÄ Àִ°æ¿ì Horizonal Index °¡ ¿ì¼±ÇÑ´Ù HIM = j+1; MainMenuForm->Item = T_INDEX; break; } } } 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; } // 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 (X>=0 && XuBitmap->Width && Y>=0 && YuBitmap->Height) { if (!bOnImage) { bOnImage = true; MainMenuForm->iMainImageMouseEnter(this); } if (iMainImage->Cross) { iMainImage->SetCrossPos(Point(X, Y)); if(!DrawORStitch)iMainImage->Cursor = crNone; } else Screen->Cursor = NULL; CursorPosition.x = X; CursorPosition.y = Y; if (MouseState) { ptSecond = Point(X, Y); pt.x = ptSecond.x-ptFirst.x; pt.y = ptSecond.y-ptFirst.y; iMainImage->SetPosition(iMainImage->PositionX-pt.x, iMainImage->PositionY-pt.y); ptFirst.x = ptSecond.x-pt.x; ptFirst.y = ptSecond.y-pt.y; } 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, X, Y)) { if (PenManagerForm->acolor == 1) { PenManagerForm->SpecialMouseMove(Shift, X, Y); if(!iMainImage->Cross)iMainImage->Cursor = crCross; } else { if (BtnClick) PenManagerForm->SpecialMouseMove(Shift, X, Y); if (!iMainImage->Cross)iMainImage->Cursor = crPen; } } else { if(!iMainImage->Cross)iMainImage->Cursor = crCross; } } PaletteForm->iMainImageMouseMove(Sender, Shift, X, Y); } } } else { MainMenuForm->iMainImageMouseLeave(this); iMainImage->Cursor = crDefault; bOnImage = false; } } 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) { PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); isPaintDirectlyClean=true; if (Active) { if (MouseState) { ptSecond = Point(X, Y); iMainImageChange(); iMainImage->SetPosition(iMainImage->PositionX-(ptSecond.x-ptFirst.x), iMainImage->PositionY-(ptSecond.y-ptFirst.y)); MouseState = 0; } else { if ((XuBitmap->Width) && (YuBitmap->Height)) { bool isNonePen; if (isNonePen=MainMenuForm->iMainImageMouseUp(this, Button, Shift, X, Y)) { PenManagerForm->SpecialMouseUp(Button, Shift, X, Y); if (AutoRepeat && (PaletteForm->Item != 6) && (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); BtnClick = false; } if(iMainImage->uBitmap->BitsPerPixel == 24){ if(!isNonePen){ iMainImage->Repaint(); if(FullViewForm->Visible==true)FullViewForm->View(); #ifndef ACADEMY if(LayerForm->Visible==true){ ((TPLayer *)(iMainImage->LayerList->Items[iMainImage->Index])) ->UpdateMiniBitmap(iMainImage->Frgb); LayerForm->LayerGrid->Repaint(); } #endif } } else { if(!isNonePen){ iMainImage->Repaint(); if(FullViewForm->Visible==true)FullViewForm->View(); #ifndef ACADEMY if(LayerForm->Visible==true){ ((TPLayer *)(iMainImage->LayerList->Items[iMainImage->Index])) ->UpdateMiniBitmap(iMainImage->Frgb); LayerForm->LayerGrid->Repaint(); } #endif } } DownState = false; } } } 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 (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; } } //--------------------------------------------------------------------------- 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; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbGridClick(TObject *Sender) { iMainImageChange(); iMainImage->Grid = sbGrid->Down; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbRulerClick(TObject *Sender) { if (sbRuler->Down == false) { Visible1->Checked = true; Visible1Click (this); } iMainImageChange(); FormResize(this); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbProtectClick(TObject *Sender) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbCrossLineClick(TObject *Sender) { if (sbCrossLine->Down) { iMainImage->Cross = true; iMainImage->CrossLine = true; } else { iMainImage->Cross = false; iMainImage->CrossLine = false; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbMaskAreaClick(TObject *Sender) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbMaskShowClick(TObject *Sender) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbAutoRepViewClick(TObject *Sender) { #ifndef ACADEMY 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; } } #endif } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbHorzScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { iMainImageChange(); iMainImage->PositionX = sbHorz->Position; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbVertScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { iMainImageChange(); iMainImage->PositionY = sbVert->Position; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- int TMainImageForm::WMNCPaint(TMessage &msg) { DefWindowProc(Handle, WM_NCPAINT, msg.WParam, msg.LParam); return 0; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetCaption() { AnsiString 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 ? DirName+"\\"+ fn: fn)+" - 256 Colors"; } else { Caption = (DirName.Length()>0 ? DirName+"\\"+ fn : fn)+" - Full Colors"; } } #ifdef ACADEMY sbProtect->Enabled = false; sbMaskArea->Enabled = false; sbMaskShow->Enabled = false; #else if (iMainImage->uBitmap->BitsPerPixel==8) { sbProtect->Enabled = true; } else { sbProtect->Enabled = false; } #endif } //---------------------------------------------------------------------------TPException __fastcall TMainImageForm::LoadFromFile(AnsiString FileName, TGraphicFileFormat Index, TPException __fastcall TMainImageForm::LoadFromFile(AnsiString 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], *bp=NULL; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; bool vector; #ifdef ACADEMY if (Index==gffTEX) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; ci = tpfh.CanvasInfor; CloseHandle(hFile); #else if (Index==gffTEX || Index==gffTFC) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; //UserColorLibForm->ThisFileHasUserColor(pPalette); 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) { pPalette->ToRGBQUAD(rgb, 256); iMainImage->LoadFromLayerFile(hFile, rgb); } else { iMainImage->LoadFromLayerFile(hFile); } } 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 } } CloseHandle(hFile); #endif } else { if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; 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); } } return EC_NONE; fail: if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadToSelectImage(AnsiString FileName, TGraphicFileFormat Index, TUnionBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &ci) { TEXPIAFILEHEADER tpfh; int x, y; float MergeRatio; RGBQUAD rgb[256]; Byte c[256], *bp=NULL; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; bool layer, vector; #ifdef ACADEMY if (Index==gffTEX) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; ci = tpfh.CanvasInfor; CloseHandle(hFile); #else if (Index==gffTEX || Index==gffTFC) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; double MergeRatio = (double) CanvasInfor.DotsPerInch / ci.DotsPerInch; ci.Height *= MergeRatio; // By GreenFish ci.Width *= MergeRatio; // Merge ¼öÁ¤ (DPIº¯È­¿¡ ´ëÇÑ Å©±â ºñÀ² Á¶Àý) ci.DotsPerInch = CanvasInfor.DotsPerInch; //==============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) { if (!FileExists(FileName)) { ec = EC_FILE_NOT_EXIST; 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; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, false))!= EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; CloseHandle(hFile); #endif } else { if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; goto fail; } ci.DotsPerInch = pBitmap->DotsPerInch; // By GreenFish ci.SetSize(cstFree, pBitmap->Width, pBitmap->Height); if (pBitmap->BitsPerPixel==8 && iMainImage->uBitmap->BitsPerPixel != 24) { 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; goto fail; } for (yy=0; yyHeight; yy++) { sp = pBitmap->GetScanLine(yy); // for (xx=0; xxWidth; 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 } } return EC_NONE; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); 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() { if (bProtect) { iMainImage->InitBackGround(0x10); } else { iMainImage->ExitBackGround(0x10); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetProtect(bool Value) { if (Value!=bProtect) { bProtect = Value; if (bProtect) sbProtect->Down = true; else sbProtect->Down = false; SetProtectBackGround(); } } //--------------------------------------------------------------------------- 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) { 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; } return true; fail: DelLineMem(); return false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DelLineMem() { if (hMemLine) { if (msx) { GlobalUnlock(hMemLine); msx = NULL; } GlobalFree(hMemLine); hMemLine = NULL; } memsize = 0; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::pos_in(TLineData &ld, int by, int bsx, int bex, int ch) { double d; if ((by>=0) && (byuBitmap->Height)) { if (*(msx+by)>bsx) { if (ch) { d = (ld.dx1 - bsx) * (ld.dx1 - bsx) + (ld.dy1 - by) * (ld.dy1 - by); if (dCaption = "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;; } return ec; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoSaveToFile(AnsiString dn, AnsiString fn, TGraphicFileFormat Index, TCompressMethod cm) { /* HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; TTexpiaBitmap *tag = NULL, *tb = NULL; HDC dcTmp = NULL; TPException ec = EC_NONE; bool layer; DWORD dwWrite; #ifdef ACADEMY if (Index == gffTEX) { #else if (Index == gffTEX || Index == gffTFC) { #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; goto fail; } tpfh.Version = TexVersion('P', 'T', 240); tpfh.CanvasInfor = CanvasInfor; 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 ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; 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; goto fail; } } else { if (!tb->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } } if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; goto fail; } iMainImage->FullViewPaint(dcTmp, 1, 1); tb->DeleteDC(dcTmp); dcTmp = NULL; if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, tb, src, 0); ////////////// HDC dcTemp=NULL; if ((dcTemp = tag->CreateDC())==NULL) goto fail; VecDraw->TagDraw(dcTemp, src); 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; goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb)) { ec = EC_FILE_NOT_WRITE; goto fail; } } layer = true; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; if (!iMainImage->SaveToLayerFile(hFile)) goto fail; delete tb; } else { if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, iMainImage->uBitmap, src, 0); ////////////// HDC dcTemp=NULL; if ((dcTemp = tag->CreateDC())==NULL) goto fail; VecDraw->TagDraw(dcTemp, src); tag->DeleteDC(dcTemp); dcTemp = NULL; //////// Vector Tag By GreenFIsh if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->uBitmap)) { ec = EC_FILE_NOT_WRITE; goto fail; } layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; } CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; #ifndef ACADEMY } else if (Index == gffT3D) { 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; goto fail; } //tpfh.Version = TexVersion('P', 'T', 230); // for fit size and point by kjs.... 230 --> 232 tpfh.Version = TexVersion('P', 'T', 232); 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; goto fail; } if ((ec = MainMenuForm->SaveTo3DFile(hFile, tpfh, tag, iMainImage->uBitmap))!=EC_NONE) goto fail; CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; } #endif } SetCaption(); return; fail: if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; } if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); EXCEPTION_MESSAGE_OK(ec); */ //need conversion } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange_none() { ///* BeConverted by linuxjun Don't Forget!! Undo_Method Byte *ssl=NULL, *dsl=NULL, *usl=NULL, *mml=NULL, usecolor; int x, y, moveleft; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; TTexpiaBitmap *SBitmap = NULL; TUnionBitmap *UBitmap = NULL; RECT rc, urc; THistoryData *ud; SBitmap = FullViewForm->OverlapBitmap; rc = FullViewForm->OverlapRect; if (FullViewForm->OverlapBack) { urc = rc; // UBitmap = FullViewForm->OverlapBack; need-conversion } else { if (Undo->GetLast() == NULL) return; ud = Undo->GetLast(); // urc = ud->Range; urc = ud->getRectRange(); //by linuxjun UBitmap = ud->uBitmap; } if (SBitmap && UBitmap) { moveleft = rc.left - urc.left; PaletteForm->DIB256Palette->UseColor = FullViewForm->preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); for (x=rc.left; 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); for (x=rc.left; 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->StopScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; for (x=rc.left; xuBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; for (x=rc.left; xuBitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); return; fail: ExitOverlap(); iMainImage->uBitmap->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); //*/ /* BeConverted by linuxjun Don't Forget!! Undo_Method Byte *ssl=NULL, *dsl=NULL, *usl=NULL, *mml=NULL, usecolor; int x, y, moveleft; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; TTexpiaBitmap *SBitmap = NULL; TUnionBitmap *UBitmap = NULL; RECT rc, urc; THistoryData *ud; SBitmap = FullViewForm->OverlapBitmap; rc = FullViewForm->OverlapRect; if (FullViewForm->OverlapBack) { urc = rc; // UBitmap = FullViewForm->OverlapBack; need-conversion } else { if (Undo->Last == NULL) return; ud = Undo->Last; urc = ud->Range; UBitmap = ud->Bitmap; } if (SBitmap && UBitmap) { moveleft = rc.left - urc.left; PaletteForm->DIB256Palette->UseColor = FullViewForm->preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); for (x=rc.left; 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); for (x=rc.left; 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->StopScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; for (x=rc.left; xuBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; for (x=rc.left; xuBitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->uBitmap->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); return; fail: ExitOverlap(); iMainImage->uBitmap->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); */ } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange_layer() { ///* BeConverted by linuxjun Don't Forget!! Undo_Method Byte *ssl=NULL, *dsl=NULL, *usl=NULL, *mml=NULL, *lp=NULL, usecolor; int x, y, moveleft; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; TTexpiaBitmap *SBitmap = NULL; TUnionBitmap *UBitmap = NULL; RECT rc, urc; THistoryData *ud=NULL; SBitmap = FullViewForm->OverlapBitmap; rc = FullViewForm->OverlapRect; if (FullViewForm->OverlapBack) { urc = rc; // UBitmap = FullViewForm->OverlapBack; need-conversion } else { if (Undo->GetLast() == NULL) return; ud = Undo->GetLast(); urc = ud->getRectRange(); UBitmap = ud->uBitmap; } if (SBitmap && UBitmap) { moveleft = rc.left - urc.left; PaletteForm->DIB256Palette->UseColor = FullViewForm->preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; lp = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++, lp++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; 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 (*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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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->StopScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + moveleft; usl = UBitmap->GetScanLine(y) + rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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++) { ssl = SBitmap->GetScanLine(y - rc.top); // usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; usl = UBitmap->GetScanLine(y) + 3*rc.left; //For New Undo by linuxjun dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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->StopScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); return; fail: ExitOverlap(); iMainImage->uBitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); /* BeConverted by linuxjun Don't Forget!! Undo_Method Byte *ssl=NULL, *dsl=NULL, *usl=NULL, *mml=NULL, *lp=NULL, usecolor; int x, y, moveleft; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; TTexpiaBitmap *SBitmap = NULL; TUnionBitmap *UBitmap = NULL; RECT rc, urc; THisotryData *ud=NULL; SBitmap = FullViewForm->OverlapBitmap; rc = FullViewForm->OverlapRect; if (FullViewForm->OverlapBack) { urc = rc; // UBitmap = FullViewForm->OverlapBack; need-conversion } else { if (Undo->Last == NULL) return; ud = Undo->Last; urc = ud->Range; UBitmap = ud->Bitmap; } if (SBitmap && UBitmap) { moveleft = rc.left - urc.left; PaletteForm->DIB256Palette->UseColor = FullViewForm->preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; lp = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++, lp++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; 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 (*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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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->StopScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->uBitmap->GetScanLine(y) + 3*rc.left; lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; 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->StopScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); return; fail: ExitOverlap(); iMainImage->uBitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); */ } //--------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////// // Gauze 8 ////////////////////////////////////////////////////////////////////////////// void __fastcall TMainImageForm::Merge_Mask_Protect_TempMask_Gauze8(TUnionBitmap *Bitmap , int px, int py) // convert by celberus { 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) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Protect_Gauze8(TUnionBitmap *Bitmap, int px, int py) { 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) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Gauze8(TUnionBitmap *Bitmap, int px, int py) // convert by celberus { 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) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Gauze8(TUnionBitmap *Bitmap, int px, int py) { 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) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_TempMask_Gauze8(TUnionBitmap *Bitmap, int px, int py) { 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 (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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_Gauze8(TUnionBitmap *Bitmap, int px, int py) { 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; 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Gauze8(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Gauze8(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- // Gauze 24 void __fastcall TMainImageForm::Merge_Mask_Temp8_TempMask_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Temp8_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_TempMask_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Gauze24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////// // Default 8 ///////////////////////////////////////////////////////////////////////////// void __fastcall TMainImageForm::Merge_Mask_Protect_TempMask_Default8(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Protect_Default8(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Default8(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Default8(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_TempMask_Default8(TUnionBitmap *Bitmap, int px, int py) { 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 (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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_Default8(TUnionBitmap *Bitmap, int px, int py) { 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) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Default8(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Default8(int px, int py) { 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); } } //--------------------------------------------------------------------------- // Default 24 void __fastcall TMainImageForm::Merge_Mask_Temp8_TempMask_Default24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Temp8_Default24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_TempMask_Default24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_Default24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Default24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Default24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Default24(TUnionBitmap *Bitmap, int px, int py) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Default24(int px, int py) { 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); } } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem_none(int X, int Y) { RECT rc; 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; 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); if (FullViewForm->Super==sOverlap) { FullViewForm->ReadyToOverlapChange(Image->SubBitmap, rc, Palette->UseColor); } 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y)+rc.left; mml = Image->Mask->GetScanLine(y)+rc.left; for (x=rc.left; xColorData[*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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); for (x=rc.left; xColorData[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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y)+ rc.left; for (x=rc.left; x 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 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(rc); WorkAreaChange(); } //================== By GreenFish (irreguler WorkArea) if (MainForm->MotiveLoad->Checked) { // Motive Library¿¡¼­ ±×¸²À» ºÒ·¯¿À¸é WorkArea->IrregularRegion(Image->SubMask, rc);// ±×¸²ÀÇ ÇüÅ¿¡ µû¶ó ÀÛ¾÷±¸¿ªÀÌ »ý±âµµ·Ï WorkAreaChange(); // ¸¸µé¾îÁÖ´Â ºÎºÐÀÔ´Ï´Ù - By GreenFish } return true; fail: if (FullViewForm->Super == sOverlap) { FullViewForm->ExitOverlapChange(); ExitOverlap(); } Image->uBitmap->StopScanLine(); if (bMaskArea) Image->Mask->StopScanLine(); Image->SubBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem_layer(int X, int Y) { RECT rc; 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; 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); if (FullViewForm->Super==sOverlap) { FullViewForm->ReadyToOverlapChange(Image->SubBitmap, rc, Palette->UseColor); } 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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; xColorData[*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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); bml = Image->BackGround->GetScanLine(y); for (x=rc.left; xColorData[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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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[*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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y)+ rc.left; bml = Image->BackGround->GetScanLine(y) + rc.left; for (x=rc.left; x 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y)+3*rc.left; bml = Image->BackGround->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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[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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); 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-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->uBitmap->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 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(rc); WorkAreaChange(); } return true; fail: if (FullViewForm->Super == sOverlap) { FullViewForm->ExitOverlapChange(); ExitOverlap(); } Image->uBitmap->StopScanLine(); if (bMaskArea) Image->Mask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->BackGround->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToClipboard() { RGBQUAD rgb[256]; BITMAPHANDLE bh, *pbh=NULL; int w, h, i, x, y; 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; if (WorkArea->Mask) { memset(&bh, 0, sizeof(BITMAPHANDLE)); w = WorkArea->Range.right-WorkArea->Range.left; h = WorkArea->Range.bottom-WorkArea->Range.top; // if (L_CreateBitmap(&bh, TYPE_CONV, w, h, iMainImage->uBitmap->BitsPerPixel, ORDER_BGR, NULL, TOP_LEFT)<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; // if ((dcSrc = iMainImage->uBitmap->CreateDC())==NULL) goto next1; convert by celberus // BitBlt(dcDst, 0, 0, w, h, dcSrc, WorkArea->Range.left, WorkArea->Range.top, SRCCOPY); iMainImage->uBitmap->UnionBitBlt(dcDst, 0, 0, w, h, WorkArea->Range.left, WorkArea->Range.top, SRCCOPY, false); // convert by celberus // iMainImage->uBitmap->DeleteDC(dcSrc); dcSrc = NULL; convert by celberus if ((dcMask = WorkArea->Mask->CreateDC())==NULL) goto next1; BitBlt(dcDst, 0, 0, w, h, dcMask, 0, 0, SRCAND); WorkArea->Mask->DeleteDC(dcMask); dcMask = NULL; L_DeleteLeadDC(dcDst); dcDst = NULL; if (L_CopyToClipboard(MainForm->Handle, &bh)<1) goto next1; 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; goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { cbi.Version = 0; cbi.Time = clock(); cbi.Width = w; cbi.Height = h; cbi.Mask = true; if (iMainImage->uBitmap->BitsPerPixel==8) { cbi.BitsPerPixel = 8; cbi.Colors = Palette->UseColor; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+ cbi.Colors*sizeof(TColorData)+cbi.Width*cbi.Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); for (i=1; i<=cbi.Colors; i++) { cd = Palette->ColorData[i]; memcpy(lpData, cd, sizeof(TColorData)); lpData += sizeof(TColorData); } if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yuBitmap->GetScanLine(WorkArea->Range.top+y); mp = WorkArea->Mask->GetScanLine(y); for (x=0; xRange.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; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; 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; goto fail; } for (y=0; yuBitmap->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; goto fail; } for (y=0; yMask->GetScanLine(y); for (x=0; xMask->BytesPerLine; x++) { *(lpData+x) = ~*(mp+x); } lpData += WorkArea->Mask->BytesPerLine; } WorkArea->Mask->StopScanLine(); GlobalUnlock(hMem); } SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } else { if ((pbh = iMainImage->uBitmap->Handle)==NULL) { ec = EC_RESOURCE_LACK; goto fail; } // L_CopyToClipboard(MainForm->Handle, pbh); // if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { cbi.Version = 0; 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)+ cbi.Colors*sizeof(TColorData)+cbi.Width*cbi.Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); for (i=1; i<=cbi.Colors; i++) { cd = Palette->ColorData[i]; memcpy(lpData, cd, sizeof(TColorData)); lpData += sizeof(TColorData); } if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yuBitmap->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; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; 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; goto fail; } for (y=0; yuBitmap->GetScanLine(y); memcpy(lpData, bp, 3*cbi.Width); lpData += 3*cbi.Width; } iMainImage->uBitmap->StopScanLine(); GlobalUnlock(hMem); } SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } return EC_NONE; fail: if (bClipboard) { if (hMem) { if (lpData) { if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); GlobalUnlock(hMem); } GlobalFree(hMem); } CloseClipboard(); } return ec; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperOff(TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { 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 = 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; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; 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; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); for (x=0; xWidth; x++) { if (*(bp+x)<1) { *(bp+x) = 0; } else { *(bp+x) += UseColor; } } TempBitmap->PutScanLine(y); sp += cbi->Width; } } TempBitmap->StopScanLine(); return true; fail: ::doDestroy(TempMask); TempBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperNormal(TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { 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 = 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; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; 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(); return true; fail: ::doDestroy(TempMask); TempBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperGauge(TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { 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 = 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; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; 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(); return true; fail: ::doDestroy(TempMask); TempBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat8To8(TClipboardInfo *cbi) { TRect r; int i, x, y, bg; bool sw = false; TColorData *Color=NULL; Byte *Bitmap=NULL, *sp=NULL; TPException ec = EC_NONE; Color = (TColorData *)((Byte *)cbi+sizeof(TClipboardInfo)); Bitmap = (Byte *)Color+cbi->Colors*sizeof(TColorData); if ((TempBitmap = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: bg = 0; sp = Bitmap; for (y=0; yHeight; y++) { for (x=0; xWidth; 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; 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(Color+i-1); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; 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(Color+i-1); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; 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; 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(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; 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(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } break; case sGauze: bg = 0; sp = Bitmap; for (y=0; yHeight; y++) { for (x=0; xWidth; 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; 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(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; 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(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } break; } return EC_NONE; fail: ::doDestroy(TempBitmap); return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat8To24(TClipboardInfo *cbi) { 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); 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); if ((TempBitmap = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: if (cbi->Mask) { if ((TempMask = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; 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; goto fail; } for (y=0; yHeight; 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; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; 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; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (cbi->Mask) { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; 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; } return EC_NONE; fail: if (TempBitmap) { ::doDestroy(TempMask); delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat24To24(TClipboardInfo *cbi) { 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 = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (cbi->BitsPerPixel==15) { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); for (x=0; xWidth; 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; yHeight; 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 = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); memcpy(mp, sp, TempMask->BytesPerLine); mm = 0x80; for (x=0; xWidth; 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 = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (cbi->Mask) { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); memcpy(mp, sp, TempMask->BytesPerLine); mm = 0x80; for (x=0; xWidth; 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; yHeight; 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; } return EC_NONE; fail: if (TempBitmap) { ::doDestroy(TempMask); delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat8To8(BITMAPHANDLE *bh, int colors, short *color) { TRect r; int i, j, x, y; RGBQUAD rgb[256]; HANDLE hBuffer = NULL; Byte *pBuffer = NULL, *bp=NULL, *mp=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 = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } L_AccessBitmap(bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: case sNormal: case sOverlap: case sGauze: if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); bp = TempBitmap->GetScanLine(y); memcpy(bp, pBuffer, bh->Width); for (x=0; xWidth; x++, bp++) { *bp = color[*bp]; } TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); break; } Palette->UseColor = cbUseColor+colors; GlobalUnlock(hBuffer); GlobalFree(hBuffer); hBuffer = NULL; L_ReleaseBitmap(bh); return EC_NONE; fail: if (TempBitmap) { if (hBuffer) { if (pBuffer) { ::doDestroy(TempMask); GlobalUnlock(hBuffer); } GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat8To24(BITMAPHANDLE *bh, int colors, short *color) { HANDLE hBuffer = NULL; Byte *pBuffer = NULL; int i, x, y, nBlack, nWhite; RGBQUAD rgb[256], t; Byte *ip=NULL, *mp=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) 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) 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 = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; goto fail; } L_AccessBitmap(bh); if (nBlack!=0 || nWhite!=255) { for (y=0; yHeight; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); ip = pBuffer; for (x=0; xWidth; 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; goto fail; } for (y=0; yHeight; 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; return EC_NONE; fail: if (TempBitmap) { if (hBuffer) { if (pBuffer) { ::doDestroy(TempMask); GlobalUnlock(hBuffer); } GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat24To24(BITMAPHANDLE *bh) { HANDLE hBuffer = NULL; Byte *pBuffer = NULL; Byte *ip=NULL, *mp=NULL, mm=NULL; int x, y; TPException ec = EC_NONE; if ((TempBitmap = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } L_AccessBitmap(bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; 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); return EC_NONE; fail: if (TempBitmap) { ::doDestroy(TempMask); if (hBuffer) { if (pBuffer) GlobalUnlock(hBuffer); GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } return ec; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::Irregularrect(HDC dcDst, TRect Src, TRect Dst) { 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); return true; fail: if (dcSrc) Mask->DeleteDC(dcSrc); if (Mask && Mask!=WorkArea->Mask) ::doDestroy(Mask); 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 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; yUnionStretchBlt(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(dcDst, Src, Dst)) goto fail; } } } break; case 1: for (y=0; yUnionStretchBlt(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(dcDst, Src, Dst)) goto fail; } } if (Dst.RightWidth) { 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(dcDst, Src, Dst)) goto fail; } } } break; case 2: for (x=0; xUnionStretchBlt(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(dcDst, Src, Dst)) goto fail; } } if (Dst.BottomHeight) { 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(dcDst, Src, Dst)) goto fail; } } } break; } return true; fail: if (dcSrc) Bitmap->DeleteDC(dcSrc); if (dcDst) Pattern->DeleteDC(dcDst); return false; } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::MosaicDraw8(TUnionBitmap *bm, int k, int m, int w, int h, int pi) { 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 = bm->GetScanLine(rect.Top) + rect.Left; memset(p, 0, rect.Right-rect.Left); bm->PutScanLine(rect.Top); for (y=rect.Top+1; yGetScanLine(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(); } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::MosaicDraw24(TUnionBitmap *bm, int k, int m, int w, int h, RGBQUAD rgb) { 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 = bm->GetScanLine(rect.Top) + 3 * rect.Left; memset24(p, 0, rect.Right-rect.Left); bm->PutScanLine(rect.Top); for (y=rect.Top+1; yGetScanLine(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(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::NormalDrawing(bool MaskBmp) { ///* BeConverted by linuxjun Don't Forget!! Undo_Method int w, h, hw, hh; int x, y; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dp, sp; THistoryData *ud=NULL; TUnionBitmap *udBitmap, *udMask; w = arwindow.size.x; h = arwindow.size.y; int ux = arwindow.s.x-w/2-1; int uy = arwindow.s.y-h/2-1; if ((ud = Undo->GetLast()) == NULL) return; Undo->UndoRead(); ///////////////////////////////////////////////// udBitmap = new TUnionBitmap; if(MaskBmp) { udMask = new TUnionBitmap; }else{ udMask = NULL; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { if(MaskBmp){ if(!udMask->Create(2*w+2,2*h+2, 8)) goto fail; udMask->Copy(0,0,2*w+2,2*h+2,MainImageForm->iMainImage->Mask,ux,uy,SRCCOPY); }else{ if(!udBitmap->Create(2*w+2,2*h+2, 8)) goto fail; udBitmap->Copy(0,0,2*w+2,2*h+2,MainImageForm->iMainImage->uBitmap,ux,uy,SRCCOPY); } }else { if(MaskBmp){ if(!udMask->Create(2*w+2,2*h+2, 1)) goto fail; udMask->Copy(0,0,2*w+2,2*h+2,MainImageForm->iMainImage->Mask,ux,uy,SRCCOPY); }else{ if(!udBitmap->Create(2*w+2,2*h+2, 24)) goto fail; udBitmap->Copy(0,0,2*w+2,2*h+2,MainImageForm->iMainImage->uBitmap,ux,uy,SRCCOPY); } } Undo->RedoRead(); if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) goto fail; // if (!ud->Mask->StartScanLineN(2)) goto fail; if (!udMask->StartScanLineN(2)) goto fail; } else { if (!iMainImage->uBitmap->StartScanLineN(2)) goto fail; // if (!ud->uBitmap->StartScanLineN(2)) goto fail; if (!udBitmap->StartScanLineN(2)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) goto fail; } /////////////////////////////////////// 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,udMask,udBitmap); 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,udMask,udBitmap); hw = arwindow.size.x/2; hh = arwindow.size.y/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,udMask,udBitmap); 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,udMask,udBitmap); if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->uBitmap->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } /////////////////////////////////// if (MaskBmp) { udMask->StopScanLine(); } else { udBitmap->StopScanLine(); } if(udMask)delete udMask; if(udBitmap)delete udBitmap; return; fail: if(udMask)delete udMask; /////////// if(udBitmap)delete udBitmap; ////////// if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); //*/ /* BeConverted by linuxjun Don't Forget!! Undo_Method int w, h, hw, hh; int x, y; int ARWidthR = MainImageForm->WidthR, ARHeightR = MainImageForm->HeightR; TPoint dp, sp; THistoryData *ud=NULL; w = arwindow.size.x; h = arwindow.size.y; if ((ud = Undo->Last) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) goto fail; if (!ud->Mask->StartScanLineN(2)) goto fail; } else { if (!iMainImage->uBitmap->StartScanLineN(2)) goto fail; if (!ud->Bitmap->StartScanLineN(2)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) goto fail; } 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); hw = arwindow.size.x/2; hh = arwindow.size.y/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); if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->Bitmap->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::HDHORDrawing(bool MaskBmp) { ///* BeConverted by linuxjun Don't Forget!! Undo_Method int hw, hh; TPoint dp, sp; THistoryData *ud=NULL; hw = arwindow.size.x/2; hh = arwindow.size.y/2; if ((ud = Undo->GetLast()) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) goto fail; if (!ud->Mask->StartScanLineN(2)) goto fail; } else { if (!iMainImage->uBitmap->StartScanLineN(2)) goto fail; if (!ud->uBitmap->StartScanLineN(2)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) goto fail; } if(hw > MWdiv){ MWdivDrawing1(MaskBmp); }else if(hw == MWdiv){ MWdivDrawing2(MaskBmp); }else if(hw < MWdiv){ MWdivDrawing3(MaskBmp); } if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->uBitmap->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); //*/ /* BeConverted by linuxjun Don't Forget!! Undo_Method int hw, hh; TPoint dp, sp; THistoryData *ud=NULL; hw = arwindow.size.x/2; hh = arwindow.size.y/2; if ((ud = Undo->Last) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) goto fail; if (!ud->Mask->StartScanLineN(2)) goto fail; } else { if (!iMainImage->uBitmap->StartScanLineN(2)) goto fail; if (!ud->Bitmap->StartScanLineN(2)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) goto fail; } if(hw > MWdiv){ MWdivDrawing1(MaskBmp); }else if(hw == MWdiv){ MWdivDrawing2(MaskBmp); }else if(hw < MWdiv){ MWdivDrawing3(MaskBmp); } if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->Bitmap->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::HDVERDrawing(bool MaskBmp) //¼¼·ÎºÐÇÒ { ///* BeConverted by linuxjun Don't Forget!! Undo_Method int hh, hw; THistoryData *ud=NULL; hw = arwindow.size.x/2; hh = arwindow.size.y/2; if ((ud = Undo->GetLast()) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(4)) goto fail; if (!ud->Mask->StartScanLineN(4)) goto fail; } else { if (!iMainImage->uBitmap->StartScanLineN(4)) goto fail; if (!ud->uBitmap->StartScanLineN(4)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(4)) goto fail; } if(hh > MHdiv){ MHdivDrawing1(MaskBmp); }else if(hh == MHdiv){ MHdivDrawing2(MaskBmp); }else if(hh < MHdiv){ MHdivDrawing3(MaskBmp); } if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->uBitmap->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); //*/ /* BeConverted by linuxjun Don't Forget!! Undo_Method int hh, hw; THistoryData *ud=NULL; hw = arwindow.size.x/2; hh = arwindow.size.y/2; if ((ud = Undo->Last) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(4)) goto fail; if (!ud->Mask->StartScanLineN(4)) goto fail; } else { if (!iMainImage->uBitmap->StartScanLineN(4)) goto fail; if (!ud->Bitmap->StartScanLineN(4)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(4)) goto fail; } if(hh > MHdiv){ MHdivDrawing1(MaskBmp); }else if(hh == MHdiv){ MHdivDrawing2(MaskBmp); }else if(hh < MHdiv){ MHdivDrawing3(MaskBmp); } if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->Bitmap->StopScanLine(); iMainImage->uBitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } //--------------------------------------------------------------------------- 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::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->GetScanLine(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) { ///* 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->PutDiffScanLineN(dp.y + y,0); iMainImage->Mask->PutDiffScanLineN(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->PutDiffScanLineN(dp.y + y,0); iMainImage->Mask->PutDiffScanLineN(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->uBitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->uBitmap->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->PutDiffScanLineN(dp.y + y,0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutDiffScanLineN(dp.y + y,0); iMainImage->LayerMask->PutDiffScanLineN(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->uBitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->uBitmap->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->PutDiffScanLineN(dp.y + y,0); iMainImage->uBitmap->PutDiffScanLineN(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->uBitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->uBitmap->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->PutDiffScanLineN(dp.y + y,0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutDiffScanLineN(dp.y + y,0); iMainImage->LayerMask->PutDiffScanLineN(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->uBitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->uBitmap->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->PutDiffScanLineN(dp.y + y,0); iMainImage->uBitmap->PutDiffScanLineN(spp.y + y, 1); } } } } //*/ /* 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 (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { if(!udBitmap->Create(w+2*hw,h+2*hh, 8)) goto fail; udBitmap->Copy(0,0,w+2*hw,h+2*hh,MainImageForm->iMainImage->uBitmap,ux,uy,SRCCOPY); if(MaskBmp){ if(!udMask->Create(w+2*hw,h+2*hh, 8)) goto fail; udMask->Copy(0,0,w+2*hw,h+2*hh,MainImageForm->iMainImage->Mask,ux,uy,SRCCOPY); } }else { if(!udBitmap->Create(w+2*hw,h+2*hh, 24)) goto fail; udBitmap->Copy(0,0,w+2*hw,h+2*hh,MainImageForm->iMainImage->uBitmap,ux,uy,SRCCOPY); if(MaskBmp){ if(!udMask->Create(w+2*hw,h+2*hh, 1)) goto fail; udMask->Copy(0,0,w+2*hw,h+2*hh,MainImageForm->iMainImage->Mask,ux,uy,SRCCOPY); } } //*/ /* if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { if(!udBitmap->Create(w,h, 8)) goto fail; udBitmap->Copy(0,0,w,h,MainImageForm->iMainImage->uBitmap,0,0,SRCCOPY); if(MaskBmp){ if(!udMask->Create(Size.x, Size.y, 8)) goto fail; udMask->Copy(0,0,Size.x,Size.y,MainImageForm->iMainImage->LayerMask,sx,sy,SRCCOPY); } }else { if(!udBitmap->Create(Size.x, Size.y, 24)) goto fail; udBitmap->Copy(0,0,Size.x,Size.y,MainImageForm->iMainImage->uBitmap,sx,sy,SRCCOPY); if(MaskBmp){ if(!udMask->Create(Size.x, Size.y, 1)) goto fail; udMask->Copy(0,0,Size.x,Size.y,MainImageForm->iMainImage->LayerMask,sx,sy,SRCCOPY); } } */ 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); } } } } /* 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_NHBDrawing(bool MaskBmp, int w, int h, TPoint dp, TPoint spp, int hhw) { 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; ux = ud->getRectRange().left; //for new undo uy = ud->getRectRange().top; //for new undo udBitmap = ud->uBitmap; udMask = ud->Mask; 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); } } } } 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 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->GetLast(); // 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; 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->uBitmap->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->uBitmap->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->uBitmap->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->uBitmap->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->uBitmap->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->uBitmap->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->uBitmap->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->uBitmap->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->uBitmap->GetScanLine(dsp.y - uy + y) + 3*(dsp.x - ux); ur1 = ud->uBitmap->GetScanLineN(spp1.y - uy + y, 1) + 3*(spp1.x - ux); ur2 = ud->uBitmap->GetScanLineN(spp2.y - uy + y, 2) + 3*(spp2.x - ux); ur3 = ud->uBitmap->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->uBitmap->GetScanLine(dsp.y - uy + y) + 3*(dsp.x - ux); ur1 = ud->uBitmap->GetScanLineN(spp1.y - uy + y, 1) + 3*(spp1.x - ux); ur2 = ud->uBitmap->GetScanLineN(spp2.y - uy + y, 2) + 3*(spp2.x - ux); ur3 = ud->uBitmap->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); } } } } //*/ /* 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) { TRect Src, Dst, PDst; TUnionBitmap *UsedColBit = NULL; int w, h, temp, ht, width, height, cnt; bool over; HDC dcDst = NULL; if ((UsedColBit = new TUnionBitmap)==NULL) goto fail; if (!ComboHeaderUsedColorMethod(UsedColBit, true)) 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)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); temp = height; //================================================ // if (w>width) width = w; // height = temp+h; // if (height>ht) height = ht+h; if (w>width) width = w; cnt = temp/ht; if ((temp-ht*cnt+h) > ht) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ cnt++; over = true; height = cnt*ht + h; } else { over = false; height = temp + h; } //================================================ Pattern->Create(width, height, 24); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (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(dcDst, Src, Dst)) goto fail; // irregularrect need-conversion } 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; return true; fail: if (UsedColBit) { delete UsedColBit; } return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderYesMethod_layer(TUnionBitmap *Pattern) { // convert by celberus TRect Src, Dst, PDst; TUnionBitmap *UsedColBit = NULL, *Bitmap = NULL; int w, h, temp, ht, width, height, cnt; bool over; // HDC dcSrc = NULL, dcDst = NULL, dcUse = NULL; convert by celberus if ((UsedColBit = new TUnionBitmap)==NULL) goto fail; if (!ComboHeaderUsedColorMethod(UsedColBit, true)) 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)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); temp = height; //================================================ // if (w>width) width = w; // height = temp+h; // if (height>ht) height = ht+h; if (w>width) width = w; cnt = temp/ht; if ((temp-ht*cnt+h) > ht) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ cnt++; over = true; height = cnt*ht + h; } else { over = false; height = temp + h; } //================================================ Pattern->Create(width, height, 24); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; // if ((dcSrc = Bitmap->CreateDC())==NULL) goto fail; convert by celberus // if ((dcDst = Pattern->CreateDC())==NULL) goto fail; convert by celberus if (WorkArea->Mask) { Dst = Rect(0, 0, Src.Right-Src.Left, temp); // BitBlt(dcDst, 0, 0, Dst.Right, Dst.Bottom, dcSrc, Src.Left, Src.Top, SRCCOPY); Pattern->Copy(0, 0, Dst.Right, Dst.Bottom, Bitmap, Src.Left, Src.Top, SRCCOPY); // convert by celberus // if (!Irregularrect(dcDst, Src, Dst)) goto fail; irregularrect need-conversion } else { // BitBlt(dcDst, 0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, // dcSrc, 0, 0, SRCCOPY); Pattern->Copy(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, Bitmap, 0, 0, SRCCOPY); // convert by celberus } // Bitmap->DeleteDC(dcSrc); dcSrc = NULL; convert by celberus delete Bitmap; Bitmap = NULL; // if ((dcUse = UsedColBit->CreateDC()) == NULL) goto fail; 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); // StretchBlt(dcDst, PDst.Left, PDst.Top, PDst.Right - PDst.Left, PDst.Bottom - PDst.Top, // dcUse, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); 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 // UsedColBit->DeleteDC(dcUse); dcUse = NULL; convert by celberus // Pattern->DeleteDC(dcDst); dcDst = NULL; convert by celberus delete UsedColBit; return true; fail: if (UsedColBit) { // if (dcDst) Pattern->DeleteDC(dcDst); convert by celberus // if (dcUse) UsedColBit->DeleteDC(dcUse); convert by celberus delete UsedColBit; } if (Bitmap) { // if (dcSrc) Bitmap->DeleteDC(dcSrc); convert by celberus delete Bitmap; Bitmap = NULL; } return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderMosaicMethod_none(TUnionBitmap *Pattern, int mx, int my) { // convert by celberus 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=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=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=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=0 && juBitmap->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=0 && iuBitmap->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(); return true; fail: if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderMosaicMethod_layer(TUnionBitmap *Pattern, int mx, int my) { 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=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=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=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=0 && juBitmap->Height) { sl = Bitmap->GetScanLine(j)+3*k*w; } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j)+3*k*w; #endif for (i=0; i=0 && iuBitmap->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); return true; fail: if (Bitmap) { if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); ::doDestroy(Bitmap); } 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 = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = 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;iItems[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;iItems[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 defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #endif oldlines=rc; } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintFreeLineLocate(TObject *Sender, HDC formDC) { // HDC formDC; HBRUSH hOldBrush=NULL; HPEN hOldPen=NULL; int nDrawMode; // int NOL=NumberOfLine; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = 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;iCount;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(); delete line; LineList->Remove(line); } First= ((LineListData *)LineList->Last())->Second; } 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;iCount;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){ #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #endif } 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)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintRectangleLocate(TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush=NULL; HPEN hOldPen=NULL; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = 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)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintEllipseLocate(TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush=NULL; HPEN hOldPen=NULL; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = 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)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif 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 = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = 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 = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // #ifdef WEAVE // MoveToEx(formDC, cp.x, iMainImage->Parent->Top-30, NULL); // LineTo(formDC, cp.x, iMainImage->Parent->Top + iMainImage->Parent->Height); // MoveToEx(formDC, iMainImage->Parent->Left-30, cp.y, NULL); // LineTo(formDC, iMainImage->Parent->Left + iMainImage->Parent->Width, cp.y); // #else // 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); // #endif 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); } } //--------------------------------------------------------------------------- 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->isDrawGrid()){ //±×¸®µå¸¦ ±×¸®´Â ¶§´Â.....PaintDirectly¿¡¼­ ±×¸±¶§.. } else { if (iMainImage->OnPaintZoom) iMainImage->OnPaintZoom(iMainImage, dcDst); } if(iMainImage->OnPaintLocate) iMainImage->OnPaintLocate(iMainImage, dcDst); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintVector(HDC dcDst, int px, int py, int vw, int vh) // By GreenFish { // this ¸¦ º¸³»´Â ÀÌÀ¯´Â Á¤È®ÇÑ ÇöÀçÀÇ MainImage¸¦ ÀνÄÇϱâ À§ÇÔÀÌ´Ù thx to k3dogs // if (MainImageForm != this) return; if (px == -1 && py == -1) // FullViewPaintÀÇ ½ÅÈ£ (Æí¹ýÀÌ´Ù..) // convert by celberus VecDraw->FullViewDraw(dcDst, 0, 0, vw, vh); // convert by celberus else VecDraw->LineDraw(dcDst, px, py, this); // Vector Draw } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::InitCurveLine() { VecDraw->bFirst = true; // Curve¸¦ ±×¸±¶§ÀÇ ÀÜ»ó ¾ø¾Ö±â } //--------------------------------------------------------------------------- int __fastcall TMainImageForm::GetLineListCount(void){ return LineList->Count; } //--------------------------------------------------------------------------- void TMainImageForm::ResetDraw(bool repaint) { LineListData *line=NULL; iMainImage->OnPaintLocate=NULL; // LineList->Clear(); ////// 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 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 { #ifdef NOTN3D #else if(Index==gffN3D){ FileName = Format("Noname%d.n3d", OPENARRAY(TVarRec, (Number+1))); MaskPixel = 0x80; PaletteForm->sbProtect->Enabled = false; 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 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->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 Height = MainForm->ClientHeight-MainForm->StatusBar->Height-4; } SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); return EC_NONE; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile(AnsiString dn, AnsiString fn, TGraphicFileFormat ExtIndex, WORD bpp) { int zi, zo; // speed-test RGBQUAD rgb[256]; TPCanvasInfor ci; TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; bool layer = false; HANDLE hFile = INVALID_HANDLE_VALUE; AnsiString ext = LowerCase(ExtractFileExt(fn)); TGraphicFileFormat RealIndex = FindExtension(ext); if(ExtIndex==gffN3D||ExtIndex==gffT3D){ if(MainForm->T3D_Item==false) return false; } if (Palette==NULL || WorkArea==NULL) return false; #ifndef ACADEMY #ifndef N_3D if (ExtIndex==gffT3D) { ec = InitFormFile_T3D(dn, fn, tpfh); // refactoring by celberus if(ec != EC_NONE) goto fail; if(MainForm->T3D_Item){ resetClientSize(); } } else { #endif #endif if ((ec = LoadFromFile(FullPathName(dn,fn), ExtIndex, iMainImage->uBitmap, Palette, ci, layer, bpp))!=EC_NONE) goto fail; if (!ResizePattern(ci, bpp, true)) { ec = EC_MEMORY_LACK; goto fail; } // by celberus FullViewForm->GetZoomRatio(iMainImage, zi, zo); // speed-test if (layer == false) { if (bpp==8) { if (iMainImage->uBitmap->BitsPerPixel==8) { #ifndef ACADEMY if (ExtIndex == gffTEX || ExtIndex == gffTFC || ExtIndex == gffWEA || ExtIndex == gffWAV || ExtIndex == gffKNT) { #else if (ExtIndex == gffTEX) { #endif } else { shiftImageData(); // ¸ðµç pixel °ª¿¡ +2À» ÇØÁØ´Ù. } } else { iMainImage->uBitmap->ColorResolution(8, CRF_OPTIMIZEDPALETTE, NULL, 250); try { shiftPaletteData(rgb); } catch (TPException TPe) { ec = TPe; goto fail; } shiftImageData(); } 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 º¸¿©ÁÖ±â À§ÇØ } } 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¿¡¼­ ¸ðµç°Å ´ÙÇØ¿ä.... } if (bpp == 8) { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); MaskPixel = 0x0F; } else { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); MaskPixel = 0x80; } resetClientSize(); DirName = dn; if (bpp==8 || bpp==16) { StrMove(StrPos(fn.c_str(), "."), ".tex", 4); } else if(ExtIndex==gffN3D) { //N3D_jeegeo StrMove(StrPos(fn.c_str(), "."), ".n3d", 4); } else { StrMove(StrPos(fn.c_str(), "."), ".tfc", 4); } FileName = fn; SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); PaletteForm->DIB256Palette->ChoiceIndex = 2; #ifndef ACADEMY #ifndef N_3D } #endif #endif if(MainForm->ReadN3D==true&&RealIndex!=gffN3D){ // *.tex //*.tfc µîÀ» n3d·Î ÀоîµéÀ̱â À§Çؼ­ //N3D_jeegeo ec = InitFormFile_ToN3D(fn, ci, bpp); if(ec != EC_NONE) goto fail; gff = gffN3D; } else { gff = ExtIndex; //by jeegeo } return EC_NONE; fail: return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile_T3D(AnsiString directoryName, AnsiString fileName, TEXPIAFILEHEADER TPFileHeader) { HANDLE hFile = INVALID_HANDLE_VALUE; TTexpiaBitmap *tempTexpiaBitmap = NULL; TPException ec; int zoomIn, zoomOut; try { if ((tempTexpiaBitmap = new TTexpiaBitmap)==NULL) { 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) { throw EC_MEMORY_LACK;} // if ((ec = LoadFromTexpiaFile(hFile, Palette, TPFileHeader, tb))!=EC_NONE) throw ec; if ((ec = LoadFromTexpiaFile(hFile, Palette, TPFileHeader, tempTexpiaBitmap))!=EC_NONE) throw ec; // convert by celberus if (!ResizePattern(TPFileHeader.CanvasInfor, 24)) { throw EC_MEMORY_LACK; } FullViewForm->GetZoomRatio(iMainImage, zoomIn, zoomOut); // convert by celberus MaskPixel = 0x80; // if (!iMainImage->uBitmap->Copy(tb, SRCCOPY)) { throw EC_RESOURCE_LACK; } need-conversion if (!iMainImage->uBitmap->Copy(tempTexpiaBitmap, SRCCOPY)) { throw EC_RESOURCE_LACK; } // convert by celberus iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); DirName = directoryName; StrMove(StrPos(fileName.c_str(), "."), ".t3d", 4); FileName = fileName; SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); if (Data3D) delete Data3D; if ((Data3D = new TData3D)==NULL) { throw EC_MEMORY_LACK; } // if ((ec = MainMenuForm->LoadFrom3DFile(hFile, TPFileHeader, tb))!=EC_NONE) throw ec; if ((ec = MainMenuForm->LoadFrom3DFile(hFile, TPFileHeader, tempTexpiaBitmap))!=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 tempTexpiaBitmap; } } catch (TPException TPe) { if(tempTexpiaBitmap) { delete tempTexpiaBitmap; } if (hFile!=INVALID_HANDLE_VALUE) { ::doDestroy(Data3D); CloseHandle(hFile); } return TPe; } return EC_NONE; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile_ToN3D(AnsiString fileName, TPCanvasInfor canvasInfor, WORD bitsPerPixel) { StrMove(StrPos(fileName.c_str(), "."), ".n3d", 4); FileName = fileName; //if (!tb->Copy(iMainImage->Bitmap, SRCCOPY)) { ec = EC_RESOURCE_LACK; goto fail; } try { if(bitsPerPixel!=24){ TUnionBitmap *tempBitmap = new TUnionBitmap; if(tempBitmap->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { throw EC_RESOURCE_LACK; } tempBitmap->Copy(0, 0, iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, iMainImage->uBitmap, 0, 0, SRCCOPY); if(!ResizePattern(canvasInfor, 24)) throw EC_MEMORY_LACK; if (!iMainImage->uBitmap->Copy(tempBitmap, SRCCOPY)) { throw EC_RESOURCE_LACK; } //speed-test } MaskPixel = 0x80; iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); PaletteForm->sbProtect->Enabled = false; if(!new3d) new3d = new TN3D(iMainImage); iMainImage->Deactivate(); //·¹ÀÌ¾î ¾÷µ¥ÀÌÆ®¸¦ À§Çؼ­ Æí¹ýÀ¸·Î.. iMainImage->Activate(); N3DMappingForm->Visible = true; N3DMappingForm->UpdateAll(); N3DMappingForm->TreeView->FullExpand(); LayerForm->Visible = false; SetCaption(); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); } catch (TPException TPe) { return TPe; } return EC_NONE; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::shiftPaletteData(RGBQUAD *rgb) { iMainImage->uBitmap->GetColors(0, 256, rgb); Palette->SetNormal(0, 0, 0, 0); for (int i = 0; i < 250; i++) { Palette->SetNormal(i+2, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue); } Palette->SetNormal(255, 255, 255, 255); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::shiftImageData() { bool colorUsed[256] = {false, }; BYTE *pLine; if (!iMainImage->uBitmap->StartScanLine()) { 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++) { *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 int screenWidth = iMainImage->uBitmap->Width+PanelVert->Width; int screenHeight = iMainImage->uBitmap->Height+PanelHorz->Height; if (sbRuler->Down) { screenWidth += Ruler->Thick; screenHeight += Ruler->Thick; } if (screenWidthuBitmap->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 ACADEMY #ifndef N_3D if(MainForm->T3D_Item) { if (Data3D&&new3d==NULL) { int btn = MessageDlg(IDS_MESSAGE_NEWMODEL, mtInformation, TMsgDlgButtons()<Source->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { iMainImage->uBitmap->ConvertColorSpace(csHLS); Data3D->Source->Copy(iMainImage->uBitmap, SRCCOPY); iMainImage->uBitmap->ConvertColorSpace(csRGB); } else { EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); 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 #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 UpdateImage(); ::RepaintColor(); ReviewStatusBar(); // Modify = false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EnlargeCanvas(int w, int h) { BITMAPHANDLE *bh = iMainImage->uBitmap->RgnBitmap->Handle; // convert by celberus RGNXFORM XForm; HRGN rgn=NULL; #ifndef ACADEMY #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()<DIB256Palette->GetBGCOLORREF(iMainImage->uBitmap->BitsPerPixel); CanvasInfor.SetSize(cstFree, w, h); if(new3d) { new3d->Resize(w, h, false); } else { iMainImage->ResizeLayer(w, h, bc); } 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 ACADEMY #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()<Source->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { iMainImage->uBitmap->ConvertColorSpace(csHLS); Data3D->Source->Copy(iMainImage->uBitmap, SRCCOPY); iMainImage->uBitmap->ConvertColorSpace(csRGB); } else {EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return;} } else { Data3D->Source->Resize(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, bc); } } else { if (iMainImage->Mask) { iMainImage->Mask->Resize(w, h, 0); } } } #endif #else if (iMainImage->Mask) { iMainImage->Mask->Resize(w, h, 0); } #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 UpdateImage(); ::RepaintColor(); AllocLineMem(h); ReviewStatusBar(); Modify = false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ResizePattern(TPCanvasInfor &pi, int bpp, bool layer) { RGBQUAD rgb[256]; 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)) 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)) goto fail; ReviewStatusBar(); return true; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::InitMerge(AnsiString FullFileName, TGraphicFileFormat Index) { int i, x, y, bg, UseColor; TPCanvasInfor ci; TRect r; RGBQUAD rgb[256]; AnsiString FileName; 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; iMainImage->SubEnabled = true; if ((TempPalette = new TPalette)==NULL) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: if ((TempBitmap = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadToSelectImage(FullFileName, Index, TempBitmap, TempPalette, ci))!=EC_NONE) goto fail; 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) { if (TempBitmap->BitsPerPixel!=8) { ec = EC_COLOR_OVERFLOW; goto fail; } bg = 0; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; 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(); if (Palette->UseColor+TempPalette->UseColor-2+bg>=252) { ec = EC_COLOR_OVERFLOW; goto fail; } UseColor = Palette->UseColor-1+bg; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; 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]; } 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; goto fail; } if (!iMainImage->SubMask->Create(iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!iMainImage->SubMask->Create(iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height, 1)) { ec = EC_MEMORY_LACK; 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 = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadToSelectImage(FullFileName, Index, TempBitmap, TempPalette, ci))!=EC_NONE) goto fail; 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; } if (Palette->UseColor+TempPalette->UseColor-2>=252) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((TempMask = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } UseColor = Palette->UseColor-1; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { pp = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); for (x=0; xWidth; 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; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } } else { if ((TempMask = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (TempBitmap->BitsPerPixel==8) { TempBitmap->GetColors(0, 256, rgb); if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; 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; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } } break; } iMainImage->InitBackGround(0x01); PenManagerForm->SetColor(Palette); Center.x = iMainImage->SubBitmap->Width/2; Center.y = iMainImage->SubBitmap->Height/2; FullViewForm->stSuper->Enabled = false; MainMenuForm->Item = T_MERGE; MainMenuForm->SubItem = 0; ::RepaintColor(); delete TempPalette; return true; fail: if (TempPalette) { if (TempBitmap) { ::doDestroy(TempMask); delete TempBitmap; TempBitmap = NULL; } delete TempPalette; } ExitMerge(); if (undoSw == true) MainImageForm->Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(ec); return false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ExitMerge() { iMainImage->SubEnabled = false; iMainImage->SubVisible = false; FullViewForm->stSuper->Enabled = true; iMainImage->ExitBackGround(0x01); ::doDestroy(TempBitmap); ::doDestroy(TempMask); VecDraw->ExitMerge(); } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToFile(AnsiString dn, AnsiString fn, TGraphicFileFormat Index, TCompressMethod cm) { 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; #ifdef ACADEMY if (Index == gffTEX) { #else if (Index == gffTEX || Index == gffTFC ) { #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; goto fail; } tpfh.Version = TexVersion('P', 'T', 300); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = iMainImage->uBitmap->BitsPerPixel; //speed-test tpfh.Compress = cm; if (WorkArea->Mask) { src = WorkArea->Range; if ((BtTemp = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; 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; 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; 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; goto fail; } } else { if (!ub->Create(iMainImage->uBitmap->Width, iMainImage->uBitmap->Height, 24)) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!ub->StartScanLine()) { ec = EC_MEMORY_LACK; 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; goto fail; } MakeTexpiaTag(tag, ub, src, 0); ////////////// if (!MainForm->MoSave) { // ¸ðƼºê save½Ã¿¡´Â º¤ÅÍ Ç¥Çö X HDC dcTemp=NULL; if ((dcTemp = tag->CreateDC())==NULL) goto fail; VecDraw->TagDraw(dcTemp, 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; goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, ub)) { ec = EC_FILE_NOT_WRITE; goto fail; } } layer = true; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; if (WorkArea && WorkArea->Mask) { if (!iMainImage->SaveToLayerFile(hFile, WorkArea->Range)) goto fail; } else { if (!iMainImage->SaveToLayerFile(hFile)) goto fail; } delete ub; } 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; goto fail; } if (!iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; 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; goto fail; } MakeTexpiaTag(tag, iMainImage->uBitmap, src); if (!MainForm->MoSave) { HDC dcTemp=NULL; if ((dcTemp = tag->CreateDC())==NULL) goto fail; //speed-test VecDraw->TagDraw(dcTemp, src); 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; goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->uBitmap)) { ec = EC_FILE_NOT_WRITE; goto fail; } } layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; } if (!MainForm->MoSave) { if (!VecDraw->SaveToFile(hFile, 2)) { // Vector File Save~ ec = EC_FILE_NOT_WRITE; goto fail; } } CloseHandle(hFile); delete tag; 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·Î } #ifndef ACADEMY } else if (Index == gffT3D) { if(MainForm->T3D_Item){ 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; goto fail; } // tpfh.Version = TexVersion('P', 'T', 230); //for fit size and point by kjs.... 230 --> 232 tpfh.Version = TexVersion('P', 'T', 232); 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; goto fail; } //speed-test if ((ec = MainMenuForm->SaveTo3DFile(hFile, tpfh, tag, iMainImage->uBitmap)) != EC_NONE) goto fail; CloseHandle(hFile); delete tag; if (dn!=DirectoryItem) { DirName = dn; FileName = fn; } } #ifdef NOTN3D #else } else if(Index == gffN3D) { //N3D_jeegeo if(MainForm->T3D_Item){ if(FileExists(FullPathName(dn, fn))){ if(FileExists(FullPathName(dn, fn)+".bak")){ DeleteFile(FullPathName(dn, fn)+".bak"); } 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; goto fail; } tpfh.Version = TexVersion('P', 'T', 300); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; //iMainImage->uBitmap->BitsPerPixel; tpfh.Compress = cmZLib; //cm; // ¿ë·®ÀÌ Å©¹Ç·Î ±âº» ¾ÐÃàÇÔ //speed-testif(N3DMappingForm==NULL||new3d==NULL) {ec = EC_FILE_NOT_WRITE; goto fail;} //speed-testif ((ec = new3d->SaveToFile(hFile, Palette, tpfh))!= EC_NONE) goto fail; //speed-test if (!VecDraw->SaveToFile(hFile, 2)) { // Vector File Save~ //speed-test ec = EC_FILE_NOT_WRITE; goto fail; //speed-test } CloseHandle(hFile); if (dn!=DirectoryItem){ DirName = dn; FileName = fn;} } #endif #endif } else { if (WorkArea->Mask) { // tpfh.CanvasInfor = CanvasInfor; // tpfh.BitsPerPixel = 24; // tpfh.Compress = cm; src = WorkArea->Range; } else { src.Left = 0; src.Top = 0; src.Right = iMainImage->uBitmap->Width; src.Bottom = iMainImage->uBitmap->Height; } // 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; goto fail; // } // if (!WriteFile(hFile, &tpfh, sizeof(TEXPIAFILEHEADER), &dwWrite, NULL)) return false; 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, TYPE_DISK)) { ec = EC_MEMORY_LACK; goto fail; } if (tb->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); tb->PutColors(0, 256, rgb); } HDC dcDst = tb->CreateDC(); iMainImage->uBitmap->UnionBitBlt(dcDst, 0, 0, tb->Width, tb->Height, src.Left, src.Top, SRCCOPY, false); tb->DeleteDC(dcDst); //if (!tb->CopyFromRect(iMainImage->uBitmap, src.Left, src.Top, SRCCOPY)) { // ec = EC_MEMORY_LACK; goto fail; //} switch (Index) { case gffBMP: if (!tb->SaveToFile(fn, FILE_BMP)) goto fail; break; case gffTIF: if (!tb->SaveToFile(fn, FILE_TIF)) goto fail; break; #ifndef ACADEMY case gffJPG: if ((ec = SaveToJPEG(tb, fn)) != EC_NONE) goto fail; break; case gffPCT: if (!tb->SaveToFile(fn, FILE_PCT)) goto fail; break; case gffPCX: if (!tb->SaveToFile(fn, FILE_PCX)) goto fail; break; case gffPNG: if (!tb->SaveToFile(fn, FILE_PNG)) goto fail; break; case gffPSD: if (!tb->SaveToFile(fn, FILE_PSD)) goto fail; break; case gffRAS: if (!tb->SaveToFile(fn, FILE_RAS)) goto fail; break; case gffTGA: if (!tb->SaveToFile(fn, FILE_TGA)) goto fail; break; case gffEPS: /*//speed-testif (iMainImage->uBitmap->BitsPerPixel == 24) ShowMessage(IDS_MESSAGE_NOTEPSATFULLCOROL); else if (!tb->SaveToFile(fn, FILE_EPS)) goto fail;*/ break; #endif default: goto fail; } DirName = ""; if (iMainImage->uBitmap->BitsPerPixel==8) { StrMove(StrPos(fn.c_str(), "."), ".tex", 4); #ifdef NOTN3D #else } else if(Index == gffN3D) { //N3D_jeegeo StrMove(StrPos(fn.c_str(), "."), ".n3d", 4); #endif } else { StrMove(StrPos(fn.c_str(), "."), ".tfc", 4); } if (dn!=DirectoryItem) FileName = fn; delete tb; } if (dn!=DirectoryItem) SetCaption(); // dn ÀÌ directoryItem°ú °°À¸¸é ¸ðƼºê ÀúÀåÀ̹ǷΠĸ¼Ç X gff = Index; //by jeegeo Modify = false; //2002.10.22. by lhskys ÀúÀå½Ã¿¡ ´Ù½Ã ÀúÀå ¹¯Áö ¾Ê±â. return EC_NONE; fail: if (ub) delete ub; if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; } if (dcSrc) iMainImage->uBitmap->DeleteDC(dcSrc); //speed-test if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; return ec; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SubBitmapPosition(int X, int Y, bool paint) { bool undoSw = false; TPException ec = EC_NONE; TRect dst; RECT r; POINT p = Point(X - Center.x, Y - Center.y); 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){ Undo->SaveData(iMainImage->SubRange); // if ((undoSw = UndoSave(UK_ALL, iMainImage->SubRange)) == false) { ec = EC_MEMORY_LACK; goto fail; } 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); } fail: EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- AnsiString __fastcall TMainImageForm::UnitName(TUnit unit) { if (unit==uDot) return "Dot"; else if (unit==uInch) return "Inch"; else if (unit==uCm) return "Cm"; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::UnitChange(TUnit unit) { CurrentUnit = unit; Ruler->AUnit = CurrentUnit; if (CurrentUnit==uDot) sbUnit->Caption = AnsiString(IDS_UNIT) + " : Dot"; else if (CurrentUnit==uInch) sbUnit->Caption = AnsiString(IDS_UNIT) + " : Inch"; else if (CurrentUnit==uCm) sbUnit->Caption = AnsiString(IDS_UNIT) + " : Cm"; FullViewForm->UnitChange(); MainMenuForm->UnitChange(); ReviewStatusBar(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChange(int zi, int zo, POINT *ptScreen) { POINT ptClient; AnsiString sbZoom; if (zi!=iMainImage->ZoomIn || zo!=iMainImage->ZoomOut) { 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(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ShowZoomText() { AnsiString 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 = "Zomm : 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 (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)) { 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) { 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) && (PenManagerForm->Selector->Number[gp[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)) { 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)) { bp[x + i] = c; lp[x + i] = 0; } } } else { for (int i = 0; i < len; i++) { if (PenManagerForm->Selector->Number[gp[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; if (PenType) { if (cy > y) y = y - ls; if (cx < x) x = x - ls; for (i = y; i < y + len; i++) set_hline(x, 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(x - dx, y + 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) { int PenType, dia, ls, rs, w, h, sw, y, x, r, yyy; double d, r1, r2, xx, yy; TLineData ld; 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; 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*(mex + y)) *(mex + y) = x; } } ld.sy -= ls; ld.ey += rs; if (!(iMainImage->uBitmap->StartScanLine())) goto fail; if (iMainImage->LayerMask) { if (!(iMainImage->LayerMask->StartScanLine())) goto fail; if (bProtect || PenManagerForm->acolor == 2) if (!(iMainImage->BackGround->StartScanLine())) goto fail; } if (iMainImage->Mask) { if (!(iMainImage->Mask->StartScanLine())) goto fail; } 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; 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_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageChange() { FullViewForm->iMainImageChange(); MainMenuForm->iMainImageChange(this); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::WorkAreaChange() { MainForm->UpdateMenuItems(NULL); PenManagerForm->WorkAreaChange(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::WorkAreaReset(bool bUndo) { WorkArea->Reset(bUndo); MainForm->UpdateMenuItems(NULL); PenManagerForm->WorkAreaChange(); } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWholeColor(TChoiceColor *ChoiceColor) { int x, y; Byte *bp=NULL, *lp=NULL; if (!iMainImage->uBitmap->StartScanLine()) return false; if (iMainImage->LayerMask) { if (!iMainImage->LayerMask->StartScanLine()) return false; for (y=0; yuBitmap->Height; y++) { bp = iMainImage->uBitmap->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=0; xuBitmap->Width; x++) { if (lp[x] == 0) ChoiceColor->Add(Palette, *(bp+x)); } } iMainImage->LayerMask->StopScanLine(); } else { for (y=0; yuBitmap->Height; y++) { bp = iMainImage->uBitmap->GetScanLine(y); for (x=0; xuBitmap->Width; x++) { ChoiceColor->Add(Palette, *(bp+x)); } } } iMainImage->uBitmap->StopScanLine(); return true; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWorkAreaColor(TChoiceColor *ChoiceColor) { 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; yRange.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; xRange.right; x++, mp++) { if (*mp && (lp[x] == 0)) { ChoiceColor->Add(Palette, *(bp+x)); } } } } else { for (y=WorkArea->Range.top; yRange.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; xRange.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; yRange.bottom; y++) { bp = iMainImage->uBitmap->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); for (x=WorkArea->Range.left; xRange.right; x++, mp++) { if (*mp) { ChoiceColor->Add(Palette, *(bp+x)); } } } } else { for (y=WorkArea->Range.top; yRange.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); mm = 0x80; bp = iMainImage->uBitmap->GetScanLine(y); for (x=WorkArea->Range.left; xRange.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(); return true; fail: if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); iMainImage->uBitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWholeBackGroundColor(TChoiceColor *ChoiceColor) { // convert by celberus int x, y; Byte *bp=NULL; TUnionBitmap *Bitmap = NULL; if ((Bitmap = iMainImage->Composition())) { if (!Bitmap->StartScanLine()) 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); } return true; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWorkAreaBackGroundColor(TChoiceColor *ChoiceColor) { // convert by celberus 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; yRange.bottom; y++) { bp = Bitmap->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); for (x=WorkArea->Range.left; xRange.right; x++, mp++) { if (*mp) ChoiceColor->Add(Palette, *(bp+x)); } } } else { for (y=WorkArea->Range.top; yRange.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); mm = 0x80; bp = Bitmap->GetScanLine(y); for (x=WorkArea->Range.left; xRange.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); return true; fail: if (Bitmap) { Bitmap->StopScanLine(); ::doDestroy(Bitmap); } WorkArea->Mask->StopScanLine(); return false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::UpdateImage() { TPoint Size; Size.x = Panel->Width*iMainImage->ZoomOut/iMainImage->ZoomIn; Size.y = Panel->Height*iMainImage->ZoomOut/iMainImage->ZoomIn; if (iMainImage->uBitmap->WidthMax = 0; else sbHorz->Max = iMainImage->uBitmap->Width-Size.x; sbHorz->SmallChange = sbHorz->Max/10; sbHorz->LargeChange = sbHorz->Max/5; // sbHorz->SmallChange = Size.x/8; <- ½ºÅ©·Ñ¹Ù À̵¿¹®Á¦ By GreenFish // sbHorz->LargeChange = Size.x/4; ¿©±â¼­´Â FormÀÇ Å©±â·Î °áÁ¤ÇÏ¿´´Âµ¥ if (iMainImage->uBitmap->HeightMax = 0; else sbVert->Max = iMainImage->uBitmap->Height-Size.y; // sbVert->SmallChange = Size.y/8; ¸·¾Æ¹ö¸®°í FormÀÇ Å©±â°¡ ¾Æ´Ñ // sbVert->LargeChange = Size.y/4; Àüü »çÀÌÁî ±âÁØÀ¸·Î ¹Ù²Þ sbVert->SmallChange = sbVert->Max/10; // SmallChange´Â Àüü »çÀÌÁîÀÇ 1/10 sbVert->LargeChange = sbVert->Max/5; // LargeChange´Â Àüü »çÀÌÁîÀÇ 1/5 } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EditCut() { 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; 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) goto fail; if ((ec = SaveToClipboard())!=EC_NONE) 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()) goto fail; if (tlb) { if (!tlb->StartScanLine()) goto fail; if (!WorkArea->Mask->StartScanLine()) goto fail; if (iMainImage->uBitmap->BitsPerPixel==8) { for (y=0; yGetScanLine(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; xPutScanLine(WorkArea->Range.top+y); tb->PutScanLine(WorkArea->Range.top+y); } } else { for (y=0; yGetScanLine(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; xRange.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()) goto fail; if (iMainImage->uBitmap->BitsPerPixel==8) { for (y=0; yGetScanLine(WorkArea->Range.top+y)+WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); for (x=0; xPutScanLine(WorkArea->Range.top+y); } } else { for (y=0; yGetScanLine(WorkArea->Range.top+y)+3*WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>= 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) 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; return; fail: if (WorkArea->Mask) { WorkArea->Mask->StopScanLine(); tb->StopScanLine(); tlb->StopScanLine(); } if (undoSw == true) MainImageForm->Undo->RemoveLast(); Screen->Cursor = cursor; if (ec == EC_NONE) ec = EC_MEMORY_LACK; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EditCopy() { TCursor cursor; TPException ec; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if ((ec = SaveToClipboard())!=EC_NONE) EXCEPTION_MESSAGE_OK(ec); Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EditPaste() { 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; 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; goto fail; } // if ((undoSw = UndoSave(UK_ALL, r)) == false) { ec = EC_MEMORY_LACK; goto fail; } memset(&bh, 0, sizeof(BITMAPHANDLE)); iMainImage->SubEnabled = true; if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } bClipboard = true; if (IsClipboardFormatAvailable(MainForm->ClipboardFormat)) { if ((hMem = GetClipboardData(MainForm->ClipboardFormat))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((cbi = (TClipboardInfo *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; 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; goto fail; } if (L_CopyFromClipboard(MainForm->Handle, &bh)<1) { ec = EC_CLIPBOARD_NOT_READ; 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; goto fail; } if (bh.BitsPerPixel<=8) { if (bh.BitsPerPixel!=8) { if (L_ColorResBitmap(&bh, &bh, 8, CRF_OPTIMIZEDPALETTE, 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; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; 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; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } } } else { ec = EC_BIG_SIZE; goto fail; } L_FreeBitmap(&bh); } else {ec = EC_NO_CLIPBOARDDATA; goto fail;} } 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); } //--------------------------------------------------------------------- TCaptureData *__fastcall TMainImageForm::MakeCapture() { TCaptureData *cd = NULL; if ((cd = new TCaptureData)==NULL) goto fail; cd->Range = WorkArea->Range; if ((cd->Bitmap = new TTexpiaBitmap)==NULL) goto fail; 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 TTexpiaBitmap)==NULL) goto fail; 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; return cd; fail: if (cd) delete cd; 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; rgbPoint = &Palette->ColorData[point]->RGB; rgbBase = &Palette->ColorData[base]->RGB; 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; 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 { 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; } return true; fail: if (Bitmap) delete Bitmap; 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 < iMainImage->uBitmap->CountX * iMainImage->uBitmap->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 = 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) { // convert by celberus bool result; if (iMainImage->LayerList->Count > 1) { result = HeaderYesMethod_layer(Pattern); } else { result = HeaderYesMethod_none(Pattern); } return result; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderUsedColorMethod(TUnionBitmap *Pattern, bool Yes) // convert by celberus { TChoiceColor *ChoiceColor = NULL; int i, j, k, l, row, width, height; short m, n, tab, bot, sbot, tb, t; AnsiString NameStr, Rgbvalue; RGBQUAD rgb[256]; TRect BitRect, StrRect, Re; TCanvas *ca = NULL; TTexpiaBitmap *tempBitmap = NULL; // by celberus TRect tempRect; // by celberus HDC tempDC; // by celberus 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); } width = GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); height = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); if (Yes) { // ComboBoxYesMethod¿¡¼­ »ç¿ë ÇÒ °ª m =100; n =70; bot = 80; sbot = 100; tb = 82; t = 90; } else { // UsedColorMethod¿¡¼­ »ç¿ë ÇÒ °ª m = 120; n = 130; bot = 130; sbot = 160; tb = 135; t = 110; } l = (width-34) / m ; // Pattern Height Á¤Çϱâ row = 1+ChoiceColor->Count / l; height = row*n+60; Pattern->Create(width, height, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); tempBitmap = new TTexpiaBitmap; // by celberus tempBitmap->Create(500, 200, 24); // by celberus ÀÓÀÇÀÇ °ª tempBitmap->FillRect(Rect(0, 0, width, height), clWhite); ca = tempBitmap->CreateCanvas(); // by celberus ca->Font->Size = 10; for (i=0, k = 0; iCount; i++, k++) { if (i%l == 0) { j = i / l; k = 0; } StrRect = Rect(44+k*m, bot+j*n, 34+m+k*m, sbot+j*n); ca->Brush->Color = clWhite; if(RGBnum==false){ switch (ChoiceColor->ColorMap[i]->Kind) { 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 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 0x10: case 0x13: case 0x14: 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 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))); } tab = (t- ca->TextWidth(NameStr)) / 2; // Adjust Center if (tab<0) tab = 0; tempRect.left = 0; tempRect.right = StrRect.right - StrRect.left; // tempRect.top = 0; tempRect.bottom = StrRect.bottom - StrRect.top; // ca->TextRect(tempRect, 44+tab+m*k - StrRect.left, tb+j*n - StrRect.top, NameStr); // by celberus Pattern->UnionBitBlt(ca->Handle, StrRect.left, StrRect.top, StrRect.right - StrRect.left, // StrRect.bottom - StrRect.top, 0, 0, SRCCOPY, true); // by celberus BitBlt(ca->Handle, 0, 0, tempRect.right, tempRect.bottom, NULL, 0, 0, WHITENESS); // ÇϳªÇϳª¾¿ Âï¾îÁÜ } tempBitmap->DeleteCanvas(ca); // tempDC = tempBitmap->CreateDC(); // by celberus // tempBitmap->DeleteDC(tempDC); // for (i=0, k = 0; iCount; i++, k++) { if (i%l == 0) { j = i / l; k = 0; } BitRect = Rect(44+k*m, 30+j*n, 34+m+k*m, bot+j*n); PrintColorChip24(Pattern, BitRect, ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue); } delete ChoiceColor; delete tempBitmap; // by celberus return true; fail: if (ChoiceColor) delete ChoiceColor; return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderMosaicMethod(TUnionBitmap *Pattern, int mx, int my) { bool result; if (iMainImage->LayerList->Count > 1) { result = HeaderMosaicMethod_layer(Pattern, mx, my); } else { result = HeaderMosaicMethod_none(Pattern, mx, my); } return result; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::UndoSave(int k, RECT r) //by linuxjun Undo_Method { Modify = true; if (FullViewForm->Super == sOverlap) FullViewForm->ExitOverlapChange(); // return Undo->Save(k, r, bSave); return Undo->UndoSave(k, r); //by linuxjun Undo_Method } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::UndoSave(int k) //by linuxjun Undo_Method { Modify = true; if (FullViewForm->Super == sOverlap) FullViewForm->ExitOverlapChange(); return Undo->UndoSave(k); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PenChange(void) { PenManagerForm->lColor->Enabled = iMainImage->uBitmap->BitsPerPixel==8; PenManagerForm->eGrade->Enabled = iMainImage->uBitmap->BitsPerPixel==8; if (MainMenuForm->Item == T_NONE) { if (PenManagerForm->Type == PT_MASK) { if (iMainImage->uBitmap->BitsPerPixel == 8) { OnSetHLine = SetHLineMask8; if (PenManagerForm->chDelete->Checked) { MaskPixel = 0x00; } else { MaskPixel = 0x0F; } } else { if (PenManagerForm->chDelete->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->chDelete->Checked) { MaskPixel = 0x00; } else { MaskPixel = 0x0F; } } else { if (PenManagerForm->chDelete->Checked) { OnSetHLine = SetHLineMaskDelete24; MaskPixel = 0x00; } else { OnSetHLine = SetHLineMask24; MaskPixel = 0x80; } } } else { if (iMainImage->uBitmap->BitsPerPixel==8) { OnSetHLine = SetHLine8ColorNo; } else { OnSetHLine = SetHLine24; } } } } //--------------------------------------------------------------------------- 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 ); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer1000ms() { // static int i=0; /*if (!BtnClick)*/ iMainImage->OutlineBitmapRgn(WorkArea->bComplex); // if(i==0&&Active&&iMainImage->CrossLine)iMainImage->Repaint(); // if(i==2)i=0; // i++; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::TimerAutoSave() { AnsiString msg, fn, ext; char *s=NULL; int FileNameLength, last1, last2, last3, last4; char FileIndex1, FileIndex2, FileIndex3, FileIndex4; TGraphicFileFormat gff; #ifdef ACADEMY gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; #else if (iMainImage->uBitmap->BitsPerPixel==8) { gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; } else { #ifndef N_3D if(MainForm->T3D_Item){ if (MainMenuForm->Item == T_3D) { gff = gffT3D; ext = ".t3d"; MainForm->SaveDialog->Filter = "Texpro Textile 3D File (*.t3d)|*.t3d"; } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } #else gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; #endif } #endif if (initsave) { TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Main.ini"); if (IniFile) { MainForm->SaveDialog->InitialDir = IniFile->ReadString("FileManager", "DirectoryName", "C:\\"); delete IniFile; } if (MainForm->SaveDialog->Execute() == mrOk) { //=============================================================== FileNameLength = MainForm->SaveDialog->FileName.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = ext[1]; FileIndex2 = ext[2]; FileIndex3 = ext[3]; FileIndex4 = ext[4]; if((FileIndex1 == MainForm->SaveDialog->FileName[last1]) &&(FileIndex2 == MainForm->SaveDialog->FileName[last2]) && (FileIndex3 == MainForm->SaveDialog->FileName[last3]) &&(FileIndex4 == MainForm->SaveDialog->FileName[last4])){ s = "PASS"; }else s=NULL; }else s=NULL; //=============================================================== // s = AnsiStrScan(MainForm->SaveDialog->FileName.c_str(), '.'); if (s==NULL) fn = MainForm->SaveDialog->FileName+ext; else fn = MainForm->SaveDialog->FileName; 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(DirectoryItem+"\\Environment.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() { if (iMainImage->LayerMask) OverlapChange_layer(); else OverlapChange_none(); } //--------------------------------------------------------------------- void __fastcall TMainImageForm::ChangeLayer() { MainMenuForm->ExitForm(); 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::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) { TransformRegionKind = RegionMethod(X, Y); if (TransformRegionKind) { bRegionDown = true; region = WorkArea->Range; } } //--------------------------------------------------------------------------- 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::iMainImageKeyDown(Word &Key) //added by qe È®´ëÃà¼Ò ´ÜÃàŰ { bool IsEditMode = false; if(TextForm) IsEditMode |= TextForm->Edit->Enabled; if(VectorForm) IsEditMode |= VectorForm->TextBox->Focused(); // Vectorform¿¡¼­ÀÇ Textµµ °í·Á By GreenFish // 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(!IsEditMode){ int Ratio = 0; if((Key == 65) || (Key == 97)){ //'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; } RatioZoom(Ratio); } if((Key == 83) || (Key == 115)){ // '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; } RatioZoom(Ratio); } } } //--------------------------------------------------------------------------- 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() { #ifndef ACADEMY if (AutoRepViewForm) { AutoRepViewForm->WriteIniFile(); ::doDestroy(AutoRepViewForm); //Error } sbAutoRepView->Down = false; #endif } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RedrawingRepeat(bool MaskBmp, bool repaint, bool Draw) { POINT sp, ep; HRGN rgn = NULL; if (Draw) { //========================================= 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 (repaint) iMainImage->Repaint(); #ifndef ACADEMY if (AutoRepViewForm) AutoRepViewForm->ReDrawImage(); #endif } //--------------------------------------------------------------------------- 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 = SelectObject(hDC, GetStockObject(NULL_BRUSH)); clOldBk = SetBkColor(hDC, clWhite); hPen = CreatePen(PS_DASHDOT, 1, clBlack); hOldPen = 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; } //--------------------------------------------------------------------- void __fastcall TMainImageForm::PaintPenLocate(TObject *Sender, HDC formDC,int X, int Y) { HBRUSH hOldBrush=NULL; HPEN hOldPen=NULL, hPen=NULL; int nDrawMode; int ls, rs, left, top, right, bottom; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); hPen = CreatePen(PS_SOLID, 1, clWhite); hOldPen = SelectObject(formDC, hPen); nDrawMode = GetROP2(formDC); SetROP2(formDC, R2_NOT); ls = PenManagerForm->Pen->BasicThick>>1; rs = PenManagerForm->Pen->BasicThick-ls; double ratio=iMainImage->ZoomIn/iMainImage->ZoomOut; if (PenManagerForm->Pen->BasicThick*ratio>5) { left = X-ls*ratio; top = Y-ls*ratio; right = X+rs*ratio+1; bottom = Y+rs*ratio+1; if (PenManagerForm->Pen->Shape) 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); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // External Function //--------------------------------------------------------------------- void __fastcall RepaintImage() { RGBQUAD rgb[256]; if (MainImageForm) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); MainImageForm->iMainImage->ChangeRGBColors(rgb); } MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); //PaletteForm->InitForm(MainImageForm->Palette); #ifndef ACADEMY LayerForm->InitForm(); #endif } } //--------------------------------------------------------------------- void __fastcall RepaintColor() { RGBQUAD rgb[256]; if (MainImageForm) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); MainImageForm->iMainImage->ChangeRGBColors(rgb); } MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); PaletteForm->InitForm(MainImageForm->Palette); #ifndef ACADEMY LayerForm->InitForm(); #endif PenManagerForm->SetColor(MainImageForm->Palette); ColorLibraryForm->View(); #ifndef ACADEMY if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) { if (AutoRepViewForm) AutoRepViewForm->ReDrawImage(); } #endif } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetMaskShow(bool Value) { if (iMainImage->MaskEnabled!=Value) { iMainImage->MaskEnabled = Value; sbMaskShow->Down = Value; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::IsMerge(POINT p) { TUnionBitmap *Bitmap=NULL; // convert by celberus 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 : goto fail; } if (TempBitmap->StartScanLine() == false) goto fail; if (Bitmap->StartScanLine() == false) goto fail; if (iMainImage->SubBitmap->StartScanLine() == false) goto fail; if (iMainImage->SubMask->StartScanLine() == false) goto fail; if (FullViewForm->Super == sGauze) { if (TempMask) { if (TempMask->StartScanLine() == false) goto fail; if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) 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) 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) goto fail; if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) 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) 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(); return; fail: iMainImage->Mask->StopScanLine(); iMainImage->SubMask->StopScanLine(); iMainImage->SubBitmap->StopScanLine(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); // need-conversion FBackGround´Â TexpiaBitmapÀ̰í uBitmapÀº UnionBitmap } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem(int X, int Y) { 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; } return true; fail: 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 = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); if (!IndexColor) IndexColor = clBlack; hPen = CreatePen(psSolid , 1, IndexColor ); hOldPen = 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 = SelectObject(dcMemV, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(dcMemV); if (!IndexColor) IndexColor = clBlack; hPen = CreatePen(psSolid , 1, IndexColor ); hOldPen = SelectObject(dcMemV, hPen); // »ö±ò ¹Ù²Ü¶§ »ç¿ë SetROP2(dcMemV, R2_COPYPEN); for (int i=0 ; iPosition) * 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 ; jParent->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::RulerMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { MainMenuForm->ExitForm(1); if (Button != mbLeft) return; if (X<24 && Y<24) { // ¸ð¼­¸® Ŭ¸¯½Ã Visible on/off Visible1Click (this); return; } if (HIM || VIM) { // À̵¿Áß¿¡ ÀÚ Å¬¸¯½Ã À妽º Á¦°Å Ruler->Cursor = crDefault; HIM = VIM = NULL; iMainImage->Repaint(); IndexSW = false; return; }else { IndexSW = true; } if ((X<24 && VI>=20) || (Y<24 && HI>=20)) return; // 20°³ ³Ñ¾î°¡¸é ±×¸¸! if (X<24) Ruler->Cursor = crHSplit; // By GreenFish if (Y<24) Ruler->Cursor = crVSplit; // ÀÛ¾÷Áß 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::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 TEXTILE 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(AnsiString FullFileName, TGraphicFileFormat Index) //2001.8.29 by lhskys ÀÛ¾÷±¸¿ª save¿¡¼­ { //SubBitmapÀÇ Å©±â¸¦ ÃøÁ¤. TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; TPalette *TempPalette = NULL; if ((TempBitmap = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((TempPalette = new TPalette)==NULL) { ec = EC_MEMORY_LACK; 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; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, TempPalette, tpfh, TempBitmap))!= 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; return true; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); EXCEPTION_MESSAGE_OK(ec); 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) { 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); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::MHdivDrawing2(bool MaskBmp) { 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); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::MHdivDrawing3(bool MaskBmp) { 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); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::MWdivDrawing1(bool MaskBmp) { 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; 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); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::MWdivDrawing2(bool MaskBmp) { 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); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::MWdivDrawing3(bool MaskBmp) { 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; 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); 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); 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); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SubBitmapPositionMC(int X, int Y, bool paint) { 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); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoSaveAs() { AnsiString msg, fn, ext; char *s=NULL; int FileNameLength, last1, last2, last3, last4; char FileIndex1, FileIndex2, FileIndex3, FileIndex4; TGraphicFileFormat gff; #ifdef ACADEMY gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; #else if (iMainImage->uBitmap->BitsPerPixel==8) { gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; } else { #ifndef N_3D if(MainForm->T3D_Item){ if (MainMenuForm->Item == T_3D) { gff = gffT3D; ext = ".t3d"; MainForm->SaveDialog->Filter = "Texpro Textile 3D File (*.t3d)|*.t3d"; } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } #else gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; #endif } #endif MainForm->SaveDialog->InitialDir = "C:\\"; fn = "texprobackup" + ext + ".back"; DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); AutoSaveForm = new TAutoSaveForm(NULL); AutoSaveForm->Update(); AutoSaveToFile(DirName, FileName, gff, MainForm->CompressMethod); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoSavebackupTimer(TObject *Sender) { if (MainImageForm) { // AutoSaveAs(); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormMouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled) { 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); } } */ } //---------------------------------------------------------------------------