Inno Setup WizardImageFile在Windows7上的字体缩放看起来很糟糕



Inno Setup WizardImageFile(和WizardSmallImageFile)的位图看起来很糟糕,因为当Windows 7启用大系统字体时,向导比平时大,但图像缩放错误。

有解决办法吗?

如果我在这样的地方添加自己的图片,就没有类似的问题:

BitmapImage1.AutoSize := True;
BitmapImage1.Align := alClient;
BitmapImage1.Left := 0;
BitmapImage1.Top := 0;
BitmapImage1.stretch := True;
BitmapImage1.Parent := Splash;

这些都是位图图像,它们的缩放比例自然很差。你只是很幸运,你自己的图像在缩放时看起来没有那么糟糕。

您必须为常见的缩放因子准备自己的一组图像。

目前常用的缩放因子有100%、125%、150%和200%。所以你应该有四种尺寸的图像,比如:

WizardImage 100.bmp
WizardImage 125.bmp
WizardImage 150.bmp
WizardImage 200.bmp
WizardSmallImage 100.bmp
WizardSmallImage 125.bmp
WizardSmallImage 150.bmp
WizardSmallImage 200.bmp

Inno Setup可以自动选择自5.6以来的最佳图像版本。只需在WizardImageFileWizardSmallImageFile中列出您的图像版本。您可以使用通配符:

[Setup]
WizardImageFile=WizardImage *.bmp
WizardImageFile=WizardSmallImage *.bmp

在旧版本的Inno Setup上(或者如果您需要自定义选择算法,或者当向导中有其他自定义图像时),您必须通过程序选择图像。

以下示例的作用与Inno Setup 5.6大致相同:

[Setup]
; Use 100% images by default
WizardImageFile=WizardImage 100.bmp
WizardSmallImageFile=WizardSmallImage 100.bmp
[Files]
; Embed all other sizes to the installer
Source: "WizardImage *.bmp"; Excludes: "* 100.bmp"; Flags: dontcopy
Source: "WizardSmallImage *.bmp"; Excludes: "* 100.bmp"; Flags: dontcopy
[Code]
function GetScalingFactor: Integer;
begin
  if WizardForm.Font.PixelsPerInch >= 192 then Result := 200
    else
  if WizardForm.Font.PixelsPerInch >= 144 then Result := 150
    else
  if WizardForm.Font.PixelsPerInch >= 120 then Result := 125
    else Result := 100;
end;
procedure LoadEmbededScaledImage(Image: TBitmapImage; NameBase: string);
var
  Name: String;
  FileName: String;
begin
  Name := Format('%s %d.bmp', [NameBase, GetScalingFactor]);
  ExtractTemporaryFile(Name);
  FileName := ExpandConstant('{tmp}' + Name);
  Image.Bitmap.LoadFromFile(FileName);
  DeleteFile(FileName);
end;
procedure InitializeWizard;
begin
  { If using larger scaling, load the correct size of images }
  if GetScalingFactor > 100 then 
  begin
    LoadEmbededScaledImage(WizardForm.WizardBitmapImage, 'WizardImage');
    LoadEmbededScaledImage(WizardForm.WizardBitmapImage2, 'WizardImage');
    LoadEmbededScaledImage(WizardForm.WizardSmallBitmapImage, 'WizardSmallImage');
  end;
end;

您可能希望对SelectDirBitmapImageSelectGroupBitmapImagePreparingErrorBitmapImage执行相同的操作。


另请参阅:

  • 如何检测和";"修复";使用Inno Setup?设置DPI
  • Inno设置在自定义页面上放置图像/控件

最新更新