Sign in Join

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

Mailing lists / lazarus / 2010-02

Alpha transparency

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Felipe Monteiro de Carvalho

Hello,

How can one use an alpha channel in TRasterImage/TBitmap?

I am trying to figure out how to use it, but I can't think of any way except using TLazIntfImage...

And even then it would be rather problematic because the image drawing routines wouldn't have Alpha support.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Geoffray
to Felipe Monteiro de Carvalho

Le Jeudi 18 F?vrier 2010 12:46:51, Felipe Monteiro de Carvalho a ?crit :

Show quoted text 11 lines
Hello, How can one use an alpha channel in TRasterImage/TBitmap? I am trying to figure out how to use it, but I can't think of any way except using TLazIntfImage... And even then it would be rather problematic because the image drawing routines wouldn't have Alpha support. thanks,

TImage and TRasterImage are components that ease image manipulation. The good news is that it can support many image format (bmp, jpeg, png and many more). The bad news is that it can't support features that are not supported by all the images format it support. As alpha channel are supported by a very few of them it can't be supported by a generic TBitmap.

To do what you want you can use TPortableNetworkGraphic (for PNG format) in place of TBitmap. It's nearly the same interface (common parent component) with PNG format abilities in more (such as alpha channel).

Regards.

Geoffray "fatalerrors" Levasseur http://jeff.levasseur.tuxfamily.org/ Sic luceat lux et pax

Reply by email

Felipe Monteiro de Carvalho
to Geoffray

Ummm, actually this is conceptually wrong, because the images are not stored in memory using the format of the file, so for any image format you can simply set TRasterImage.PixelFormat to pf32bit to allocate a 8-bit channel for Alpha while in memory.

The problem is that I can't find routines to draw to this Alpha channel. It seams it isn't yet implemented, and because Delphi doesn't implement it we also need to think of an interface for this.

Also, 32-bit Bitmaps support transparency:

http://en.wikipedia.org/wiki/Comparison_of_graphics_file_formats

The separate classes for each format only implement load/saving to stream/file ... the actual in memory format options is common.

To do what you want you can use TPortableNetworkGraphic (for PNG format) in place of TBitmap. It's nearly the same interface (common parent component) with PNG format abilities in more (such as alpha channel).

Not really. Have you ever checked the declaration of TPortableNetworkGraphic? It doesn't implement anything except load/saving to stream/file

I took a look at the interface from TPNGObject (from TPNGImage project) which was bought by Delphi and it seams only to offer a scanline for the alpha channel.

Felipe Monteiro de Carvalho

Reply by email