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

前端之家收集整理的这篇文章主要介绍了inno-setup – Inno Setup WizardImageFile在Windows 7上使用字体缩放看起来很糟糕前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Inno Setup的位图WizardImageFile(和WizardSmallImageFile)看起来很糟糕,因为当Windows 7启用了大型系统字体时,向导比平常大,但图像缩放得很糟糕.

有修复吗?

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

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

解决方法

这些是位图图像,它们自然会严重缩放.你很幸运,你自己的图像在缩放时看起来并不那么糟糕.

您必须为常见的缩放因子准备自己的一组图像,并动态选择正确的缩放因子.在Inno Setup中没有本机支持.

目前使用的常见缩放因子是100%,125%,150%和200%.所以你应该有四种尺寸的图像.

您可以使用WizardImageFileWizardSmallImageFile指令分配100%大小的图像,并在使用大缩放时使用Pascal脚本覆盖它.

说我有这些图像文件

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

这是您使用它们来显示用户计算机上缩放的正确大小的方法

[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 LoadEmbededScaledBitmap(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
    LoadEmbededScaledBitmap(WizardForm.WizardBitmapImage,'WizardImage');
    LoadEmbededScaledBitmap(WizardForm.WizardBitmapImage2,'WizardImage');
    LoadEmbededScaledBitmap(WizardForm.WizardSmallBitmapImage,'WizardSmallImage');
  end;
end;

您可能希望对SelectDirBitmapImage,SelectGroupBitmapImage和PreparingErrorBitmapImage执行相同的操作.

也可以看看:

> How to detect and “fix” DPI settings with Inno Setup?
> Inno Setup Placing image/control on custom page

原文链接:https://www.f2er.com/delphi/103196.html

猜你在找的Delphi相关文章