[lazarus] Bitmap transparency?

Micha Nelissen M.Nelissen at student.tue.nl
Mon Nov 10 02:14:36 EST 2003


Mattias Gaertner wrote:

> On Sun, 09 Nov 2003 18:23:39 +0100
> Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
> 
> 
>>Mattias Gaertner wrote:
>>
>>
>>>On Sun, 09 Nov 2003 15:08:06 +0100
>>>Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
>>>
>>>>I have been looking, but I can't find it in the archives / code: what 
>>>>functions do I need to implement?
>>>
>>>
>>>See winapih.inc, search for RawImage.
>>>See graphtype.pp for the RawImage format. 
>>>intfgraphics.pas contains the TLazIntfImage which uses the 5 functions.
>>
>>Is GetDescriptionFromDevice only used to create a device compatible 
>>bitmap? 
> 
> 
> I guess, you mean the right thing.
> GetDescriptionFromDevice should return only a RawImage description. No
> width, no height. Just the information about color depth, bits per pixel,
> ... . No real data. This information is used to calculate the needed memory
> and to know, how to set pixels.

Ok, so what fields need to be filled in GetDescriptionFromDevice?

>>If so, this can be done in win32 via CreateCompatibleBitmap. 
>>Retrieving all information requested by TRawImageDescription from a 
>>device context is very tedious, requires handling several cases (because 
>>in win32 objective a DC is a 'stateless' something to be drawn to).
>>
>>Second reason is that the following lcl call CreateBitmapFromRawImage 
>>will use CreateBitmap which is not recommended by the win32 docs for 
>>most bitmaps:
>>
>>---
>>While the CreateBitmap function can be used to create color bitmaps, for 
>>performance reasons applications should use CreateBitmap to create 
>>monochrome bitmaps and CreateCompatibleBitmap to create color bitmaps. 
>>When a color bitmap returned from CreateBitmap is selected into a device 
>>context, Windows must ensure that the bitmap matches the format of the 
>>device context it is being selected into. 
> 
> 
> Sounds like what we want. With the information in the RawImage description
> the data created already matches the color format. The interface only needs
> to setup the header.
> The idea is to implement "CreateCompatibleBitmap" in a platform independent
> way.
> Under win32 afaik you would normally use CreateCompatibleBitmap to create a
> bitmap. 

The 'compatible' in CreateCompatibleBitmap means compatible to some DC. 
With the current 5 fpimage functions, this function cannot be used, 
because I don't know what DC to create a compatible bitmap to.

What I was trying to say is: in the example at the top of the 
intfgraphics unit, there is the sequence (GetDescriptionFromDevice, 
CreateBitmap); my question is: is GetDescriptionFromDevice in any other 
context? Ie. is it used for anything else than calling CreateBitmap 
later on? Otherwise we could remove the GetDescriptionFromDevice and 
replace it with CreateBitmapCompatibleToDevice, as you suggested later 
in this post.

Regards,

Micha.









More information about the Lazarus mailing list