[lazarus] Bitmap transparency?

Micha Nelissen M.Nelissen at student.tue.nl
Wed Nov 12 15:02:14 EST 2003

Mattias Gaertner wrote:

> On Wed, 12 Nov 2003 20:31:08 +0100
> Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
>>Let me first say: the color format I mean is the RRGGBBAA and how bits 
>>each take.
>>Yes. But the winapi can convert between color formats automatically. You 
>>give the win32 interface a color format, and it can pass it on to the 
>>winapi for processing.
> Yes. But every conversion reduces the quality, so we should try to find the
> current format.

Agreed, but when you have the right number of bits, it's not so bad 
anymore, right?

>>>Hardly believable. 
>>>Can this BITMAPINFO only retrieved from bitmaps or can you create a
>>>bitmap fom any device and get a BTMAPINFO? And with this, get the color
>>>format from any DC?
>>The BITMAPINFO is contained with a DIBSECTION. The DIBSECTION can only 
>>be retrieved for device independant bitmaps, that means, bitmaps created 
>>by CreateDIBSection. No other function returns a BITMAPINFO structure.
>>The BITMAP structure can always be retrieved from any bitmap. But it 
>>doesn't contain the information to fill in {red,blue,green}{shift,prec}.
> AFAIK the INFOHEADER does. See for example
> http://astronomy.swin.edu.au/~pbourke/dataformats/bmp/.

I was not completely correct indeed. The DIBSECTION contains a 
BITMAPINFOHEADER.biCompression is BI_BITFIELDS, then and only then does 

Yes, but they are reading from disk. An in-memory bitmap, ie an HBITMAP 
handle, is different.

Ah I think found something finally:


>>>>I think that's the reason why in delphi there is a pfDevice 
>>>>for TPixelFormat.
>>>>Any tips? Shall I return a default color format in the raw image?
>>>Yes. I guess, at least the screen resolution can be retrieved, can't it?
>>I am able to get the color depth and bits per pixel used, eg. 16, 24, 32 
> I guess, win32 also defines, what bits are the red, green and blue?

It does not by default :(. The BITMAPINFO structure only suggests what 
'defaults' are supported by windows 95.


More information about the Lazarus mailing list