Inno Setup-如何显示透明的PNG图像?

use*_*054 2 inno-setup

我想在欢迎页面上显示它。

那怎么可能?

mir*_*eil 6

根据http://news.jrsoftware.org/news/innosetup.code/msg23217.html上发布的新闻组,安装表单不支持 PNG,欢迎页面也不支持 PNG。


Ign*_*tor 5

但是,如果您的主要目的是显示部分透明的图像,则有一种解决方法:

类的ReplaceColorReplaceWithColor属性TBitmapImage允许动态地用另一种颜色替换图像中的一种颜色。诀窍是用向导的背景颜色替换“虚拟”颜色(例如洋红色):

  • 将 png 转换为 bmp(这将删除 alpha 通道)
  • 替换哪个应该是透明的与不在图像的其他部分发生的颜色的图像的部分(例如品红色:#FF00FF
  • 将图像包含在您的 ISS 中:

    [Files]
    Source: "my\transparent\image.bmp"; DestDir: "{tmp}"; Flags: dontcopy
    
    Run Code Online (Sandbox Code Playgroud)
  • 将图像添加到向导页面:

    [Code]
    
    procedure InitializeWizard;
    var
        ImageFile: String;
        Image: TBitmapImage;
    begin
        ImageFile := ExpandConstant('{tmp}\image.bmp');
        ExtractTemporaryFile('image.bmp');
        Image := TBitmapImage.Create(WizardForm);
        with Image do
        begin
            Bitmap.LoadFromFile(ImageFile);
            Parent := WizardForm.WelcomePage;
            Left := 10;
            Top := 10;
            Width := 30;
            Height := 30;
            ReplaceColor := $00FF00FF;                        // Replace magenta...
            ReplaceWithColor := WizardForm.WelcomePage.Color; // ...with the background color of the page
        end;
    end;
    
    Run Code Online (Sandbox Code Playgroud)

它不像真正的 alpha 透明度那么漂亮,但对于简单的情况应该没问题。


Rob*_*beN 5

在5.5.7更新(2015年12月28日)中,实现了具有Alpha通道功能的32位BMP。

WizardImageFile和WizardSmallImageFile [Setup]section指令现在支持带有alpha通道的32位位图文件。使用new WizardImageAlphaFormat [Setup]section指令指定位图文件的红色,绿色和蓝色通道值是否预先与alpha通道值相乘。由HonzaRameš通过GitHub提供

Pascal脚本更改:
TBitmapImage现在支持带有alpha通道的32位位图文件。确保Bitmap.AlphaFormat在加载位图文件之前设置属性。

http://www.jrsoftware.org/files/is5-whatsnew.htm