You've already forked lazarus-ccr
lazmapviewer: Fix crash when painting outside the buffer.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7168 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -60,6 +60,11 @@ uses
|
|||||||
LCLType,
|
LCLType,
|
||||||
FPImgCanv, GraphType;
|
FPImgCanv, GraphType;
|
||||||
|
|
||||||
|
function InRange(x, min, max: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (x >= min) and (x <= max);
|
||||||
|
end;
|
||||||
|
|
||||||
{$IF Laz_FullVersion < 1090000}
|
{$IF Laz_FullVersion < 1090000}
|
||||||
// Workaround for http://mantis.freepascal.org/view.php?id=27144
|
// Workaround for http://mantis.freepascal.org/view.php?id=27144
|
||||||
procedure CopyPixels(ASource, ADest: TLazIntfImage;
|
procedure CopyPixels(ASource, ADest: TLazIntfImage;
|
||||||
@ -164,6 +169,10 @@ begin
|
|||||||
for i := 0 to intfImg.Width - 1 do begin
|
for i := 0 to intfImg.Width - 1 do begin
|
||||||
cimg := intfImg.Colors[i, j];
|
cimg := intfImg.Colors[i, j];
|
||||||
alpha := cimg.Alpha / word($FFFF);
|
alpha := cimg.Alpha / word($FFFF);
|
||||||
|
if not InRange(i + X, 0, FBuffer.Width-1) then
|
||||||
|
Continue;
|
||||||
|
if not InRange(j + Y, 0, FBuffer.Height-1) then
|
||||||
|
Continue;
|
||||||
cbuf := FBuffer.Colors[i + X, j + Y];
|
cbuf := FBuffer.Colors[i + X, j + Y];
|
||||||
cbuf.Red := Round(alpha * cimg.Red + (1 - alpha) * cbuf.Red);
|
cbuf.Red := Round(alpha * cimg.Red + (1 - alpha) * cbuf.Red);
|
||||||
cbuf.Green := Round(alpha * cimg.Green + (1 - alpha) * cbuf.Green);
|
cbuf.Green := Round(alpha * cimg.Green + (1 - alpha) * cbuf.Green);
|
||||||
@ -173,7 +182,8 @@ begin
|
|||||||
end else
|
end else
|
||||||
for j := 0 to intfImg.Height - 1 do
|
for j := 0 to intfImg.Height - 1 do
|
||||||
for i := 0 to intfImg.Width - 1 do
|
for i := 0 to intfImg.Width - 1 do
|
||||||
FBuffer.Colors[i + X, j + Y] := intfImg.Colors[i, j];
|
if InRange(i + x, 0, FBuffer.Width-1) and InRange(j + Y, 0, FBuffer.Height-1) then
|
||||||
|
FBuffer.Colors[i + X, j + Y] := intfImg.Colors[i, j];
|
||||||
finally
|
finally
|
||||||
intfimg.Free;
|
intfimg.Free;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user