TBitmap in RGBA also under Windows lazarus / 39-Graphics ---------------------------------------------------------------------- Mathias · 2024-06-21 14:25 If you create a simple bitmap as follows, you get a 32-bit image under Linux and a 24-bit image under Windows. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormPaint(Sender: TObject);var  bit: TBitmap;begin  bit := TBitmap.Create;  bit.SetSize(256, 256);  bit.Canvas.Brush.Color := clRed;  bit.Canvas.Rectangle(10, 10, 50, 50);   WriteLn('OS: ', {$I %FPCTARGETOS%});  WriteLn('Pixel format: ', bit.PixelFormat);  WriteLn('bits per Pixel: ', bit.RawImage.Description.BitsPerPixel);  WriteLn('Red Shift: ', bit.RawImage.Description.RedShift);   Canvas.Draw(50, 50, bit);  bit.Free;end;    Output: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ wine project1.exe OS: Win64Pixel format: pf24bitbits per Pixel: 24Red Shift: 16$ ./project1OS: LinuxPixel format: pf24bitbits per Pixel: 32Red Shift: 16  So now my question, can you force the format when creating it to be RGA, BGR, RGBA, ABGR, etc. It has to work somehow, if you load something with TImage.LoadFromFile, it is different depending on whether it is BMP or PNG with or without alpha. Does anyone have an idea how to do this? I have already tried Bit.RawImage.Description.Init_BPP32_R8G8B8A8_BIO_TTB(w,h) And another thing, why is the PixelFormat <> bitPerPixel in my example code under Windows? ---------------------------------------------------------------------- Leledumbo · 2024-06-25 08:24 Quote from: Mathias on June 21, 2024, 04:25:21 pmSo now my question, can you force the format when creating it to be RGA, BGR, RGBA, ABGR, etc. Yes, PixelFormat property is read-write, not read only, so set that. The description also answers why the default is different. ---------------------------------------------------------------------- Mathias · 2024-06-29 13:18 Can you show me an example of how I can create an RGBA32 TBitmap? What do I have to change in the following code to make it work? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormPaint(Sender: TObject);var  bit: TBitmap;begin  bit := TBitmap.Create;  bit.SetSize(128, 128);   bit.Canvas.Rectangle(16, 16, 128 - 16, 128 - 16);  Canvas.Draw(10, 10, bit);   bit.Free;end; ---------------------------------------------------------------------- lainz · 2024-06-29 14:03 Quote from: Mathias on June 29, 2024, 03:18:31 pmCan you show me an example of how I can create an RGBA32 TBitmap? What do I have to change in the following code to make it work? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormPaint(Sender: TObject);var  bit: TBitmap;begin  bit := TBitmap.Create;  bit.SetSize(128, 128);   bit.Canvas.Rectangle(16, 16, 128 - 16, 128 - 16);  Canvas.Draw(10, 10, bit);   bit.Free;end;   Using BGRABitmap? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  bit: TBGRABitmap; bit := TBGRABitmap.Create(128, 128);bit.CanvasBGRA.Rectangle(16, 16, 128 - 16, 128 - 16);bit.SaveToFile('file_32_bit.png');bit.Free;