troubles painting a simple bitmat pf32bit in linux lazarus version lazarus / 39-Graphics ---------------------------------------------------------------------- dcelso · 2012-09-20 22:07 hello to all, I have created a simple example that runs well in windows but in linux does not show anyting. my form have only a timage in "alclient" and a tlavel to show if it is in 32 bit mode. Code: [Select]object Form1: TForm1   Left = 461   Height = 240   Top = 195   Width = 320   Caption = 'Form1'   ClientHeight = 240   ClientWidth = 320   OnShow = FormShow   LCLVersion = '0.9.30.4'   object Image1: TImage     Left = 0     Height = 240     Top = 0     Width = 320     Align = alClient     Center = True   end   object Label1: TLabel     Left = 61     Height = 1     Top = 191     Width = 1     ParentColor = False   end end And the pascal code only create on the event onshow a pf32bit with a red square in the center. Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,   StdCtrls; type   { TForm1 }   TForm1 = class(TForm)     Image1: TImage;     ImageList1: TImageList;     Label1: TLabel;     procedure FormShow(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormShow(Sender: TObject); var   img: TPicture;   bmp: TBitmap; begin   img := TPicture.Create;   img.Bitmap.PixelFormat := pf32bit;   img.Bitmap.SetSize(150, 150);   img.Bitmap.Canvas.Brush.Color := clRed;   img.Bitmap.Canvas.FillRect(50, 50, 100, 100);   image1.Picture.Assign(img);   if img.Bitmap.PixelFormat = pf32bit then   begin     Label1.Caption := '32';   end   else   begin     Label1.Caption := '0';   end;   img.free; end; end. I repeat that in windows it works well and in linux not. ¿What is the problem? ¿linux does not support  Bitmap with pixelformat in pf32bits? or i have a problem. If i change pf32bit for pf24bit or pf16bit or pf15bit it works perfectly. ---------------------------------------------------------------------- Blaazen · 2012-09-20 23:12 Hi, I tested and it works on both GTK2 and Qt4. But I can see in the *.lfm file that you have LCLVersion 0.9.30.4 which a little old and I am sure there were many changes. I tested with Lazarus 1.1 SVN. You can also try to put there: Code: [Select]  img.Bitmap.Canvas.Brush.Color := clBlack;   img.Bitmap.Canvas.FillRect(0, 0, img.Bitmap.Width, img.Bitmap.Height);    after the SetSize method because 32bit mode has transparency. So upgrade Lazarus and try your code again. ---------------------------------------------------------------------- dcelso · 2012-09-21 12:20 Thanks, in lazarus 1.0 runs well. Now the alpha channel is not read or alwais is 255. In this example I tried put the form in red color, and now i tried to put a green square with a little scuare transparent inside to show the red form color. But it not works. the form is this: Code: [Select]object Form1: TForm1   Left = 514   Height = 488   Top = 303   Width = 603   Caption = 'Form1'   ClientHeight = 488   ClientWidth = 603   Color = clRed   OnShow = FormShow   LCLVersion = '1.1'   object Image1: TImage     Left = 0     Height = 488     Top = 0     Width = 603     Align = alClient     Transparent = True   end   object Label1: TLabel     Left = 117     Height = 21     Top = 395     Width = 9     Caption = '0'     ParentColor = False   end end Using TBitmat my example is the next: Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,   StdCtrls; type   { TForm1 }   TForm1 = class(TForm)     Image1: TImage;     Label1: TLabel;     procedure FormShow(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormShow(Sender: TObject); var   bmp : TBitmap; begin   bmp:= TBitmap.Create;   bmp.PixelFormat:=pf32bit;   bmp.SetSize(150,150);   bmp.Canvas.Brush.Color:= clGreen;   bmp.Canvas.FillRect(20,20,130,130);   bmp.Canvas.Brush.Color:= clNone;   //bmp.Canvas.Brush.Style:=bsClear;   //bmp.Canvas.Pen.Style:=psClear;   bmp.Canvas.FillRect(50,50,100,100);   Image1.Picture.assign(bmp);   if Image1.Picture.Bitmap.PixelFormat = pf32bit then   begin        Label1.Caption:='32';   end;   bmp.Free; end; end. I see a green windows but instead of color red I see white color. ;( I tried change brush style and pen  but the result is not the correct, too. Using TPFImageBItmat my example is the next: Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,   StdCtrls, FPImage,FPCanvas; type   { TForm1 }   TForm1 = class(TForm)     Image1: TImage;     Label1: TLabel;     procedure FormShow(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormShow(Sender: TObject); var   bmp : TFPImageBitmap; begin   bmp:= TBitmap.Create;   bmp.SetSize(150,150);   bmp.PixelFormat:=pf32bit;   bmp.canvas.Brush.FPColor:= FPColor(255,0,0,255);   bmp.canvas.FillRect(20,20,130,130);   bmp.canvas.Brush.FPColor:= FPColor(0,0,0,0);   bmp.canvas.FillRect(50,50,100,100);   Image1.Picture.assign(bmp);   if Image1.Picture.Bitmap.PixelFormat = pf32bit then   begin        Label1.Caption:='32';   end;   bmp.Free; end; end. I see a black box instead of a green windows that shows the red color inside it. ¿What is my error using TBitmat an TFPImageBitmap? I Think that im doing the correct.