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
This commit is contained in:
yangjixian
2011-12-28 08:25:00 +00:00
parent 13fe8899a3
commit feee1b756f

View File

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