inno-setup - Inno Setup WizardImageFile 在 Windows 7 上的字体缩放看起来很糟糕

标签 inno-setup pascalscript dpi-aware

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 以来可以自动选择图像的最佳版本。 只需在 WizardImageFile 中列出您的图像版本和 WizardSmallImageFile .您可以使用通配符:

[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 - Inno Setup WizardImageFile 在 Windows 7 上的字体缩放看起来很糟糕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26543603/

相关文章:

java - 如何配置 Inno Setup 以检查 Visual C++ Redistributable Packages

C# DLL 导出到 Inno-Setup - 错误 E0434F4D

inno-setup - 当 WizardForm 最小化并恢复时 Inno Setup 检测(收到通知)

delphi - 无法从 PascalScript 调用 Get_ProcAddress

c++ - Windows 8 之前的 GetProcessDpiAwareness()

installation - 在 Inno Setup 中执行 UninstallString

delphi - 更改所有对话框的整个字体名称(第 2 部分)

inno-setup - 从 Pascal 代码更改 Inno Setup 消息

windows-xp - Windows XP 中的 DPI Aware 应用程序