mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-09 23:05:58 +02:00
LCL/GraphUtils: Fix image up-scaling by procedure ScaleImg. Issue #41614.
This commit is contained in:
parent
ba09545f7b
commit
412af2a70b
@ -368,24 +368,28 @@ end;
|
|||||||
|
|
||||||
procedure ScaleImg(AImage: TCustomBitmap; AWidth, AHeight: Integer);
|
procedure ScaleImg(AImage: TCustomBitmap; AWidth, AHeight: Integer);
|
||||||
var
|
var
|
||||||
srcImg: TLazIntfImage = nil;
|
srcImg, destImg: TLazIntfImage;
|
||||||
destCanvas: TLazCanvas = nil;
|
destCanvas: TLazCanvas;
|
||||||
begin
|
begin
|
||||||
if (AImage.Width = AWidth) and (AImage.Height = AHeight) then
|
if (AImage.Width = AWidth) and (AImage.Height = AHeight) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
srcImg := AImage.CreateIntfImage;
|
||||||
|
destImg := AImage.CreateIntfImage;
|
||||||
try
|
try
|
||||||
// Create the source LazIntfImage
|
destImg.SetSize(AWidth, AHeight);
|
||||||
srcImg := AImage.CreateIntfImage;
|
destCanvas := TLazCanvas.Create(destImg);
|
||||||
// Create the destination LazCanvas
|
try
|
||||||
destCanvas := TLazCanvas.Create(srcImg);
|
if (AWidth > srcImg.Width) and (AHeight > srcImg.Height) then
|
||||||
// Execute the canvas.StretchDraw
|
destCanvas.Interpolation := TFPBaseInterpolation.Create;
|
||||||
destCanvas.StretchDraw(0, 0, AWidth, AHeight, srcImg);
|
destCanvas.StretchDraw(0, 0, AWidth, AHeight, srcImg);
|
||||||
// Reload the stretched image into the CustomBitmap
|
destCanvas.Interpolation.Free;
|
||||||
AImage.LoadFromIntfImage(srcImg);
|
AImage.LoadFromIntfImage(destImg);
|
||||||
AImage.SetSize(AWidth, AHeight);
|
finally
|
||||||
|
destCanvas.Free;
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
destCanvas.Free;
|
destImg.Free;
|
||||||
srcImg.Free;
|
srcImg.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user