How to do a transparent splash screen using a 32 bits image png in linux lazarus / 39-Graphics ---------------------------------------------------------------------- dcelso · 2013-01-26 16:52 Hello, to all. I have a  png image to do a splash screen for my application. I would like do it using transparent options. The basic code is do a form, put in alclient a timage and load into it the image 32bits png. After do it the image is correctly painted showing the background form color in his transparent pixels, and my idea is do that show the dekstop pixels instea of bacground from color. In windows, using updatelayerdedwidows function, i can do it, the tweak used in delphi runs wells in lazarus windows version, I saw it in : http://melander.dk/articles/alphasplash/ But it does not run in lazarus linux version. Anyone have any idea? Thanks to all. ---------------------------------------------------------------------- lainz · 2013-01-26 17:24 Really you do that code works on Windows? You can show us the code? Thanks. ---------------------------------------------------------------------- dcelso · 2013-01-26 17:30 Yes, if you do all steps put in the before link, you can optain gratifying results. Resuming it is that I said. Do a form, put in alclient a timage and load into it the image 32bits png. And use updatelayerdedwidows function in onshow method. ---------------------------------------------------------------------- lainz · 2013-01-26 17:46 And where is UpdateLayeredWindow; I can't find WinAPI in Lazarus =D ---------------------------------------------------------------------- dcelso · 2013-01-26 18:08 In user32.dll , please.  Read the link that i put before. It says the details better than me. Sorry, My esoEnglish is too poor. ---------------------------------------------------------------------- lainz · 2013-01-26 21:47 Quote from: dcelso on January 26, 2013, 07:08:21 pmIn user32.dll , please.  Read the link that i put before. It says the details better than me. Sorry, My esoEnglish is too poor. Ok my english maybe us poor too =) but also my programming, so if you get it already working please upload the project.. ---------------------------------------------------------------------- dcelso · 2013-01-28 13:31 Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses  {$IFDEF WINDOWS}  windows,  {$ENDIF}  Classes,  SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, FPimage; type   { TForm1 }   TForm1 = class(TForm)     Image1: TImage;     procedure FormShow(Sender: TObject);   private     { private declarations }   public     procedure Execute;   end; var   Form1: TForm1; implementation {$R *.lfm} {$IFDEF WINDOWS} function UpdateLayeredWindow(hwnd: HWND; hdcDst: HDC; pptDst: PPoint;   psize: PSize; hdcSrc: HDC; pptSrc: PPoint; crKey: TColor;   pblend: PBlendFunction; dwFlags: DWORD): BOOL; stdcall; external 'user32'; {$ENDIF} { TForm1 } procedure TForm1.FormShow(Sender: TObject); begin   Image1.Picture.LoadFromFile('image.bmp');   Execute; end; procedure TForm1.Execute; var    {$IFDEF WINDOWS}    BlendFunction: TBlendFunction;    BitmapSize: TSize;    {$ENDIF}    BitmapPos: TPoint;    exStyle: DWORD;  begin    {$IFDEF WINDOWS}    // Enable window layering    exStyle := GetWindowLongA(Handle, GWL_EXSTYLE);    if (exStyle and WS_EX_LAYERED = 0) then      SetWindowLong(Handle, GWL_EXSTYLE, exStyle or WS_EX_LAYERED);    {$ENDIF}      // Resize form to fit bitmap      ClientWidth := image1.picture.Bitmap.Width;      ClientHeight := image1.picture.Bitmap.Height;      // Position bitmap on form      BitmapPos.x:=0;      BitmapPos.y:=0;      {$IFDEF WINDOWS}      BitmapSize.cx := image1.picture.Bitmap.Width;      BitmapSize.cy := image1.picture.Bitmap.Height;      // Setup alpha blending parameters      BlendFunction.BlendOp := AC_SRC_OVER;      BlendFunction.BlendFlags := 0;      BlendFunction.SourceConstantAlpha := 255;      BlendFunction.AlphaFormat := AC_SRC_ALPHA;      // ... and action!      UpdateLayeredWindow(Handle, 0, nil, @BitmapSize, image1.picture.Bitmap.Canvas.Handle,        @BitmapPos, 0, @BlendFunction, ULW_ALPHA);      {$ENDIF} end; end. Code: [Select][/object Form1: TForm1   Left = 305   Height = 240   Top = 263   Width = 320   Caption = 'Form1'   ClientHeight = 240   ClientWidth = 320   OnShow = FormShow   LCLVersion = '1.1'   object Image1: TImage     Left = 0     Height = 240     Top = 0     Width = 320     Align = alClient   end end]