LazMapViewer: Fix drawing of scaled transparent tiles by RGBGraphics drawing engine. Issue #39078.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9500 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-11-05 13:12:06 +00:00
parent 9eec695b86
commit 92d090919b

View File

@ -278,6 +278,7 @@ begin
try
try
FImage := TRGB32Bitmap.CreateFromStream(AStream, Reader);
// Make sure that all tiles have the size defined by TileSize.
StretchImageIfNeeded(FImage, TileSize.CX, TileSize.CY);
except
@ -298,19 +299,10 @@ end;
Needed to have all tiles at the same size. }
procedure TRGB32BitmapCacheItem.StretchImageIfNeeded(var AImage: TRGB32Bitmap;
ANewWidth, ANewHeight: Integer);
var
w, h: Integer;
begin
if AImage = nil then
exit;
w := AImage.Width;
h := AImage.Height;
if (w <> ANewWidth) or (h <> ANewHeight) then
begin
// AImage.SaveToFile('test512.png');
if Assigned(AImage) then
if (AImage.Width <> ANewWidth) or (AImage.Height <> ANewHeight) then
AImage.StretchTrunc(ANewWidth, ANewHeight);
// AImage.SaveToFile('test256.png');
end;
end;
destructor TMvRGBGraphicsDrawingEngine.Destroy;
@ -422,17 +414,15 @@ procedure TMvRGBGraphicsDrawingEngine.DrawCacheItem(X, Y: Integer;
AImg: TPictureCacheItem; ADrawMode: TItemDrawMode; AOpacity: Single);
var
Item: TRGB32BitmapCacheItem;
Alpha: Byte;
begin
Item := (AImg as TRGB32BitmapCacheItem);
if ADrawMode = idmDraw then
FBuffer.Draw(X, Y, Item.Image)
else
begin
if ADrawMode = idmUseOpacity
then Alpha := Round(AOpacity * 255)
else Alpha := 0;
AlphaBlendImages(FBuffer, Item.Image, X, Y, Alpha);
case ADrawMode of
idmDraw:
FBuffer.Draw(X, Y, Item.Image);
idmUseOpacity:
AlphaBlendImages(FBuffer, Item.Image, X, Y, round(AOpacity * 255));
idmUseSourceAlpha:
AlphaBlendImages(FBuffer, Item.Image, X, Y);
end;
end;