From feee1b756f0e8e6659428ef9a4c41784c8be4386 Mon Sep 17 00:00:00 2001 From: yangjixian Date: Wed, 28 Dec 2011 08:25:00 +0000 Subject: [PATCH] Fix bug of scale and improve the function. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2202 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/lazimageeditor/DLBmpUtils.inc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/applications/lazimageeditor/DLBmpUtils.inc b/applications/lazimageeditor/DLBmpUtils.inc index 780345577..6afc3a634 100644 --- a/applications/lazimageeditor/DLBmpUtils.inc +++ b/applications/lazimageeditor/DLBmpUtils.inc @@ -776,7 +776,7 @@ end; procedure StretchDLBMPEx(ACanvas: TCanvas; Src: TDLBitmap; NewLeft, NewTop, NewWidth, NewHeight: integer; Posx, Posy, aWidth, aHeight: integer); var - iw, ih, dw, dh, i, j, k, m, ypos, xpos, ylen, xlen: DWord; Dest: TDLBitmap; sw, sh: Float; LScan1, LScan2: pRGBATriple; + iw, ih, th, ww, dw, dh, i, j, k, m, ypos, xpos, ylen, xlen: DWord; Dest: TDLBitmap; sw, sh: Float; LScan1, LScan2: pRGBATriple; begin Dest := TDLBitmap.Create; dw := NewWidth - NewLeft; @@ -789,6 +789,10 @@ begin sw := 1; if sh = 0 then sh := 1; + if iw = 0 then + iw := 1; + if ih = 0 then + ih := 1; Dest.Width := dw; Dest.Height := dh; if dw > aWidth then @@ -811,14 +815,15 @@ begin ylen := dh; ypos := 0 end; - m := Trunc(ypos / sh); + m := ypos div ih; + ww := xpos div iw; for i := ypos to ylen - 1 do begin LScan1 := Dest.Scanline[i]; LScan2 := Src.Scanline[m]; if (i mod ih) = 0 then m := m + 1; - k := Trunc(xpos / sw);; + k := ww; for j := xpos to xlen - 1 do begin LScan1[j] := LScan2[k];