user830054
user830054

Reputation: 309

Inno Setup - how to show a transparent PNG Image?

I want to show it on the welcome page.

How is that possible?

Upvotes: 5

Views: 4718

Answers (3)

RobeN
RobeN

Reputation: 5456

In 5.5.7 update (28th December 2015) there was 32bit BMP with Alpha Channel function implemented.

The WizardImageFile and WizardSmallImageFile [Setup] section directives now support 32 bit bitmap files with an alpha channel. Use the new WizardImageAlphaFormat [Setup] section directive to specify if the bitmap file has its red, green and blue channel values premultiplied with the alpha channel value or not. Contributed by Honza Rameš via GitHub.

and

Pascal Scripting changes:
Class TBitmapImage now supports 32 bit bitmap files with an alpha channel. Make sure to set the Bitmap.AlphaFormat property before loading the bitmap file.

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

Upvotes: 7

Ignitor
Ignitor

Reputation: 3055

However, there is a workaround if your intention is mainly to show a partially transparent image:

the ReplaceColor and ReplaceWithColor properties of the TBitmapImage class allow replacing a color in the image with another color dynamically. The trick is to replace a "dummy" color (e.g. magenta) with the background color of the wizzard:

  • Convert the png to bmp (this will remove the alpha channel)
  • Replace the parts of the image which should be transparent with a color which doesn't occur in the rest of the image (e.g. magenta: #FF00FF)
  • Include the image in your ISS:

    [Files]
    Source: "my\transparent\image.bmp"; DestDir: "{tmp}"; Flags: dontcopy
    
  • Add the image to the wizzard page:

    [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;
    

It is not as pretty as a real alpha transparency but should be fine for simple cases.

Upvotes: 6

mirtheil
mirtheil

Reputation: 9192

According to the newsgroup posting at http://news.jrsoftware.org/news/innosetup.code/msg23217.html, PNGs are not supported on Setup Forms and would also be unsupported on the Welcome Page.

Upvotes: 6

Related Questions