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:
parent
da9f7d5ffa
commit
7e20dce069
@ -60,6 +60,11 @@ uses
|
||||
LCLType,
|
||||
FPImgCanv, GraphType;
|
||||
|
||||
function InRange(x, min, max: Integer): Boolean;
|
||||
begin
|
||||
Result := (x >= min) and (x <= max);
|
||||
end;
|
||||
|
||||
{$IF Laz_FullVersion < 1090000}
|
||||
// Workaround for http://mantis.freepascal.org/view.php?id=27144
|
||||
procedure CopyPixels(ASource, ADest: TLazIntfImage;
|
||||
@ -164,6 +169,10 @@ begin
|
||||
for i := 0 to intfImg.Width - 1 do begin
|
||||
cimg := intfImg.Colors[i, j];
|
||||
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.Red := Round(alpha * cimg.Red + (1 - alpha) * cbuf.Red);
|
||||
cbuf.Green := Round(alpha * cimg.Green + (1 - alpha) * cbuf.Green);
|
||||
@ -173,7 +182,8 @@ begin
|
||||
end else
|
||||
for j := 0 to intfImg.Height - 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
|
||||
intfimg.Free;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user