[gtkada] How to access the alpha channel in a Pixbuf

Michal Svoboda pht at spatium.org
Tue Nov 6 19:50:53 CET 2007


Hello,

I've loaded a PNG image with alpha channel into a Pixbuf (I can see that
Get_Has_Alpha returns true). Then I want to manipulate the pixel data,
including the alpha channel. 

In C, the gdk_pixbuf_get_pixels() function should return a pointer to
the bytes of the image, and if I understand that correctly, that would
be in RGBA format.

The Get_Pixels function in GtkAda is imported directly from the said C
function and returns Rgb_Buffer_Access, which used to be access type to
array of bytes (guchars) but since v2.10 it is access type to array of
Rgb_Record, which does not have an Alpha member.

So the questions are:

1. How should I access the alpha channel data?
Should I do unchecked_conversion to array of guchars? (Or packed record
with R, G, B, and A members)

2. In case of RGBA data format, is the array of Rgb_Record consistent at
all with the image data? (ie. does it not treat the alpha channel byte
as a color byte of the next pixel?)

3. Or is there a different way to access the alpha channel?

Regards,
Michal Svoboda



More information about the gtkada mailing list