Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-05

How to emulate SetDIBits and GetDIBits in Linux

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi guys

In MS Windows I use the following API functions:

1/
SetDIBits(bmap.Canvas.Handle, bmap.Handle, 0, bmap.Height, data,

            PBitmapInfo(bitmapInfop)^, DIB_RGB_COLORS);

To set the pixels in a bitmap (bmap) using the colour data found in the specified device-independent bitmap (data)

and

2/
GetDIBits(bmap.Canvas.Handle, bmap.Handle, 0, bmap.Height, data,

            PBitmapInfo(bitmapInfop)^, DIB_RGB_COLORS);

To retrieve the bits of the specified compatible bitmap (bmap) and write same into a buffer (data)

//-------------------------------------------------------- where
DIB_RGB_COLORS = 0 // colour table in RGBs

and

  PRGBQuad = ^TRGBQuad;
  tagRGBQUAD = packed record
    rgbBlue     : Byte;
    rgbGreen    : Byte;
    rgbRed      : Byte;
    rgbReserved : Byte;
  end;
  TRGBQuad = tagRGBQUAD;
  PBitmapInfo = ^TBitmapInfo;
  tagBITMAPINFO = packed record
    bmiHeader : TBitMapInfoHeader;
    bmicolors : array[0..0] of TRGBQuad;
  end;
  TBitmapInfo = tagBITMAPINFO;
//--------------------------------------------------------

Does anyone know how to do the same in Linux using FPC. Code must not bound only to the LCL, i.e. must function in GUI and console apps. I can do everything else, I'm not able to create the bitmap from the RGB data.

Thanks
Nino