소스 검색

Add 2 additional sizes (1.5x & 2x) for the Images.res icons* and use them when the scaling is high enough. Do same for cases where the main icon is used (SelLangFrom & UninstProgressForm). This avoids tiny icons on high DPI.

* = for DISKICON there's just one addition: 64x64 in addition to the existing 48x48.
Martijn Laan 4 년 전
부모
커밋
fa7a53d949
9개의 변경된 파일45개의 추가작업 그리고 32개의 파일을 삭제
  1. 30 19
      Components/BitmapImage.pas
  2. 1 0
      ISHelp/isetup.xml
  3. 4 4
      Projects/CompExeUpdate.pas
  4. BIN
      Projects/Images.res
  5. 1 1
      Projects/NewDisk.pas
  6. 1 1
      Projects/SelLangForm.pas
  7. 2 2
      Projects/UninstProgressForm.pas
  8. 3 3
      Projects/Wizard.pas
  9. 3 2
      whatsnew.htm

+ 30 - 19
Components/BitmapImage.pas

@@ -41,8 +41,7 @@ type
   public
   public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
-    procedure InitializeFromIcon(const Icon: TIcon; const BkColor: TColor); overload;
-    function InitializeFromIcon(const hInstance: HINST; const ResourceName: PChar; const BkColor: TColor): Boolean; overload;
+    function InitializeFromIcon(const hInstance: HINST; const ResourceName: PChar; const BkColor: TColor; const AscendingTrySizes: array of Integer): Boolean;
   published
   published
     property Align;
     property Align;
     property Anchors;
     property Anchors;
@@ -76,37 +75,49 @@ procedure Register;
 implementation
 implementation
 
 
 uses
 uses
-  Resample;
+  Math, Resample;
 
 
 procedure Register;
 procedure Register;
 begin
 begin
   RegisterComponents('JR', [TBitmapImage]);
   RegisterComponents('JR', [TBitmapImage]);
 end;
 end;
 
 
-procedure TBitmapImage.InitializeFromIcon(const Icon: TIcon; const BkColor: TColor);
-begin
-  { Set sizes (overrides any scaling) }
-  Width := Icon.Width;
-  Height := Icon.Height;
-
-  { Draw icon into bitmap }
-  Bitmap.Canvas.Brush.Color := BkColor;
-  Bitmap.Width := Width;
-  Bitmap.Height := Height;
-  Bitmap.Canvas.Draw(0, 0, Icon);
-end;
-
-function TBitmapImage.InitializeFromIcon(const hInstance: HINST; const ResourceName: PChar; const BkColor: TColor): Boolean;
+function TBitmapImage.InitializeFromIcon(const hInstance: HINST; const ResourceName: PChar; const BkColor: TColor; const AscendingTrySizes: array of Integer): Boolean;
 var
 var
   Handle: THandle;
   Handle: THandle;
   Icon: TIcon;
   Icon: TIcon;
+  I, Size: Integer;
 begin
 begin
-  Handle := LoadImage(hInstance, ResourceName, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+  { Find the largest regular icon size smaller than the scaled image }
+  Size := 0;
+  for I := Length(AscendingTrySizes)-1 downto 0 do begin
+    if (Width >= AscendingTrySizes[I]) and (Height >= AscendingTrySizes[I]) then begin
+      Size := AscendingTrySizes[I];
+      Break;
+    end;
+  end;
+  if Size = 0 then
+    Size := Min(Width, Height);
+
+  { Load the desired icon }
+  Handle := LoadImage(hInstance, ResourceName, IMAGE_ICON, Size, Size, LR_DEFAULTCOLOR);
+  if Handle = 0 then
+    Handle := LoadImage(hInstance, ResourceName, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
   if Handle <> 0 then begin
   if Handle <> 0 then begin
     Icon := TIcon.Create;
     Icon := TIcon.Create;
     try
     try
       Icon.Handle := Handle;
       Icon.Handle := Handle;
-      InitializeFromIcon(Icon, BkColor);
+
+      { Set sizes (overrides any scaling) }
+      Width := Icon.Width;
+      Height := Icon.Height;
+
+      { Draw icon into bitmap }
+      Bitmap.Canvas.Brush.Color := BkColor;
+      Bitmap.Width := Width;
+      Bitmap.Height := Height;
+      Bitmap.Canvas.Draw(0, 0, Icon);
+
       Result := True;
       Result := True;
     finally
     finally
       Icon.Free;
       Icon.Free;

+ 1 - 0
ISHelp/isetup.xml

@@ -5082,6 +5082,7 @@ DiskSliceSize=1457664
 <setuptopic directive="SetupIconFile">
 <setuptopic directive="SetupIconFile">
 <body>
 <body>
 <p>Specifies a custom program icon to use for Setup/Uninstall. The file must be located in your installation's <link topic="sourcedirectorynotes">source directory</link> when running the compiler, unless a fully qualified pathname is specified or the pathname is prefixed by "compiler:", in which case it looks for the file in the compiler directory.</p>
 <p>Specifies a custom program icon to use for Setup/Uninstall. The file must be located in your installation's <link topic="sourcedirectorynotes">source directory</link> when running the compiler, unless a fully qualified pathname is specified or the pathname is prefixed by "compiler:", in which case it looks for the file in the compiler directory.</p>
+<p>It is recommended to include at least the following sizes in your icon: 16x16, 32x32, 48x48, 64x64, and 256x256.</p>.
 <example><pre>SetupIconFile=MyProgSetup.ico</pre></example>
 <example><pre>SetupIconFile=MyProgSetup.ico</pre></example>
 </body>
 </body>
 </setuptopic>
 </setuptopic>

+ 4 - 4
Projects/CompExeUpdate.pas

@@ -18,7 +18,7 @@ uses
 
 
 procedure UpdateSetupPEHeaderFields(const F: TCustomFile;
 procedure UpdateSetupPEHeaderFields(const F: TCustomFile;
   const IsVistaCompatible, IsTSAware, IsDEPCompatible, IsASLRCompatible: Boolean);
   const IsVistaCompatible, IsTSAware, IsDEPCompatible, IsASLRCompatible: Boolean);
-procedure UpdateIcons(const FileName, IcoFileName: String; const DeleteUninstallImage: Boolean);
+procedure UpdateIcons(const FileName, IcoFileName: String; const DeleteUninstallIcon: Boolean);
 procedure UpdateVersionInfo(const F: TCustomFile;
 procedure UpdateVersionInfo(const F: TCustomFile;
   const NewBinaryFileVersion, NewBinaryProductVersion: TFileVersionNumbers;
   const NewBinaryFileVersion, NewBinaryProductVersion: TFileVersionNumbers;
   const NewCompanyName, NewFileDescription, NewTextFileVersion, NewLegalCopyright,
   const NewCompanyName, NewFileDescription, NewTextFileVersion, NewLegalCopyright,
@@ -319,7 +319,7 @@ begin
   Result := True;
   Result := True;
 end;
 end;
 
 
-procedure UpdateIcons(const FileName, IcoFileName: String; const DeleteUninstallImage: Boolean);
+procedure UpdateIcons(const FileName, IcoFileName: String; const DeleteUninstallIcon: Boolean);
 type
 type
   PIcoItemHeader = ^TIcoItemHeader;
   PIcoItemHeader = ^TIcoItemHeader;
   TIcoItemHeader = packed record
   TIcoItemHeader = packed record
@@ -458,8 +458,8 @@ begin
       try
       try
         { Delete default icons }
         { Delete default icons }
         OldGroupIconDir := DeleteIcon(H, M, 'MAINICON');
         OldGroupIconDir := DeleteIcon(H, M, 'MAINICON');
-        if DeleteUninstallImage then
-          DeleteIcon(H, M, 'Z_UNINSTALLIMAGE');
+        if DeleteUninstallIcon then
+          DeleteIcon(H, M, 'Z_UNINSTALLICON');
 
 
         { Build the new group icon resource }
         { Build the new group icon resource }
         NewGroupIconDirSize := 3*SizeOf(Word)+Ico.ItemCount*SizeOf(TGroupIconDirItem);
         NewGroupIconDirSize := 3*SizeOf(Word)+Ico.ItemCount*SizeOf(TGroupIconDirItem);

BIN
Projects/Images.res


+ 1 - 1
Projects/NewDisk.pas

@@ -80,7 +80,7 @@ begin
   OKButton.Caption := SetupMessages[msgButtonOK];
   OKButton.Caption := SetupMessages[msgButtonOK];
   CancelButton.Caption := SetupMessages[msgButtonCancel];
   CancelButton.Caption := SetupMessages[msgButtonCancel];
 
 
-  DiskBitmapImage.InitializeFromIcon(HInstance, 'Z_DISKIMAGE', Color); {don't localize}
+  DiskBitmapImage.InitializeFromIcon(HInstance, 'Z_DISKICON', Color, [48, 64]); {don't localize}
 
 
   TryEnableAutoCompleteFileSystem(PathEdit.Handle);
   TryEnableAutoCompleteFileSystem(PathEdit.Handle);
 
 

+ 1 - 1
Projects/SelLangForm.pas

@@ -161,7 +161,7 @@ begin
   OKButton.Caption := SetupMessages[msgButtonOK];
   OKButton.Caption := SetupMessages[msgButtonOK];
   CancelButton.Caption := SetupMessages[msgButtonCancel];
   CancelButton.Caption := SetupMessages[msgButtonCancel];
 
 
-  IconBitmapImage.InitializeFromIcon(Application.Icon, MainPanel.Color);
+  IconBitmapImage.InitializeFromIcon(HInstance, 'MAINICON', MainPanel.Color, [32, 48, 64]);
 
 
   KeepSizeY := True;
   KeepSizeY := True;
 end;
 end;

+ 2 - 2
Projects/UninstProgressForm.pas

@@ -112,8 +112,8 @@ begin
 
 
   PageNameLabel.Font.Style := [fsBold];
   PageNameLabel.Font.Style := [fsBold];
   PageNameLabel.Caption := SetupMessages[msgWizardUninstalling];
   PageNameLabel.Caption := SetupMessages[msgWizardUninstalling];
-  if not WizardSmallBitmapImage.InitializeFromIcon(HInstance, 'Z_UNINSTALLIMAGE', MainPanel.Color) then {don't localize}
-    WizardSmallBitmapImage.InitializeFromIcon(Application.Icon, MainPanel.Color);
+  if not WizardSmallBitmapImage.InitializeFromIcon(HInstance, 'Z_UNINSTALLICON', MainPanel.Color, [32, 48, 64]) then {don't localize}
+    WizardSmallBitmapImage.InitializeFromIcon(HInstance, 'MAINICON', MainPanel.Color, [32, 48, 64]); {don't localize}
   if SetupMessages[msgBeveledLabel] <> '' then begin
   if SetupMessages[msgBeveledLabel] <> '' then begin
     BeveledLabel.Caption := ' ' + SetupMessages[msgBeveledLabel] + ' ';
     BeveledLabel.Caption := ' ' + SetupMessages[msgBeveledLabel] + ' ';
     BeveledLabel.Visible := True;
     BeveledLabel.Visible := True;

+ 3 - 3
Projects/Wizard.pas

@@ -871,9 +871,9 @@ begin
   WizardBitmapImage2.Stretch := (shWizardImageStretch in SetupHeader.Options);
   WizardBitmapImage2.Stretch := (shWizardImageStretch in SetupHeader.Options);
   WizardSmallBitmapImage.Bitmap := SelectBestImage(WizardSmallImages, WizardSmallBitmapImage.Width, WizardSmallBitmapImage.Height);
   WizardSmallBitmapImage.Bitmap := SelectBestImage(WizardSmallImages, WizardSmallBitmapImage.Width, WizardSmallBitmapImage.Height);
   WizardSmallBitmapImage.Stretch := (shWizardImageStretch in SetupHeader.Options);
   WizardSmallBitmapImage.Stretch := (shWizardImageStretch in SetupHeader.Options);
-  SelectDirBitmapImage.InitializeFromIcon(HInstance, 'Z_DIRIMAGE', SelectDirPage.Color); {don't localize}
-  SelectGroupBitmapImage.InitializeFromIcon(HInstance, 'Z_GROUPIMAGE', SelectProgramGroupPage.Color); {don't localize}
-  PreparingErrorBitmapImage.InitializeFromIcon(HInstance, 'Z_STOPIMAGE', PreparingPage.Color); {don't localize}
+  SelectDirBitmapImage.InitializeFromIcon(HInstance, 'Z_DIRICON', SelectDirPage.Color, [32, 48, 64]); {don't localize}
+  SelectGroupBitmapImage.InitializeFromIcon(HInstance, 'Z_GROUPICON', SelectProgramGroupPage.Color, [32, 48, 64]); {don't localize}
+  PreparingErrorBitmapImage.InitializeFromIcon(HInstance, 'Z_STOPICON', PreparingPage.Color, [16, 24, 32]); {don't localize}
 
 
   { Initialize wpWelcome page }
   { Initialize wpWelcome page }
   RegisterExistingPage(wpWelcome, WelcomePage, nil, '', '');
   RegisterExistingPage(wpWelcome, WelcomePage, nil, '', '');

+ 3 - 2
whatsnew.htm

@@ -41,12 +41,13 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
 </ul>
 </ul>
 <p><span class="head2">Graphics modernized</span></p>
 <p><span class="head2">Graphics modernized</span></p>
 <ul>
 <ul>
-  <li>Updated all Compiler IDE toolbar icons and the wizard images used by the Compiler IDE's New Script Wizard wizard.</li>
   <li>Updated the default application icon used by Setup and Uninstall if [Setup] section directive <tt>SetupIconFile</tt> is not set.</li>
   <li>Updated the default application icon used by Setup and Uninstall if [Setup] section directive <tt>SetupIconFile</tt> is not set.</li>
+  <li>Updated all Compiler IDE toolbar icons and the wizard images used by the Compiler IDE's New Script Wizard wizard.</li>
   <li>Updated the small wizard image used by Uninstall if [Setup] section directive <tt>SetupIconFile</tt> is not set.</li>
   <li>Updated the small wizard image used by Uninstall if [Setup] section directive <tt>SetupIconFile</tt> is not set.</li>
-  <li>[Setup] section directives <tt>WizardImageFile</tt> and <tt>WizardSmallImageFile</tt> now default to a blank value which makes Setup use new built-in wizard images which are more modern and include versions for higher DPI settings.</li>
+  <li>[Setup] section directives <tt>WizardImageFile</tt> and <tt>WizardSmallImageFile</tt> now default to a blank value which makes Setup use new built-in wizard images which are more modern.</li>
   <li>Updated the folder, group, and stop icons used by Setup's <i>Select Destination Location</i>, <i>Select Start Menu Folder</i>, and <i>Preparing to Install</i> wizard pages.</li>
   <li>Updated the folder, group, and stop icons used by Setup's <i>Select Destination Location</i>, <i>Select Start Menu Folder</i>, and <i>Preparing to Install</i> wizard pages.</li>
   <li>Updated the disk icon used by Setup's <i>Setup Needs the Next Disk</i> form.</li>
   <li>Updated the disk icon used by Setup's <i>Setup Needs the Next Disk</i> form.</li>
+  <li>All these icon and images updates include the automatic use of larger versions on higher DPI settings.</li>
 </ul>
 </ul>
 <p><span class="head2">Other changes</span></p>
 <p><span class="head2">Other changes</span></p>
 <ul>
 <ul>