diff --git a/components/lazmapviewer/source/addons/rgbgraphics_drawingengine/mvde_rgbgraphics.pas b/components/lazmapviewer/source/addons/rgbgraphics_drawingengine/mvde_rgbgraphics.pas index 53484c261..e8dd5b2ac 100644 --- a/components/lazmapviewer/source/addons/rgbgraphics_drawingengine/mvde_rgbgraphics.pas +++ b/components/lazmapviewer/source/addons/rgbgraphics_drawingengine/mvde_rgbgraphics.pas @@ -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'); - AImage.StretchTrunc(ANewWidth, ANewHeight); - // AImage.SaveToFile('test256.png'); - end; + if Assigned(AImage) then + if (AImage.Width <> ANewWidth) or (AImage.Height <> ANewHeight) then + AImage.StretchTrunc(ANewWidth, ANewHeight); 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;