FIX: Blurry icons in viewer/editor/differ (issue #2752)

This commit is contained in:
Alexander Koblov 2026-03-29 15:03:31 +03:00
commit af11aa348b
2 changed files with 18 additions and 7 deletions

View file

@ -30,6 +30,10 @@ uses
type
{ TImageList }
TImageList = class(Controls.TImageList);
{ TdmComData }
TdmComData = class(TDataModule)
@ -151,6 +155,7 @@ var
AName: String;
AFactor: Double;
AResolutions: array of Integer;
AResolutions2: array of Integer;
ABitmaps: array of TCustomBitmap;
begin
Images.Clear;
@ -161,32 +166,34 @@ begin
AResolutions[1]:= 24; // AdjustIconSize(24, 96);
AResolutions[2]:= 32; // AdjustIconSize(32, 96);
if gToolIconsSize >= 48 then
if not (gToolIconsSize in [16, 24, 32]) then
begin
SetLength(ABitmaps, 4);
SetLength(AResolutions, 4);
AResolutions[3]:= gToolIconsSize;
end;
AResolutions2:= Copy(AResolutions);
AFactor:= findScaleFactorByFirstForm;
if (AFactor > 1.0) then
begin
I:= Round(gToolIconsSize * AFactor);
if (I <> 16) and (I <> 24) and (I <> 32) then
for I:= 0 to High(AResolutions2) do
begin
SetLength(ABitmaps, Length(ABitmaps) + 1);
SetLength(AResolutions, Length(AResolutions) + 1);
AResolutions[High(AResolutions)]:= I;
AResolutions2[I]:= Round(AResolutions2[I] * AFactor);
end;
end;
Images.RegisterResolutions(AResolutions);
I:= AResolutions2[0];
Images.SetWidthHeight(I, I);
Images.RegisterResolutions(AResolutions2);
for AName in ANames do
begin
for I:= 0 to High(AResolutions) do
begin
// GetThemeIcon takes into account
// CanvasScaleFactor, so use original icon size here
ABitmaps[I]:= PixMapManager.GetThemeIcon(AName, AResolutions[I]);
if (ABitmaps[I] = nil) then ABitmaps[I]:= TBitmap.Create;
end;

View file

@ -2649,6 +2649,10 @@ begin
Result:= LoadIconThemeBitmap(AIconName, AIconSize);
if Assigned(Result) then
begin
// LoadIconThemeBitmap takes into account
// CanvasScaleFactor, so use scaled icon size here
AIconSize := Round(AIconSize * findScaleFactorByFirstForm());
if (Result.Width > AIconSize) or (Result.Height > AIconSize) then
begin
ABitmap:= Graphics.TBitmap.Create;