From 614dc4a2a30936b28c7df90de8eab887fc08da0c Mon Sep 17 00:00:00 2001 From: ondrej Date: Sun, 4 Feb 2018 01:23:48 +0000 Subject: [PATCH] lcl: image list: simplify scaling git-svn-id: trunk@57248 - --- lcl/include/imglist.inc | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/lcl/include/imglist.inc b/lcl/include/imglist.inc index 91639c1b81..934a58f012 100644 --- a/lcl/include/imglist.inc +++ b/lcl/include/imglist.inc @@ -1084,23 +1084,10 @@ end; function TCustomImageListResolutions.FindBestToCopyFrom(const ATargetWidth, AIgnoreIndex: Integer): Integer; -var - SmallestToDownscale: Integer; begin - SmallestToDownscale := -1; - for Result := 0 to Count-1 do // first try to find the smallest (but bigger) multiple - begin - if (Result<>AIgnoreIndex) then - begin - if (Items[Result].Width mod ATargetWidth = 0) then - Exit - else - if (SmallestToDownscale < 0) and (Items[Result].Width>ATargetWidth) then - SmallestToDownscale := Result; - end; - end; - if SmallestToDownscale>=0 then - Exit(SmallestToDownscale); + for Result := 0 to Count-1 do // find the smallest (but bigger) image + if (Result<>AIgnoreIndex) and (Items[Result].Width>=ATargetWidth) then + Exit; Result := Count-1; // just pickup the biggest image to scale up if Result=AIgnoreIndex then @@ -1264,20 +1251,12 @@ function TCustomImageList.AddMultipleResolutions( Images: array of TCustomBitmap): Integer; function FindImage(const ATargetWidth: Integer): TCustomBitmap; - var - SmallestToDownscale: TCustomBitmap; begin - SmallestToDownscale := nil; - for Result in Images do // first try to find the smallest (but bigger) multiple + for Result in Images do // find the smallest (but bigger) image begin - if (Result.Width mod ATargetWidth = 0) then - Exit - else - if (SmallestToDownscale = nil) and (Result.Width>ATargetWidth) then - SmallestToDownscale := Result; + if (Result.Width>=ATargetWidth) then + Exit; end; - if SmallestToDownscale<>nil then - Exit(SmallestToDownscale); Result := Images[High(Images)]; // just pickup the biggest image to scale up end;