//--------------------------------------------------------------------------- #include #pragma hdrstop #include "LogData.h" #include "Clear.h" #include "MainImage.h" #include "Palette.h" #include "Undo.h" #include "Main.h" #include "MainMenu.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzButton" #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); rzbtWhole->Caption = IDS_COMMON_WHOLE; rzbtWindowIn->Caption = IDS_WINDOWIN; rzbtWindowOut->Caption = IDS_WINDOWOUT; rzbtByPen->Caption = IDS_BYPEN; //============================================================================== MakeMenuHintByShortcut(); } //--------------------------------------------------------------------------- // Public Method //--------------------------------------------------------------------------- void __fastcall TClearForm::InitForm() { BEGIN_LOG("Clear"); /// 각 Form들 독립적으로 관리하기 위해 주석처리 //ParentHeight = Parent->Height+20; ClientHeight = 50; /// 각 Form들 독립적으로 관리하기 위해 주석처리 //Parent->Height = ParentHeight+ClientHeight; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { MainImageForm->OnSetHLine = SetHLine8; } else { MainImageForm->OnSetHLine = SetHLine24; } if (MainImageForm->WorkArea->Mask) { rzbtWindowIn->Enabled = true; rzbtWindowOut->Enabled = true; } else { rzbtWindowIn->Enabled = false; rzbtWindowOut->Enabled = false; } // N3D¿¡¼­ ¾²·p렴ٽø·= if (MainForm->VLayerItem->Checked) { // button is rzbtByPen->Enabled = true; // disable } else { // except in Layer rzbtByPen->Enabled = false; // } // by jeegeo if(MainImageForm->iMainImage->LayerList->Count > 1)rzbtByPen->Enabled = true; END_LOG; } //---------------------------------------------------------------------------- void __fastcall TClearForm::SetHLine8(int x, int y, int len, COLORREF c) { BEGIN_LOG("Clear"); 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); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TClearForm::SetHLine24(int x, int y, int len, COLORREF c) { BEGIN_LOG("Clear"); 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); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TClearForm::WholeClear() // 팝업메뉴에서 쓸려고 함수를 만듬. { // playzzang BEGIN_LOG("Clear"); TCursor cursor; RECT r; COLORREF C; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; bool bReflection = false; if (MainImageForm->iMainImage->Reflection && MainImageForm->reflection){ bReflection = true; r.left = MainImageForm->reflection->BitmapRange.left; r.top = MainImageForm->reflection->BitmapRange.top; r.right = MainImageForm->reflection->BitmapRange.right; r.bottom = MainImageForm->reflection->BitmapRange.bottom; 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) { if (MainImageForm->iMainImage->LayerMask) MainImageForm->iMainImage->LayerMask->FillRect(r, PALETTEINDEX(255)); MainImageForm->iMainImage->uBitmap->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); } else { C = PaletteForm->DIB256Palette->GetBGCOLORREF(24); MainImageForm->iMainImage->uBitmap->FillRect(r, C); if (MainImageForm->iMainImage->LayerMask) MainImageForm->iMainImage->LayerMask->FillRect(r, clWhite); } } else { 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) { if (MainImageForm->iMainImage->LayerMask) MainImageForm->iMainImage->LayerMask->FillRect(r, PALETTEINDEX(255)); MainImageForm->iMainImage->uBitmap->SetAllToBlank(); // by celberus sorry MainImageForm->iMainImage->uBitmap->UnloadAll(); // by celberus unload all ȏ´°΀º ºκр�illRect¸¦ G¹ʍ } 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); MainForm->UpdateMenuItems(NULL); if (!bReflection) MainImageForm->iMainImage->isRepaintAll = true; //8.0¿¡¼­ whole clear½`repaint ¹®f ::RepaintImage(); Screen->Cursor = cursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TClearForm::WindowIn() // for popmenu by playzzang { BEGIN_LOG("Clear"); // added by maxleo21c (05.04.08) MainMenuForm->ClearWindowIn(); /* 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); */ END_LOG; } //--------------------------------------------------------------------------- void __fastcall TClearForm::WindowOut() // for popmenu by playzzang { BEGIN_LOG("Clear"); if (MainImageForm->iMainImage->Reflection && MainImageForm->reflection){ Reflection_WindowOut(); END_LOG; return; } 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; TPException ec = EC_NONE; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; mbp = MainImageForm->iMainImage->uBitmap; LMbmp = MainImageForm->iMainImage->LayerMask; sx = MainImageForm->WorkArea->Range.left; sy = MainImageForm->WorkArea->Range.top; r.left = 0; r.top = 0; r.right = mbp->Width; r.bottom = mbp->Height; if ((undoSw = MainImageForm->UndoSave(UK_ALL, r))== false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Size.x = MainImageForm->WorkArea->Range.right-MainImageForm->WorkArea->Range.left; Size.y = MainImageForm->WorkArea->Range.bottom-MainImageForm->WorkArea->Range.top; 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)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!LMbmp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!LMbmp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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; END_LOG; 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); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TClearForm::Reflection_WindowOut() { BEGIN_LOG("Clear"); TCursor cursor; TPoint Size; RECT r; 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; TPException ec = EC_NONE; MainMenuForm->showClear = false; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; mbp = MainImageForm->iMainImage->uBitmap; LMbmp = MainImageForm->iMainImage->LayerMask; RECT rt; POINT pts = MainImageForm->reflection->FindOriginalPos(MainImageForm->WorkArea->Range.left, MainImageForm->WorkArea->Range.top); POINT pte = MainImageForm->reflection->FindOriginalPos(MainImageForm->WorkArea->Range.right, MainImageForm->WorkArea->Range.bottom); rt.left = min(pts.x, pte.x); rt.top = min(pts.y, pte.y); rt.right = max(pts.x, pte.x); rt.bottom = max(pts.y, pte.y); sx = rt.left; sy = rt.top; r.left = MainImageForm->reflection->BitmapRange.left; r.top = MainImageForm->reflection->BitmapRange.top; r.right = MainImageForm->reflection->BitmapRange.right; r.bottom = MainImageForm->reflection->BitmapRange.bottom; TTexpiaBitmap *WaMask = new TTexpiaBitmap; HDC dcWaMask = NULL, dcMask = NULL; int width = MainImageForm->WorkArea->Mask->Width; int height = MainImageForm->WorkArea->Mask->Height; if (MainImageForm->WorkArea->Mask->BitsPerPixel==8){ MainImageForm->WorkArea->Mask->GetColors(0, 256, rgb); WaMask->Create(MainImageForm->WorkArea->Mask->Width, MainImageForm->WorkArea->Mask->Height, 8, rgb); } else { WaMask->Create(MainImageForm->WorkArea->Mask->Width, MainImageForm->WorkArea->Mask->Height, 1); } dcWaMask = WaMask->CreateDC(); dcMask = MainImageForm->WorkArea->Mask->CreateDC(); if (MainImageForm->reflection->Direction == D_LR && MainImageForm->reflection->WorkSide == D_LEFT){ StretchBlt(dcWaMask, width, 0, width * (-1), height, dcMask, 0, 0, width, height, SRCCOPY); } else if (MainImageForm->reflection->Direction == D_TB && MainImageForm->reflection->WorkSide == D_TOP){ StretchBlt(dcWaMask, 0, height, width, height* (-1), dcMask, 0, 0, width, height, SRCCOPY); } else { StretchBlt(dcWaMask, 0, 0, MainImageForm->WorkArea->Mask->Width, MainImageForm->WorkArea->Mask->Height, dcMask, 0, 0, MainImageForm->WorkArea->Mask->Width, MainImageForm->WorkArea->Mask->Height, SRCCOPY); } DeleteDC(dcWaMask); DeleteDC(dcMask); if ((undoSw = MainImageForm->UndoSave(UK_ALL, r))== false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Size.x = MainImageForm->WorkArea->Range.right-MainImageForm->WorkArea->Range.left; Size.y = MainImageForm->WorkArea->Range.bottom-MainImageForm->WorkArea->Range.top; if (LMbmp) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { COLORREF color = PaletteForm->DIB256Palette->GetBGCOLORREF(8); COLORREF mcolor = PALETTEINDEX(255); if (!mbp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!WaMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!LMbmp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } int j = 0; for (int y = r.top; y < r.bottom; y++){ if (y >= sy && y < sy + Size.y){ pp = mbp->GetScanLine(y); lp = LMbmp->GetScanLine(y); mp = (Byte *)WaMask->GetScanLine(j); for (int x = r.left; x < r.right; x++){ if (x >= sx && x < sx + Size.x){ if (*mp){ // } else { pp[x] = color; lp[x] = mcolor; } mp++; } else { pp[x] = color; lp[x] = mcolor; } } j++; } else { pp = mbp->GetScanLine(y); lp = LMbmp->GetScanLine(y); for (x = r.left; x < r.right; x++) { pp[x] = color; lp[x] = mcolor; } } mbp->PutScanLine(y); LMbmp->PutScanLine(y); } WaMask->StopScanLine(); mbp->StopScanLine(); LMbmp->StopScanLine(); } else { COLORREF color = PaletteForm->DIB256Palette->GetBGCOLORREF(24); COLORREF mcolor = clWhite; if (!mbp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!LMbmp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!WaMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } int j = 0; for (int y = r.top; y < r.bottom; y++){ pp = mbp->GetScanLine(y); lp = LMbmp->GetScanLine(y); if (y >= sy && y < sy + Size.y){ mp = (Byte *)WaMask->GetScanLine(j); mm = 0x80; for (int x = r.left; x < r.right; x++){ if (x >= sx && x <= sx + Size.x){ if (*mp & mm){ // } else { pp[x*3] = color >> 16 & 0xFF; pp[x*3+1] = color >> 8 & 0xFF; pp[x*3+2] = color & 0xFF; *(lp + (x>>3)) &= ~(0x80 >> (x & 7)); } if (mm == 1) { mm = 0x80; mp++; } else mm >>= 1; } else { pp[x*3] = color >> 16 & 0xFF; pp[x*3+1] = color >> 8 & 0xFF; pp[x*3+2] = color & 0xFF; *(lp + (x>>3)) &= ~(0x80 >> (x & 7)); } } j++; } else { for (int x = r.left; x < r.right; x++) { pp[x*3] = color >> 16 & 0xFF; pp[x*3+1] = color >> 8 & 0xFF; pp[x*3+2] = color & 0xFF; *(lp + (x>>3)) &= ~(0x80 >> (x & 7)); } } mbp->PutScanLine(y); LMbmp->PutScanLine(y); } LMbmp->StopScanLine(); WaMask->StopScanLine(); mbp->StopScanLine(); } } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { COLORREF color = PaletteForm->DIB256Palette->GetBGCOLORREF(8); if (!mbp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!WaMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } int j = 0; for (int y = r.top; y < r.bottom; y++){ pp = mbp->GetScanLine(y); if (y >= sy && y < sy + Size.y){ mp = (Byte *)WaMask->GetScanLine(j); for (int x = r.left; x < r.right; x++){ if (x >= sx && x < sx + Size.x){ if (*mp){ // } else pp[x] = color; mp++; } else { pp[x] = color; } } j++; } else { for (int x = r.left; x < r.right; x++){ pp[x] = color; } } mbp->PutScanLine(y); } WaMask->StopScanLine(); mbp->StopScanLine(); } else { COLORREF color = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (!mbp->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!WaMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } int j = 0; for (int y = r.top; y < r.bottom; y++){ pp = mbp->GetScanLine(y); if (y >= sy && y < sy + Size.y){ mp = (Byte *)WaMask->GetScanLine(j); mm = 0x80; for (int x = r.left; x < r.right; x++){ if (x >= sx && x <= sx + Size.x){ if (*mp & mm){ } else { pp[x*3] = color >> 16 & 0xFF; pp[x*3+1] = color >> 8 & 0xFF; pp[x*3+2] = color & 0xFF; } if (mm == 1) { mm = 0x80; mp++; } else mm >>= 1; } else { pp[x*3] = color >> 16 & 0xFF; pp[x*3+1] = color >> 8 & 0xFF; pp[x*3+2] = color & 0xFF; } } j++; } else { for (int x = r.left; x < r.right; x++){ pp[x*3] = color >> 16 & 0xFF; pp[x*3+1] = color >> 8 & 0xFF; pp[x*3+2] = color & 0xFF; } } mbp->PutScanLine(y); } WaMask->StopScanLine(); mbp->StopScanLine(); } } delete WaMask; // 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; END_LOG; 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); END_LOG; } //--------------------------------------------------------------------------- // added by maxleo21c (05.04.07) void __fastcall TClearForm::iMainImageKeyDown(WORD Key, TShiftState Shift) { if (Key == '1') { WholeClear(); } else if (Key == '2') { if (rzbtWindowIn->Enabled) WindowIn(); } else if (Key == '3') { if (rzbtByPen->Enabled) ; } else if (Key == '4') { if (rzbtWindowOut->Enabled) WindowOut(); } } //--------------------------------------------------------------------------- void __fastcall TClearForm::Whole1Click(TObject *Sender) { TSpeedButton *sp = (TSpeedButton *)Sender; switch(sp->Tag){ case 1 : WholeClear(); break; case 2 : WindowIn(); break; case 3 : WindowOut(); break; } } //--------------------------------------------------------------------------- void __fastcall TClearForm::ClearPopupMenuPopup(TObject *Sender) { if (MainImageForm->WorkArea->Mask) { WindowIn1->Enabled = true; WindowOut1->Enabled = true; } else { WindowIn1->Enabled = false; WindowOut1->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TClearForm::MakeMenuHintByShortcut() { BEGIN_LOG(""); rzbtWhole->Hint = TexActionManager->GetHint("Clear", "Whole"); rzbtWindowIn->Hint = TexActionManager->GetHint("Clear", "WorkAreaIn"); rzbtWindowOut->Hint = TexActionManager->GetHint("Clear", "WorkAreaOut"); rzbtByPen->Hint = TexActionManager->GetHint("Clear", "ByPen"); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TClearForm::ExecuteHotKey(String command) { if (command == "Whole") { WholeClear(); } else if (command == "WorkAreaIn") { if (rzbtWindowIn->Enabled == true) WindowIn(); } else if (command == "WorkAreaOut") { if (rzbtWindowOut->Enabled == true) WindowOut(); } else if (command == "ByPen") { if (rzbtByPen->Enabled == true) rzbtByPen->Down = true; } } //--------------------------------------------------------------------------- void __fastcall TClearForm::rzbtWholeClick(TObject *Sender) { WholeClear(); } //--------------------------------------------------------------------------- void __fastcall TClearForm::rzbtWindowInClick(TObject *Sender) { WindowIn(); } //--------------------------------------------------------------------------- void __fastcall TClearForm::rzbtWindowOutClick(TObject *Sender) { WindowOut(); } //--------------------------------------------------------------------------- void __fastcall TClearForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //---------------------------------------------------------------------------