<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Lazarus Pascal - Better image scaling for TImage - Delphi, Lazarus, Free Pascal				            </title>
            <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-better-image-scaling-for-timage/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 11 Aug 2026 18:23:54 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Lazarus Pascal - Better image scaling for TImage</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-better-image-scaling-for-timage/#post-6219</link>
                        <pubDate>Fri, 09 Jan 2026 12:44:49 +0000</pubDate>
                        <description><![CDATA[Specifically with Windows, I noticed how poorly a TImage scales.With a little trick you can redraw the image using a different type of interpolation like so:
procedure BetterScaleImage(AWid...]]></description>
                        <content:encoded><![CDATA[<p>Specifically with Windows, I noticed how poorly a TImage scales.<br />With a little trick you can redraw the image using a different type of interpolation like so:</p>
<pre contenteditable="false">procedure BetterScaleImage(AWidth, AHeight: Integer; sourceImage:Timage);
var
  srcImg, destImg: TLazIntfImage;
  cnv: TLazCanvas;
  interp: TFPBaseInterpolation;
begin
  if sourceImage.Picture.Bitmap = nil then Exit;

  srcImg := sourceImage.Picture.Bitmap.CreateIntfImage;
  destImg := TLazIntfImage.CreateCompatible(srcImg, AWidth, AHeight);

  try
    cnv := TLazCanvas.Create(destImg);
    try
      interp := TFPBaseInterpolation.Create;
      try
        cnv.Interpolation := interp;
        cnv.StretchDraw(0, 0, AWidth, AHeight, srcImg);

        sourceImage.Picture.Bitmap.LoadFromIntfImage(destImg);

      finally
        interp.Free;
      end;
    finally
      cnv.Free;
    end;
  finally
    destImg.Free;
    srcImg.Free;
  end;
end;                        </pre>
<p>After loading an image in your TImage, simply call BetterScaleImage(width,height,TImage) to scale it better.<br />Under Windows this will be a world of difference. </p>
<p>Enjoy!</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-better-image-scaling-for-timage/#post-6219</guid>
                    </item>
							        </channel>
        </rss>
		