//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Repro_F.h" #include "FullView.h" #include "MainImage.h" #include "Palette.h" #include "Undo.h" #include "MainMenu.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #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] //--------------------------------------------------------------------------- TReproForm *ReproForm; //--------------------------------------------------------------------------- __fastcall TReproForm::TReproForm(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *)Owner)->Handle; //================== 2001.3.26 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è StringTable.Create(DirectoryCommon, 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); sbRect->Caption = IDS_COMMON_RECTANGLE; sbPull->Caption = IDS_PULL; sbX->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; btnPull->Caption = IDS_COMMON_RUN; btInit1->Caption = IDS_INITIALIZE; btnPullPreView->Caption = IDS_PULLPREVIEW; //============================================= } //--------------------------------------------------------------------------- void __fastcall TReproForm::FormCreate(TObject *Sender) { // 2001.3.26 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è } //--------------------------------------------------------------------------- void __fastcall TReproForm::btnSizeClick(TObject *Sender) { if (btnSize->Caption == IDS_COMMON_LENGTH) { btnSize->Caption = IDS_RATIO; } else if (btnSize->Caption == IDS_RATIO) { btnSize->Caption = IDS_COMMON_LENGTH; } ChangeUnit(MainImageForm->CurrentUnit); } //--------------------------------------------------------------------------- //void __fastcall TReproForm::btInit1Click(TObject *Sender) //{ // if (item == TREPRO_RECT) { // InitRect(); // SetSizeText(); // } //} //--------------------------------------------------------------------------- void __fastcall TReproForm::UpDownLabelClick(TObject *Sender) { if (item == TREPRO_XFIX) { if (XTextItem == _StateDown) { UpDownLabel->Caption = IDS_COMMON_UP; XTextItem = _StateUp; } else if (XTextItem == _StateUp) { UpDownLabel->Caption = IDS_COMMON_DOWN; XTextItem = _StateDown; } } else if (item == TREPRO_YFIX) { if (YTextItem == _StateRight) { LeftRightLabel->Caption = IDS_COMMON_LEFT; YTextItem = _StateLeft; } else if (YTextItem == _StateLeft) { LeftRightLabel->Caption = IDS_COMMON_RIGHT; YTextItem = _StateRight; } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::btnXRunClick(TObject *Sender) { TCursor OldCursor; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->iMainImage->LayerMask) perspective_reproportion_layer(); else perspective_reproportion(); MainImageForm->WorkAreaReset(); Screen->Cursor = OldCursor; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); } //--------------------------------------------------------------------------- void __fastcall TReproForm::btnPullClick(TObject *Sender) { TCursor OldCursor; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->iMainImage->LayerMask) pull_image_repro_layer(); else pull_image_repro(); MainImageForm->WorkAreaReset(); 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 ´ç±â±â ¿£ÅÍ·Î ½ÇÇàÇßÀ»¶§ ÀÜ»óÁ¦°Å... } //--------------------------------------------------------------------------- void __fastcall TReproForm::EditKeyPress(TObject *Sender, char &Key) { if((Key == '\n' || Key == '\r') && sbPull->Down)btnPullClick(this); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ else if (Key == '\n' || Key == '\r') { if (sbRect->Down == false || norun == 1){ //lhskys ¿£Å͸¦ ¹Þ¾ÒÀ»¶§ PullEdit(Sender); //lhskys edit·Î °¥°ÍÀΰ¡ ÆÇ´Ü SelectNext((TWinControl *)Sender, true, true); //lhskys Key = 0; //lhskys }else if(norun == 0){ //lhskys ¹Ù·Î ½ÇÇàŰ·Î.... if(sbRect->Down){ //lhskys btnRectRunClick(this); //lhskys } } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::EditKeyPress1(TObject *Sender, char &Key) //by lhskys 2001.03.07 { //¹Ì¸®º¸±âÀ§ÇØ Å°¸¦ ¹Þ´Â°÷ if((Key == '\n' || Key == '\r') && sbPull->Down)btnPullClick(this); else if (Key == '\n' || Key == '\r') { if (sbRect->Down == false || norun == 1){ PullEdit(Sender); SelectNext((TWinControl *)Sender, true, true); Key = 0; PreviewRun(this); } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::FunctionClick(TObject *Sender) { TSpeedButton *s; MainImageForm->iMainImage->OnPaintLocate=NULL; MainImageForm->iMainImage->Repaint(); ///////»©Áö¸¶½Ã¿À //PULL¿¡¼­ ¾¸ s = (TSpeedButton *)Sender; if (s == sbRect) { RectMode(); InitRect(); sbRect->Down = true; } else if (s == sbPull) { PullMode(); ExitRect(); sbPull->Down = true; btnPull->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ } else if (s == sbX) { XReproMode(); ExitRect(); sbX->Down = true; } else if (s == sbY) { YReproMode(); ExitRect(); sbY->Down = true; } eXsize->Enabled = false; eYsize->Enabled = true; // by celberus } //--------------------------------------------------------------------------- void __fastcall TReproForm::PullEdit(TObject *Sender) { TEdit *e; int l1, l2, angle, ratio; e = (TEdit *)Sender; if (e->Text != "") { if (e == EXAngle) { compute_len(l1, l2); angle = StrToInt(EXAngle->Text); if ((angle > 9) && (angle < 81)) { s_repro.angle = angle; compute_len(l1, l2); lXlength1->Caption = l1; lXlength2->Caption = l2; } else { EXAngle->Text = s_repro.angle; } if ((s_repro.ratio < l1) || (s_repro.ratio > l2)) { s_repro.ratio = l1; lXlength1->Caption = l1; lXlength2->Caption = l2; EXratio->Text = l1; } } else if (e == EXratio) { compute_len(l1, l2); lXlength1->Caption = l1; lXlength2->Caption = l2; ratio = StrToInt(EXratio->Text); if ((ratio >= l1) && (ratio <= l2)) { s_repro.ratio = ratio; lXlength1->Caption = l1; lXlength2->Caption = l2; EXratio->Text = s_repro.ratio; } else { lXlength1->Caption = l1; lXlength2->Caption = l2; EXratio->Text = s_repro.ratio; } } else if (e == eYAngle) { compute_len(l1, l2); angle = StrToInt(eYAngle->Text); if ((angle > 9) && (angle < 81)) { s_repro.angle = angle; compute_len(l1, l2); lYlength1->Caption = l1; lYlength2->Caption = l2; } else { eYAngle->Text = s_repro.angle; } if ((s_repro.ratio < l1) || (s_repro.ratio > l2)) { s_repro.ratio = l1; lYlength1->Caption = l1; lYlength2->Caption = l2; eYratio->Text = l1; } } else if (e == eYratio) { compute_len(l1, l2); lYlength1->Caption = l1; lYlength2->Caption = l2; ratio = StrToInt(eYratio->Text); if ((ratio >= l1) && (ratio <= l2)) { s_repro.ratio = ratio; lYlength1->Caption = l1; lXlength2->Caption = l2; eYratio->Text = s_repro.ratio; } else { lYlength1->Caption = l1; lYlength2->Caption = l2; eYratio->Text = s_repro.ratio; } } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::shRectMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { eXsize->Enabled = true; eYsize->Enabled = true; // by celberus eXsize->SetFocus(); eXsize->SelectAll(); norun = 1; //lhskys ½ÇÇàÀ» ÇÒ¶§¸¦ Ç¥½ÃÇϱâÀ§ÇØ InitRect(); sbRect->Down = false; item = TREPRO_NULL; } //--------------------------------------------------------------------------- void __fastcall TReproForm::btnRectRunClick(TObject *Sender) { norun = 0; //lhskys ½ÇÇàÀ» ÇÏÁö ¾ÊÀ»¶§¸¦ Ç¥½ÃÇϱâÀ§ÇØ bool crtSw = false, crtSw1 = false, crtSw2 = false; TPItemImage *Image = MainImageForm->iMainImage; if (btnSize->Caption == IDS_COMMON_LENGTH) { if (eXsize->Text != "") { switch (MainImageForm->CurrentUnit) { case uDot : ReproRect.size.x = StrToInt(eXsize->Text); break; case uInch : ReproRect.size.x = StrToFloat(eXsize->Text) * MainImageForm->CanvasInfor.DotsPerInch; break; case uCm : ReproRect.size.x = StrToFloat(eXsize->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } } if (eYsize->Text != "") { switch (MainImageForm->CurrentUnit) { case uDot : ReproRect.size.y = StrToInt(eYsize->Text); break; case uInch : ReproRect.size.y = StrToFloat(eYsize->Text) * MainImageForm->CanvasInfor.DotsPerInch; break; case uCm : ReproRect.size.y = StrToFloat(eYsize->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } } } else if (btnSize->Caption == IDS_RATIO) { if (eXsize->Text != "") { ReproRect.size.x = window.size.x * StrToFloat(eXsize->Text) / 100.0; } if (eYsize->Text != "") { ReproRect.size.y = window.size.y * StrToFloat(eYsize->Text) / 100.0; } } MainImageForm->iMainImage->SubEnabled = true; if (Image->uBitmap->BitsPerPixel==8) { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; } else { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) goto fail; if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 1)) == false) goto fail; } Image->SubVisible = false; rect_repro(); if(!sbRect->Down)ExitRect(); return; fail : if (crtSw) window.Back->Destroy(); if (crtSw1) Image->SubBitmap->Destroy(); if (crtSw2) Image->SubMask->Destroy(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- 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) { ///* //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 // 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+1, window.e.x, window.e.y+1))) == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { if(!area->Create(window.e.x-window.s.x+1, window.e.y-window.s.y+1, 8)) 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)) 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) 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); 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 == 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); 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 == 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); 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 == 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); 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 == 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,1) + tp2.x) = *(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) { *(Image->uBitmap->GetScanLine(tp2.y - y,tp2.x,1) + tp2.x) = *(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) { *(Image->uBitmap->GetScanLine(tp2.y + y,tp2.x,1) + tp2.x) = *(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) { *(Image->uBitmap->GetScanLine(tp2.y - y,tp2.x,1) + tp2.x) = *(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; return; fail : if (undoSw) { area->StopScanLine(); Image->uBitmap->StopScanLine(); // Undo->RemoveLast(); MainImageForm->Undo->RemoveLast(); } if(area)delete area; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); // */ /* //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) { ///* //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; if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(window.s.x, window.s.y+1, window.e.x, window.e.y+1))) == false) goto fail; if (Image->uBitmap->BitsPerPixel==8) { if(!area->Create(window.e.x-window.s.x+1, window.e.y-window.s.y+1, 8)) 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)) 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) goto fail; if(area->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,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; 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-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 == 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-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 == 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-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 == 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-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 == 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-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) { *(Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x) = *(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) { *(Image->uBitmap->GetScanLine(tp2.y + y) + tp2.x) = *(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) { *(Image->uBitmap->GetScanLine(tp2.y - y) + tp2.x) = *(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; return; fail : if (undoSw) { area->StopScanLine(); Image->uBitmap->StopScanLine(); MainImageForm->Undo->RemoveLast(); } if(area)delete area; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); /* //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) { ///* //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; // 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; if (Image->uBitmap->BitsPerPixel==8) { if(!area->Create(window.e.x-window.s.x, window.e.y-window.s.y, 8)) 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)) 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) 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]; 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; return; fail : Image->Mask->StopScanLine(); area->StopScanLine(); Image->uBitmap->StopScanLine(); if (undoSw == true) MainImageForm->Undo->RemoveLast(); if(area)delete area; 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=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) { ///* //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; // 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(); if (Image->uBitmap->BitsPerPixel==8) { if(!area->Create(window.e.x-window.s.x, window.e.y-window.s.y, 8)) 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)) 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)) 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)) 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) 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,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) 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(); 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_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 *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; EXAngle->Text = 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->Text = s_repro.ratio; XTextItem = _StateUp; UpDownLabel->Caption = IDS_COMMON_UP; PullEdit(EXAngle); EXAngle->SetFocus(); EXAngle->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::PullMode(void) { item = TREPRO_PULL; RectPanel->Visible = false; YPanel->Visible = false; XPanel->Visible = false; PullPanel->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->Text = 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->Text = s_repro.ratio; YTextItem = _StateLeft; LeftRightLabel->Caption = IDS_COMMON_LEFT; PullEdit(eYAngle); eYAngle->SetFocus(); eYAngle->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::RectMode(void) { item = TREPRO_RECT; PullPanel->Visible = false; XPanel->Visible = false; YPanel->Visible = false; RectPanel->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TReproForm::SubMouseMove(int X, int Y) { // 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; 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) return; if (Image->uBitmap->BitsPerPixel==8) { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; } else { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) goto fail; if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 1)) == false) 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 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); } 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_MEMORY_LACK); } //--------------------------------------------------------------------------- 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; } //--------------------------------------------------------------------------- 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 : eXsize->Text = ReproRect.size.x; break; case uInch : eXsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eXsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } switch (MainImageForm->CurrentUnit) { case uDot : eYsize->Text = ReproRect.size.y; break; case uInch : eYsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eYsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); } } else if (btnSize->Caption == IDS_RATIO) { eXsize->Text = Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.x / window.size.x))); eYsize->Text = Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.y / window.size.y))); } } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TReproForm::InitForm() { TCursor OldCursor; TPItemImage *Image = MainImageForm->iMainImage; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; ParentHeight = Parent->Height+20; ClientHeight = 216; Parent->Height = ParentHeight+ClientHeight; window.Bitmap = NULL; window.Mask = NULL; window.Back = NULL; if ((window.Bitmap = new TUnionBitmap) == NULL) goto fail; // convert by celberus if ((window.Mask = new TUnionBitmap) == NULL) goto fail; if ((window.Back = new TUnionBitmap) == NULL) goto fail; PullStep = 0; XTextItem = _StateUp; YTextItem = _StateLeft; item = TREPRO_RECT; sbRect->Down = true; sbRect->Click(); PullPanel->Visible = false; XPanel->Visible = false; YPanel->Visible = false; RectPanel->Visible = true; 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); SelectNext((TWinControl *)btnRectRun, true, true); Screen->Cursor = OldCursor; btnRectRun->SetFocus(); //lhskys ½ÃÀ۽à focus¸¦ Ç¥½ÃÇϵµ·Ï norun = 0; //lhskys ¿£ÅÍ۸¦ ÃÆÀ»¶§ ½ÇÇà À¯¹«¸¦ Ç¥½ÃÇϱâÀ§ÇØ eXsize->Enabled = false; eYsize->Enabled = false; // by celberus 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_MEMORY_LACK); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); } //--------------------------------------------------------------------------- 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; Image->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TReproForm::rect_repro(void) { TCursor OldCursor; RECT rd, rs1, rs2; bool undoSw = false; HRGN hRgn = NULL; TPItemImage *Image = MainImageForm->iMainImage; TTexpiaBitmap *Mask = NULL; 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) goto fail; if ((Mask = new TTexpiaBitmap) == NULL) goto fail; if (!Mask->Copy(MainImageForm->WorkArea->Mask, SRCCOPY)) goto fail; if (MainImageForm->iMainImage->LayerMask) { if (!rect_repro_layer()) goto fail; } else { if (!rect_repro_none()) goto fail; } if (!Mask->ResizeStretch(ReproRect.size.x, ReproRect.size.y)) 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; return; fail: if (hRgn) DeleteObject(hRgn); if (Mask) delete Mask; if (undoSw) MainImageForm->Undo->RemoveLast(); Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- HRGN __fastcall TReproForm::Mask2Region(TTexpiaBitmap *Mask, int px, int py) { 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(); return hRgn; fail: if (hRgn) DeleteObject(hRgn); return NULL; } //--------------------------------------------------------------------------- bool __fastcall TReproForm::MakeImage() { TPItemImage *Image = MainImageForm->iMainImage; // HDC /*imageDC = NULL, wbitmapDC = NULL,*/ wmaskDC = NULL, wbackDC = NULL; // convert by celberus Image->uBitmap->RgnBitmap->RemoveRegion(); // convert by celberus // if((imageDC = Image->uBitmap->CreateDC()) == NULL) goto fail; convert by celberus // if((wbackDC = window.Back->CreateDC()) == NULL) goto fail; // 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 // if((wmaskDC = window.Mask->CreateDC()) == NULL) goto fail; // BitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wmaskDC, 0, 0, SRCAND); window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Mask, 0, 0, SRCAND); // window.Mask->DeleteDC(wmaskDC); wmaskDC = NULL; // if((wbitmapDC = window.Bitmap->CreateDC()) == NULL) goto fail; convert by celberus // BitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, wbitmapDC, 0, 0, SRCPAINT); // window.Bitmap->UnionBitBlt(wbackDC, 0, 0, ReproRect.size.x, ReproRect.size.y, 0, 0, SRCPAINT, false); // convert by celberus window.Back->Copy(0, 0, ReproRect.size.x, ReproRect.size.y, window.Bitmap, 0, 0, SRCPAINT); // convert by celberus // window.Bitmap->DeleteDC(wbitmapDC); convert by celberus // BitBlt(imageDC, ReproRect.s.x, ReproRect.s.y, ReproRect.size.x, ReproRect.size.y, // wbackDC, 0, 0, SRCCOPY); // Image->uBitmap->UnionBitBlt(wbackDC, ReproRect.s.x, ReproRect.s.y, ReproRect.size.x, ReproRect.size.y, // 0, 0, SRCCOPY, true); // convert by celberus Image->uBitmap->Copy(ReproRect.s.x, ReproRect.s.y, ReproRect.size.x, ReproRect.size.y, window.Back, 0, 0, SRCCOPY); // convert by celberus // window.Back->DeleteDC(wbackDC); // Image->uBitmap->DeleteDC(imageDC); convert by celberus return true; fail: // 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 return false; } //--------------------------------------------------------------------------- bool __fastcall TReproForm::rect_repro_none(void) { 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(); return true; fail: MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TReproForm::rect_repro_layer(void) { 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); return true; fail: Image->LayerMask->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Image->uBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- void __fastcall TReproForm::ReproMouseDown(int X, int Y) { if (item == TREPRO_RECT) { MainImageForm->iMainImage->SubVisible = false; rect_repro(); sbRect->Down = false; item = TREPRO_NULL; ExitRect(); } else if (item == TREPRO_PULL) { PullMouseDown(X, Y); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::ReproMouseMove(int X, int Y, TShiftState Shift) { if(Shift.Contains(ssShift))SubSquareMouseMove(X, Y); else SubMouseMove(X, Y); } //--------------------------------------------------------------------------- void __fastcall TReproForm::iMainImageKeyDown(int Key) { if (item == TREPRO_RECT) { int px, py; switch (Key) { case 10: // '\r' case 13: // '\n' EditKeyPress(this, Key); //lhskys ¿£ÅÍ۸¦ ¾ç¹æÇâ¿¡¼­ °°ÀÌ break; //lhskys ¹ÞÀ¸¹Ç·Î È£ÃâÀ» ÇÑ´Ù case 37: 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 38: 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 39: 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 40: 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 17: rect_repro(); break; // Ctrl - Key ¿Ö ÄÁÆ®·ÑÀ» ¸¸µé¾ú´ÂÁö... // case 16: squareSW = true; break; // Shift - Key } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::iMainImageKeyUp() { MainImageForm->ReadyToArrowKeyDown(true); } //--------------------------------------------------------------------------- void __fastcall TReproForm::iMainImageChange(void) { } //--------------------------------------------------------------------------- void __fastcall TReproForm::SetReproImage(void) { int x, y, xx; Byte *WP, *WBP, *MP, mm, *PP, *LP; COLORREF bgc, c; 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; 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) goto fail; if (Image->SubMask->Create(window.size.x, window.size.y, 8, rgb) == false) goto fail; if (window.Bitmap->Create(window.size.x, window.size.y, 8, rgb) == false) goto fail; if (window.Mask->Create(window.size.x, window.size.y, 8, rgb) == false) goto fail; if (window.Back->Create(window.size.x, window.size.y, 8, rgb) == false) goto fail; if (window.Bitmap->StartScanLine() == false) goto fail; if (window.Mask->StartScanLine() == false) goto fail; if (Image->uBitmap->StartScanLine() == false) goto fail; if (MainImageForm->WorkArea->Mask->StartScanLine() == false) goto fail; if (Image->LayerMask) { if (Image->LayerMask->StartScanLine() == false) 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 (Image->SubBitmap->Create(window.size.x, window.size.y, 24) == false) goto fail; if (Image->SubMask->Create(window.size.x, window.size.y, 1) == false) goto fail; if (window.Bitmap->Create(window.size.x, window.size.y, 24) == false) goto fail; if (window.Mask->Create(window.size.x, window.size.y, 1) == false) goto fail; if (window.Back->Create(window.size.x, window.size.y, 24) == false) goto fail; if (window.Bitmap->StartScanLine() == false) goto fail; if (window.Mask->StartScanLine() == false) goto fail; if (Image->uBitmap->StartScanLine() == false) goto fail; if (MainImageForm->WorkArea->Mask->StartScanLine() == false) goto fail; if (Image->LayerMask) { if (Image->LayerMask->StartScanLine() == false) 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(); } Image->SubMask->Copy(window.Mask, SRCCOPY); // Èæ¹é À̹ÌÁö Á¦°Å by celberus 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_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TReproForm::ChangeUnit(TUnit CUnit) { if (btnSize->Caption == IDS_COMMON_LENGTH) { lUnit->Caption = MainImageForm->UnitName(CUnit); switch (CUnit) { case uDot : eXsize->Text = ReproRect.size.x; eYsize->Text = ReproRect.size.y; lXsize->Caption = window.size.x; lYsize->Caption = window.size.y; break; case uInch : eXsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch))); eYsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch))); lXsize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.x / MainImageForm->CanvasInfor.DotsPerInch))); lYsize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.y / MainImageForm->CanvasInfor.DotsPerInch))); break; case uCm : eXsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); eYsize->Text = Format("%.2f", OPENARRAY(TVarRec, ((double)ReproRect.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); lXsize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.x / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); lYsize->Caption = Format("%.2f", OPENARRAY(TVarRec, ((double)window.size.y / MainImageForm->CanvasInfor.DotsPerInch * 2.54))); break; } } else if (btnSize->Caption == IDS_RATIO) { eXsize->Text = Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.x / window.size.x))); eYsize->Text = Format("%.2f", OPENARRAY(TVarRec, (100.0 * ReproRect.size.y / window.size.y))); lUnit->Caption = " %"; lXsize->Caption = 100; lYsize->Caption = 100; } } //---------------------------------------------------------------------------- void __fastcall TReproForm::btInit1Click(TObject *Sender) { if (item == TREPRO_RECT || item == TREPRO_NULL) { InitRect(); SetSizeText(); } } //--------------------------------------------------------------------------- void __fastcall TReproForm::lUnitClick(TObject *Sender) { eXsize->Enabled = true; eYsize->Enabled = true; // by celberus eXsize->SetFocus(); eXsize->SelectAll(); norun = 1; //lhskys ½ÇÇàÀ» ÇÒ¶§¸¦ Ç¥½ÃÇϱâÀ§ÇØ InitRect(); sbRect->Down = false; item = TREPRO_NULL; } //--------------------------------------------------------------------------- void __fastcall TReproForm::Preview(void) //by lhskys 2001.03.07 { // ½ÇÇàÇϱâÀü¿¡ // 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) 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); 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); } //---------------------------------------------------------------------------- void __fastcall TReproForm::PreviewRun(TObject *Sender) //by lhskys 2001.03.07 { // ½ÇÇàÇϱâÀü¿¡ COLORREF C; norun = 0; // ¹Ì¸®º¸±â 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 (btnSize->Caption == IDS_COMMON_LENGTH) { if (eXsize->Text != "") { switch (MainImageForm->CurrentUnit) { case uDot : ReproRect.size.x = StrToInt(eXsize->Text); break; case uInch : ReproRect.size.x = StrToFloat(eXsize->Text) * MainImageForm->CanvasInfor.DotsPerInch; break; case uCm : ReproRect.size.x = StrToFloat(eXsize->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } } if (eYsize->Text != "") { switch (MainImageForm->CurrentUnit) { case uDot : ReproRect.size.y = StrToInt(eYsize->Text); break; case uInch : ReproRect.size.y = StrToFloat(eYsize->Text) * MainImageForm->CanvasInfor.DotsPerInch; break; case uCm : ReproRect.size.y = StrToFloat(eYsize->Text) * MainImageForm->CanvasInfor.DotsPerInch / 2.54; } } } else if (btnSize->Caption == IDS_RATIO) { if (eXsize->Text != "") { ReproRect.size.x = window.size.x * StrToFloat(eXsize->Text) / 100.0; } if (eYsize->Text != "") { ReproRect.size.y = window.size.y * StrToFloat(eYsize->Text) / 100.0; } } MainImageForm->iMainImage->SubEnabled = true; MainImageForm->iMainImage->SubVisible = false; 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) goto fail; if ((crtSw1 = Image->SubBitmap->Create(Repro.size.x, Repro.size.y, 8, rgb)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(Repro.size.x, Repro.size.y, 8, rgb)) == false) 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) goto fail; if ((crtSw1 = Image->SubBitmap->Create(Repro.size.x, Repro.size.y, 24)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(Repro.size.x, Repro.size.y, 1)) == false) 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(); return; fail : if (crtSw) window.Back->Destroy(); if (crtSw1) Image->SubBitmap->Destroy(); if (crtSw2) Image->SubMask->Destroy(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TReproForm::AngleChange(TObject *Sender) { TEdit *e; int angle; e = (TEdit *)Sender; if (e->Text != "") { if (e == EXAngle) { angle = StrToInt(EXAngle->Text); if ((angle > 9) && (angle < 81)) { PullEdit(Sender); } }else if (e == eYAngle) { angle = StrToInt(eYAngle->Text); if ((angle > 9) && (angle < 81)) { PullEdit(Sender); } } } } //--------------------------------------------------------------------------- void __fastcall TReproForm::DistanceChange(TObject *Sender) { TEdit *e; int l1, l2, ratio; e = (TEdit *)Sender; if (e->Text != "") { compute_len(l1, l2); if (e == EXratio) { ratio = StrToInt(EXratio->Text); if ((ratio >= l1) && (ratio <= l2)) { PullEdit(Sender); } }else if (e == eYratio) { ratio = StrToInt(eYratio->Text); 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; btnPull->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) { // 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; 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) return; if (Image->uBitmap->BitsPerPixel==8) { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 8, rgb)) == false) goto fail; } else { if ((crtSw = window.Back->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) goto fail; if ((crtSw1 = Image->SubBitmap->Create(ReproRect.size.x, ReproRect.size.y, 24)) == false) goto fail; if ((crtSw2 = Image->SubMask->Create(ReproRect.size.x, ReproRect.size.y, 1)) == false) 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 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); } 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_MEMORY_LACK); } //---------------------------------------------------------------------------