From 8f132d9180e4d389a63165dcbffd0a272acf1ea8 Mon Sep 17 00:00:00 2001 From: yangjixian Date: Wed, 4 May 2011 07:57:14 +0000 Subject: [PATCH] fixed zoom bugs. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1610 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/lazimageeditor/DLBmpUtils.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/applications/lazimageeditor/DLBmpUtils.inc b/applications/lazimageeditor/DLBmpUtils.inc index 4910317b1..46e7bf522 100644 --- a/applications/lazimageeditor/DLBmpUtils.inc +++ b/applications/lazimageeditor/DLBmpUtils.inc @@ -677,19 +677,22 @@ end; procedure StretchDLBMP(ACanvas: TCanvas; Src: TDLBitmap; NewLeft, NewTop, NewWidth, NewHeight: integer); var - sw, sh, dw, dh, i, j: DWord; - Dest: TDLBitmap; + dw, dh, i, j: DWord; Dest: TDLBitmap; sw, sh: Float; begin Dest := TDLBitmap.Create; - sw := Max(1, NewWidth div Src.Width); - sh := Max(1, NewHeight div Src.Height); dw := NewWidth - NewLeft; dh := NewHeight - NewTop; + sw := dw / Src.Width; + sh := dh / Src.Height; + if sw = 0 then + sw := 1; + if sh = 0 then + sh := 1; Dest.Width := dw; Dest.Height := dh; for i := 0 to dh - 1 do for j := 0 to dw - 1 do - Dest.Pixels[j, i] := Src.Pixels[j div sw, i div sh]; + Dest.Pixels[j, i] := Src.Pixels[Trunc(j / sw), Trunc(i / sh)]; Dest.InvalidateScanLine; ACanvas.Draw(NewLeft, NewTop, Dest); Dest.Free;