//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Repro_F.h" #include "FullView.h" #include "MainImage.h" #include "Palette.h" #include "Undo.h" #include "MainMenu.h" #include "Main.h" #include "LogData.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TNumEdit" #pragma link "RzPanel" #pragma link "RzButton" #pragma link "RzCmboBx" #pragma link "RzBckgnd" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_PULL StringTable[0] #define IDS_PERSPFIXX StringTable[1] #define IDS_PERSPFIXY StringTable[2] #define IDS_TYPE StringTable[3] #define IDS_RATIO StringTable[4] #define IDS_PERSPANGLE StringTable[5] #define IDS_PERSPDISTANCE StringTable[6] #define IDS_PERSPSHAPE StringTable[7] #define IDS_SETPOINT StringTable[8] #define IDS_INITIALIZE StringTable[9] #define IDS_PULLPREVIEW StringTable[10] #define IDS_PERSP StringTable[11] #define IDS_LINK StringTable[12] //--------------------------------------------------------------------------- TReproForm *ReproForm; //--------------------------------------------------------------------------- __fastcall TReproForm::TReproForm(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *)Owner)->Handle; //================== 2001.3.26 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è StringTable.Create(DirectoryBin, Language, "Repro"); SetSmallFont(Font); // SetSmallFont(StaticText5->Font); // SetSmallFont(lShape->Font); // SetSmallFont(Label2->Font); // SetSmallFont(Label3->Font); // SetSmallFont(Label4->Font); // SetSmallFont(Label5->Font); // SetSmallFont(Label6->Font); // SetSmallFont(Label9->Font); // SetSmallFont(lYlength2->Font); // SetSmallFont(lYlength1->Font); // SetSmallFont(lXlength2->Font); // SetSmallFont(lXlength1->Font); // SetSmallFont(LeftRightLabel->Font); // SetSmallFont(UpDownLabel->Font); rzbtRect->Caption = IDS_COMMON_RECTANGLE; rzbtPull->Caption = IDS_PULL; rzbtPersp->Caption = IDS_PERSPFIXX; // sbY->Caption = IDS_PERSPFIXY; // lShape->Caption = IDS_TYPE; // btnSize->Caption = IDS_RATIO; // btnRectRun->Caption = IDS_COMMON_RUN; // Label2->Caption = IDS_PERSPANGLE; // Label3->Caption = IDS_PERSPDISTANCE; // Label9->Caption = IDS_PERSPSHAPE; // LeftRightLabel->Caption = IDS_COMMON_LEFT; // btnYrun->Caption = IDS_COMMON_RUN; // Label4->Caption = IDS_PERSPANGLE; // Label5->Caption = IDS_PERSPDISTANCE; // Label6->Caption = IDS_PERSPSHAPE; // UpDownLabel->Caption = IDS_COMMON_UP; // btnXRun->Caption = IDS_COMMON_RUN; // StaticText5->Caption = IDS_SETPOINT; ImgAngle->Hint = IDS_PERSPANGLE; ImgDistance->Hint = IDS_PERSPDISTANCE; rzbtnRectRun->Caption = IDS_COMMON_RUN; rzbtnPullRun->Caption = IDS_COMMON_RUN; rzbtPersp->Caption = IDS_PERSP; rzbtnPerspRun->Caption = IDS_COMMON_RUN; rzmtInit->Hint = IDS_INITIALIZE; rzmtLink->Hint = IDS_LINK; miUp->Caption = IDS_COMMON_UP; miDown->Caption = IDS_COMMON_DOWN; miLeft->Caption = IDS_COMMON_LEFT; miRight->Caption = IDS_COMMON_RIGHT; // btnPullPreView->Caption = IDS_PULLPREVIEW; //============================================= MakeMenuHintByShortcut(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::FormCreate(TObject *Sender) { // 2001.3.26 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è } //--------------------------------------------------------------------------- //void __fastcall TReproForm::rzmtInitClick(TObject *Sender) //{ // if (item == TREPRO_RECT) { // InitRect(); // SetSizeText(); // } //} //--------------------------------------------------------------------------- void __fastcall TReproForm::btnXRunClick(TObject *Sender) { BEGIN_LOG(""); TCursor OldCursor; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->iMainImage->LayerMask) perspective_reproportion_layer(); else perspective_reproportion(); MainImageForm->WorkAreaReset(); MainForm->UpdateMenuItems(NULL); Screen->Cursor = OldCursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::rzbtnPullRunClick(TObject *Sender) { BEGIN_LOG(""); TCursor OldCursor; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->iMainImage->LayerMask) pull_image_repro_layer(); else pull_image_repro(); MainImageForm->WorkAreaReset(); MainForm->UpdateMenuItems(NULL); Screen->Cursor = OldCursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); MainImageForm->DrawLineLocate(Point(Rpos[0].x, Rpos[0].y), Point(Rpos[1].x, Rpos[1].y),0); //lhskys ´ç±â±â ¿£ÅÍ·Î ½ÇÇàÇßÀ»¶§ ÀÜ»óÁ¦°Å... END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::EditKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if(Key == VK_RETURN ) { if (rzbtPull->Down) rzbtnPullRunClick(this); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ else { if (rzbtRect->Down == false || norun == 1){ //lhskys ¿£Å͸¦ ¹Þ¾ÒÀ»¶§ PullEdit(Sender); //lhskys edit·Î °¥°ÍÀΰ¡ ÆÇ´Ü SelectNext((TWinControl *)Sender, true, true); //lhskys Key = 0; //lhskys }else if(norun == 0){ //lhskys ¹Ù·Î ½ÇÇàŰ·Î.... if(rzbtRect->Down){ //lhskys rzbtnRectRunClick(this); //lhskys } } } g_FocusControl->SetFocus(); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::FunctionClick(TObject *Sender) { TSpeedButton *s; Graphics::TBitmap *bmpIcon = NULL; MainImageForm->iMainImage->OnPaintLocate=NULL; MainImageForm->iMainImage->Repaint(); ///////»©Áö¸¶½Ã¿À //PULL¿¡¼­ ¾¸ s = (TSpeedButton *)Sender; if (s == rzbtRect) { rzplRect->Top = 27; ReproForm->ClientHeight = 112; rzplRect->Visible = true; rzplPull->Visible = false; rzplPersp->Visible = false; RectMode(); InitRect(); rzbtRect->Down = true; } else if (s == rzbtPull) { rzplPull->Top = 27; ReproForm->ClientHeight = 61; rzplRect->Visible = false; rzplPull->Visible = true; rzplPersp->Visible = false; PullMode(); ExitRect(); rzbtPull->Down = true; // rzbtEnter->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ // } else if (s == sbX) { // XReproMode(); // ExitRect(); // sbX->Down = true; // } else if (s == sbY) { // YReproMode(); // ExitRect(); // sbY->Down = true; } else if (s == rzbtPersp) { rzplPersp->Top = 27; ReproForm->ClientHeight = 81; // ¾ÆÀÌÄÜ ¼³Á¤ bmpIcon = new Graphics::TBitmap; imglstIcon->GetBitmap(0, bmpIcon); rzmtXaxis->Glyph->Assign(bmpIcon); if (bmpIcon) delete bmpIcon; bmpIcon = NULL; bmpIcon = new Graphics::TBitmap; imglstIcon->GetBitmap(5, bmpIcon); rzmtYaxis->Glyph->Assign(bmpIcon); if (bmpIcon) delete bmpIcon; bmpIcon = NULL; rzplRect->Visible = false; rzplPull->Visible = false; rzplPersp->Visible = true; XReproMode(); ExitRect(); rzbtPersp->Down = true; } //nedXSize->Enabled = false; //nedYSize->Enabled = false; // by celberus } //--------------------------------------------------------------------------- void __fastcall TReproForm::PullEdit(TObject *Sender) { TNumEdit *e; int l1, l2, angle, ratio; e = (TNumEdit *)Sender; if (e->Value > 0) { // if (e == EXAngle) { if (e == edAngle && item == TREPRO_XFIX) { compute_len(l1, l2); // angle = EXAngle->Value; angle = edAngle->Value; if ((angle > 9) && (angle < 81)) { s_repro.angle = angle; compute_len(l1, l2); // lXlength1->Caption = l1; // lXlength2->Caption = l2; } else { // EXAngle->Value = s_repro.angle; edAngle->Value = s_repro.angle; } if ((s_repro.ratio < l1) || (s_repro.ratio > l2)) { s_repro.ratio = l1; // lXlength1->Caption = l1; // lXlength2->Caption = l2; // EXratio->Value = l1; edRatio->Value = l1; } // } else if (e == EXratio) { } else if (e == edRatio && item == TREPRO_XFIX) { compute_len(l1, l2); // lXlength1->Caption = l1; // lXlength2->Caption = l2; // ratio = EXratio->Value; ratio = edRatio->Value; if ((ratio >= l1) && (ratio <= l2)) { s_repro.ratio = ratio; // lXlength1->Caption = l1; // lXlength2->Caption = l2; // EXratio->Value = s_repro.ratio; edRatio->Value = s_repro.ratio; } else { // lXlength1->Caption = l1; // lXlength2->Caption = l2; // EXratio->Value = s_repro.ratio; edRatio->Value = s_repro.ratio; } // } else if (e == eYAngle) { } else if (e == edAngle && item == TREPRO_YFIX) { compute_len(l1, l2); // angle = eYAngle->Value; angle = edAngle->Value; if ((angle > 9) && (angle < 81)) { s_repro.angle = angle; compute_len(l1, l2); // lYlength1->Caption = l1; // lYlength2->Caption = l2; } else { // eYAngle->Value = s_repro.angle; edAngle->Value = s_repro.angle; } if ((s_repro.ratio < l1) || (s_repro.ratio > l2)) { s_repro.ratio = l1; // lYlength1->Caption = l1; // lYlength2->Caption = l2; // eYratio->Value = l1; edRatio->Value = l1; } // } else if (e == eYratio) { } else if (e == edRatio && item == TREPRO_YFIX) { compute_len(l1, l2); // lYlength1->Caption = l1; // lYlength2->Caption = l2; // ratio = eYratio->Value; ratio = edRatio->Value; if ((ratio >= l1) && (ratio <= l2)) { s_repro.ratio = ratio; // lYlength1->Caption = l1; // lXlength2->Caption = l2; // eYratio->Value = s_repro.ratio; edRatio->Value = s_repro.ratio; } else { // lYlength1->Caption = l1; // lYlength2->Caption = l2; // eYratio->Value = s_repro.ratio; edRatio->Value = s_repro.ratio; } } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::shRectMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { //nedXSize->Enabled = true; //nedYSize->Enabled = true; // by celberus nedXSize->SetFocus(); nedXSize->SelectAll(); norun = 1; //lhskys ½ÇÇàÀ» ÇÒ¶§¸¦ Ç¥½ÃÇϱâÀ§ÇØ InitRect(); rzbtRect->Down = false; item = TREPRO_NULL; } //--------------------------------------------------------------------------- void __fastcall TReproForm::rzbtnRectRunClick(TObject *Sender) { BEGIN_LOG(""); norun = 0; //lhskys ½ÇÇàÀ» ÇÏÁö ¾ÊÀ»¶§¸¦ Ç¥½ÃÇϱâÀ§ÇØ bool crtSw = false, crtSw1 = false, crtSw2 = false; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; // if (btnSize->Caption == IDS_COMMON_LENGTH) { // if (nedXSize->Value > 0) { // switch (MainImageForm->CurrentUnit) { // case uDot : ReproRect.size.x = nedXSize->IntValue; break; // case uInch : ReproRect.size.x = nedXSize->Value * MainImageForm->CanvasInfor.DotsPerInch; break; // case uCm : ReproRect.size.x = nedXSize->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54; // } // } // if (nedYSize->Value > 0) { // switch (MainImageForm->CurrentUnit) { // case uDot : ReproRect.size.y = nedYSize->IntValue; break; // case uInch : ReproRect.size.y = nedYSize->Value * MainImageForm->CanvasInfor.DotsPerInch; break; // case uCm : ReproRect.size.y = nedYSize->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54; // } // } // } else if (btnSize->Caption == IDS_RATIO) { // if (nedXSize->Value > 0) { // ReproRect.size.x = window.size.x * nedXSize->Value / 100.0; // } // if (nedYSize->Value > 0) { // ReproRect.size.y = window.size.y * nedYSize->Value / 100.0; // } // } if (rzcbUnit->ItemIndex ==0) { if (nedXSize->Value > 0) { ReproRect.size.x = window.size.x * nedXSize->Value / 100.0; } if (nedYSize->Value > 0) { ReproRect.size.y = window.size.y * nedYSize->Value / 100.0; } } else if (rzcbUnit->ItemIndex ==1) { if (nedXSize->Value > 0) { ReproRect.size.x = nedXSize->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } if (nedYSize->Value > 0) { ReproRect.size.y = nedYSize->IntValue * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } } else if (rzcbUnit->ItemIndex ==2) { if (nedXSize->Value > 0) { ReproRect.size.x = nedXSize->Value * MainImageForm->CanvasInfor.DotsPerInch; } if (nedYSize->Value > 0) { ReproRect.size.y = nedYSize->IntValue * MainImageForm->CanvasInfor.DotsPerInch; } } else if (rzcbUnit->ItemIndex == 3) { if (nedXSize->Value > 0) { ReproRect.size.x = nedXSize->IntValue; } if (nedYSize->Value > 0) { ReproRect.size.y = nedYSize->IntValue; } } MainImageForm->iMainImage->SubEnabled = true; if (Image->uBitmap->BitsPerPixel==8) { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 1)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } Image->SubVisible = false; rect_repro(); if(!rzbtRect->Down)ExitRect(); END_LOG; return; fail : if (crtSw) window.Back->Destroy(); if (crtSw1) Image->SubBitmap->Destroy(); if (crtSw2) Image->SubMask->Destroy(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::XYEditClick(TObject *Sender) { TEdit *s = (TEdit *) Sender; s->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::XYEditDblClick(TObject *Sender) { TEdit *s = (TEdit *) Sender; s->SelectAll(); s->SetFocus(); } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- void __fastcall TReproForm::AddIrrePoint(TList *list, bool curve, TPoint pos, TPoint apex) { } //--------------------------------------------------------------------------- void __fastcall TReproForm::moveline(void) { MainImageForm->DrawLineLocate(Point(Rpos[0].x, Rpos[0].y), Point(Rpos[1].x, Rpos[1].y),4); MainImageForm->DrawLineLocate(Point(Rpos[1].x, Rpos[1].y), Point(Rpos[2].x, Rpos[2].y),4); MainImageForm->DrawLineLocate(Point(Rpos[2].x, Rpos[2].y), Point(Rpos[3].x, Rpos[3].y),4); MainImageForm->DrawLineLocate(Point(Rpos[3].x, Rpos[3].y), Point(Rpos[0].x, Rpos[0].y),4); } //--------------------------------------------------------------------------- void __fastcall TReproForm::perspective_reproportion(void) { BEGIN_LOG(""); ///* //BeConverted by linuxjun Don't Forget!! Undo_Method int c, d, x, y, xi; double sd, xd, l, alpha1, alpha2, theta, a, b, x1, x2, y1, y2, si, yi, yd; TPoint u_ptr, tp, tp1, tp2; Byte *IPP, *IPM, *AP, *APN; TUnionBitmap *area=new TUnionBitmap; // convert by celberus bool undoSw = false, sw; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; //BeConverted by linuxjun Don't Forget!! Undo_Method TPException ec = EC_NONE; // if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(window.s.x, window.s.y+1, window.e.x, window.e.y+1))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel==8) { RGBQUAD rgb[256]; Image->uBitmap->GetColors(0, 256, rgb); if(!area->Create(window.e.x-window.s.x+1, window.e.y-window.s.y+1, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x+1, window.e.y-window.s.y+1,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); }else { if(!area->Create(window.e.x-window.s.x+1, window.e.y-window.s.y+1, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x+1, window.e.y-window.s.y+1,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); } // ud = Undo->Last; // area = Undo->Last->Bitmap; // Image->uBitmap->FillRect(Rect(window.s.x, window.s.y+1, window.e.x, window.e.y+1), Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y+1), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); if(Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if(area->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (item == TREPRO_XFIX) { // sw = UpDownLabel->Caption == IDS_COMMON_UP; sw = (XTextItem == _StateUp); alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; y1 = l * a; y2 = l * b; if (sw) { tp1 = Point(window.s.x + (window.size.x >> 1), window.e.y - 1); } else { tp1 = Point(window.s.x + (window.size.x >> 1), window.s.y); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + u_ptr.x-window.s.x; for (x = 0; x < xd; x++, IPP++, IPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width && MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); } if (tp2.x - x >= 0 && MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPM]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width && MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); } if (tp2.x - x >= 0 && MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPM]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); } } } } Image->uBitmap->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + u_ptr.x-window.s.x; for (x = 0; x < xd; x++, IPP++, IPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width && MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); } if (tp2.x - x >= 0 && MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPM]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width && MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); } if (tp2.x - x >= 0 && MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); } } } } Image->uBitmap->PutScanLine(tp2.y); } } } else { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + 3 * (u_ptr.x-window.s.x); for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } } Image->uBitmap->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + 3 * (u_ptr.x-window.s.x); for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } } Image->uBitmap->PutScanLine(tp2.y); } } } } else if (item == TREPRO_YFIX) { // sw = LeftRightLabel->Caption == IDS_COMMON_LEFT; sw = YTextItem == _StateLeft; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; x1 = l * a; x2 = l * b; if (sw) { tp1 = Point(window.e.x - 1, window.s.y + (window.size.y >> 1)); } else { tp1 = Point(window.s.x, window.s.y + (window.size.y >> 1)); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y + y,tp2.x,1) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y + yi-window.s.y,u_ptr.x-window.s.x,1) + u_ptr.x-window.s.x); Image->uBitmap->PutScanLine(tp2.y + y,tp2.x,1); } } if (tp.y - y >= 0) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y - y,tp2.x,1) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y - yi-window.s.y,u_ptr.x-window.s.x,1) + u_ptr.x-window.s.x); Image->uBitmap->PutScanLine(tp2.y - y,tp2.x,1); } } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y + y,tp2.x,1) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y + yi-window.s.y,u_ptr.x-window.s.x,1) + u_ptr.x-window.s.x); Image->uBitmap->PutScanLine(tp2.y + y,tp2.x,1); } } if (tp.y - y >= 0) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y - y,tp2.x,1) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y - yi-window.s.y,u_ptr.x-window.s.x,1) + u_ptr.x-window.s.x); Image->uBitmap->PutScanLine(tp2.y - y,tp2.x,1); } } } } } } else { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y,tp2.x,1) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y + yi-window.s.y,(u_ptr.x-window.s.x),1) + 3 * (u_ptr.x-window.s.x); CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y + y,tp2.x,1); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y,tp2.x,1) + 3 * tp2.x; // AP = area->GetScanLine(u_ptr.y - yi-window.s.y,u_ptr.x,1) + 3 * u_ptr.x; AP = area->GetScanLine(u_ptr.y - yi-window.s.y,(u_ptr.x-window.s.x),1) + 3 * (u_ptr.x-window.s.x); CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y - y,tp2.x,1); } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y,tp2.x,1) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y + yi-window.s.y) + 3 * (u_ptr.x-window.s.x); CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y + y,tp2.x,1); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y,tp2.x,1) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y - yi-window.s.y) + 3 * (u_ptr.x-window.s.x); CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y - y,tp2.x,1); } } } } } } area->StopScanLine(); Image->uBitmap->StopScanLine(); // ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); //2001.6.19 by lhskys autorepeat ::RepaintImage(); if(area)delete area; END_LOG; return; fail : if (undoSw) { area->StopScanLine(); Image->uBitmap->StopScanLine(); // Undo->RemoveLast(); MainImageForm->Undo->RemoveLast(); } if(area)delete area; EXCEPTION_MESSAGE_OK(ec); END_LOG; // */ /* //BeConverted by linuxjun Don't Forget!! Undo_Method int c, d, x, y, xi; double sd, xd, l, alpha1, alpha2, theta, a, b, x1, x2, y1, y2, si, yi, yd; TPoint u_ptr, tp, tp1, tp2; Byte *IPP, *IPM, *AP, *APN; // TUnionBitmap *area; // convert by celberus TUndoManager *area; // convert by celberus bool undoSw = false, sw; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; //BeConverted by linuxjun Don't Forget!! Undo_Method // if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) goto fail; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(window.s.x, window.s.y, window.e.x, window.e.y))) == false) goto fail; ud = MainImageForm->Undo->GetLast(); area = MainImageForm->iMainImage->uBitmap->PartialUndo; area->LoadLast(ud->FromRgb); // area = MainImageForm->Undo->GetLast()->uBitmap; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); if(Image->uBitmap->StartScanLine() == false) goto fail; if(area->StartScanLine() == false) goto fail; if (item == TREPRO_XFIX) { sw = UpDownLabel->Caption == IDS_COMMON_UP; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; y1 = l * a; y2 = l * b; if (sw) { tp1 = Point(window.s.x + (window.size.x >> 1), window.e.y); } else { tp1 = Point(window.s.x + (window.size.x >> 1), window.s.y); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); Image->uBitmap->GetScanLine(u_ptr.y); //caution!! AP = area->GetUndoScanLine(u_ptr.y) + u_ptr.x; //caution!! IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; for (x = 0; x < xd; x++, IPP++, IPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); } if (tp2.x - x >= 0) { *IPM = *(AP - xi); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); } if (tp2.x - x >= 0) { *IPM = *(AP - xi); } } } } Image->uBitmap->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); Image->uBitmap->GetScanLine(u_ptr.y); //caution!! AP = area->GetUndoScanLine(u_ptr.y) + u_ptr.x; //caution!! IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; for (x = 0; x < xd; x++, IPP++, IPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); } if (tp2.x - x >= 0) { *IPM = *(AP - xi); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); } if (tp2.x - x >= 0) { *IPM = *(AP - xi); } } } } Image->uBitmap->PutScanLine(tp2.y); } } } else { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); Image->uBitmap->GetScanLine(u_ptr.y); AP = area->GetUndoScanLine(u_ptr.y) + 3 * u_ptr.x; IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y +- d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } } Image->uBitmap->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); Image->uBitmap->GetScanLine(u_ptr.y); AP = area->GetUndoScanLine(u_ptr.y) + 3 * u_ptr.x; IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); } } } } Image->uBitmap->PutScanLine(tp2.y); } } } } else if (item == TREPRO_YFIX) { sw = LeftRightLabel->Caption == IDS_COMMON_LEFT; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; x1 = l * a; x2 = l * b; if (sw) { tp1 = Point(window.e.x, window.s.y + (window.size.y >> 1)); } else { tp1 = Point(window.s.x, window.s.y + (window.size.y >> 1)); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { *(Image->uBitmap->GetScanLine(tp2.y + y) + tp2.x) = *(area->GetUndoScanLine(u_ptr.y + yi) + u_ptr.x); Image->uBitmap->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { *(Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x) = *(area->GetUndoScanLine(u_ptr.y - yi) + u_ptr.x); Image->uBitmap->PutScanLine(tp2.y - y); } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { *(Image->uBitmap->GetScanLine(tp2.y + y) + tp2.x) = *(area->GetUndoScanLine(u_ptr.y + yi) + u_ptr.x); Image->uBitmap->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { *(Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x) = *(area->GetUndoScanLine(u_ptr.y - yi) + u_ptr.x); Image->uBitmap->PutScanLine(tp2.y - y); } } } } } else { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y) + 3 * tp2.x; AP = area->GetUndoScanLine(u_ptr.y + yi) + 3 * u_ptr.x; CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y) + 3 * tp2.x; AP = area->GetUndoScanLine(u_ptr.y - yi) + 3 * u_ptr.x; CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y - y); } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y) + 3 * tp2.x; AP = area->GetUndoScanLine(u_ptr.y + yi) + 3 * u_ptr.x; CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y) + 3 * tp2.x; AP = area->GetUndoScanLine(u_ptr.y - yi) + 3 * u_ptr.x; CopyPixel24(IPP, AP); Image->uBitmap->PutScanLine(tp2.y - y); } } } } } } area->StopScanLine(); Image->uBitmap->StopScanLine(); // ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); //2001.6.19 by lhskys autorepeat ::RepaintImage(); return; fail : if (undoSw) { area->StopScanLine(); Image->uBitmap->StopScanLine(); MainImageForm->Undo->RemoveLast(); } EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } //--------------------------------------------------------------------------- void __fastcall TReproForm::perspective_reproportion_layer(void) { BEGIN_LOG(""); ///* //BeConverted by linuxjun Don't Forget!! Undo_Method int c, d, x, y, xi; double sd, xd, l, alpha1, alpha2, theta, a, b, x1, x2, y1, y2, si, yi, yd; TPoint u_ptr, tp, tp1, tp2; Byte *IPP, *IPM, *AP, *APN, *LPP, *LPM, *LP; TUnionBitmap *area = new TUnionBitmap; // convert by celberus bool undoSw = false, sw; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; TPException ec = EC_NONE; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(window.s.x, window.s.y+1, window.e.x, window.e.y+1))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel==8) { RGBQUAD rgb[256]; Image->uBitmap->GetColors(0, 256, rgb); if(!area->Create(window.e.x-window.s.x+1, window.e.y-window.s.y+1, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x+1, window.e.y-window.s.y+1,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); }else { if(!area->Create(window.e.x-window.s.x+1, window.e.y-window.s.y+1, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x+1, window.e.y-window.s.y+1,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); } // ud = MainImageForm->Undo->GetLast(); // area = MainImageForm->Undo->GetLast()->uBitmap; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); if(Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if(area->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if(Image->LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel==8) { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y)+ window.s.x; for (x = window.s.x; x < window.e.x; x++, LP++) { if (x < Image->uBitmap->Width) { *(LP) = 0xFF; } } Image->LayerMask->PutScanLine(y,window.s.x,window.e.x-window.s.x+1); } } } else { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y); for (x = window.s.x; x < window.e.x; x++) { if (x < Image->uBitmap->Width) { *(LP + (x>>3)) |= (0x80 >> (x&7)); } } Image->LayerMask->PutScanLine(y,window.s.x,window.e.x-window.s.x+1); } } } if (item == TREPRO_XFIX) { // sw = UpDownLabel->Caption == IDS_COMMON_UP; sw = XTextItem == _StateUp; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; y1 = l * a; y2 = l * b; if (sw) { tp1 = Point(window.s.x + (window.size.x >> 1), window.e.y - 1); } else { tp1 = Point(window.s.x + (window.size.x >> 1), window.s.y); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + u_ptr.x-window.s.x; LPP = LPM = Image->LayerMask->GetScanLine(tp2.y) + tp2.x; for (x = 0; x < xd; x++, IPP++, IPM--, LPP++, LPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); *LPP = 0; } } if (tp2.x - x >= 0) { if (MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPM]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); *LPM = 0; } } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); *LPP = 0; } } if (tp2.x - x >= 0) { if (MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPM]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); *LPM = 0; } } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + u_ptr.x -window.s.x; LPP = LPM = Image->LayerMask->GetScanLine(tp2.y) + tp2.x; for (x = 0; x < xd; x++, IPP++, IPM--, LPP++, LPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); *LPP = 0; } } if (tp2.x - x >= 0) { if (MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPM]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); *LPM = 0; } } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IPP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPP]->Protect != 0 && MainImageForm->bProtect == false)) { *IPP = *(AP + xi); *LPP = 0; } } if (tp2.x - x >= 0) { if (MainImageForm->Palette->ColorData[*IPM]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IPM]->Protect != 0 && MainImageForm->bProtect == false)) { *IPM = *(AP - xi); *LPM = 0; } } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } } } else { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + 3 * (u_ptr.x-window.s.x); LPP = Image->LayerMask->GetScanLine(tp2.y); for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y-window.s.y) + 3 * (u_ptr.x-window.s.x); LPP = Image->LayerMask->GetScanLine(tp2.y); for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == tp1.y - d) || (tp2.y == tp1.y- d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } } } } else if (item == TREPRO_YFIX) { // sw = LeftRightLabel->Caption == IDS_COMMON_LEFT; sw = alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; x1 = l * a; x2 = l * b; if (sw) { tp1 = Point(window.e.x - 1, window.s.y + (window.size.y >> 1)); } else { tp1 = Point(window.s.x, window.s.y + (window.size.y >> 1)); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y + y) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y + yi-window.s.y) + u_ptr.x-window.s.x); *(Image->LayerMask->GetScanLine(tp2.y + y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } } if (tp.y - y >= 0) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y - yi-window.s.y) + u_ptr.x-window.s.x); *(Image->LayerMask->GetScanLine(tp2.y - y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y + y) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y + yi-window.s.y) + u_ptr.x-window.s.x); *(Image->LayerMask->GetScanLine(tp2.y + y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } } if (tp.y - y >= 0) { Byte *IP = Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x; if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *(area->GetScanLine(u_ptr.y - yi-window.s.y) + u_ptr.x-window.s.x); *(Image->LayerMask->GetScanLine(tp2.y - y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } } } } else { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y + yi-window.s.y) + 3 * (u_ptr.x-window.s.x); LPP = Image->LayerMask->GetScanLine(tp2.y + y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y - yi-window.s.y) + 3 *( u_ptr.x-window.s.x); LPP = Image->LayerMask->GetScanLine(tp2.y - y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y + yi-window.s.y) + 3 *( u_ptr.x-window.s.x); LPP = Image->LayerMask->GetScanLine(tp2.y + y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y - yi-window.s.y) + 3 * (u_ptr.x-window.s.x); LPP = Image->LayerMask->GetScanLine(tp2.y - y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } } } } Image->LayerMask->StopScanLine(); area->StopScanLine(); Image->uBitmap->StopScanLine(); // ud->Complete(); ::RepaintImage(); if(area)delete area; END_LOG; return; fail : if (undoSw) { area->StopScanLine(); Image->uBitmap->StopScanLine(); MainImageForm->Undo->RemoveLast(); } if(area)delete area; EXCEPTION_MESSAGE_OK(ec); END_LOG; /* //BeConverted by linuxjun Don't Forget!! Undo_Method int c, d, x, y, xi; double sd, xd, l, alpha1, alpha2, theta, a, b, x1, x2, y1, y2, si, yi, yd; TPoint u_ptr, tp, tp1, tp2; Byte *IPP, *IPM, *AP, *APN, *LPP, *LPM; TUnionBitmap *area; // convert by celberus bool undoSw = false, sw; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) goto fail; ud = Undo->Last; area = Undo->Last->Bitmap; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); if(Image->uBitmap->StartScanLine() == false) goto fail; if(area->StartScanLine() == false) goto fail; if(Image->LayerMask->StartScanLine() == false) goto fail; if (item == TREPRO_XFIX) { sw = UpDownLabel->Caption == IDS_COMMON_UP; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; y1 = l * a; y2 = l * b; if (sw) { tp1 = Point(window.s.x + (window.size.x >> 1), window.e.y); } else { tp1 = Point(window.s.x + (window.size.x >> 1), window.s.y); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; AP = area->GetScanLine(u_ptr.y) + u_ptr.x; LPP = LPM = Image->LayerMask->GetScanLine(tp2.y) + tp2.x; for (x = 0; x < xd; x++, IPP++, IPM--, LPP++, LPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); *LPP = 0; } if (tp2.x - x >= 0) { *IPM = *(AP - xi); *LPM = 0; } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); *LPP = 0; } if (tp2.x - x >= 0) { *IPM = *(AP - xi); *LPM = 0; } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + tp2.x; AP = area->GetScanLine(u_ptr.y) + u_ptr.x; LPP = LPM = Image->LayerMask->GetScanLine(tp2.y) + tp2.x; for (x = 0; x < xd; x++, IPP++, IPM--, LPP++, LPM--) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); *LPP = 0; } if (tp2.x - x >= 0) { *IPM = *(AP - xi); *LPM = 0; } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { *IPP = *(AP + xi); *LPP = 0; } if (tp2.x - x >= 0) { *IPM = *(AP - xi); *LPM = 0; } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } } } else { for (d = 0; d < y1 + y2; d++) { if (d < y1) { theta = atan((y1 - d) / l); c = (window.size.y / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y) + 3 * u_ptr.x; LPP = Image->LayerMask->GetScanLine(tp2.y); for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y +- d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } else { theta = atan((d - y1) / l); c = window.size.y / (2.0 * a) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x, tp1.y - c); tp2 = Point(tp1.x, tp1.y - d); } else { u_ptr = Point(tp1.x, tp1.y + c); tp2 = Point(tp1.x, tp1.y + d); } si = window.size.y / (2.0 * a * cos(alpha1 + theta)); sd = l / cos(theta); xd = window.size.x * sd / (2.0 * si); IPP = IPM = Image->uBitmap->GetScanLine(tp2.y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y) + 3 * u_ptr.x; LPP = Image->LayerMask->GetScanLine(tp2.y); for (x = 0; x < xd; x++, IPP += 3, IPM -= 3) { xi = x * si / sd; if (sw) { if ((tp2.y == window.e.y - d) || (tp2.y == window.e.y - d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } else { if ((tp2.y == window.s.y + d) || (tp2.y == window.s.y + d + 1)) { if (tp2.x + x < Image->uBitmap->Width) { APN = AP + 3 * xi; CopyPixel24(IPP, APN); *(LPP + ((tp2.x+x)>>3)) &= ~(0x80 >> ((tp2.x+x)&7)); } if (tp2.x - x >= 0) { APN = AP - 3 * xi; CopyPixel24(IPM, APN); *(LPP + ((tp2.x-x)>>3)) &= ~(0x80 >> ((tp2.x-x)&7)); } } } } Image->uBitmap->PutScanLine(tp2.y); Image->LayerMask->PutScanLine(tp2.y); } } } } else if (item == TREPRO_YFIX) { sw = LeftRightLabel->Caption == IDS_COMMON_LEFT; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l = s_repro.ratio; x1 = l * a; x2 = l * b; if (sw) { tp1 = Point(window.e.x, window.s.y + (window.size.y >> 1)); } else { tp1 = Point(window.s.x, window.s.y + (window.size.y >> 1)); } if (Image->uBitmap->BitsPerPixel==8) { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { *(Image->uBitmap->GetScanLine(tp2.y + y) + tp2.x) = *(area->GetScanLine(u_ptr.y + yi) + u_ptr.x); *(Image->LayerMask->GetScanLine(tp2.y + y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { *(Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x) = *(area->GetScanLine(u_ptr.y - yi) + u_ptr.x); *(Image->LayerMask->GetScanLine(tp2.y - y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { *(Image->uBitmap->GetScanLine(tp2.y + y) + tp2.x) = *(area->GetScanLine(u_ptr.y + yi) + u_ptr.x); *(Image->LayerMask->GetScanLine(tp2.y + y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { *(Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x) = *(area->GetScanLine(u_ptr.y - yi) + u_ptr.x); *(Image->LayerMask->GetScanLine(tp2.y - y) + tp2.x) = 0; Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } } } else { for (d = 0; d < x1 + x2; d++) { if (d < x1) { theta = atan((x1 - d) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 - theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 - theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y + yi) + 3 * u_ptr.x; LPP = Image->LayerMask->GetScanLine(tp2.y + y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y - yi) + 3 * u_ptr.x; LPP = Image->LayerMask->GetScanLine(tp2.y - y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } else { theta = atan((d - x1) / l); c = (window.size.x / (2.0 * a)) * tan(alpha1 + theta); if (sw) { u_ptr = Point(tp1.x - c, tp1.y); tp2 = Point(tp1.x - d, tp1.y); } else { u_ptr = Point(tp1.x + c, tp1.y); tp2 = Point(tp1.x + d, tp1.y); } si = window.size.x / (2 * a * cos(alpha1 + theta)); sd = l / cos(theta); yd = window.size.y * sd / (2.0 * si); for (y = 0; y < yd; y++) { yi = y * si / sd; tp.y = window.s.y + (window.size.y >> 1); if (tp.y + y < Image->uBitmap->Height) { IPP = Image->uBitmap->GetScanLine(tp2.y + y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y + yi) + 3 * u_ptr.x; LPP = Image->LayerMask->GetScanLine(tp2.y + y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y + y); Image->LayerMask->PutScanLine(tp2.y + y); } if (tp.y - y >= 0) { IPP = Image->uBitmap->GetScanLine(tp2.y - y) + 3 * tp2.x; AP = area->GetScanLine(u_ptr.y - yi) + 3 * u_ptr.x; LPP = Image->LayerMask->GetScanLine(tp2.y - y); CopyPixel24(IPP, AP); *(LPP + (tp2.x>>3)) &= ~(0x80 >> (tp2.x&7)); Image->uBitmap->PutScanLine(tp2.y - y); Image->LayerMask->PutScanLine(tp2.y - y); } } } } } } Image->LayerMask->StopScanLine(); area->StopScanLine(); Image->uBitmap->StopScanLine(); ud->Complete(); ::RepaintImage(); return; fail : if (undoSw) { area->StopScanLine(); Image->uBitmap->StopScanLine(); Undo->RemoveLast(); } EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } //--------------------------------------------------------------------------- void __fastcall TReproForm::compute_len(int &l1, int &l2) { double alpha1, alpha2, a, b; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); l1 = window.size.y * cos(alpha1) / (2.0 * a); l2 = window.size.y / (a + b); } //--------------------------------------------------------------------------- void __fastcall TReproForm::repro_dis(double *a, double *b, double *c, double *sqr, int i, int j, int k) { a[i] = Rpos[j].y - Rpos[k].y; b[i] = Rpos[k].x - Rpos[j].x; c[i] = Rpos[j].x * Rpos[k].y - Rpos[k].x * Rpos[j].y; sqr[i] = sqrt(a[i] * a[i] + b[i] * b[i]); if(sqr[i]==0){sqr[i]=1; c[i]=Rpos[j].x;} } //--------------------------------------------------------------------------- void __fastcall TReproForm::pull_image_repro(void) { BEGIN_LOG(""); ///* //BeConverted by linuxjun for Undo_Method int x, y, nx, ny, winlx, winly; double lx1, lx2, ly1, ly2; double a[4], b[4], c[4], sqr[4]; TUnionBitmap *area=new TUnionBitmap; // convert by linuxjun Byte *IP, *AP, *MP; bool undoSw = false; TPlaneVertex pv; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; TPException ec = EC_NONE; // if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(window.s.x, window.s.y, window.e.x, window.e.y))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } //by linuxjun // ud = MainImageForm->Undo->GetLast(); // area = ud->uBitmap; if (Image->uBitmap->BitsPerPixel==8) { RGBQUAD rgb[256]; Image->uBitmap->GetColors(0, 256, rgb); if(!area->Create(window.e.x-window.s.x, window.e.y-window.s.y, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x, window.e.y-window.s.y,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); }else { if(!area->Create(window.e.x-window.s.x, window.e.y-window.s.y, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x, window.e.y-window.s.y,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); } Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); pv.Create(Rpos[0], Rpos[1], Rpos[2], Rpos[3]); repro_dis(a, b, c, sqr, 0, 0, 1); repro_dis(a, b, c, sqr, 1, 2, 3); repro_dis(a, b, c, sqr, 2, 3, 0); repro_dis(a, b, c, sqr, 3, 1, 2); winlx = window.size.x - 1; winly = window.size.y - 1; if (Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (area->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 && (*MP == 0)) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; if(lx1==0 && lx2==0) lx2=1; if(ly1==0 && ly2==0) ly2=1; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // *IP = *(area->GetScanLine(window.s.y+ny) + window.s.x + nx); *IP = *(area->GetScanLine(ny) + nx); //by linuxjun } } } } Image->uBitmap->PutScanLine(y, pv.start.x, pv.end.x-pv.start.x +1); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (*MP == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; if(lx1==0 && lx2==0) lx2=1; if(ly1==0 && ly2==0) ly2=1; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); *IP = *(area->GetScanLine(ny)+nx); //by linuxjun } } } } Image->uBitmap->PutScanLine(y, pv.start.x, pv.end.x-pv.start.x +1); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if ((MP[x >> 3] & (0x80 >> (x & 7))) == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; if(lx1==0 && lx2==0) lx2=1; if(ly1==0 && ly2==0) ly2=1; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); AP = area->GetScanLine(ny)+3*(nx); //by linuxjun CopyPixel24(IP, AP); } } } } Image->uBitmap->PutScanLine(y, pv.start.x, pv.end.x-pv.start.x +1); } } } Image->Mask->StopScanLine(); } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; if(lx1==0 && lx2==0) lx2=1; if(ly1==0 && ly2==0) ly2=1; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); *IP = *(area->GetScanLine(ny)+nx); //by linuxjun } } } } Image->uBitmap->PutScanLine(y, pv.start.x, pv.end.x-pv.start.x +1); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; if(lx1==0 && lx2==0) lx2=1; if(ly1==0 && ly2==0) ly2=1; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); *IP = *(area->GetScanLine(ny)+nx); //by linuxjun } } } Image->uBitmap->PutScanLine(y, pv.start.x, pv.end.x-pv.start.x +1); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; if(lx1==0 && lx2==0) lx2=1; if(ly1==0 && ly2==0) ly2=1; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); AP = area->GetScanLine(ny)+3*(nx); //by linuxjun CopyPixel24(IP, AP); } } } Image->uBitmap->PutScanLine(y, pv.start.x, pv.end.x-pv.start.x +1); } } } } area->StopScanLine(); Image->uBitmap->StopScanLine(); // ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); //2001.6.19 by lhskys autorepeat ::RepaintImage(); if(area)delete area; END_LOG; return; fail : Image->Mask->StopScanLine(); area->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) MainImageForm->Undo->RemoveLast(); if(area)delete area; EXCEPTION_MESSAGE_OK(ec); END_LOG; /* //BeConverted by linuxjun Don't Forget!! Undo_Method int x, y, nx, ny, winlx, winly; double lx1, lx2, ly1, ly2; double a[4], b[4], c[4], sqr[4]; TUnionBitmap *area=New TUnionBitmap; // convert by celberus Byte *IP, *AP, *MP; bool undoSw = false; TPlaneVertex pv; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; // if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) goto fail; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(window.s.x, window.s.y, window.e.x, window.e.y))) == false) goto fail; //by linuxjun ud = MainImageForm->Undo->GetLast(); area = ud->uBitmap; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); pv.Create(Rpos[0], Rpos[1], Rpos[2], Rpos[3]); repro_dis(a, b, c, sqr, 0, 0, 1); repro_dis(a, b, c, sqr, 1, 2, 3); repro_dis(a, b, c, sqr, 2, 3, 0); repro_dis(a, b, c, sqr, 3, 1, 2); winlx = window.size.x - 1; winly = window.size.y - 1; if (Image->uBitmap->StartScanLine() == false) goto fail; if (area->StartScanLine() == false) goto fail; if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 && (*MP == 0)) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny) + window.s.x + nx); } } } } Image->uBitmap->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (*MP == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } } Image->uBitmap->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if ((MP[x >> 3] & (0x80 >> (x & 7))) == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); } } } } Image->uBitmap->PutScanLine(y); } } } Image->Mask->StopScanLine(); } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } } Image->uBitmap->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } Image->uBitmap->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); } } } Image->uBitmap->PutScanLine(y); } } } } area->StopScanLine(); Image->uBitmap->StopScanLine(); // ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); //2001.6.19 by lhskys autorepeat ::RepaintImage(); return; fail : Image->Mask->StopScanLine(); area->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) MainImageForm->Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ /* //BeConverted by linuxjun Don't Forget!! Undo_Method int x, y, nx, ny, winlx, winly; double lx1, lx2, ly1, ly2; double a[4], b[4], c[4], sqr[4]; TUnionBitmap *area; // convert by celberus Byte *IP, *AP, *MP; bool undoSw = false; TPlaneVertex pv; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) goto fail; ud = Undo->Last; area = ud->Bitmap; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); pv.Create(Rpos[0], Rpos[1], Rpos[2], Rpos[3]); repro_dis(a, b, c, sqr, 0, 0, 1); repro_dis(a, b, c, sqr, 1, 2, 3); repro_dis(a, b, c, sqr, 2, 3, 0); repro_dis(a, b, c, sqr, 3, 1, 2); winlx = window.size.x - 1; winly = window.size.y - 1; if (Image->uBitmap->StartScanLine() == false) goto fail; if (area->StartScanLine() == false) goto fail; if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 && (*MP == 0)) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny) + window.s.x + nx); } } } } Image->uBitmap->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (*MP == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } } Image->uBitmap->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if ((MP[x >> 3] & (0x80 >> (x & 7))) == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); } } } } Image->uBitmap->PutScanLine(y); } } } Image->Mask->StopScanLine(); } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } } Image->uBitmap->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } Image->uBitmap->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); } } } Image->uBitmap->PutScanLine(y); } } } } area->StopScanLine(); Image->uBitmap->StopScanLine(); ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); //2001.6.19 by lhskys autorepeat ::RepaintImage(); return; fail : Image->Mask->StopScanLine(); area->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } //--------------------------------------------------------------------------- void __fastcall TReproForm::pull_image_repro_layer(void) { BEGIN_LOG(""); ///* //BeConverted by linuxjun Don't Forget!! Undo_Method int x, y, nx, ny, winlx, winly; double lx1, lx2, ly1, ly2; double a[4], b[4], c[4], sqr[4]; TUnionBitmap *layermask=new TUnionBitmap; TUnionBitmap *area=new TUnionBitmap; // convert by celberus Byte *IP, *AP, *MP, *LP, *ULP; bool undoSw = false; TPlaneVertex pv; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; // THistoryData *ud; // if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(window.s.x, window.s.y, window.e.x, window.e.y))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } //by linuxjun // ud = MainImageForm->Undo->GetLast(); if (Image->uBitmap->BitsPerPixel==8) { RGBQUAD rgb[256]; Image->uBitmap->GetColors(0, 256, rgb); if(!area->Create(window.e.x-window.s.x, window.e.y-window.s.y, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x, window.e.y-window.s.y,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); if(!layermask->Create(window.e.x-window.s.x, window.e.y-window.s.y, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } layermask->Copy(0,0,window.e.x-window.s.x, window.e.y-window.s.y,Image->LayerMask,window.s.x,window.s.y,SRCCOPY); }else { if(!area->Create(window.e.x-window.s.x, window.e.y-window.s.y, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } area->Copy(0,0,window.e.x-window.s.x, window.e.y-window.s.y,Image->uBitmap,window.s.x,window.s.y,SRCCOPY); if(!layermask->Create(window.e.x-window.s.x, window.e.y-window.s.y, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } layermask->Copy(0,0,window.e.x-window.s.x, window.e.y-window.s.y,Image->LayerMask,window.s.x,window.s.y,SRCCOPY); } //area = ud->uBitmap; //layermask = ud->LayerMask; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); pv.Create(Rpos[0], Rpos[1], Rpos[2], Rpos[3]); repro_dis(a, b, c, sqr, 0, 0, 1); repro_dis(a, b, c, sqr, 1, 2, 3); repro_dis(a, b, c, sqr, 2, 3, 0); repro_dis(a, b, c, sqr, 3, 1, 2); winlx = window.size.x - 1; winly = window.size.y - 1; if (Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (area->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (layermask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel==8) { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y)+ window.s.x; for (x = window.s.x; x < window.e.x; x++, LP++) { if (x < Image->uBitmap->Width) { *(LP) = 0xFF; } } Image->LayerMask->PutScanLine(y,window.s.x,window.e.x-window.s.x+1); } } } else { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y); for (x = window.s.x; x < window.e.x; x++) { if (x < Image->uBitmap->Width) { *(LP + (x>>3)) |= (0x80 >> (x&7)); } } Image->LayerMask->PutScanLine(y,window.s.x,window.e.x-window.s.x+1); } } } if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; LP = Image->LayerMask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++, LP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 && (*MP == 0)) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(ny)+nx); // ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; ULP = layermask->GetScanLine(ny)+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); Image->LayerMask->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; LP = Image->LayerMask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++, LP++) { if (x < Image->uBitmap->Width) { if (*MP == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); // ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; *IP = *(area->GetScanLine(ny)+nx); ULP = layermask->GetScanLine(ny)+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); Image->LayerMask->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; MP = Image->Mask->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if ((MP[x >> 3] & (0x80 >> (x & 7))) == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); // AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); AP = area->GetScanLine(ny)+3*(nx); CopyPixel24(IP, AP); // ULP = layermask->GetScanLine(window.s.y+ny)+((window.s.x+nx)>>3); ULP = layermask->GetScanLine(ny)+((nx)>>3); if( !( ( ( 0x80 >> ((nx)&7) ) ) & (*ULP) ) ) *(LP + (x>>3)) &= ~(0x80 >> (x&7)); else *(LP + (x>>3)) |= (0x80 >> (x&7)); } } } } Image->uBitmap->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); Image->LayerMask->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); } } } Image->Mask->StopScanLine(); } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; LP = Image->LayerMask->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, LP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(ny)+nx); ULP = layermask->GetScanLine(ny)+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); Image->LayerMask->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; LP = Image->LayerMask->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, LP++) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(ny)+nx); ULP = layermask->GetScanLine(ny)+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } Image->uBitmap->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); Image->LayerMask->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; LP = Image->LayerMask->GetScanLine(y); for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(ny)+3*(nx); CopyPixel24(IP, AP); ULP = layermask->GetScanLine(ny)+((nx)>>3); if( !( ( ( 0x80 >> ((nx)&7) ) ) & (*ULP) ) ) *(LP + (x>>3)) &= ~(0x80 >> (x&7)); else *(LP + (x>>3)) |= (0x80 >> (x&7)); } } } Image->uBitmap->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); Image->LayerMask->PutScanLine(y,pv.start.x,pv.end.x-pv.start.x+1); } } } } Image->LayerMask->StopScanLine(); area->StopScanLine(); layermask->StopScanLine(); Image->uBitmap->StopScanLine(); // ud->Complete(); if(area)delete area; if(layermask)delete layermask; ::RepaintImage(); END_LOG; return; fail : Image->Mask->StopScanLine(); Image->LayerMask->StopScanLine(); area->StopScanLine(); layermask->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) MainImageForm->Undo->RemoveLast(); if(area)delete area; if(layermask)delete layermask; EXCEPTION_MESSAGE_OK(ec); END_LOG; /* //BeConverted by linuxjun Don't Forget!! Undo_Method int x, y, nx, ny, winlx, winly; double lx1, lx2, ly1, ly2; double a[4], b[4], c[4], sqr[4]; TUnionBitmap *layermask, *area; // convert by celberus Byte *IP, *AP, *MP, *LP, *ULP; bool undoSw = false; TPlaneVertex pv; TPItemImage *Image = MainImageForm->iMainImage; THistoryData *ud; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) goto fail; ud = Undo->Last; area = ud->Bitmap; layermask = ud->LayerMask; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); pv.Create(Rpos[0], Rpos[1], Rpos[2], Rpos[3]); repro_dis(a, b, c, sqr, 0, 0, 1); repro_dis(a, b, c, sqr, 1, 2, 3); repro_dis(a, b, c, sqr, 2, 3, 0); repro_dis(a, b, c, sqr, 3, 1, 2); winlx = window.size.x - 1; winly = window.size.y - 1; if (Image->uBitmap->StartScanLine() == false) goto fail; if (area->StartScanLine() == false) goto fail; if (layermask->StartScanLine() == false) goto fail; if (Image->LayerMask->StartScanLine() == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y)+ window.s.x; for (x = window.s.x; x < window.e.x; x++, LP++) { if (x < Image->uBitmap->Width) { *(LP) = 0xFF; } } Image->LayerMask->PutScanLine(y); } } } else { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y); for (x = window.s.x; x < window.e.x; x++) { if (x < Image->uBitmap->Width) { *(LP + (x>>3)) |= (0x80 >> (x&7)); } } Image->LayerMask->PutScanLine(y); } } } if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; LP = Image->LayerMask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++, LP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 && (*MP == 0)) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; LP = Image->LayerMask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++, LP++) { if (x < Image->uBitmap->Width) { if (*MP == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; MP = Image->Mask->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if ((MP[x >> 3] & (0x80 >> (x & 7))) == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); ULP = layermask->GetScanLine(window.s.y+ny)+((window.s.x+nx)>>3); if( !( ( ( 0x80 >> ((window.s.x+nx)&7) ) ) & (*ULP) ) ) *(LP + (x>>3)) &= ~(0x80 >> (x&7)); else *(LP + (x>>3)) |= (0x80 >> (x&7)); } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } Image->Mask->StopScanLine(); } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; LP = Image->LayerMask->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, LP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; LP = Image->LayerMask->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, LP++) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; LP = Image->LayerMask->GetScanLine(y); for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); ULP = layermask->GetScanLine(window.s.y+ny)+((window.s.x+nx)>>3); if( !( ( ( 0x80 >> ((window.s.x+nx)&7) ) ) & (*ULP) ) ) *(LP + (x>>3)) &= ~(0x80 >> (x&7)); else *(LP + (x>>3)) |= (0x80 >> (x&7)); } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } } Image->LayerMask->StopScanLine(); area->StopScanLine(); layermask->StopScanLine(); Image->uBitmap->StopScanLine(); ud->Complete(); ::RepaintImage(); return; fail : Image->Mask->StopScanLine(); Image->LayerMask->StopScanLine(); area->StopScanLine(); layermask->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); */ } //--------------------------------------------------------------------------- void __fastcall TReproForm::PullMouseDown(int x, int y) { int i; for (i = 0; i <= 3; i++) { if ((Rpos[i].x < x + 5) && (Rpos[i].x > x - 5) && (Rpos[i].y < y + 5) && (Rpos[i].y > y - 5)) { if (PullStep == 0) { PullStep = i + 1; break; } else { PullStep = 0; break; } } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::PullMouseMove(int x, int y) { int i; TPItemImage *Image = MainImageForm->iMainImage; for (i = 0; i <= 3; i++) { if ((Rpos[i].x < x + 5) && (Rpos[i].x > x - 5) && (Rpos[i].y < y + 5) && (Rpos[i].y > y - 5)) { Image->Cursor = crHandPoint; break; } else { if (!MainImageForm->iMainImage->Cross)Image->Cursor = crCross; } } if (PullStep) { Rpos[PullStep - 1].x = x; Rpos[PullStep - 1].y = y; } moveline(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::XReproMode(void) { double alpha1, alpha2, a, b, e1, e2; item = TREPRO_XFIX; // RectPanel->Visible = false; // PullPanel->Visible = false; // YPanel->Visible = false; // XPanel->Visible = true; s_repro.angle = 45; edAngle->Value = s_repro.angle; // EXAngle->Value = s_repro.angle; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); e1 = window.size.x * cos(alpha1) / (2.0 * a); e2 = window.size.y / (a + b); s_repro.ratio = (e1 + e2) / 2.0; // EXratio->Value = s_repro.ratio; edRatio->Value = s_repro.ratio; XTextItem = _StateUp; // UpDownLabel->Caption = IDS_COMMON_UP; PullEdit(edAngle); // PullEdit(EXAngle); // EXAngle->SetFocus(); // EXAngle->SelectAll(); edAngle->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::PullMode(void) { item = TREPRO_PULL; rzplRect->Visible = false; // YPanel->Visible = false; rzplPersp->Visible = false; rzplPull->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TReproForm::YReproMode(void) { double alpha1, alpha2, a, b, e1, e2; item = TREPRO_YFIX; // RectPanel->Visible = false; // PullPanel->Visible = false; // XPanel->Visible = false; // YPanel->Visible = true; s_repro.angle = 45; // eYAngle->Value = s_repro.angle; edAngle->Value = s_repro.angle; alpha1 = (90.0 - s_repro.angle) * M_PI / 180.0; a = tan(alpha1); alpha2 = atan(2.0 * a) - alpha1; b = tan(alpha2); e1 = window.size.x * cos(alpha1) / (2.0 * a); e2 = window.size.y / (a + b); s_repro.ratio = (e1 + e2) / 2.0; // eYratio->Value = s_repro.ratio; edRatio->Value = s_repro.ratio; YTextItem = _StateLeft; // LeftRightLabel->Caption = IDS_COMMON_LEFT; // PullEdit(eYAngle); PullEdit(edAngle); // eYAngle->SetFocus(); edAngle->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::RectMode(void) { item = TREPRO_RECT; rzplPull->Visible = false; rzplPersp->Visible = false; // YPanel->Visible = false; rzplRect->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TReproForm::SubMouseMove(int X, int Y) { BEGIN_LOG(""); // HDC /*imageDC = NULL,*/ maskDC = NULL, /*reproDC = NULL, wbitmapDC = NULL, // convert by celberus // wmaskDC = NULL, wbackDC = NULL*/; bool crtSw = false, crtSw1 = false, crtSw2 = false; RECT r; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; if (X < 0) X = 0; else if (X > Image->uBitmap->Width) X = Image->uBitmap->Width; if (Y < 0) Y = 0; else if (Y > Image->uBitmap->Height) Y = Image->uBitmap->Height; if (item == TREPRO_RECT) { if (X < window.s.x) { ReproRect.s.x = X; ReproRect.e.x = window.e.x; ReproRect.size.x = window.e.x - X; } else { ReproRect.s.x = window.s.x; ReproRect.e.x = X; ReproRect.size.x = X - ReproRect.s.x; } if (Y < window.s.y) { ReproRect.s.y = Y; ReproRect.e.y = window.e.y; ReproRect.size.y = window.e.y - Y; } else { ReproRect.s.y = window.s.y; ReproRect.e.y = Y; ReproRect.size.y = Y - ReproRect.s.y; } Image->SubRange.left = ReproRect.s.x; Image->SubRange.top = ReproRect.s.y; Image->SubRange.right = ReproRect.e.x; Image->SubRange.bottom = ReproRect.e.y; if (ReproRect.size.x == 0 || ReproRect.size.y == 0) { END_LOG; return; } #ifndef FASTAR if (Image->uBitmap->BitsPerPixel==8) { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 1)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } // if ((imageDC = Image->uBitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((wbackDC = window.Back->CreateDC()) == NULL) goto fail; // if ((wmaskDC = window.Mask->CreateDC()) == NULL) goto fail; // if ((wbitmapDC = window.Bitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((reproDC = Image->SubBitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((maskDC = Image->SubMask->CreateDC()) == NULL) goto fail; // SetStretchBltMode(maskDC, COLORONCOLOR); // StretchBlt(maskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, window.size.x, window.size.y, SRCCOPY); Image->SubMask->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, window.size.x, window.size.y, SRCCOPY); // convert by celberus // Image->SubMask->DeleteDC(maskDC); // BitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, imageDC, ReproRect.s.x, ReproRect.s.y, SRCCOPY); // Image->uBitmap->UnionBitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, ReproRect.s.x, ReproRect.s.y, SRCCOPY, false); // convert by celberus window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, Image->uBitmap, ReproRect.s.x, ReproRect.s.y, SRCCOPY); // convert by celberus // SetStretchBltMode(wbackDC, COLORONCOLOR); // StretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, window.size.x, window.size.y, SRCAND); window.Back->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, window.size.x, window.size.y, SRCAND); // convert by celberus // StretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wbitmapDC, 0, 0, window.size.x, window.size.y, SRCPAINT); // window.Bitmap->UnionStretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, window.size.x, window.size.y, SRCPAINT); // convert by celberus window.Back->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Bitmap, 0, 0, window.size.x, window.size.y, SRCPAINT); // convert by celberus // BitBlt(reproDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wbackDC, 0, 0, SRCCOPY); // Image->SubBitmap->UnionBitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, SRCCOPY, true); // convert by celberus Image->SubBitmap->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Back, 0, 0, SRCCOPY); // convert by celberus // if (maskDC) Image->SubMask->DeleteDC(maskDC); // ¾ø¾î¼­ Ãß°¡ by celberus // Image->SubBitmap->DeleteDC(reproDC); convert by celberus // window.Bitmap->DeleteDC(wbitmapDC); convert by celberus // window.Mask->DeleteDC(wmaskDC); // window.Back->DeleteDC(wbackDC); // Image->uBitmap->DeleteDC(imageDC); convert by celberus #else Image->setSubPaintType(typeExpansion); // by celberus Image->setSubPaintRatio((double)ReproRect.size.x / window.size.x, (double)ReproRect.size.y / window.size.y ); // by celberus #endif SetSizeText(); Image->SubVisible = true; r.left = paintrect.left < Image->SubRange.left ? paintrect.left : Image->SubRange.left; r.top = paintrect.top < Image->SubRange.top ? paintrect.top : Image->SubRange.top; r.right = paintrect.right > Image->SubRange.right ? paintrect.right : Image->SubRange.right; r.bottom = paintrect.bottom > Image->SubRange.bottom ? paintrect.bottom : Image->SubRange.bottom; paintrect = Image->SubRange; Image->RectPaint(r); } else if (item == TREPRO_PULL) { PullMouseMove(X, Y); } END_LOG; return; fail: // if (maskDC) Image->SubMask->DeleteDC(maskDC); // if (reproDC) Image->SubBitmap->DeleteDC(reproDC); convert by celberus // if (wbitmapDC) window.Bitmap->DeleteDC(wbitmapDC); convert by celberus // if (wmaskDC) window.Mask->DeleteDC(wmaskDC); // if (wbackDC) window.Back->DeleteDC(wbackDC); // if (imageDC) Image->uBitmap->DeleteDC(imageDC); convert by celberus if (crtSw2) Image->SubMask->Destroy(); if (crtSw1) Image->SubBitmap->Destroy(); if (crtSw) window.Back->Destroy(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::InitRect() { ReproRect.s.x = window.s.x; ReproRect.e.x = window.e.x; ReproRect.s.y = window.s.y; ReproRect.e.y = window.e.y; ReproRect.size.x = window.size.x; ReproRect.size.y = window.size.y; MainImageForm->iMainImage->SubEnabled = true; MainImageForm->iMainImage->SubVisible = false; #ifdef FASTAR initSubBitmap(); #endif } //--------------------------------------------------------------------------- void __fastcall TReproForm::ExitRect() { MainImageForm->iMainImage->SubVisible = false; MainImageForm->iMainImage->SubEnabled = false; } //--------------------------------------------------------------------------- void __fastcall TReproForm::SetSizeText() { // if (btnSize->Caption == IDS_COMMON_LENGTH) { // switch (MainImageForm->CurrentUnit) { // case uDot : nedXSize->Value = ReproRect.size.x; break; // case uInch : nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch; break; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch))); break; // case uCm : nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54; break; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); // } // switch (MainImageForm->CurrentUnit) { // case uDot : nedYSize->Value = ReproRect.size.y; break; // case uInch : nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch; break; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch))); break; // case uCm : nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54; break; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); // } // } else if (btnSize->Caption == IDS_RATIO) { // nedXSize->Value = 100.0 * ReproRect.size.x / window.size.x; // //Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.x / window.size.x))); // nedYSize->Value = 100.0 * ReproRect.size.y / window.size.y; // //Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.y / window.size.y))); // } if (rzcbUnit->ItemIndex ==0) { nedXSize->Value = 100.0 * ReproRect.size.x / window.size.x; nedYSize->Value = 100.0 * ReproRect.size.y / window.size.y; } else if (rzcbUnit->ItemIndex ==1) { nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54; nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54; } else if (rzcbUnit->ItemIndex ==2) { nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch; nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch; } else if (rzcbUnit->ItemIndex == 3) { nedXSize->Value = ReproRect.size.x; nedYSize->Value = ReproRect.size.y; } } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TReproForm::InitForm() { BEGIN_LOG(""); TCursor OldCursor; // TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //ParentHeight = Parent->Height+20; ClientHeight = 216; /// °¢ Formµé µ¶¸³ÀûÀ¸·Î °ü¸®Çϱâ À§ÇØ ÁÖ¼®Ã³¸® //Parent->Height = ParentHeight+ClientHeight; window.Bitmap = NULL; window.Mask = NULL; window.Back = NULL; if ((window.Bitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus if ((window.Mask = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((window.Back = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } #ifdef FASTAR initWindowBitmap(); #endif PullStep = 0; XTextItem = _StateUp; YTextItem = _StateLeft; item = TREPRO_RECT; rzbtRect->Down = true; rzbtRect->Click(); rzplPull->Visible = false; // XPanel->Visible = false; rzplPersp->Visible = false; rzplRect->Visible = true; #ifndef FASTAR SetReproImage(); #endif Rpos[0].x = window.s.x; Rpos[0].y = window.s.y; Rpos[1].x = window.e.x; Rpos[1].y = window.s.y; Rpos[2].x = window.e.x; Rpos[2].y = window.e.y; Rpos[3].x = window.s.x; Rpos[3].y = window.e.y; ChangeUnit(MainImageForm->CurrentUnit); // SelectNext((TWinControl *)btnRectRun, true, true); Screen->Cursor = OldCursor; // btnRectRun->SetFocus(); //lhskys ½ÃÀ۽à focus¸¦ Ç¥½ÃÇϵµ·Ï // À§ÀÇ setfocus ¹Ú»óÈÆÀÌ ÁÖ¼®Ã³¸® (05.04.21) - ¿Ö ÇÊ¿äÇÑÁö ¾Ë¼ö¾øÀ½(ÇöÀç ´ÜÃàŰ // »ç¿ë½Ã ¹®Á¦(abstract¿¡·¯ ¹ß»ý)°¡ ¹ß»ýÇϱ⠶§¹®¿¡ ÁÖ¼®À¸·Î ó¸®ÇßÀ½) norun = 0; //lhskys ¿£ÅÍ۸¦ ÃÆÀ»¶§ ½ÇÇà À¯¹«¸¦ Ç¥½ÃÇϱâÀ§ÇØ //nedXSize->Enabled = false; //nedYSize->Enabled = false; // by celberus rzcbUnit->ItemIndex = 0; ReproForm->Width = 210; END_LOG; return; fail: if (window.Back) delete window.Back; if (window.Mask) delete window.Mask; if (window.Bitmap) delete window.Bitmap; Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::ExitForm(void) { TPItemImage *Image = MainImageForm->iMainImage; if (window.Back) { delete window.Back; window.Back = 0; } if (window.Mask) { delete window.Mask; window.Mask = 0; } if (window.Bitmap) { delete window.Bitmap; window.Bitmap = 0; } ExitRect(); Image->OnPaintLocate=NULL; #ifdef FASTAR Image->setSubPaintType(typeNone); // by celberus #endif Image->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::rect_repro(void) { BEGIN_LOG(""); TCursor OldCursor; RECT rd, rs1, rs2; bool undoSw = false; HRGN hRgn = NULL; TPItemImage *Image = MainImageForm->iMainImage; TTexpiaBitmap *Mask = NULL; TPException ec = EC_NONE; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; ReproRect.e.x = ReproRect.s.x + ReproRect.size.x; ReproRect.e.y = ReproRect.s.y + ReproRect.size.y; if (ReproRect.e.x > Image->uBitmap->Width) { ReproRect.e.x = Image->uBitmap->Width; ReproRect.size.x = ReproRect.e.x - ReproRect.s.x; } if (ReproRect.e.y > Image->uBitmap->Height) { ReproRect.e.y = Image->uBitmap->Height; ReproRect.size.y = ReproRect.e.y - ReproRect.s.y; } rs1.left = window.s.x; rs1.top = window.s.y; rs1.right = window.s.x + window.size.x; rs1.bottom = window.s.y + window.size.y; rs2.left = ReproRect.s.x; rs2.top = ReproRect.s.y; rs2.right = ReproRect.e.x; rs2.bottom = ReproRect.e.y; UnionRect(&rd, &rs1, &rs2); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) rd = MainImageForm->AutoRep_UndoRect(rd); //2001.6.19 by lhskys autorepeat if ((undoSw = MainImageForm->UndoSave(UK_ALL, rd)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((Mask = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Mask->Copy(MainImageForm->WorkArea->Mask, SRCCOPY)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!rect_repro_layer()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!rect_repro_none()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (!Mask->ResizeStretch(ReproRect.size.x, ReproRect.size.y)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } hRgn = Mask2Region(Mask, ReproRect.s.x, ReproRect.s.y); delete Mask; MainImageForm->WorkArea->SetRegion(hRgn); DeleteObject(hRgn); MainImageForm->WorkAreaChange(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); //2001.6.19 by lhskys autorepeat ::RepaintImage(); SetReproImage(); Rpos[0].x = window.s.x; Rpos[0].y = window.s.y; Rpos[1].x = window.e.x; Rpos[1].y = window.s.y; Rpos[2].x = window.e.x; Rpos[2].y = window.e.y; Rpos[3].x = window.s.x; Rpos[3].y = window.e.y; ChangeUnit(MainImageForm->CurrentUnit); Screen->Cursor = OldCursor; END_LOG; return; fail: if (hRgn) DeleteObject(hRgn); if (Mask) delete Mask; if (undoSw) MainImageForm->Undo->RemoveLast(); Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- HRGN __fastcall TReproForm::Mask2Region(TTexpiaBitmap *Mask, int px, int py) { BEGIN_LOG(""); HRGN hRgn = NULL; int x, y, sw, p; Byte *mp, mm; Mask->StartScanLine(); if (Mask->BitsPerPixel == 8) { for (y=0; yHeight; y++) { mp = Mask->GetScanLine(y); sw = 0; for (x=0; xWidth; x++, mp++) { if (sw) { if (!*mp) sw = 2; } else { if (*mp) { sw = 1; p = x; } } if (sw == 2) { MergeRegion(hRgn, px + p, py + y, px + x, py + y + 1); sw = 0; } } if (sw == 1) { MergeRegion(hRgn, px + p, py + y, px + x, py + y + 1); } } } else { for (y=0; yHeight; y++) { mp = Mask->GetScanLine(y); sw = 0; mm = 0x80; for (x=0; xWidth; x++) { if (sw) { if (!(*mp & mm)) sw = 2; } else { if (*mp & mm) { sw = 1; p = x; } } if (sw == 2) { MergeRegion(hRgn, px + p, py + y, px + x, py + y + 1); sw = 0; } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } if (sw == 1) { MergeRegion(hRgn, px + p, py + y, px + x, py + y + 1); } } } Mask->StopScanLine(); END_LOG; return hRgn; fail: if (hRgn) DeleteObject(hRgn); END_LOG; return NULL; } //--------------------------------------------------------------------------- bool __fastcall TReproForm::MakeImage() { BEGIN_LOG(""); TPItemImage *Image = MainImageForm->iMainImage; // HDC /*imageDC = NULL, wbitmapDC = NULL,*/ wmaskDC = NULL, wbackDC = NULL; // convert by celberus Image->uBitmap->RgnBitmap->RemoveRegion(); // convert by celberus #ifdef FASTAR if (Image->uBitmap->BitsPerPixel == 8) { if (!window.Back->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) goto fail; } else { if (!window.Back->Create(ReproRect.size.x, ReproRect.size.y, 24)) goto fail; } #endif window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, Image->uBitmap, ReproRect.s.x, ReproRect.s.y, SRCCOPY); // convert by celberus window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, SRCAND); window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Bitmap, 0, 0, SRCPAINT); // convert by celberus if (Image->uBitmap->BitsPerPixel == 8) { Image->uBitmap->StartScanLine(); window.Back->StartScanLine(); Byte *IP, *WB; for (int y = 0; y < ReproRect.size.y; y++){ IP = Image->uBitmap->GetScanLine(ReproRect.s.y + y); WB = window.Back->GetScanLine(y); IP += ReproRect.s.x; for(int x = 0; x < ReproRect.size.x; x++, IP++, WB++){ if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 // »öº¸È£ »óŰ¡ ¾Æ´Ï¸é º¸¿©Áöµµ·Ï - by monkman (2009.10.08) || (MainImageForm->Palette->ColorData[*IP]->Protect != 0 && MainImageForm->bProtect == false)) { *IP = *WB; } } Image->uBitmap->PutScanLine(ReproRect.s.y + y); } Image->uBitmap->StopScanLine(); window.Back->StopScanLine(); } else { Image->uBitmap->Copy(ReproRect.s.x, ReproRect.s.y, ReproRect.size.x, ReproRect.size.y, window.Back, 0, 0, SRCCOPY); // convert by celberus } END_LOG; return true; fail: END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall TReproForm::rect_repro_none(void) { BEGIN_LOG(""); int i, j; Byte *IP, *WP, mm; COLORREF c; TPItemImage *Image = MainImageForm->iMainImage; // HDC /*wbitmapDC = NULL,*/ wmaskDC = NULL; //convert by celberus window.Mask->ResizeStretch(ReproRect.size.x, ReproRect.size.y); if (Image->uBitmap->BitsPerPixel==8) { window.Bitmap->ResizeStretch(ReproRect.size.x, ReproRect.size.y); if (!Image->uBitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; c = PaletteForm->DIB256Palette->GetBGCOLORREF(8); for (i=0; iuBitmap->GetScanLine(window.s.y+i)+window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(i); for (j=0; juBitmap->PutScanLine(window.s.y + i); } MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); } else { window.Bitmap->CopyFromRect(Image->uBitmap, window.s.x, window.s.y, SRCCOPY); window.Bitmap->ResizeStretch(ReproRect.size.x, ReproRect.size.y, true); // if((wbitmapDC = window.Bitmap->CreateDC()) == NULL) goto fail; convert by celberus // if((wmaskDC = window.Mask->CreateDC()) == NULL) goto fail; // BitBlt(wmaskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, NULL, 0, 0, DSTINVERT); window.Mask->UnionBitBlt(NULL, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, DSTINVERT, true); // convert by celberus // BitBlt(wbitmapDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, SRCAND); // window.Bitmap->UnionBitBlt(wmaskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, SRCAND, true); // convert by celberus window.Bitmap->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, SRCAND); // convert by celberus // BitBlt(wmaskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, NULL, 0, 0, DSTINVERT); window.Mask->UnionBitBlt(NULL, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, DSTINVERT, true); // convert by celberus // window.Mask->DeleteDC(wmaskDC); // window.Bitmap->DeleteDC(wbitmapDC); convert by celberus if (!Image->uBitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; c = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (i=0; iuBitmap->GetScanLine(window.s.y+i)+3*window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(i); mm = 0x80; for (j=0; j>= 1; } Image->uBitmap->PutScanLine(window.s.y + i); } MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); } MakeImage(); END_LOG; return true; fail: MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall TReproForm::rect_repro_layer(void) { BEGIN_LOG(""); int i, j; Byte *IP, *WP, mm, *LP; COLORREF c; TPItemImage *Image = MainImageForm->iMainImage; // HDC /*wbitmapDC = NULL,*/ wmaskDC = NULL; // convert by celberus window.Mask->ResizeStretch(ReproRect.size.x, ReproRect.size.y); if (Image->uBitmap->BitsPerPixel==8) { window.Bitmap->ResizeStretch(ReproRect.size.x, ReproRect.size.y); if (!Image->uBitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (!Image->LayerMask->StartScanLine()) goto fail; c = PaletteForm->DIB256Palette->GetBGCOLORREF(8); for (i=0; iuBitmap->GetScanLine(window.s.y+i)+window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(i); LP = Image->LayerMask->GetScanLine(window.s.y+i)+window.s.x; for (j=0; juBitmap->PutScanLine(window.s.y + i); Image->LayerMask->PutScanLine(window.s.y + i); } Image->LayerMask->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); } else { window.Bitmap->CopyFromRect(Image->uBitmap, window.s.x, window.s.y, SRCCOPY); window.Bitmap->ResizeStretch(ReproRect.size.x, ReproRect.size.y, true); // if((wbitmapDC = window.Bitmap->CreateDC()) == NULL) goto fail; convert by celberus // if((wmaskDC = window.Mask->CreateDC()) == NULL) goto fail; // BitBlt(wmaskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, NULL, 0, 0, DSTINVERT); window.Mask->UnionBitBlt(NULL, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, DSTINVERT, true); // convert by celberus // BitBlt(wbitmapDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, SRCAND); // window.Bitmap->UnionBitBlt(wmaskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, SRCAND, true); // convert by celberus window.Bitmap->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, SRCAND); // convert by celberus // BitBlt(wmaskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, NULL, 0, 0, DSTINVERT); window.Mask->UnionBitBlt(NULL, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, DSTINVERT, true); // convert by celberus // window.Mask->DeleteDC(wmaskDC); // window.Bitmap->DeleteDC(wbitmapDC); convert by celberus if (!Image->uBitmap->StartScanLine()) goto fail; if (!MainImageForm->WorkArea->Mask->StartScanLine()) goto fail; if (!Image->LayerMask->StartScanLine()) goto fail; c = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (i=0; iuBitmap->GetScanLine(window.s.y+i)+3*window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(i); LP = Image->LayerMask->GetScanLine(window.s.y+i); mm = 0x80; for (j=0; j>3)) |= (0x80 >> ((window.s.x+j)&7)); } if (mm==1) { WP++; mm = 0x80; } else mm >>= 1; } Image->uBitmap->PutScanLine(window.s.y + i); Image->LayerMask->PutScanLine(window.s.y + i); } Image->LayerMask->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); } MakeImage(); Image->LayerMask->CopyToRect(ReproRect.s.x, ReproRect.s.y, window.Mask, SRCAND); END_LOG; return true; fail: Image->LayerMask->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TReproForm::ReproMouseDown(int X, int Y) { BEGIN_LOG(""); if (item == TREPRO_RECT) { MainImageForm->iMainImage->SubVisible = false; rect_repro(); rzbtRect->Down = false; item = TREPRO_NULL; ExitRect(); } else if (item == TREPRO_PULL) { PullMouseDown(X, Y); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::ReproMouseMove(int X, int Y, TShiftState Shift) { BEGIN_LOG(""); if (Shift.Contains(ssShift) || rzmtLink->Down) SubSquareMouseMove(X, Y); else SubMouseMove(X, Y); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::iMainImageKeyDown(WORD Key, TShiftState Shift) { BEGIN_LOG(String(Key)); if (item == TREPRO_RECT) { int px, py; switch (Key) { case VK_RETURN: EditKeyDown(this, Key, Shift); //lhskys ¿£ÅÍ۸¦ ¾ç¹æÇâ¿¡¼­ °°ÀÌ break; //lhskys ¹ÞÀ¸¹Ç·Î È£ÃâÀ» ÇÑ´Ù case VK_LEFT: MainImageForm->ReadyToArrowKeyDown(false); if (window.e.x == ReproRect.e.x) { if (window.s.x == ReproRect.s.x) { px = ReproRect.e.x - 1; } else { px = ReproRect.s.x - 1; } } else { px = ReproRect.e.x - 1; } if (ReproRect.s.y < window.s.y) { SubMouseMove(px, ReproRect.s.y); } else { SubMouseMove(px, ReproRect.e.y); } break; // left case VK_UP: MainImageForm->ReadyToArrowKeyDown(false); if (window.e.y == ReproRect.e.y) { if (window.s.y == ReproRect.s.y) { py = ReproRect.e.y - 1; } else { py = ReproRect.s.y - 1; } } else { py = ReproRect.e.y - 1; } if (ReproRect.s.x < window.s.x) { SubMouseMove(ReproRect.s.x, py); } else { SubMouseMove(ReproRect.e.x, py); } break; // top case VK_RIGHT: MainImageForm->ReadyToArrowKeyDown(false); if (window.s.x == ReproRect.s.x) { px = ReproRect.e.x + 1; } else { px = ReproRect.s.x + 1; } if (ReproRect.s.y < window.s.y) { SubMouseMove(px, ReproRect.s.y); } else { SubMouseMove(px, ReproRect.e.y); } break; // right case VK_DOWN: MainImageForm->ReadyToArrowKeyDown(false); if (window.s.y == ReproRect.s.y) { py = ReproRect.e.y + 1; } else { py = ReproRect.s.y + 1; } if (ReproRect.s.x < window.s.x) { SubMouseMove(ReproRect.s.x, py); } else { SubMouseMove(ReproRect.e.x, py); } break; // bottom case VK_CONTROL: rect_repro(); break; // Ctrl - Key ¿Ö ÄÁÆ®·ÑÀ» ¸¸µé¾ú´ÂÁö... // case 16: squareSW = true; break; // Shift - Key } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::iMainImageKeyUp() { MainImageForm->ReadyToArrowKeyDown(true); } //--------------------------------------------------------------------------- void __fastcall TReproForm::iMainImageChange(void) { } //--------------------------------------------------------------------------- void __fastcall TReproForm::SetReproImage(void) { BEGIN_LOG(""); int x, y, xx; Byte *WP, *WBP, *MP, mm, *PP, *LP; COLORREF bgc, c; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; window.s.x = MainImageForm->WorkArea->Range.left; window.s.y = MainImageForm->WorkArea->Range.top; window.e.x = MainImageForm->WorkArea->Range.right; window.e.y = MainImageForm->WorkArea->Range.bottom; window.size.x = window.e.x - window.s.x; window.size.y = window.e.y - window.s.y; ReproRect.s = window.s; ReproRect.e = window.e; ReproRect.size = window.size; ReproRect.Bitmap = 0; ReproRect.Mask = 0; ReproRect.Back = 0; Image->SubRange.left = window.s.x; Image->SubRange.top = window.s.y; if (Image->uBitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (Image->SubBitmap->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->SubMask->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Bitmap->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Back->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->WorkArea->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (Image->LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); PP = Image->uBitmap->GetScanLine(window.s.y+y)+window.s.x; LP = Image->LayerMask->GetScanLine(window.s.y+y)+window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(y); for (x=0; xPalette->ColorData[*PP]->Protect == 0)*/) { *WBP = *PP; *MP = 0; } else { *WBP = 0x00; *MP = 0xFF; } } window.Bitmap->PutScanLine(y); window.Mask->PutScanLine(y); } Image->LayerMask->StopScanLine(); } else { for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); PP = Image->uBitmap->GetScanLine(window.s.y+y)+window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(y); for (x=0; xPalette->ColorData[*PP]->Protect == 0)*/) { *WBP = *PP; *MP = 0x00; } else { *WBP = 0x00; *MP = 0xFF; } } window.Bitmap->PutScanLine(y); window.Mask->PutScanLine(y); } } window.Bitmap->StopScanLine(); window.Mask->StopScanLine(); Image->uBitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); } else { if (Image->SubBitmap->Create(window.size.x, window.size.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->SubMask->Create(window.size.x, window.size.y, 1) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Bitmap->Create(window.size.x, window.size.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->Create(window.size.x, window.size.y, 1) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Back->Create(window.size.x, window.size.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->WorkArea->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (Image->LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); *MP = 0; PP = Image->uBitmap->GetScanLine(window.s.y+y)+3*window.s.x; LP = Image->LayerMask->GetScanLine(window.s.y + y); WP = MainImageForm->WorkArea->Mask->GetScanLine(y); x = 0; mm = 0x80; while(1) { xx = x + window.s.x; if ((*WP&mm) && (*(LP + (xx >> 3)) & (0x80 >> (xx & 7 ))) == 0) { CopyPixel24(WBP, PP); } else { SetPixel24(WBP, 0); *MP |= mm; } x++; if(x >= window.size.x) break; WBP += 3; PP += 3; if (mm==1) { MP++; *MP = 0; WP++; mm = 0x80; } else mm >>= 1; } window.Bitmap->PutScanLine(y); window.Mask->PutScanLine(y); } Image->LayerMask->StopScanLine(); } else { for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); *MP = 0; PP = Image->uBitmap->GetScanLine(window.s.y+y)+3*window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(y); x=0; mm = 0x80; while(1) { if (*WP&mm) { CopyPixel24(WBP, PP); } else { SetPixel24(WBP, 0); *MP |= mm; } x++; if(x >= window.size.x) break; WBP += 3; PP += 3; if (mm==1) { MP++; *MP = 0; WP++; mm = 0x80; } else mm >>= 1; } window.Bitmap->PutScanLine(y); window.Mask->PutScanLine(y); } } window.Bitmap->StopScanLine(); window.Mask->StopScanLine(); Image->uBitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); } #ifdef FASTAR Image->SubBitmap->Copy(window.Bitmap, SRCCOPY); #endif Image->SubMask->Copy(window.Mask, SRCCOPY); // Èæ¹é À̹ÌÁö Á¦°Å by celberus END_LOG; return; fail : if (Image->LayerMask) Image->LayerMask->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); window.Mask->StopScanLine(); window.Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::ChangeUnit(TUnit CUnit) { // if (btnSize->Caption == IDS_COMMON_LENGTH) { // lUnit->Caption = MainImageForm->UnitName(CUnit); // switch (CUnit) { // case uDot : // nedXSize->Value = ReproRect.size.x; // nedYSize->Value = ReproRect.size.y; // lbXSize->Caption = window.size.x; // lbYSize->Caption = window.size.y; // break; // case uInch : // nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch))); // nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch))); // lbXSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.x / MainImageForm->CanvasInfor.DotsPerInch))); // lbYSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.y / MainImageForm->CanvasInfor.DotsPerInch))); // break; // case uCm : // nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); // nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54; // //Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); // lbXSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); // lbYSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); // break; // } // } else if (btnSize->Caption == IDS_RATIO) { // nedXSize->Value = 100.0 * ReproRect.size.x / window.size.x; // //Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.x / window.size.x))); // nedYSize->Value = 100.0 * ReproRect.size.y / window.size.y; // //Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.y / window.size.y))); // lUnit->Caption = " %"; // lbXSize->Caption = 100; // lbYSize->Caption = 100; // } // % if (rzcbUnit->ItemIndex ==0) { nedXSize->Value = 100.0 * ReproRect.size.x / window.size.x; nedYSize->Value = 100.0 * ReproRect.size.y / window.size.y; lbXSize->Caption = 100; lbYSize->Caption = 100; } // cm else if (rzcbUnit->ItemIndex ==1) { nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54; nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54; lbXSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); lbYSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } // inch else if (rzcbUnit->ItemIndex ==2) { nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch; nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch; lbXSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.x / MainImageForm->CanvasInfor.DotsPerInch))); lbYSize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.y / MainImageForm->CanvasInfor.DotsPerInch))); } // dot else if (rzcbUnit->ItemIndex == 3) { nedXSize->Value = ReproRect.size.x; nedYSize->Value = ReproRect.size.y; lbXSize->Caption = window.size.x; lbYSize->Caption = window.size.y; } } //---------------------------------------------------------------------------- void __fastcall TReproForm::rzmtInitClick(TObject *Sender) { if (item == TREPRO_RECT || item == TREPRO_NULL) { RectMode(); InitRect(); SetSizeText(); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::btInit1Click(TObject *Sender) { if (item == TREPRO_RECT || item == TREPRO_NULL) { InitRect(); SetSizeText(); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::lUnitClick(TObject *Sender) { //nedXSize->Enabled = true; //nedYSize->Enabled = true; // by celberus nedXSize->SetFocus(); nedXSize->SelectAll(); norun = 1; //lhskys ½ÇÇàÀ» ÇÒ¶§¸¦ Ç¥½ÃÇϱâÀ§ÇØ InitRect(); rzbtRect->Down = false; item = TREPRO_NULL; } //--------------------------------------------------------------------------- void __fastcall TReproForm::Preview(void) //by lhskys 2001.03.07 { // ½ÇÇàÇϱâÀü¿¡ BEGIN_LOG(""); // HDC /*imageDC = NULL,*/ maskDC = NULL, /*reproDC = NULL, wbitmapDC = NULL,*/ // ¹Ì¸®º¸±â //convert by celberus // wmaskDC = NULL, wbackDC = NULL; RECT r; TPItemImage *Image = MainImageForm->iMainImage; ReproRect.e.x = ReproRect.s.x + ReproRect.size.x; ReproRect.e.y = ReproRect.s.y + ReproRect.size.y; if (ReproRect.e.x > Image->uBitmap->Width) { ReproRect.e.x = Image->uBitmap->Width; ReproRect.size.x = ReproRect.e.x - ReproRect.s.x; } if (ReproRect.e.y > Image->uBitmap->Height) { ReproRect.e.y = Image->uBitmap->Height; ReproRect.size.y = ReproRect.e.y - ReproRect.s.y; } Image->SubRange.left = ReproRect.s.x; Image->SubRange.top = ReproRect.s.y; Image->SubRange.right = ReproRect.e.x; Image->SubRange.bottom = ReproRect.e.y; if (ReproRect.size.x == 0 || ReproRect.size.y == 0) { END_LOG; return; } // if ((imageDC = Image->uBitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((wbackDC = window.Back->CreateDC()) == NULL) goto fail; // if ((wmaskDC = window.Mask->CreateDC()) == NULL) goto fail; // if ((wbitmapDC = window.Bitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((reproDC = Image->SubBitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((maskDC = Image->SubMask->CreateDC()) == NULL) goto fail; // SetStretchBltMode(maskDC, COLORONCOLOR); // StretchBlt(maskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, window.size.x, window.size.y, SRCCOPY); Image->SubMask->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, window.size.x, window.size.y, SRCCOPY); // convert by celberus // Image->SubMask->DeleteDC(maskDC); // BitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, imageDC, ReproRect.s.x, ReproRect.s.y, SRCCOPY); // Image->uBitmap->UnionBitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, ReproRect.s.x, ReproRect.s.y, SRCCOPY, false); // convert by celberus window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, Image->uBitmap, ReproRect.s.x, ReproRect.s.y, SRCCOPY); // convert by celberus // SetStretchBltMode(wbackDC, COLORONCOLOR); // StretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, window.size.x, window.size.y, SRCAND); window.Back->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, window.size.x, window.size.y, SRCAND); // convert by celberus // StretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wbitmapDC, 0, 0, window.size.x, window.size.y, SRCPAINT); // window.Bitmap->UnionStretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, window.size.x, window.size.y, SRCPAINT); // convert by celberus window.Back->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Bitmap, 0, 0, window.size.x, window.size.y, SRCPAINT); // convert by celberus // BitBlt(reproDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wbackDC, 0, 0, SRCCOPY); // Image->SubBitmap->UnionBitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, SRCCOPY, true); // convert by celberus Image->SubBitmap->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Back, 0, 0, SRCCOPY); // convert by celberus // if (maskDC) Image->SubMask->DeleteDC(maskDC); // by celberus ¾ø¾î¼­ Ãß°¡ // Image->SubBitmap->DeleteDC(reproDC); convert by celberus // window.Bitmap->DeleteDC(wbitmapDC); convert by celberus // window.Mask->DeleteDC(wmaskDC); // window.Back->DeleteDC(wbackDC); // Image->uBitmap->DeleteDC(imageDC); convert by celberus Image->SubVisible = true; r.left = paintrect.left < Image->SubRange.left ? paintrect.left : Image->SubRange.left; r.top = paintrect.top < Image->SubRange.top ? paintrect.top : Image->SubRange.top; r.right = paintrect.right > Image->SubRange.right ? paintrect.right : Image->SubRange.right; r.bottom = paintrect.bottom > Image->SubRange.bottom ? paintrect.bottom : Image->SubRange.bottom; paintrect = Image->SubRange; Image->RectPaint(r); END_LOG; return; fail: // if (maskDC) Image->SubMask->DeleteDC(maskDC); // if (reproDC) Image->SubBitmap->DeleteDC(reproDC); convert by celberus // if (wbitmapDC) window.Bitmap->DeleteDC(wbitmapDC); convert by celberus // if (wmaskDC) window.Mask->DeleteDC(wmaskDC); // if (wbackDC) window.Back->DeleteDC(wbackDC); // if (imageDC) Image->uBitmap->DeleteDC(imageDC); convert by celberus EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; } //---------------------------------------------------------------------------- void __fastcall TReproForm::PreviewRun(TObject *Sender) //by lhskys 2001.03.07 { // ½ÇÇàÇϱâÀü¿¡ BEGIN_LOG(""); COLORREF C; norun = 0; // ¹Ì¸®º¸±â TPException ec = EC_NONE; bool crtSw = false, crtSw1 = false, crtSw2 = false; TPItemImage *Image = MainImageForm->iMainImage; window.s.x = MainImageForm->WorkArea->Range.left; window.s.y = MainImageForm->WorkArea->Range.top; window.e.x = MainImageForm->WorkArea->Range.right; window.e.y = MainImageForm->WorkArea->Range.bottom; window.size.x = window.e.x - window.s.x; window.size.y = window.e.y - window.s.y; if (rzcbUnit->ItemIndex ==0) { if (nedXSize->Value > 0) { ReproRect.size.x = window.size.x * nedXSize->Value / 100.0; } if (nedYSize->Value > 0) { ReproRect.size.y = window.size.y * nedYSize->Value / 100.0; } } else if (rzcbUnit->ItemIndex ==1) { if (nedXSize->Value > 0) { ReproRect.size.x = nedXSize->Value * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } if (nedYSize->Value > 0) { ReproRect.size.y = nedYSize->IntValue * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } } else if (rzcbUnit->ItemIndex ==2) { if (nedXSize->Value > 0) { ReproRect.size.x = nedXSize->Value * MainImageForm->CanvasInfor.DotsPerInch; } if (nedYSize->Value > 0) { ReproRect.size.y = nedYSize->IntValue * MainImageForm->CanvasInfor.DotsPerInch; } } else if (rzcbUnit->ItemIndex == 3) { if (nedXSize->Value > 0) { ReproRect.size.x = nedXSize->IntValue; } if (nedYSize->Value > 0) { ReproRect.size.y = nedYSize->IntValue; } } MainImageForm->iMainImage->SubEnabled = true; MainImageForm->iMainImage->SubVisible = false; #ifdef FASTAR Image->setSubPaintType(typeNone); // by celberus #endif if (Image->uBitmap->BitsPerPixel==8) { Repro.size.x = max(ReproRect.size.x,window.size.x); Repro.size.y = max(ReproRect.size.y,window.size.y); if ((crtSw = window.Back->Create(Repro.size.x, Repro.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(Repro.size.x, Repro.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(Repro.size.x, Repro.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Image->SubMask->BackgroundColor = 0; // by celberus ¹Ì¸®º¸±âÇÒ¶§ ¿øº» °¨Ãß±â // HDC hDC = Image->SubBitmap->CreateDC(); convert by celberus // BitBlt(hDC,0,0,window.size.x, window.size.y,NULL,0,0,WHITENESS); // Image->SubBitmap->UnionBitBlt(NULL,0,0,window.size.x, window.size.y,0,0,WHITENESS, true); // convert by celberus // Image->SubBitmap->DeleteDC(hDC); convert by celberus C = PaletteForm->DIB256Palette->GetBGCOLORREF(8); MainImageForm->iMainImage->SubBitmap->FillRect(Rect(0,0,MainImageForm->iMainImage->SubBitmap->Width,MainImageForm->iMainImage->SubBitmap->Height), C); } else { Repro.size.x = max(ReproRect.size.x,window.size.x); Repro.size.y = max(ReproRect.size.y,window.size.y); if ((crtSw = window.Back->Create(Repro.size.x, Repro.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(Repro.size.x, Repro.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(Repro.size.x, Repro.size.y, 1)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Image->SubMask->UnionBitBlt(NULL, 0, 0, Image->SubMask->Width, Image->SubMask->Height, 0, 0, BLACKNESS, true); // by celberus ¹Ì¸®º¸±âÇÒ¶§ ¿øº» °¨Ãß±â // HDC hDC = Image->SubBitmap->CreateDC(); convert by celberus // BitBlt(hDC,0,0,window.size.x, window.size.y,NULL,0,0,WHITENESS); // Image->SubBitmap->UnionBitBlt(NULL,0,0,window.size.x, window.size.y,0,0,WHITENESS, true); // convert by celberus // Image->SubBitmap->DeleteDC(hDC); convert by celberus C = PaletteForm->DIB256Palette->GetBGCOLORREF(24); MainImageForm->iMainImage->SubBitmap->FillRect(Rect(0,0,MainImageForm->iMainImage->SubBitmap->Width,MainImageForm->iMainImage->SubBitmap->Height), C); } Image->SubVisible = false; Preview(); END_LOG; return; fail : if (crtSw) window.Back->Destroy(); if (crtSw1) Image->SubBitmap->Destroy(); if (crtSw2) Image->SubMask->Destroy(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::AngleChange(TObject *Sender) { TNumEdit *e; int angle; e = (TNumEdit *)Sender; if (e->Value > 0) { // if (e == EXAngle) { if (e == edAngle && item == TREPRO_XFIX) { // angle = EXAngle->IntValue; angle = edAngle->IntValue; if ((angle > 9) && (angle < 81)) { PullEdit(Sender); } // }else if (e == eYAngle) { }else if (e == edAngle && item == TREPRO_YFIX) { // angle = eYAngle->IntValue; angle = edAngle->IntValue; if ((angle > 9) && (angle < 81)) { PullEdit(Sender); } } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::DistanceChange(TObject *Sender) { TNumEdit *e; int l1, l2, ratio; e = (TNumEdit *)Sender; if (e->Value > 0) { compute_len(l1, l2); // if (e == EXratio) { if (e == edRatio && item == TREPRO_XFIX) { // ratio = EXratio->IntValue; ratio = edRatio->IntValue; if ((ratio >= l1) && (ratio <= l2)) { PullEdit(Sender); } // }else if (e == eYratio) { }else if (e == edRatio && item == TREPRO_YFIX) { // ratio = eYratio->IntValue; ratio = edRatio->IntValue; if ((ratio >= l1) && (ratio <= l2)) { PullEdit(Sender); } } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::btnPullPreViewClick(TObject *Sender) { /* TCursor OldCursor; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->iMainImage->LayerMask) pull_layer_PreView(); else pull_PreView(); // MainImageForm->WorkAreaReset(); Screen->Cursor = OldCursor; rzbtEnter->SetFocus(); // PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); // MainImageForm->DrawLineLocate(Point(Rpos[0].x, Rpos[0].y), Point(Rpos[1].x, Rpos[1].y),0); //lhskys ´ç±â±â ¿£ÅÍ·Î ½ÇÇàÇßÀ»¶§ ÀÜ»óÁ¦°Å...*/ } //--------------------------------------------------------------------------- void __fastcall TReproForm::pull_PreView(void) { /* int x, y, nx, ny, winlx, winly; double lx1, lx2, ly1, ly2; double a[4], b[4], c[4], sqr[4]; TTexpiaBitmap *area; Byte *IP, *AP, *MP; bool undoSw = false; TPlaneVertex pv; TPItemImage *Image = MainImageForm->iMainImage; TUndoData *ud; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) goto fail; ud = Undo->Last; area = ud->Bitmap; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); pv.Create(Rpos[0], Rpos[1], Rpos[2], Rpos[3]); repro_dis(a, b, c, sqr, 0, 0, 1); repro_dis(a, b, c, sqr, 1, 2, 3); repro_dis(a, b, c, sqr, 2, 3, 0); repro_dis(a, b, c, sqr, 3, 1, 2); winlx = window.size.x - 1; winly = window.size.y - 1; if (Image->uBitmap->StartScanLine() == false) goto fail; if (area->StartScanLine() == false) goto fail; if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 && (*MP == 0)) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny) + window.s.x + nx); } } } } Image->uBitmap->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++) { if (x < Image->uBitmap->Width) { if (*MP == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } } Image->uBitmap->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if ((MP[x >> 3] & (0x80 >> (x & 7))) == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); } } } } Image->uBitmap->PutScanLine(y); } } } Image->Mask->StopScanLine(); } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } } Image->uBitmap->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); } } } Image->uBitmap->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); } } } Image->uBitmap->PutScanLine(y); } } } } area->StopScanLine(); Image->uBitmap->StopScanLine(); ud->Complete(); if (MainImageForm->AutoRepeat && (MainImageForm->LayerCNT == MainImageForm->ARLayerCnt)) MainImageForm->RedrawingRepeat(false, false); //2001.6.19 by lhskys autorepeat ::RepaintImage(); return; fail : Image->Mask->StopScanLine(); area->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK);*/ } //--------------------------------------------------------------------------- void __fastcall TReproForm::pull_layer_PreView(void) { /* int x, y, nx, ny, winlx, winly; double lx1, lx2, ly1, ly2; double a[4], b[4], c[4], sqr[4]; TTexpiaBitmap *area,*layermask; Byte *IP, *AP, *MP, *LP, *ULP; bool undoSw = false; TPlaneVertex pv; TPItemImage *Image = MainImageForm->iMainImage; TUndoData *ud; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0,0,Image->uBitmap->Width,Image->uBitmap->Height))) == false) goto fail; ud = Undo->Last; area = ud->Bitmap; layermask = ud->LayerMask; Image->uBitmap->FillRect(Rect(window.s.x, window.s.y, window.e.x, window.e.y), PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); pv.Create(Rpos[0], Rpos[1], Rpos[2], Rpos[3]); repro_dis(a, b, c, sqr, 0, 0, 1); repro_dis(a, b, c, sqr, 1, 2, 3); repro_dis(a, b, c, sqr, 2, 3, 0); repro_dis(a, b, c, sqr, 3, 1, 2); winlx = window.size.x - 1; winly = window.size.y - 1; if (Image->uBitmap->StartScanLine() == false) goto fail; if (area->StartScanLine() == false) goto fail; if (layermask->StartScanLine() == false) goto fail; if (Image->LayerMask->StartScanLine() == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y)+ window.s.x; for (x = window.s.x; x < window.e.x; x++, LP++) { if (x < Image->uBitmap->Width) { *(LP) = 0xFF; } } Image->LayerMask->PutScanLine(y); } } } else { for (y = window.s.y; y < window.e.y; y++) { if (y < Image->uBitmap->Height) { LP = Image->LayerMask->GetScanLine(y); for (x = window.s.x; x < window.e.x; x++) { if (x < Image->uBitmap->Width) { *(LP + (x>>3)) |= (0x80 >> (x&7)); } } Image->LayerMask->PutScanLine(y); } } } if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; LP = Image->LayerMask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++, LP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0 && (*MP == 0)) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y) + pv.start.x; MP = Image->Mask->GetScanLine(y) + pv.start.x; LP = Image->LayerMask->GetScanLine(y) + pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, MP++, LP++) { if (x < Image->uBitmap->Width) { if (*MP == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; MP = Image->Mask->GetScanLine(y); LP = Image->LayerMask->GetScanLine(y); for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if ((MP[x >> 3] & (0x80 >> (x & 7))) == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); ULP = layermask->GetScanLine(window.s.y+ny)+((window.s.x+nx)>>3); if( !( ( ( 0x80 >> ((window.s.x+nx)&7) ) ) & (*ULP) ) ) *(LP + (x>>3)) &= ~(0x80 >> (x&7)); else *(LP + (x>>3)) |= (0x80 >> (x&7)); } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } Image->Mask->StopScanLine(); } else { if (Image->uBitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; LP = Image->LayerMask->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, LP++) { if (x < Image->uBitmap->Width) { if (MainImageForm->Palette->ColorData[*IP]->Protect == 0) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+pv.start.x; LP = Image->LayerMask->GetScanLine(y)+pv.start.x; for (x = pv.start.x; x < pv.end.x; x++, IP++, LP++) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); *IP = *(area->GetScanLine(window.s.y+ny)+window.s.x+nx); ULP = layermask->GetScanLine(window.s.y+ny)+window.s.x+nx; if( (*ULP)==0xFF ) *(LP) = 0xFF; else *(LP) = 0; } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } } else { for (y = pv.start.y; y < pv.end.y; y++) { if (y < Image->uBitmap->Height) { IP = Image->uBitmap->GetScanLine(y)+3*pv.start.x; LP = Image->LayerMask->GetScanLine(y); for (x = pv.start.x; x < pv.end.x; x++, IP+=3) { if (x < Image->uBitmap->Width) { if (pv.Check(x, y)) { ly1 = fabs(a[0] * x + b[0] * y + c[0]) / sqr[0]; ly2 = fabs(a[1] * x + b[1] * y + c[1]) / sqr[1]; lx1 = fabs(a[2] * x + b[2] * y + c[2]) / sqr[2]; lx2 = fabs(a[3] * x + b[3] * y + c[3]) / sqr[3]; nx = winlx * lx1 / (lx1 + lx2); ny = winly * ly1 / (ly1 + ly2); AP = area->GetScanLine(window.s.y+ny)+3*(window.s.x+nx); CopyPixel24(IP, AP); ULP = layermask->GetScanLine(window.s.y+ny)+((window.s.x+nx)>>3); if( !( ( ( 0x80 >> ((window.s.x+nx)&7) ) ) & (*ULP) ) ) *(LP + (x>>3)) &= ~(0x80 >> (x&7)); else *(LP + (x>>3)) |= (0x80 >> (x&7)); } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } } } } Image->LayerMask->StopScanLine(); area->StopScanLine(); layermask->StopScanLine(); Image->uBitmap->StopScanLine(); ud->Complete(); ::RepaintImage(); return; fail : Image->Mask->StopScanLine(); Image->LayerMask->StopScanLine(); area->StopScanLine(); layermask->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK);*/ } //--------------------------------------------------------------------------- void __fastcall TReproForm::SubSquareMouseMove(int X, int Y) { BEGIN_LOG(""); // HDC /*imageDC = NULL,*/ maskDC = NULL, /*reproDC = NULL, wbitmapDC = NULL,*/ // convert by celberus // wmaskDC = NULL, wbackDC = NULL; bool crtSw = false, crtSw1 = false, crtSw2 = false; RECT r; TPItemImage *Image = MainImageForm->iMainImage; int SubX, SubY; TPException ec = EC_NONE; if (X < 0) X = 0; else if (X > Image->uBitmap->Width) X = Image->uBitmap->Width; if (Y < 0) Y = 0; else if (Y > Image->uBitmap->Height) Y = Image->uBitmap->Height; if (item == TREPRO_RECT) { if (X < window.s.x) { ReproRect.s.x = X; ReproRect.e.x = window.e.x; ReproRect.size.x = window.e.x - X; } else { ReproRect.s.x = window.s.x; ReproRect.e.x = X; ReproRect.size.x = X - ReproRect.s.x; } if (Y < window.s.y) { ReproRect.s.y = Y; ReproRect.e.y = window.e.y; ReproRect.size.y = window.e.y - Y; } else { ReproRect.s.y = window.s.y; ReproRect.e.y = Y; ReproRect.size.y = Y - ReproRect.s.y; } // ReproRect.size.x : ReproRect.size.y = window.size.x : window.size.y SubX = ReproRect.size.y * window.size.x / window.size.y; SubY = ReproRect.size.x * window.size.y / window.size.x; if(SubX > ReproRect.size.x){ if (Y < window.s.y) { ReproRect.s.y = window.e.y - SubY; ReproRect.e.y = window.e.y; ReproRect.size.y = SubY; } else { ReproRect.s.y = window.s.y; ReproRect.e.y = window.s.y + SubY; ReproRect.size.y = SubY; } }else if(SubY > ReproRect.size.y){ if (X < window.s.x) { ReproRect.s.x = window.e.x - SubX; ReproRect.e.x = window.e.x; ReproRect.size.x = SubX; } else { ReproRect.s.x = window.s.x; ReproRect.e.x = window.s.x + SubX; ReproRect.size.x = SubX; } } /* =========== Á¤»ç°¢Çü. ============ if(ReproRect.size.x < ReproRect.size.y){ if (Y < window.s.y){ ReproRect.s.y = window.e.y - ReproRect.size.x; ReproRect.e.y = window.e.y; ReproRect.size.y = ReproRect.size.x; } else if (Y > window.s.y){ ReproRect.s.y = window.s.y; ReproRect.e.y = window.s.y + ReproRect.size.x; ReproRect.size.y = ReproRect.size.x; } }else if(ReproRect.size.x > ReproRect.size.y){ if (X < window.s.x){ ReproRect.s.x = window.e.x - ReproRect.size.y; ReproRect.e.x = window.e.x; ReproRect.size.x = ReproRect.size.y; } else if (X > window.s.x){ ReproRect.s.x = window.s.x; ReproRect.e.x = window.s.x + ReproRect.size.y; ReproRect.size.x = ReproRect.size.y; } } */ Image->SubRange.left = ReproRect.s.x; Image->SubRange.top = ReproRect.s.y; Image->SubRange.right = ReproRect.e.x; Image->SubRange.bottom = ReproRect.e.y; if (ReproRect.size.x == 0 || ReproRect.size.y == 0) { END_LOG; return; } #ifndef FASTAR if (Image->uBitmap->BitsPerPixel==8) { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 1)) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } // if ((imageDC = Image->uBitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((wbackDC = window.Back->CreateDC()) == NULL) goto fail; // if ((wmaskDC = window.Mask->CreateDC()) == NULL) goto fail; // if ((wbitmapDC = window.Bitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((reproDC = Image->SubBitmap->CreateDC()) == NULL) goto fail; convert by celberus // if ((maskDC = Image->SubMask->CreateDC()) == NULL) goto fail; // SetStretchBltMode(maskDC, COLORONCOLOR); // StretchBlt(maskDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, window.size.x, window.size.y, SRCCOPY); Image->SubMask->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, window.size.x, window.size.y, SRCCOPY); // convert by celberus // Image->SubMask->DeleteDC(maskDC); // BitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, imageDC, ReproRect.s.x, ReproRect.s.y, SRCCOPY); // Image->uBitmap->UnionBitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, ReproRect.s.x, ReproRect.s.y, SRCCOPY, false); // convert by celberus window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, Image->uBitmap, ReproRect.s.x, ReproRect.s.y, SRCCOPY); // convert by celberus // SetStretchBltMode(wbackDC, COLORONCOLOR); // StretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, window.size.x, window.size.y, SRCAND); window.Back->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, window.size.x, window.size.y, SRCAND); // convert by celberus // StretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wbitmapDC, 0, 0, window.size.x, window.size.y, SRCPAINT); // window.Bitmap->UnionStretchBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, window.size.x, window.size.y, SRCPAINT); // convert by celberus window.Back->UnionStretchBlt(0, 0, ReproRect.size.x, ReproRect.size.y, window.Bitmap, 0, 0, window.size.x, window.size.y, SRCPAINT); // convert by celberus // BitBlt(reproDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wbackDC, 0, 0, SRCCOPY); // Image->SubBitmap->UnionBitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, SRCCOPY, true); // convert by celberus Image->SubBitmap->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Back, 0, 0, SRCCOPY); // convert by celberus // if (maskDC) Image->SubMask->DeleteDC(maskDC); // ¾ø¾î¼­ Ãß°¡ by celberus // Image->SubBitmap->DeleteDC(reproDC); convert by celberus // window.Bitmap->DeleteDC(wbitmapDC); convert by celberus // window.Mask->DeleteDC(wmaskDC); // window.Back->DeleteDC(wbackDC); // Image->uBitmap->DeleteDC(imageDC); convert by celberus #else Image->setSubPaintType(typeExpansion); // by celberus Image->setSubPaintRatio((double)ReproRect.size.x / window.size.x, (double)ReproRect.size.y / window.size.y ); // by celberus #endif SetSizeText(); Image->SubVisible = true; r.left = paintrect.left < Image->SubRange.left ? paintrect.left : Image->SubRange.left; r.top = paintrect.top < Image->SubRange.top ? paintrect.top : Image->SubRange.top; r.right = paintrect.right > Image->SubRange.right ? paintrect.right : Image->SubRange.right; r.bottom = paintrect.bottom > Image->SubRange.bottom ? paintrect.bottom : Image->SubRange.bottom; paintrect = Image->SubRange; Image->RectPaint(r); } else if (item == TREPRO_PULL) { PullMouseMove(X, Y); } END_LOG; return; fail: // if (maskDC) Image->SubMask->DeleteDC(maskDC); // if (reproDC) Image->SubBitmap->DeleteDC(reproDC); convert by celberus // if (wbitmapDC) window.Bitmap->DeleteDC(wbitmapDC); convert by celberus // if (wmaskDC) window.Mask->DeleteDC(wmaskDC); // if (wbackDC) window.Back->DeleteDC(wbackDC); // if (imageDC) Image->uBitmap->DeleteDC(imageDC); convert by celberus if (crtSw2) Image->SubMask->Destroy(); if (crtSw1) Image->SubBitmap->Destroy(); if (crtSw) window.Back->Destroy(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::nedYSizeKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_RETURN) { //btnRectRun->SetFocus(); //PreviewRun(this); PreviewRun(this); rzbtnRectRun->SetFocus(); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::nedXSizeKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_RETURN){ //nedYSize->SetFocus(); PreviewRun(this); rzbtnRectRun->SetFocus(); } } //--------------------------------------------------------------------------- #ifdef FASTAR void __fastcall TReproForm::initWindowBitmap(void) { BEGIN_LOG(""); int x, y, xx; Byte *WP, *WBP, *MP, mm, *PP, *LP; COLORREF bgc, c; TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; window.s.x = MainImageForm->WorkArea->Range.left; window.s.y = MainImageForm->WorkArea->Range.top; window.e.x = MainImageForm->WorkArea->Range.right; window.e.y = MainImageForm->WorkArea->Range.bottom; window.size.x = window.e.x - window.s.x; window.size.y = window.e.y - window.s.y; ReproRect.s = window.s; ReproRect.e = window.e; ReproRect.size = window.size; ReproRect.Bitmap = 0; ReproRect.Mask = 0; ReproRect.Back = 0; Image->SubRange.left = window.s.x; Image->SubRange.top = window.s.y; if (Image->uBitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (window.Bitmap->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if (window.Back->Create(window.size.x, window.size.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->WorkArea->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (Image->LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); PP = Image->uBitmap->GetScanLine(window.s.y+y)+window.s.x; LP = Image->LayerMask->GetScanLine(window.s.y+y)+window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(y); for (x=0; xPutScanLine(y); window.Mask->PutScanLine(y); } Image->LayerMask->StopScanLine(); } else { for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); PP = Image->uBitmap->GetScanLine(window.s.y+y)+window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(y); for (x=0; xPutScanLine(y); window.Mask->PutScanLine(y); } } window.Bitmap->StopScanLine(); window.Mask->StopScanLine(); Image->uBitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); } else { if (window.Bitmap->Create(window.size.x, window.size.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->Create(window.size.x, window.size.y, 1) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if (window.Back->Create(window.size.x, window.size.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (window.Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->uBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->WorkArea->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (Image->LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); *MP = 0; PP = Image->uBitmap->GetScanLine(window.s.y+y)+3*window.s.x; LP = Image->LayerMask->GetScanLine(window.s.y + y); WP = MainImageForm->WorkArea->Mask->GetScanLine(y); x = 0; mm = 0x80; while(1) { xx = x + window.s.x; if ((*WP&mm) && (*(LP + (xx >> 3)) & (0x80 >> (xx & 7 ))) == 0) { CopyPixel24(WBP, PP); } else { SetPixel24(WBP, 0); *MP |= mm; } x++; if(x >= window.size.x) break; WBP += 3; PP += 3; if (mm==1) { MP++; *MP = 0; WP++; mm = 0x80; } else mm >>= 1; } window.Bitmap->PutScanLine(y); window.Mask->PutScanLine(y); } Image->LayerMask->StopScanLine(); } else { for (y=0; yGetScanLine(y); MP = window.Mask->GetScanLine(y); *MP = 0; PP = Image->uBitmap->GetScanLine(window.s.y+y)+3*window.s.x; WP = MainImageForm->WorkArea->Mask->GetScanLine(y); x=0; mm = 0x80; while(1) { if (*WP&mm) { CopyPixel24(WBP, PP); } else { SetPixel24(WBP, 0); *MP |= mm; } x++; if(x >= window.size.x) break; WBP += 3; PP += 3; if (mm==1) { MP++; *MP = 0; WP++; mm = 0x80; } else mm >>= 1; } window.Bitmap->PutScanLine(y); window.Mask->PutScanLine(y); } } window.Bitmap->StopScanLine(); window.Mask->StopScanLine(); Image->uBitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); } END_LOG; return; fail : if (Image->LayerMask) Image->LayerMask->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); window.Mask->StopScanLine(); window.Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::initSubBitmap(void) { BEGIN_LOG(""); TPItemImage *Image = MainImageForm->iMainImage; TPException ec = EC_NONE; if (Image->uBitmap->BitsPerPixel==8) { if (!Image->SubBitmap->Create(window.size.x, window.size.y, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Image->SubMask->Create(window.size.x, window.size.y, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (!Image->SubBitmap->Create(window.size.x, window.size.y, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!Image->SubMask->Create(window.size.x, window.size.y, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } Image->SubBitmap->Copy(0, 0, window.size.x, window.size.y, window.Bitmap, 0, 0, SRCCOPY); Image->SubMask->Copy( 0, 0, window.size.x, window.size.y, window.Mask, 0, 0, SRCCOPY); END_LOG; return; fail: if (Image->SubBitmap) Image->SubBitmap->Destroy(); if (Image->SubMask) Image->SubMask->Destroy(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TReproForm::Rectangle1Click(TObject *Sender) { TSpeedButton *sp = (TSpeedButton *)Sender; switch(sp->Tag){ case 1 : FunctionClick(rzbtRect); break; case 2 : FunctionClick(rzbtPull); // rzbtEnter->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ break; case 3 : case 4 : FunctionClick(rzbtPersp); break; } } //--------------------------------------------------------------------------- void __fastcall TReproForm::MakeMenuHintByShortcut() { BEGIN_LOG(""); //rzbtRect->Hint = TexActionManager->GetHint("Proportion", "Rectangle"); //rzbtPull->Hint = TexActionManager->GetHint("Proportion", "Pull"); rzmtXaxis->Hint = TexActionManager->GetHint("Proportion", "PerspectiveByAxisX"); rzmtYaxis->Hint = TexActionManager->GetHint("Proportion", "PerspectiveByAxisY"); END_LOG; } //--------------------------------------------------------------------------- #endif void __fastcall TReproForm::ExecuteHotKey(String command) { if (command == "Rectangle") { rzbtRect->Down = true; FunctionClick(rzbtRect); } else if (command == "Pull") { rzbtPull->Down = true; FunctionClick(rzbtPull); } else if (command == "PerspectiveByAxisX") { rzbtPersp->Down = true; FunctionClick(rzbtPersp); PopupXClick(miUp); } else if (command == "PerspectiveByAxisY") { rzbtPersp->Down = true; FunctionClick(rzbtPersp); PopupYClick(miLeft); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::nedXSizeClick(TObject *Sender) { nedXSize->SelectAll(); nedXSize->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::nedXSizeChange(TObject *Sender) { if (rzmtLink->Down) nedYSize->Text = nedXSize->Text; } //--------------------------------------------------------------------------- void __fastcall TReproForm::nedYSizeClick(TObject *Sender) { nedYSize->SelectAll(); nedYSize->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::nedYSizeChange(TObject *Sender) { if (rzmtLink->Down) nedXSize->Text = nedYSize->Text; } //--------------------------------------------------------------------------- /* void __fastcall TReproForm::rzmtEditMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { nedXSize->Enabled = true; nedYSize->Enabled = true; // by celberus nedXSize->SetFocus(); nedXSize->SelectAll(); norun = 1; //lhskys ½ÇÇàÀ» ÇÒ¶§¸¦ Ç¥½ÃÇϱâÀ§ÇØ InitRect(); rzbtRect->Down = false; item = TREPRO_NULL; } */ //--------------------------------------------------------------------------- void __fastcall TReproForm::rzcbUnitChange(TObject *Sender) { if (rzcbUnit->ItemIndex ==0) { nedXSize->Value = 100.0 * ReproRect.size.x / window.size.x; nedYSize->Value = 100.0 * ReproRect.size.y / window.size.y; } else if (rzcbUnit->ItemIndex ==1) { nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54; nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54; } else if (rzcbUnit->ItemIndex ==2) { nedXSize->Value = (double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch; nedYSize->Value = (double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch; } else if (rzcbUnit->ItemIndex == 3) { nedXSize->Value = ReproRect.size.x; nedYSize->Value = ReproRect.size.y; } ChangeUnit(MainImageForm->CurrentUnit); } //--------------------------------------------------------------------------- void __fastcall TReproForm::ChangeAxis(TObject *Sender) { TRzMenuToolbarButton* bt; bt = static_cast(Sender); if (bt->Tag == 0) { XReproMode(); ExitRect(); } else if (bt->Tag == 1) { YReproMode(); ExitRect(); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::PopupXClick(TObject *Sender) { TMenuItem* mItem = static_cast(Sender); Graphics::TBitmap *bmpIcon = NULL; int nImageIndex = -1; item = TREPRO_XFIX; if (mItem->Tag == 0) { XTextItem = _StateUp; rzmtXaxis->Tag = 0; } else if (mItem->Tag == 1) { XTextItem = _StateDown; rzmtXaxis->Tag = 1; } // ¾ÆÀÌÄÜ ¼³Á¤ if (rzmtXaxis->Tag == 0) nImageIndex = 0; else if (rzmtXaxis->Tag == 1) nImageIndex = 2; bmpIcon = new Graphics::TBitmap; imglstIcon->GetBitmap(nImageIndex, bmpIcon); rzmtXaxis->Glyph->Assign(bmpIcon); if (bmpIcon) delete bmpIcon; bmpIcon = NULL; if (rzmtYaxis->Tag == 0) nImageIndex = 5; else if (rzmtYaxis->Tag == 1) nImageIndex = 7; bmpIcon = new Graphics::TBitmap; imglstIcon->GetBitmap(nImageIndex, bmpIcon); rzmtYaxis->Glyph->Assign(bmpIcon); if (bmpIcon) delete bmpIcon; bmpIcon = NULL; } //--------------------------------------------------------------------------- void __fastcall TReproForm::PopupYClick(TObject *Sender) { TMenuItem* mItem = static_cast(Sender); Graphics::TBitmap *bmpIcon = NULL; int nImageIndex = -1; item = TREPRO_YFIX; if (mItem->Tag == 0) { YTextItem = _StateLeft; rzmtYaxis->Tag = 0; } else if (mItem->Tag == 1) { YTextItem = _StateRight; rzmtYaxis->Tag = 1; } // ¾ÆÀÌÄÜ ¼³Á¤ if (rzmtYaxis->Tag == 0) nImageIndex = 4; else if (rzmtYaxis->Tag == 1) nImageIndex = 6; bmpIcon = new Graphics::TBitmap; imglstIcon->GetBitmap(nImageIndex, bmpIcon); rzmtYaxis->Glyph->Assign(bmpIcon); if (bmpIcon) delete bmpIcon; bmpIcon = NULL; if (rzmtXaxis->Tag == 0) nImageIndex = 1; else if (rzmtXaxis->Tag == 1) nImageIndex = 3; bmpIcon = new Graphics::TBitmap; imglstIcon->GetBitmap(nImageIndex, bmpIcon); rzmtXaxis->Glyph->Assign(bmpIcon); if (bmpIcon) delete bmpIcon; bmpIcon = NULL; } //--------------------------------------------------------------------------- void __fastcall TReproForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //---------------------------------------------------------------------------