Hi

I'm looking to manipulate a GdkPixbuf at the pixel level and have found 
that the actual pixel data is not stored in the way I expected.

In order to get the pixel data I have used the following code (where 
image is a static GtkWidget declared in the header file):

void pixel_data(GtkWidget *widget, GdkEvent *event, gpointer data)
{
        int i, array_size;
        GdkPixbuf *image_data;

        i = 0;
        image_data = gtk_image_get_pixbuf(GTK_IMAGE(image));
        array_size = 3 * (gdk_pixbuf_get_width(image_data) * 
gdk_pixbuf_get_height(image_data));
        
        for(i=0; i < array_size; i++)
                g_print("%d, ", (int) gdk_pixbuf_get_pixels(image_data)[i]);
}


My assumption was that the guchar pointer returned by 
gdk_pixbuf_get_pixels() would store the pixel data as an 8 bit int for 
the R, G and B channels for each pixel. ie. a 2*2 pixel image with 24bit 
colour would print out the following (assuming the image was white):

255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,

However the following was output:

255, 255, 255, 255, 255, 255, 80, 64, 255, 255, 255, 255,

I then output the rowstride for the image which was 8 (bytes per row) 
which prompted me to hack the code to loop 16 times and got:

255, 255, 255, 255, 255, 255, 80, 64, 255, 255, 255, 255, 255, 255, 0, 0, 
rowstride: 8

My Question is simply why are there two extra bytes per image row, what do 
they represent and what is a rowstride? - the documentation assumes this 
knowledge!

I'm using GTK2.0 and redhat 7.3

Cheers

_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to