//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Clear.h" #include "MainImage.h" #include "Palette.h" #include "Undo.h" #include "Main.h" #include "MainMenu.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_WINDOWIN StringTable[0] #define IDS_WINDOWOUT StringTable[1] #define IDS_BYPEN StringTable[2] //--------------------------------------------------------------------------- TClearForm *ClearForm; //--------------------------------------------------------------------------- __fastcall TClearForm::TClearForm(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *)Owner)->Handle; //============================================================================== StringTable.Create(DirectoryItem, Language, "Clear"); SetSmallFont(Font); SpeedButtonWhole->Caption = IDS_COMMON_WHOLE; SpeedButtonWindowIn->Caption = IDS_WINDOWIN; SpeedButtonWindowOut->Caption = IDS_WINDOWOUT; sbByPen->Caption = IDS_BYPEN; //============================================================================== } //--------------------------------------------------------------------------- void __fastcall TClearForm::FormCreate(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TClearForm::SpeedButtonWholeClick(TObject *Sender) { WholeClear(); } //--------------------------------------------------------------------------- void __fastcall TClearForm::SpeedButtonWindowInClick(TObject *Sender) { WindowIn(); } //--------------------------------------------------------------------------- void __fastcall TClearForm::SpeedButtonWindowOutClick(TObject *Sender) { WindowOut(); } //--------------------------------------------------------------------------- // Public Method //--------------------------------------------------------------------------- void __fastcall TClearForm::InitForm() { ParentHeight = Parent->Height+20; ClientHeight = 54; Parent->Height = ParentHeight+ClientHeight; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { MainImageForm->OnSetHLine = SetHLine8; } else { MainImageForm->OnSetHLine = SetHLine24; } if (MainImageForm->WorkArea->Mask) { SpeedButtonWindowIn->Enabled = true; SpeedButtonWindowOut->Enabled = true; } else { SpeedButtonWindowIn->Enabled = false; SpeedButtonWindowOut->Enabled = false; } // N3D¿¡¼­ ¾²·Á°í ´Ù½Ã¸·À½ // if (MainForm->VLayerItem->Checked) { // button is // sbByPen->Enabled = true; // disable // } else { // except in Layer // sbByPen->Enabled = false; // // } // by jeegeo if(MainImageForm->iMainImage->LayerList->Count > 1)sbByPen->Enabled = true; } //---------------------------------------------------------------------------- void __fastcall TClearForm::SetHLine8(int x, int y, int len, COLORREF c) { Byte *IP, *LP; COLORREF color = PaletteForm->DIB256Palette->GetBGCOLORREF(8); IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+x; if (MainImageForm->iMainImage->LayerMask) { LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y)+x; for (int xx = x; xx < x + len; xx++, IP++, LP++) { *IP = color; *LP = 0xFF; } MainImageForm->iMainImage->LayerMask->PutScanLine(y); } else { for (int xx = x; xx < x + len; xx++, IP++, LP++) { *IP = color; } } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TClearForm::SetHLine24(int x, int y, int len, COLORREF c) { Byte *IP, *LP; COLORREF color = PaletteForm->DIB256Palette->GetBGCOLORREF(24); IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+3*x; if (MainImageForm->iMainImage->LayerMask) { LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y); for (int xx = x; xx < x + len; xx++, IP+=3) { SetPixel24(IP, color); LP[xx >> 3] |= (0x80 >> (xx & 7)); } MainImageForm->iMainImage->LayerMask->PutScanLine(y); } else { for (int xx = x; xx < x + len; xx++, IP+=3) { SetPixel24(IP, color); } } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TClearForm::WholeClear() // ÆË¾÷¸Þ´º¿¡¼­ ¾µ·Á°í ÇÔ¼ö¸¦ ¸¸µë. { // playzzang TCursor cursor; RECT r; COLORREF C; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; r.left = 0; r.top = 0; r.right = MainImageForm->iMainImage->uBitmap->Width; r.bottom = MainImageForm->iMainImage->uBitmap->Height; MainImageForm->UndoSave(UK_ALL, r); if(MainImageForm->iMainImage->LayerList->Count==1){ // PaletteForm->DIB256Palette->ChoiceIndex = 2; ///////by jeegeo PaletteForm->DIB256Palette->UseColor = 2; // } // if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { // C = PaletteForm->DIB256Palette->GetBGCOLORREF(8); // MainImageForm->iMainImage->uBitmap->FillRect(r, C); if (MainImageForm->iMainImage->LayerMask) MainImageForm->iMainImage->LayerMask->FillRect(r, PALETTEINDEX(255)); MainImageForm->iMainImage->uBitmap->SetAllToBlank(); // by celberus MainImageForm->iMainImage->uBitmap->UnloadAll(); // by celberus unload all Çϴ°ÍÀº ºÎºÐÀûÀÎ FillRect¸¦ ÀÇ¹Ì } else { C = PaletteForm->DIB256Palette->GetBGCOLORREF(24); MainImageForm->iMainImage->uBitmap->FillRect(r, C); if (MainImageForm->iMainImage->LayerMask) MainImageForm->iMainImage->LayerMask->FillRect(r, clWhite); } if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); MainImageForm->WorkAreaReset(true); // MainImageForm->iMainImage->uBitmap->SetAllToModified(); // by celberus MainImageForm->iMainImage->isRepaintAll = true; //8.0¿¡¼­ whole clear½Ã repaint ¹®Á¦ ::RepaintImage(); Screen->Cursor = cursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); } //--------------------------------------------------------------------------- void __fastcall TClearForm::WindowIn() // for popmenu by playzzang { TCursor cursor; TPoint Size; TUnionBitmap *bp; // convert by celberus int x, y, sx, sy, ww, hh; Byte *mp, *pp, *lp, mm; bool undoSw; RECT rt, art; COLORREF c; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; rt = MainImageForm->WorkArea->Range; if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rt = MainImageForm->AutoRep_UndoRect(rt); if ((undoSw = MainImageForm->UndoSave(UK_ALL, rt)) == false) goto fail; Size.x = MainImageForm->WorkArea->Range.right-MainImageForm->WorkArea->Range.left; Size.y = MainImageForm->WorkArea->Range.bottom-MainImageForm->WorkArea->Range.top; bp = MainImageForm->iMainImage->uBitmap; sx = MainImageForm->WorkArea->Range.left; sy = MainImageForm->WorkArea->Range.top; if (!bp->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) goto fail; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { c = PaletteForm->DIB256Palette->GetBGCOLORREF(8); for (y=0; yGetScanLine(sy + y) + sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(sy + y) + sx; for (x=0; xPutScanLine(sy + y); MainImageForm->iMainImage->LayerMask->PutScanLine(sy + y); } } else { c = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y=0; yGetScanLine(sy + y)+3*sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(sy + y); mm = 0x80; for (x=0; x>3)) |= (0x80 >> ((sx+x)&7)); } if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } bp->PutScanLine(sy + y); MainImageForm->iMainImage->LayerMask->PutScanLine(sy + y); } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { c = PaletteForm->DIB256Palette->GetBGCOLORREF(8); for (y=0; yGetScanLine(sy + y) + sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); for (x=0; xPutScanLine(sy + y); } } else { c = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y=0; yGetScanLine(sy + y)+3*sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>= 1; } bp->PutScanLine(sy + y); } } } MainImageForm->WorkArea->Mask->StopScanLine(); bp->StopScanLine(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); ::RepaintImage(); Screen->Cursor = cursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); return; fail: MainImageForm->WorkArea->Mask->StopScanLine(); bp->StopScanLine(); Screen->Cursor = cursor; if (undoSw) MainImageForm->Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TClearForm::WindowOut() // for popmenu by playzzang { //ÀÛ¾÷±¸¿ª ¹Ù±ù ºÎºÐÀ» Áö¿ì´Â ·çƾ //* BeConverted by linuxjun Don't Forget!! Undo_Method TCursor cursor; TPoint Size; RECT r, Dst; int x, y, sx, sy; Byte *mp, *pp, *pBitmap, *lp, *pMask, mm; bool undoSw; TUnionBitmap *mbp, *LMbmp, *Bitmap, *LayerMask; // convert by celberus RGBQUAD rgb[256]; THistoryData *ud; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; mbp = MainImageForm->iMainImage->uBitmap; LMbmp = MainImageForm->iMainImage->LayerMask; r.left = 0; r.top = 0; r.right = mbp->Width; r.bottom = mbp->Height; if ((undoSw = MainImageForm->UndoSave(UK_ALL, r))== false) goto fail; Size.x = MainImageForm->WorkArea->Range.right-MainImageForm->WorkArea->Range.left; Size.y = MainImageForm->WorkArea->Range.bottom-MainImageForm->WorkArea->Range.top; sx = MainImageForm->WorkArea->Range.left; sy = MainImageForm->WorkArea->Range.top; // ud = Undo->Last; // ud = MainImageForm->Undo->GetLast(); // Bitmap = ud->Bitmap; Bitmap = new TUnionBitmap; if(LMbmp) { LayerMask = new TUnionBitmap; }else{ LayerMask = NULL; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { MainImageForm->iMainImage->uBitmap->GetColors(0, 256, rgb); if(!Bitmap->Create(Size.x, Size.y, 8, rgb)) goto fail; Bitmap->Copy(0,0,Size.x,Size.y,MainImageForm->iMainImage->uBitmap,sx,sy,SRCCOPY); if(LMbmp){ MainImageForm->iMainImage->LayerMask->GetColors(0, 256, rgb); if(!LayerMask->Create(Size.x, Size.y, 8, rgb)) goto fail; LayerMask->Copy(0,0,Size.x,Size.y,MainImageForm->iMainImage->LayerMask,sx,sy,SRCCOPY); } }else { if(!Bitmap->Create(Size.x, Size.y, 24)) goto fail; Bitmap->Copy(0,0,Size.x,Size.y,MainImageForm->iMainImage->uBitmap,sx,sy,SRCCOPY); if(LMbmp){ if(!LayerMask->Create(Size.x, Size.y, 1)) goto fail; LayerMask->Copy(0,0,Size.x,Size.y,MainImageForm->iMainImage->LayerMask,sx,sy,SRCCOPY); } } Dst = Rect(0, 0, mbp->Width, mbp->Height); if (LMbmp) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); LMbmp->FillRect(Dst, PALETTEINDEX(255)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (!LMbmp->StartScanLine()) goto fail; if (!LayerMask->StartScanLine()) goto fail; for (y = 0; y < Size.y; y++) { pp = mbp->GetScanLine(sy + y) + sx; lp = LMbmp->GetScanLine(sy + y) + sx; pBitmap = Bitmap->GetScanLine(y); pMask = LayerMask->GetScanLine(y); mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, pBitmap++, mp++, lp++, pMask++) { if (*mp) { *pp = *pBitmap; *lp = *pMask; } } mbp->PutScanLine(sy + y); LMbmp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); LMbmp->StopScanLine(); LayerMask->StopScanLine(); } else { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); LMbmp->FillRect(Dst, clWhite); if (!mbp->StartScanLine()) goto fail; if (!LMbmp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!LayerMask->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y=0; yGetScanLine(sy + y) + 3*sx; pBitmap = Bitmap->GetScanLine(y); pMask = LayerMask->GetScanLine(y); lp = LMbmp->GetScanLine(sy + y); mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>3)) & (0x80 >> ((sx+x) & 7))) { if (*(pMask + ((x)>>3)) & (0x80 >> ((x) & 7))) { *(lp + ((sx+x)>>3)) |= (0x80 >> ((sx+x) & 7)); } else { *(lp + ((sx+x)>>3)) &= ~(0x80 >> ((sx+x) & 7)); } } if (mm == 1) { mp ++; mm = 0x80; } else mm >>= 1; } mbp->PutScanLine(sy + y); LMbmp->PutScanLine(sy + y); } LMbmp->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); LayerMask->StopScanLine(); } } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y = 0; y < Size.y; y++) { pp = mbp->GetScanLine(sy + y) + sx; pBitmap = Bitmap->GetScanLine(y); mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, pBitmap++, mp++) { if (*mp) *pp = *pBitmap; } mbp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); } else { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y=0; yGetScanLine(sy + y) + 3*sx; pBitmap = Bitmap->GetScanLine(y); mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>= 1; } mbp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); } } // ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); ::RepaintImage(); Screen->Cursor = cursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); if(Bitmap)delete Bitmap; if(LayerMask) delete LayerMask; return; fail: MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); Screen->Cursor = cursor; // if (undoSw) Undo->RemoveLast(); if(Bitmap)delete Bitmap; if(LayerMask) delete LayerMask; if (undoSw) MainImageForm->Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); /* BeConverted by linuxjun Don't Forget!! Undo_Method TCursor cursor; TPoint Size; RECT r, Dst; int x, y, sx, sy; Byte *mp, *pp, *pBitmap, *lp, *pMask, mm; bool undoSw; TUnionBitmap *mbp, *LMbmp, *Bitmap, *LayerMask; // convert by celberus RGBQUAD rgb[256]; THistoryData *ud; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; mbp = MainImageForm->iMainImage->uBitmap; LMbmp = MainImageForm->iMainImage->LayerMask; r.left = 0; r.top = 0; r.right = mbp->Width; r.bottom = mbp->Height; if ((undoSw = MainImageForm->UndoSave(UK_ALL, r))== false) goto fail; Size.x = MainImageForm->WorkArea->Range.right-MainImageForm->WorkArea->Range.left; Size.y = MainImageForm->WorkArea->Range.bottom-MainImageForm->WorkArea->Range.top; sx = MainImageForm->WorkArea->Range.left; sy = MainImageForm->WorkArea->Range.top; // ud = Undo->Last; ud = MainImageForm->Undo->GetLast(); // Bitmap = ud->Bitmap; Bitmap = ud->uBitmap; LayerMask = ud->LayerMask; Dst = Rect(0, 0, mbp->Width, mbp->Height); if (LMbmp) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); LMbmp->FillRect(Dst, PALETTEINDEX(255)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (!LMbmp->StartScanLine()) goto fail; if (!LayerMask->StartScanLine()) goto fail; for (y = 0; y < Size.y; y++) { pp = mbp->GetScanLine(sy + y) + sx; lp = LMbmp->GetScanLine(sy + y) + sx; pBitmap = Bitmap->GetScanLine(sy + y) + sx; pMask = LayerMask->GetScanLine(sy + y) + sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, pBitmap++, mp++, lp++, pMask++) { if (*mp) { *pp = *pBitmap; *lp = *pMask; } } mbp->PutScanLine(sy + y); LMbmp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); LMbmp->StopScanLine(); LayerMask->StopScanLine(); } else { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); LMbmp->FillRect(Dst, clWhite); if (!mbp->StartScanLine()) goto fail; if (!LMbmp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!LayerMask->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y=0; yGetScanLine(sy + y) + 3*sx; pBitmap = Bitmap->GetScanLine(sy + y) + 3*sx; pMask = LayerMask->GetScanLine(sy + y); lp = LMbmp->GetScanLine(sy + y); mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>3)) & (0x80 >> ((sx+x) & 7))) { *(lp + ((sx+x)>>3)) |= (0x80 >> ((sx+x) & 7)); } else { *(lp + ((sx+x)>>3)) &= ~(0x80 >> ((sx+x) & 7)); } } if (mm == 1) { mp ++; mm = 0x80; } else mm >>= 1; } mbp->PutScanLine(sy + y); LMbmp->PutScanLine(sy + y); } LMbmp->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); LayerMask->StopScanLine(); } } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y = 0; y < Size.y; y++) { pp = mbp->GetScanLine(sy + y) + sx; pBitmap = Bitmap->GetScanLine(sy + y) + sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, pBitmap++, mp++) { if (*mp) *pp = *pBitmap; } mbp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); } else { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y=0; yGetScanLine(sy + y) + 3*sx; pBitmap = Bitmap->GetScanLine(sy + y)+3*sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>= 1; } mbp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); } } // ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); ::RepaintImage(); Screen->Cursor = cursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); return; fail: MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); Screen->Cursor = cursor; // if (undoSw) Undo->RemoveLast(); if (undoSw) MainImageForm->Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); /* BeConverted by linuxjun Don't Forget!! Undo_Method TCursor cursor; TPoint Size; RECT r, Dst; int x, y, sx, sy; Byte *mp, *pp, *pBitmap, *lp, *pMask, mm; bool undoSw; TUnionBitmap *mbp, *LMbmp, *Bitmap, *LayerMask; // convert by celberus RGBQUAD rgb[256]; THistoryData *ud; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; mbp = MainImageForm->iMainImage->uBitmap; LMbmp = MainImageForm->iMainImage->LayerMask; r.left = 0; r.top = 0; r.right = mbp->Width; r.bottom = mbp->Height; if ((undoSw = MainImageForm->UndoSave(UK_ALL, r))== false) goto fail; Size.x = MainImageForm->WorkArea->Range.right-MainImageForm->WorkArea->Range.left; Size.y = MainImageForm->WorkArea->Range.bottom-MainImageForm->WorkArea->Range.top; sx = MainImageForm->WorkArea->Range.left; sy = MainImageForm->WorkArea->Range.top; ud = Undo->Last; Bitmap = ud->Bitmap; LayerMask = ud->LayerMask; Dst = Rect(0, 0, mbp->Width, mbp->Height); if (LMbmp) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); LMbmp->FillRect(Dst, PALETTEINDEX(255)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (!LMbmp->StartScanLine()) goto fail; if (!LayerMask->StartScanLine()) goto fail; for (y = 0; y < Size.y; y++) { pp = mbp->GetScanLine(sy + y) + sx; lp = LMbmp->GetScanLine(sy + y) + sx; pBitmap = Bitmap->GetScanLine(sy + y) + sx; pMask = LayerMask->GetScanLine(sy + y) + sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, pBitmap++, mp++, lp++, pMask++) { if (*mp) { *pp = *pBitmap; *lp = *pMask; } } mbp->PutScanLine(sy + y); LMbmp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); LMbmp->StopScanLine(); LayerMask->StopScanLine(); } else { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); LMbmp->FillRect(Dst, clWhite); if (!mbp->StartScanLine()) goto fail; if (!LMbmp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!LayerMask->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y=0; yGetScanLine(sy + y) + 3*sx; pBitmap = Bitmap->GetScanLine(sy + y) + 3*sx; pMask = LayerMask->GetScanLine(sy + y); lp = LMbmp->GetScanLine(sy + y); mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>3)) & (0x80 >> ((sx+x) & 7))) { *(lp + ((sx+x)>>3)) |= (0x80 >> ((sx+x) & 7)); } else { *(lp + ((sx+x)>>3)) &= ~(0x80 >> ((sx+x) & 7)); } } if (mm == 1) { mp ++; mm = 0x80; } else mm >>= 1; } mbp->PutScanLine(sy + y); LMbmp->PutScanLine(sy + y); } LMbmp->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); LayerMask->StopScanLine(); } } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y = 0; y < Size.y; y++) { pp = mbp->GetScanLine(sy + y) + sx; pBitmap = Bitmap->GetScanLine(sy + y) + sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); for (x = 0; x < Size.x; x++, pp++, pBitmap++, mp++) { if (*mp) *pp = *pBitmap; } mbp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); } else { mbp->FillRect(Dst, PaletteForm->DIB256Palette->GetBGCOLORREF(24)); if (!mbp->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; for (y=0; yGetScanLine(sy + y) + 3*sx; pBitmap = Bitmap->GetScanLine(sy + y)+3*sx; mp = (Byte *)MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>= 1; } mbp->PutScanLine(sy + y); } MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); } } ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); ::RepaintImage(); Screen->Cursor = cursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); return; fail: MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); mbp->StopScanLine(); Screen->Cursor = cursor; if (undoSw) Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ }