Recent

Author Topic: GTK2 How to work with 32bpp image pixels?  (Read 209 times)

ALLIGATOR

  • Full Member
  • ***
  • Posts: 191
GTK2 How to work with 32bpp image pixels?
« on: June 09, 2025, 08:08:44 pm »
Lazarus, Linux, LCL, GTK2

How can I make it normal?
(Under Windows, a 10x10 pixel square, as expected)

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   pData: PUint32;
  4.   x, y: integer;
  5. begin
  6.   Image1.Width:=20;
  7.   Image1.Height:=20;
  8.  
  9.   Image1.Picture.Bitmap.PixelFormat:=pf32bit;
  10.   Image1.Picture.Bitmap.Width:=20;
  11.   Image1.Picture.Bitmap.Height:=20;
  12.  
  13.   Caption := TypInfo.GetEnumName(TypeInfo(TPixelFormat), Ord(Image1.Picture.Bitmap.PixelFormat));
  14.   Caption := Caption + ', ' + Image1.Picture.Bitmap.RawImage.Description.BitsPerPixel.ToString;
  15.  
  16.   Image1.Picture.Bitmap.BeginUpdate();
  17.   for y:=0 to 9 do
  18.   begin
  19.     pData:=PUInt32(Image1.Picture.Bitmap.RawImage.GetLineStart(y));
  20.     for x:=0 to 9 do
  21.       PUInt32(pData)[x]:=$FFFFFFFF;
  22.   end;
  23.   Image1.Picture.Bitmap.EndUpdate();
  24. end;

 

TinyPortal © 2005-2018