在 Inno Setup 6 中,TBitmapImage 在缩放显示上呈现的尺寸大于其尺寸

TBitmapImage is rendered larger than its size on scaled display in Inno Setup 6

刚刚更新到最新的 Inno Setup v.6.0.3。但现在我的 TBitmapImage 图像出现了白色边框。下面的脚本在旧版本 5 上工作得很好。

那么,新版本和我使用多年的脚本似乎有什么问题?

请注意,我已将显示缩放了大约 125%。

ExtractTemporaryFile(ExpandConstant( '{#BackgroundImage}' ));
BackgroundBitmapImage := TBitmapImage.Create(MainForm);
BackgroundBitmapImage.Left := 0;
BackgroundBitmapImage.Top := 50;
BackgroundBitmapImage.AutoSize := True;
BackgroundBitmapImage.Bitmap.LoadFromFile( ExpandConstant('{tmp}\{#BackgroundImage}')  );
BackgroundBitmapImage.Parent := MainForm;

图像的确切大小都没有解决问题。

ExtractTemporaryFile(ExpandConstant( '{#BackgroundImage}' ));
BackgroundBitmapImage := TBitmapImage.Create(MainForm);
BackgroundBitmapImage.Left := 0;
BackgroundBitmapImage.Top := 50;
BackgroundBitmapImage.Width := 600;
BackgroundBitmapImage.Height := 500;
BackgroundBitmapImage.AutoSize := False;
BackgroundBitmapImage.Bitmap.LoadFromFile( ExpandConstant('{tmp}\{#BackgroundImage}')  );
BackgroundBitmapImage.Parent := MainForm;

您的 MainForm window 所在的显示器是 scaled/zoomed。

当您设置 .Parent 时,控件会重新缩放到目标显示。为防止这种情况,请在(隐式)设置大小之前设置 .Parent

ExtractTemporaryFile('{#BackgroundImage}');
BackgroundBitmapImage := TBitmapImage.Create(MainForm);
BackgroundBitmapImage.Parent := MainForm;
BackgroundBitmapImage.Left := 0;
BackgroundBitmapImage.Top := 50;
BackgroundBitmapImage.AutoSize := True;
BackgroundBitmapImage.Bitmap.LoadFromFile(
  ExpandConstant('{tmp}\{#BackgroundImage}'));

请注意,无需为 '{#BackgroundImage}' 调用 ExpandConstant,因为它 .