[lazarus] Bitmap transparency?

Micha Nelissen M.Nelissen at student.tue.nl
Sun Nov 9 12:15:12 EST 2003


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? 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. Since CreateCompatibleBitmap 
takes a device context, it returns a bitmap that has the same format as 
the specified device context. Because of this, subsequent calls to 
SelectObject are faster than with a color bitmap returned from CreateBitmap.
---

I don't know what the exact performance penalty is, but if it's even in 
the docs...

I am just asking because if you're _only_ after a call to 
CreateCompatibleBitmap, (not using device info like height, width) there 
is a much easier way.

Micha.







More information about the Lazarus mailing list