//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Undo_F.h" #include "MainImage.h" #include "Palette.h" #include "Fullview.h" #include "Undo.h" //#include "MainMenu.h" //lhskys shifta¸¦ ¾²±â À§ÇØ shifta ´Â »ö¹Ù²Ù±â Ææ¿¡¼­ shift¿Í ¸¶¿ì½º¿ÞÂÊÀ» Ŭ¸¯ÇßÀ»¶§¸¦ ³ªÅ¸³¿ #include "LogData.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzEdit" #pragma link "RzSpnEdt" #pragma link "RzButton" #pragma link "RzRadChk" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_PEN StringTable[0] #define IDS_MAXIMUMCOUNT StringTable[1] #define IDS_NUMBER StringTable[2] #define IDS_LAST StringTable[3] #define IDS_STACK StringTable[4] #define IDS_SWAP StringTable[5] //--------------------------------------------------------------------------- TUndoForm *UndoForm; //--------------------------------------------------------------------------- __fastcall TUndoForm::TUndoForm(TComponent* Owner) : TForm(Owner) { BEGIN_LOG(""); //=========================== 2001.3.27 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è //================================================ StringTable.Create(DirectoryBin, Language, "Undo"); SetSmallFont(Font); // SetSmallFont(Panel1->Font); // SetSmallFont(Panel2->Font); // SetSmallFont(UndoPanel->Font); SetSmallFont(Label1->Font); SetSmallFont(Label2->Font); SetSmallFont(Label3->Font); SetSmallFont(LDelLabel->Font); UndoAll->Caption = IDS_COMMON_WHOLE; UndoPen->Caption = IDS_PEN; Label1->Caption = IDS_MAXIMUMCOUNT; Label2->Caption = IDS_NUMBER; Label3->Caption = IDS_COMMON_DELETE; LDelLabel->Caption = IDS_LAST; BitBtn2->Caption = IDS_COMMON_RUN; //================================================ // UndoCount = Undo->Maximum; //lhskys UndoCount = ÃʱâÈ­ bPenUndoUse = false; //================================ END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::FormCreate(TObject *Sender) { // //BitBtn1->Visible = false; // By GreenFish ÀÌÀüÀÇ Undo ¹öư º¸Á¸ //LUndoState->Visible = false; //Label5->Visible = false; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::LUndoStateClick(TObject *Sender) { /* BEGIN_LOG(""); LUndoState->Caption = IDS_SWAP; //<-------------by linuxjun Undo_Method------------->// Review(); END_LOG; */ } //--------------------------------------------------------------------------- void __fastcall TUndoForm::LDelLabelMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { /* Ææ¾ðµÎ¿¡¼­ »èÁ¦ "¸¶Áö¸·" Ŭ¸¯½Ã "Àüü"·Î ¹Ù²ïÈÄ ¿Àµ¿ÀÛÇÏ´Â ¿¡·¯ ¼öÁ¤À» À§ÇØ ¸·À½ 2004.09.01 if (DelItem==Delete1) { LDelLabel->Caption = IDS_COMMON_WHOLE; // DelItem = Delete2; } else if (DelItem==Delete2) { LDelLabel->Caption = IDS_LAST; // DelItem = Delete1; } */ /* if (DelItem==Delete1) { LDelLabel->Caption = IDS_COMMON_WHOLE; DelItem = Delete2; } else if (DelItem==Delete2) { LDelLabel->Caption = IDS_LAST; DelItem = Delete1; } */ } //--------------------------------------------------------------------------- void __fastcall TUndoForm::BitBtn2Click(TObject *Sender) { BEGIN_LOG(""); // UndoCount = UndoCount -1; //lhskys UndoÇÑ È½¼ö¸¦ üũ // Edit2->Text = UndoCount; //lhskys UndoÇÒ ¼ö ÀÖ´Â ¼ö RetrievePaletteCount(); // bPenUndoUse = false; //block by linuxjun // if (DelItem==Delete1) { // Undo->RemoveLast(); // } else if (DelItem==Delete2) { // Undo->RemoveAll(); // } FullViewForm->ExitOverlapChange(); StatusPen(); MainImageForm->Undo->PenUndoRead(); //by linuxjun Undo_Method caution because I don't know this is right Review(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::EUndoMaxChange(TObject *Sender) { BEGIN_LOG(""); if (EUndoMax->Text.Length() > 0) { if (EUndoMax->Value < 1) EUndoMax->Value =1; if (EUndoMax->Value > 1000) EUndoMax->Value = 1000; //MainImageForm->Undo->Maximum = MainImageForm->Undo->GetMaxUndoNum(); //MainImageForm->Undo->Maximum = EUndoMax->Value; MainImageForm->Undo->SetMaxUndoNum(EUndoMax->Value); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::UndoAllClick(TObject *Sender) { BEGIN_LOG(""); /* if (bPenUndoUse) BitBtn2Click(this); MainImageForm->Undo->ExitPenUndo(); Review(); */ if (bPenUndoUse){ //BitBtn2Click(this); MainImageForm->Undo->ExitPenUndo(); bPenUndoUse=false; } Review(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::UndoPenClick(TObject *Sender) { BEGIN_LOG(""); Review(); bPenUndoUse=true; TempUseColorCount = StrToInt(PaletteForm->FGColor->Text1); MainImageForm->Undo->InitPenUndo(); // GreenFish ÆæÀ¸·ÎÀÇ ¸®µÎ ÀúÀå¹®Á¦ ÀÛ¾÷Áß // if (bPenUndoUse) BitBtn2Click(this); BitBtn2Click(this); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::Review() { BEGIN_LOG(""); // BitBtn1->Enabled = UndoAll->Checked && UndoCount;//Undo->Count>0; by lhskys º¯¼ö ±³Ã¼ // BitBtn2->Enabled = UndoCount>0; //Undo->Count>0; by lhskys º¯¼ö ±³Ã¼ /* switch (Undo->Method) { case UM_STACK: ClientHeight = 221; Parent->Height = ParentHeight+ClientHeight; LUndoState->Caption = IDS_STACK; EUndoMax->Value = Undo->Maximum; Edit2->Text = Undo->GetListCount('Undo'); break; case UM_SWAP: ClientHeight = 97; Parent->Height = ParentHeight+ClientHeight; LUndoState->Caption = IDS_SWAP; break; } */ if (this->Visible == true) { //EUndoMax->Value = MainImageForm->Undo->Maximum; EUndoMax->Value = MainImageForm->Undo->GetMaxUndoNum(); // Edit2->Text = MainImageForm->Undo->GetListCount('Undo')+1; Edit2->Text = MainImageForm->Undo->GetListCount()+1; if (UndoAll->Checked) { ClientHeight = 115;//163; //Parent->Height = ParentHeight+ClientHeight; } else { ClientHeight = 165;// 215; //Parent->Height = ParentHeight+ClientHeight; } } // UndoBtn->Enabled = UndoAll->Checked;// && Undo->GetListCount('Undo'); // By GreenFish // RedoBtn->Enabled = UndoAll->Checked;// && Undo->GetListCount('Redo'); if(UndoAll->Checked){ UndoBtn->Enabled = MainImageForm->Undo->CanUndoNow(); RedoBtn->Enabled = MainImageForm->Undo->CanRedoNow(); }else{ UndoBtn->Enabled = true; RedoBtn->Enabled = true; } if (this->Visible == true) { if(UndoBtn->Enabled == false && RedoBtn->Enabled == true)RedoBtn->SetFocus(); else if(UndoBtn->Enabled == true && RedoBtn->Enabled == false)UndoBtn->SetFocus(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::StatusPen() { BEGIN_LOG(""); // TUndoData *ud; THistoryData *ud; //by linuxjun Undo_Method int i, j; //if (Undo->Count > 0) { if (MainImageForm->Undo->GetCount() > 0 && MainImageForm->Undo->CanUndoNow()) { // if ((ud = Undo->Last)==NULL) goto fail; if(MainImageForm->Undo->CanPenUndoNow()){ if ((ud = MainImageForm->Undo->GetLast())==NULL) goto fail; //by linuxjun Undo_Method //if ((ud = MainImageForm->Undo->getPenUndoData())==NULL) goto fail; //by linuxjun Undo_Method if (ud->getUndoKind()&UK_PATTERN) { //by linuxjun Undo_Method memset(piChange, 0, 256); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) if(ud->FromPalette->UseColor >256)ud->FromPalette->UseColor = 255; for (i=1, j = 0; i<=ud->FromPalette->UseColor; i++) { if (ud->FromPalette->ColorData[i]->Compare(MainImageForm->Palette->ColorData[i])==false) { j++; piChange[i] = ud->FromPalette->UseColor+j; } } UndoPen->Enabled = ud->FromPalette->UseColor+j<252; } else { UndoPen->Enabled = true; } }else{ UndoAll->Checked = true; // UndoPen->Enabled = false; } // ud->Complete(); } else { if(UndoAll->Checked){ UndoAll->Checked = true; UndoPen->Enabled = false; }else{ //write the code needed to prevent from the Layer Undo if(MainImageForm->Undo->CanPenUndoNow()) { UndoAll->Checked = false; UndoPen->Enabled = true; }else{ UndoAll->Checked = true; UndoPen->Enabled = true; } } } bFirst = true; END_LOG; return; fail: EXCEPTION_MESSAGE_OK(EC_NONE); /* // TUndoData *ud; THistoryData *ud; //by linuxjun Undo_Method int i, j; //if (Undo->Count > 0) { if (MainImageForm->Undo->GetCount() > 0 && MainImageForm->Undo->CanUndoNow()) { // if ((ud = Undo->Last)==NULL) goto fail; if ((ud = MainImageForm->Undo->GetLast())==NULL) goto fail; //by linuxjun Undo_Method //if ((ud = MainImageForm->Undo->getPenUndoData())==NULL) goto fail; //by linuxjun Undo_Method if (ud->getUndoKind()&UK_PATTERN) { //by linuxjun Undo_Method memset(piChange, 0, 256); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) if(ud->FromPalette->UseColor >256)ud->FromPalette->UseColor = 255; for (i=1, j = 0; i<=ud->FromPalette->UseColor; i++) { if (ud->FromPalette->ColorData[i]->Compare(MainImageForm->Palette->ColorData[i])==false) { j++; piChange[i] = ud->FromPalette->UseColor+j; } } UndoPen->Enabled = ud->FromPalette->UseColor+j<252; } else { UndoPen->Enabled = true; } // ud->Complete(); } else { if(UndoAll->Checked){ UndoAll->Checked = true; UndoPen->Enabled = false; }else{ //write the code needed to prevent from the Layer Undo if(MainImageForm->Undo->CanPenUndoNow()) { UndoAll->Checked = false; UndoPen->Enabled = true; }else{ UndoAll->Checked = true; UndoPen->Enabled = false; } } } bFirst = true; return; fail: EXCEPTION_MESSAGE_OK(EC_NONE); */ END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::InitForm() { BEGIN_LOG(""); //ParentHeight = Parent->Height+20; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { MainImageForm->OnSetHLine = SetHLine8; } else { MainImageForm->OnSetHLine = SetHLine24; } UndoAll->Checked = true; DelItem = Delete1; // if (this->Visible) { // StatusPen(); // Review(); // } StatusPen(); Review(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::SetHLine8(int x, int y, int len, COLORREF c) { BEGIN_LOG(""); THistoryData *ud; int xx, yy, i, j; TPException ec; Byte *IP, *UP, *LP, *ULP; if ((ud = MainImageForm->Undo->getPenUndoData())==NULL) { ec = EC_NONE; goto fail; } if (ud->getUndoKind()&UK_PATTERN) { if (bFirst) { for (i=1, j=0; i<252; i++) { if (piChange[i]) { MainImageForm->Palette->Copy(piChange[i], ud->FromPalette->ColorData[i]); j++; } else { piChange[i] = i; } } MainImageForm->Palette->UseColor = ud->FromPalette->UseColor+j; ::RepaintColor(); bFirst = false; } if(!ud->uBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (ud->LayerMask) { if(!ud->LayerMask->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+x; LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y)+x; UP = ud->uBitmap->GetUndoScanLine(y)+x; ULP = ud->LayerMask->GetUndoScanLine(y)+x; for (xx = x; xx < x + len; xx++, IP++, UP++, LP++, ULP++) { *IP = piChange[*UP]; *LP = *ULP; } MainImageForm->iMainImage->LayerMask->PutScanLine(y); MainImageForm->iMainImage->uBitmap->PutScanLine(y); ud->LayerMask->StopUndoScanLine(); } else { IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+x; UP = ud->uBitmap->GetUndoScanLine(y)+x; for (xx = x; xx < x + len; xx++, IP++, UP++) { *IP = piChange[*UP]; } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } ud->uBitmap->StopUndoScanLine(); } if (ud->getUndoKind()&UK_MASK) { if (ud->Mask) { if(!ud->Mask->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->Mask->GetScanLine(y)+x; UP = ud->Mask->GetUndoScanLine(y)+x; for (xx = x; xx < x + len; xx++, IP++, UP++) { *IP = *UP; } MainImageForm->iMainImage->Mask->PutScanLine(y); ud->Mask->StopUndoScanLine(); } } END_LOG; return; fail: if (ud) { if(ud->Mask)ud->Mask->StopUndoScanLine(); ud->uBitmap->StopUndoScanLine(); if (ud->LayerMask) ud->LayerMask->StopUndoScanLine(); } EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- /*void __fastcall TUndoForm::SetHLine8(int x, int y, int len, COLORREF c) { // TUndoData *ud; THistoryData *ud; //by linuxjun Undo_Method int xx, yy, i, j, ec; Byte *IP, *UP, *LP, *ULP; TTexpiaBitmap *tempBitmap; int StartPartNum=MainImageForm->iMainImage->uBitmap->Union2PartN(x,y); //by linuxjun Undo_Method int EndPartNum=MainImageForm->iMainImage->uBitmap->Union2PartN(x+len,y); //by linuxjun Undo_Method if ((ud = MainImageForm->Undo->getPenUndoData())==NULL) { ec = EC_NONE; goto fail; }///////// IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y,x,x+len)+x; //speed-test for(int n=StartPartNum;n<=EndPartNum;n++) { if (MainImageForm->iMainImage->uBitmap->PartialUndo->getPenUndoBitmap(n)->BitsPerPixel!=0) { // if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_NONE; goto fail; }///////// if (ud->getUndoKind()&UK_PATTERN) {///////// tempBitmap = MainImageForm->iMainImage->uBitmap->PartialUndo->getPenUndoBitmap(n); if (bFirst) { for (i=1, j=0; i<252; i++) { if (piChange[i]) { MainImageForm->Palette->Copy(piChange[i], ud->FromPalette->ColorData[i]); ///////// j++; } else { piChange[i] = i; } } MainImageForm->Palette->UseColor = ud->FromPalette->UseColor+j; ///////// ::RepaintColor(); bFirst = false; } //if ((y >= ud->getRectRange().top) && (y < ud->getRectRange().bottom)) { // yy = y - ud->getRectRange().top; yy = MainImageForm->iMainImage->uBitmap->Union2PartY(y); //<------------------by linuxjun Undo_Method------------->// int StartX,EndX; //by linuxjun Undo_Method if (n==StartPartNum) { StartX=MainImageForm->iMainImage->uBitmap->Union2PartX(x); }else{ StartX=0; } if (n==EndPartNum) { EndX=MainImageForm->iMainImage->uBitmap->Union2PartX(x+len); }else { EndX=tempBitmap->Width; } //<------------------------------------------------------>// if(!tempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } ///////// if (ud->LayerMask) { if(!ud->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } //IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+x; //speed-test btRect[n].left // IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y,x,x+len)+x; //Undo_Method //blocked since it may be bug //LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y)+x; // LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y,x,x+len)+x; //UP = ud->uBitmap->GetScanLine(yy)+x-ud->getRectRange().left; //UP = tempBitmap->GetScanLine(yy)+x-ud->getRectRange().left; //UP = tempBitmap->GetScanLine(yy)+x-ud->getRectRange().left; UP = tempBitmap->GetScanLine(yy)+StartX; // ULP = ud->LayerMask->GetScanLine(yy,x,x+len)+x-ud->getRectRange().left; for (xx = StartX; xx < EndX; xx++, IP++, UP++, LP++, ULP++) { //// if ((xx >= ud->getRectRange().left) && (xx < ud->getRectRange().right)) { *IP = piChange[*UP]; *LP = *ULP; //// } } // MainImageForm->iMainImage->LayerMask->PutScanLine(y,x,x+len); MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,x+len); //speed-test ud->LayerMask->StopScanLine(); } else { UP = tempBitmap->GetScanLine(yy)+StartX; //by linuxjun Undo_Method for (xx = StartX; xx < EndX; xx++, IP++, UP++, LP++, ULP++) { *IP = piChange[*UP]; } MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,x+len); //speed-test } tempBitmap->StopScanLine(); //} } } } // ud->Complete(); return; fail: if (ud) { ud->Mask->StopScanLine(); if(tempBitmap)tempBitmap->StopScanLine(); if (ud->LayerMask) ud->LayerMask->StopScanLine(); } EXCEPTION_MESSAGE_OK(ec); } */ //--------------------------------------------------------------------------- /*void __fastcall TUndoForm::SetHLine24(int x, int y, int len, COLORREF c) { THistoryData *ud; int xx, yy, ec; BYTE *IP, *UP, *LP, *ULP, im, um; TTexpiaBitmap *tempBitmap; int StartPartNum=MainImageForm->iMainImage->uBitmap->Union2PartN(x,y); //by linuxjun Undo_Method int EndPartNum=MainImageForm->iMainImage->uBitmap->Union2PartN(x+len,y); //by linuxjun Undo_Method if ((ud = MainImageForm->Undo->getPenUndoData())==NULL) { ec = EC_NONE; goto fail; } // if ((y >= ud->getRectRange().top) && (y < ud->getRectRange().bottom)) { // yy = y - ud->getRectRange().top; for(int n=StartPartNum;n<=EndPartNum;n++) { if (ud->getUndoKind()&UK_PATTERN) { ///////// tempBitmap = MainImageForm->iMainImage->uBitmap->PartialUndo->getPenUndoBitmap(n); if(!ud->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } yy = MainImageForm->iMainImage->uBitmap->Union2PartY(y); //<------------------by linuxjun Undo_Method------------->// int StartX,EndX; //by linuxjun Undo_Method if (n==StartPartNum) { StartX=MainImageForm->iMainImage->uBitmap->Union2PartX(x); }else{ StartX=0; } if (n==EndPartNum) { EndX=MainImageForm->iMainImage->uBitmap->Union2PartX(x+len); }else { EndX=tempBitmap->Width; } //<------------------------------------------------------>// if (ud->LayerMask) { // if(!ud->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y,x,x+len)+3*x; //speed-test // LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y,x,x+len); UP = tempBitmap->GetScanLine(yy)+3*(x-ud->getRectRange().left); // ULP = ud->LayerMask->GetScanLine(yy,x,x+len); for (xx = StartX; xx < EndX; xx++, IP+=3, UP+=3) { //if ((xx >= ud->getRectRange().left) && (xx < ud->getRectRange().right)) { CopyPixel24(IP, UP); /* if (ULP[(xx-ud->getRectRange().left) >> 3] & (0x80 >> ((xx-ud->getRectRange().left) & 7))) { LP[xx >> 3] |= (0x80 >> (xx & 7)); } else { LP[xx >> 3] &= ~(0x80 >> (xx & 7)); } */ //} /* } // MainImageForm->iMainImage->LayerMask->PutScanLine(y,x,x+len); /* MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,x+len); //speed-test // ud->LayerMask->StopScanLine(); } else { IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y,x,x+len)+3*x; //speed-test UP = tempBitmap->GetScanLine(yy)+3*(x-ud->getRectRange().left); for (xx = x; xx < x + len; xx++, IP+=3, UP+=3) { //if ((xx >= ud->getRectRange().left) && (xx < ud->getRectRange().right)) { CopyPixel24(IP, UP); //} } MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,x+len); //speed-test } ud->uBitmap->StopScanLine(); } /*if (ud->getUndoKind()&UK_MASK) { if (ud->Mask) { if(!ud->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->Mask->GetScanLine(y,x,x+len)+(x>>3); im = 0x80>>(x&7); UP = ud->Mask->GetScanLine(yy,x,x+len)+((x-ud->getRectRange().left)>>3); um = 0x80>>((x-ud->getRectRange().left)&7); for (xx = x; xx < x + len; xx++) if ((xx >= ud->getRectRange().left) && (xx < ud->getRectRange().right)) { if (*UP&um) { *IP |= im; } else { *IP &= ~im; } } if (im==1) { IP++; im = 0x80; } else im >>= 1; if (um==1) { UP++; um = 0x80; } else um >>= 1; } MainImageForm->iMainImage->Mask->PutScanLine(y,x,x+len); ud->Mask->StopScanLine(); } }*/ /* } // ud->Complete(); /* return; fail: if (ud) { ud->Mask->StopScanLine(); if(tempBitmap)tempBitmap->StopScanLine(); if (ud->LayerMask) ud->LayerMask->StopScanLine(); ud->uBitmap->StopScanLine(); } EXCEPTION_MESSAGE_OK(ec); } */ //--------------------------------------------------------------------------- void __fastcall TUndoForm::SetHLine24(int x, int y, int len, COLORREF c) { BEGIN_LOG(""); THistoryData *ud; int xx, yy; TPException ec; BYTE *IP, *UP, *LP, *ULP, im, um; if ((ud = MainImageForm->Undo->getPenUndoData())==NULL) { ec = EC_NONE; goto fail; } // if ((ud = Undo->GetLast())==NULL) { ec = EC_NONE; goto fail; } // if ((y >= ud->Range.top) && (y < ud->Range.bottom)) { // yy = y - ud->Range.top; if (ud->getUndoKind()&UK_PATTERN) { if(!ud->uBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (ud->LayerMask) { if(!ud->LayerMask->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // MainImageForm->iMainImage->uBitmap->UndoCheckActivePart(int y); // by linuxjun IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+3*x; LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y); // UP = ud->Bitmap->PartialUndo->GetUndoScanLine(yy)+3*(x-ud->Range.left); UP = ud->uBitmap->GetUndoScanLine(y)+3*(x); ULP = ud->LayerMask->GetUndoScanLine(y); for (xx = x; xx < x + len; xx++, IP+=3, UP+=3) { // if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { CopyPixel24(IP, UP); // if (ULP[(xx-ud->Range.left) >> 3] & (0x80 >> ((xx-ud->Range.left) & 7))) { if (ULP[(xx) >> 3] & (0x80 >> ((xx) & 7))) { LP[xx >> 3] |= (0x80 >> (xx & 7)); } else { LP[xx >> 3] &= ~(0x80 >> (xx & 7)); } // } } MainImageForm->iMainImage->LayerMask->PutScanLine(y); MainImageForm->iMainImage->uBitmap->PutScanLine(y); ud->LayerMask->StopUndoScanLine(); } else { IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+3*x; // UP = ud->uBitmap->GetScanLine(yy)+3*(x-ud->Range.left); UP = ud->uBitmap->GetUndoScanLine(y)+3*(x); for (xx = x; xx < x + len; xx++, IP+=3, UP+=3) { // if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { CopyPixel24(IP, UP); // } } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } ud->uBitmap->StopUndoScanLine(); } if (ud->getUndoKind()&UK_MASK) { if (ud->Mask) { if(!ud->Mask->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->Mask->GetScanLine(y)+(x>>3); im = 0x80>>(x&7); // UP = ud->Mask->GetScanLine(y)+((x-ud->Range.left)>>3); UP = ud->Mask->GetUndoScanLine(y)+((x)>>3); // um = 0x80>>((x-ud->Range.left)&7); um = 0x80>>((x)&7); for (xx = x; xx < x + len; xx++) { // if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { if (*UP&um) { *IP |= im; } else { *IP &= ~im; } // } if (im==1) { IP++; im = 0x80; } else im >>= 1; if (um==1) { UP++; um = 0x80; } else um >>= 1; } MainImageForm->iMainImage->Mask->PutScanLine(y); ud->Mask->StopUndoScanLine(); } } // } // ud->Complete(); END_LOG; return; fail: if (ud) { if(ud->Mask)ud->Mask->StopUndoScanLine(); if (ud->LayerMask) ud->LayerMask->StopUndoScanLine(); ud->uBitmap->StopUndoScanLine(); } EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- /*void __fastcall TUndoForm::SetHLine8(int x, int y, int len, COLORREF c) { TUndoData *ud; int xx, yy, i, j, ec; Byte *IP, *UP, *LP, *ULP; if ((ud = Undo->Last)==NULL) { ec = EC_NONE; goto fail; } if (ud->Kind&UK_PATTERN) { if (bFirst) { for (i=1, j=0; i<252; i++) { if (piChange[i]) { MainImageForm->Palette->Copy(piChange[i], ud->Palette->ColorData[i]); j++; } else { piChange[i] = i; } } MainImageForm->Palette->UseColor = ud->Palette->UseColor+j; ::RepaintColor(); bFirst = false; } if ((y >= ud->Range.top) && (y < ud->Range.bottom)) { yy = y - ud->Range.top; if(!ud->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (ud->LayerMask) { if(!ud->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+x; LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y)+x; UP = ud->Bitmap->GetScanLine(yy)+x-ud->Range.left; ULP = ud->LayerMask->GetScanLine(yy)+x-ud->Range.left; for (xx = x; xx < x + len; xx++, IP++, UP++, LP++, ULP++) { if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { *IP = piChange[*UP]; *LP = *ULP; } } MainImageForm->iMainImage->LayerMask->PutScanLine(y); MainImageForm->iMainImage->uBitmap->PutScanLine(y); ud->LayerMask->StopScanLine(); } else { IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+x; UP = ud->Bitmap->GetScanLine(yy)+x-ud->Range.left; for (xx = x; xx < x + len; xx++, IP++, UP++, LP++, ULP++) { if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { *IP = piChange[*UP]; } } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } ud->Bitmap->StopScanLine(); } } if (ud->Kind&UK_MASK) { if (ud->Mask) { if ((y >= ud->Range.top) && (y < ud->Range.bottom)) { yy = y - ud->Range.top; if(!ud->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->Mask->GetScanLine(y)+x; UP = ud->Mask->GetScanLine(yy)+x-ud->Range.left; for (xx = x; xx < x + len; xx++, IP++, UP++) { if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { *IP = *UP; } } MainImageForm->iMainImage->Mask->PutScanLine(y); ud->Mask->StopScanLine(); } } } ud->Complete(); return; fail: if (ud) { ud->Mask->StopScanLine(); ud->Bitmap->StopScanLine(); if (ud->LayerMask) ud->LayerMask->StopScanLine(); } EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TUndoForm::SetHLine24(int x, int y, int len, COLORREF c) { TUndoData *ud; int xx, yy, ec; BYTE *IP, *UP, *LP, *ULP, im, um; if ((ud = Undo->Last)==NULL) { ec = EC_NONE; goto fail; } if ((y >= ud->Range.top) && (y < ud->Range.bottom)) { yy = y - ud->Range.top; if (ud->Kind&UK_PATTERN) { if(!ud->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (ud->LayerMask) { if(!ud->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+3*x; LP = MainImageForm->iMainImage->LayerMask->GetScanLine(y); UP = ud->Bitmap->GetScanLine(yy)+3*(x-ud->Range.left); ULP = ud->LayerMask->GetScanLine(yy); for (xx = x; xx < x + len; xx++, IP+=3, UP+=3) { if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { CopyPixel24(IP, UP); if (ULP[(xx-ud->Range.left) >> 3] & (0x80 >> ((xx-ud->Range.left) & 7))) { LP[xx >> 3] |= (0x80 >> (xx & 7)); } else { LP[xx >> 3] &= ~(0x80 >> (xx & 7)); } } } MainImageForm->iMainImage->LayerMask->PutScanLine(y); MainImageForm->iMainImage->uBitmap->PutScanLine(y); ud->LayerMask->StopScanLine(); } else { IP = MainImageForm->iMainImage->uBitmap->GetScanLine(y)+3*x; UP = ud->Bitmap->GetScanLine(yy)+3*(x-ud->Range.left); for (xx = x; xx < x + len; xx++, IP+=3, UP+=3) { if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { CopyPixel24(IP, UP); } } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } ud->Bitmap->StopScanLine(); } if (ud->Kind&UK_MASK) { if (ud->Mask) { if(!ud->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } IP = MainImageForm->iMainImage->Mask->GetScanLine(y)+(x>>3); im = 0x80>>(x&7); UP = ud->Mask->GetScanLine(yy)+((x-ud->Range.left)>>3); um = 0x80>>((x-ud->Range.left)&7); for (xx = x; xx < x + len; xx++) { if ((xx >= ud->Range.left) && (xx < ud->Range.right)) { if (*UP&um) { *IP |= im; } else { *IP &= ~im; } } if (im==1) { IP++; im = 0x80; } else im >>= 1; if (um==1) { UP++; um = 0x80; } else um >>= 1; } MainImageForm->iMainImage->Mask->PutScanLine(y); ud->Mask->StopScanLine(); } } } ud->Complete(); return; fail: if (ud) { ud->Mask->StopScanLine(); if (ud->LayerMask) ud->LayerMask->StopScanLine(); ud->Bitmap->StopScanLine(); } EXCEPTION_MESSAGE_OK(ec); } */ //--------------------------------------------------------------------------- void __fastcall TUndoForm::iMainImageKeyDown(WORD Key, TShiftState Shift) { BEGIN_LOG(""); if ( Key == VK_RETURN && UndoAll->Checked == true) //lhskys Àüü¸¦ ¿¡¼­ ¿£ÅÍŰ ½ÇÇà // if (BitBtn1->Enabled)BitBtn1Click(this); if (UndoBtn->Enabled) UndoBtnClick (this); // By GreenFish (üÁ¦ º¯°æ) if ( Key == VK_RETURN && UndoPen->Checked == true) //lhskys ÆæÀ¸·Î ¿¡¼­ ¿£ÅÍŰ ½ÇÇà if( BitBtn2->Enabled)BitBtn2Click(this); END_LOG; } //---------------------------------------------------------------------------- void __fastcall TUndoForm::UndoBtnClick(TObject *Sender) { BEGIN_LOG(""); TCursor old_cursor; old_cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->reflection){ int undocount = MainImageForm->Undo->GetListCount(); if (MainImageForm->reflection->BackupUndoCount < undocount){ MainImageForm->UndoBtnExec(); //by linuxjun if (this->Visible) { Edit2->Text = undocount + 1; // BeConverted by linuxjun Don't Forget!! Undo_Method StatusPen(); Review(); } } } else { MainImageForm->UndoBtnExec(); //by linuxjun if (this->Visible) { Edit2->Text = MainImageForm->Undo->GetListCount()+1; // BeConverted by linuxjun Don't Forget!! Undo_Method StatusPen(); Review(); } } Screen->Cursor = old_cursor; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::RedoBtnClick(TObject *Sender) { BEGIN_LOG(""); if (MainImageForm->reflection){ int undocount = MainImageForm->Undo->GetListCount(); if (MainImageForm->reflection->BackupUndoCount <= undocount){ MainImageForm->RedoBtnExec(); if (this->Visible) { Edit2->Text = undocount + 1; StatusPen(); Review(); } } } else { MainImageForm->RedoBtnExec(); if (this->Visible) { Edit2->Text = MainImageForm->Undo->GetListCount()+1; StatusPen(); Review(); } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::ExitForm() { BEGIN_LOG(""); if (UndoPen->Checked) RetrievePaletteCount(); if (bPenUndoUse){ MainImageForm->Undo->ExitPenUndo(); bPenUndoUse=false; // BitBtn2Click(this); } Visible = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::RetrievePaletteCount() { BEGIN_LOG(""); PaletteForm->DIB256Palette->UseColor = TempUseColorCount+1; PaletteForm->FGColor->Text1 = TempUseColorCount; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TUndoForm::EUndoMaxMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TEdit *s; s = (TEdit *)Sender; s->SetFocus(); s->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TUndoForm::EditorSelectAll(TObject *Sender) { SetFocusAndSelectAll(Sender); } //--------------------------------------------------------------------------- void __fastcall TUndoForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); HWND hWnd = ((TWinControl *)Owner)->Handle; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //---------------------------------------------------------------------------