[lazarus] Bitmap transparency?
Micha Nelissen
M.Nelissen at student.tue.nl
Wed Nov 12 14:22:33 EST 2003
Mattias Gaertner wrote:
> On Wed, 12 Nov 2003 09:23:06 +0100
> Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
>
>
>>Mattias Gaertner wrote:
>>
>>
>>>On Mon, 10 Nov 2003 08:07:09 +0100
>>>Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
>>>
>>>
>>>
>>>
>>>>I think I can fill the RawImageDesc fields except palette, and I don't
>>>>know what to do with RedPrec, RedShift, etc..
>>>
>>>
>>>You need to find out the color format of the device/bitmap for this.
>>
>>Sorry I keep nagging about this subject, but:
>>1) there is one function not needing a DC to create a bitmap,
>>'CreateBitmap'. It is not possible to retrieve color format of this
>>bitmap. Even a google search did not turn up anything on the color
>>format subject. I guess, nobody uses it.
>>2) the functions that do have information on color format also need a
>>DC. You create a device independant bitmap with CreateDIBSection, and a
>>device dependant one with CreateDIBitmap. Long live the winapi, logic is
>>nowhere to be found it seems! The names are very unlogical.
>
>
> Ok. So, under win32 it seems, it is up to the user to keep book of the
> format of a DC/bitmap. But this data is win32 specific, so the LCL user
> can't do it. It must be done, by the win32 intf. Right?
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.
>>3) there is no function to retrieve the color format of a device. One
>>can only guess at it, based on BITMAPINFO structure help. That's because
>>the winapi support converting the color formats on the fly. For example,
>>using CreateDIBitmap, you specify the color format your source bitmap is
>>in, and the winapi will convert it to the color format of the target
>>device. It seems logical that one would be able to retrieve the color
>>format of the device for fast rendering and stuff, but it just seems
>>impossible.
>
>
> 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}.
Creating a DIB section isn't of much use, if you ask me, because that's
already what the rawimage is.
>>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
bits.
Regards,
Micha.
More information about the Lazarus
mailing list