Hello to all,
I have problems in linux converting a 32 tbitmap in a tlazintfimage and after reconverting it in 32bit tbitmap.
After of the conversion form tlazfintfimage to TBitma, the bitmat is a 24bit black image.
In lazarus windows this does not happen.
The example code is the next:
*unit1.lfm*
********
object Form1: TForm1
Left = 247
Height = 402
Top = 208
Width = 546
Caption = 'Form1'
ClientHeight = 402
ClientWidth = 546
LCLVersion = '1.1'
object Image1: TImage
Left = 32
Height = 250
Top = 48
Width = 224
end
object Label1: TLabel
Left = 320
Height = 15
Top = 176
Width = 34
Caption = 'Label1'
ParentColor = False
end
object Label2: TLabel
Left = 320
Height = 15
Top = 212
Width = 34
Caption = 'Label2'
ParentColor = False
end
object Label3: TLabel
Left = 323
Height = 15
Top = 244
Width = 34
Caption = 'Label3'
ParentColor = False
end
object Button1: TButton
Left = 312
Height = 25
Top = 96
Width = 75
Caption = 'Button1'
OnClick = Button1Click
TabOrder = 0
end
object Button2: TButton
Left = 408
Height = 25
Top = 96
Width = 75
Caption = 'Button2'
OnClick = Button2Click
TabOrder = 1
end
end
* unit.pas*
*********^
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Buttons, FPimage,IntfGraphics, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
bmp: TBitmap;
i,j : integer;
lazBMP: TLazIntfImage;
begin
bmp:= TBitmap.Create;
bmp.PixelFormat:=pf32bit;
bmp.SetSize(100,100);
lazBMP:=bmp.CreateIntfImage;
Label1.Caption:='before:'+inttostr(PIXELFORMAT_BPP[bmp.PixelFormat]);
for i:=0 to 99 do
for j:=0 to 99 do
lazBMP.Colors[i,j] := colYellow;
for i:=40 to 89 do
for j:=40 to 89 do
lazBMP.Colors[i,j] := colRed;
for i:=45 to 55 do
for j:=45 to 55 do
lazBMP.Colors[i,j] := colTransparent;
bmp.LoadFromIntfImage(lazBMP);
Label2.Caption:='after:'+inttostr(PIXELFORMAT_BPP[bmp.PixelFormat]);
lazBMP.free;
Image1.Picture.Assign(bmp);
Label3.Caption:='in Timage:'+inttostr(PIXELFORMAT_BPP[bmp.PixelFormat]);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
bmp: TBitmap;
i,j : integer;
begin
bmp:= TBitmap.Create;
bmp.PixelFormat:=pf32bit;
bmp.SetSize(100,100);
Label1.Caption:='before:'+inttostr(PIXELFORMAT_BPP[bmp.PixelFormat]);
for i:=0 to 99 do
for j:=0 to 99 do
bmp.canvas.Colors[i,j] := colYellow;
for i:=40 to 89 do
for j:=40 to 89 do
bmp.canvas.Colors[i,j] := colRed;
for i:=45 to 55 do
for j:=45 to 55 do
bmp.canvas.Colors[i,j] := colTransparent;
bmp.LoadFromIntfImage(bmp.CreateIntfImage);
Image1.Picture.Assign(bmp);
label2.Caption:='';
Label3.Caption:='in Timage:'+inttostr(PIXELFORMAT_BPP[bmp.PixelFormat]);
end;
end.
In the example if you press button 1 on linux version, you can see that after of loadfromintfimage, the bitmat is wrong. On windows version it run correcly.
Any one know what is the problem?