A little scale speed improved.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2201 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
yangjixian
2011-12-28 07:41:47 +00:00
parent dbb82e587b
commit 13fe8899a3

View File

@ -776,13 +776,15 @@ end;
procedure StretchDLBMPEx(ACanvas: TCanvas; Src: TDLBitmap;
NewLeft, NewTop, NewWidth, NewHeight: integer; Posx, Posy, aWidth, aHeight: integer);
var
dw, dh, i, j, k, ypos, xpos, ylen, xlen: DWord; Dest: TDLBitmap; sw, sh: Float; LScan1, LScan2: pRGBATriple;
iw, ih, 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;
dh := NewHeight - NewTop;
sw := dw / Src.Width;
sh := dh / Src.Height;
iw := dw div Src.Width;
ih := dh div Src.Height;
if sw = 0 then
sw := 1;
if sh = 0 then
@ -809,14 +811,19 @@ begin
ylen := dh;
ypos := 0
end;
m := Trunc(ypos / sh);
for i := ypos to ylen - 1 do
begin
LScan1 := Dest.Scanline[i];
LScan2 := Src.Scanline[Trunc(i / sh)];
LScan2 := Src.Scanline[m];
if (i mod ih) = 0 then
m := m + 1;
k := Trunc(xpos / sw);;
for j := xpos to xlen - 1 do
begin
k := Trunc(j / sw);
LScan1[j] := LScan2[k];
if (j mod iw) = 0 then
k := k + 1;
end;
end;
Dest.InvalidateScanLine;