fixed zoom bugs.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1610 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
yangjixian
2011-05-04 07:57:14 +00:00
parent 973fdb4bf6
commit 8f132d9180

View File

@ -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;