question regarding pixbuf

2007-03-22 Thread Alexander Eichner
hello,

i have a problem when i load images with a certain size.
Normally the rowstride given with gdk_pixbuf_get_rowstride
is calculated with width of the image multiplied with the number of
channels in the image.
But if i load an RGB Image with for example 314px*240px in size
I get an rowstride of 944 instead of 942.
If i load an image with 324px*248px I get an rowstride of 972 which is
correct (324 * 3).
It doesn't matter if the image is PNG or JPEG.
Is this a bug or am I doing something wrong?
Here is code i use to load the image and read the informations.

image_filename =
gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));

original = gdk_pixbuf_new_from_file(image_filename, NULL);

width = gdk_pixbuf_get_width(original);

height = gdk_pixbuf_get_height(original);

rowstride = gdk_pixbuf_get_rowstride(original);

n_channels = gdk_pixbuf_get_n_channels(original);

Thanks in advance
Alexander

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: question regarding pixbuf

2007-03-22 Thread Ernie Wright
Alexander Eichner wrote:

 i have a problem when i load images with a certain size.
 Normally the rowstride given with gdk_pixbuf_get_rowstride
 is calculated with width of the image multiplied with the number of
 channels in the image.
 But if i load an RGB Image with for example 314px*240px in size
 I get an rowstride of 944 instead of 942.

The rowstride isn't necessarily equal to the width times the number of
channels.  Very often each row is padded to the next 2-byte or 4-byte
boundary, so that the start of each row is 16-bit or 32-bit aligned,
making image access faster on some hardware.  I'd have to check GDK
specifically, but in general it's also possible for the channels of an
image to be larger than 8 bits.

- Ernie  http://home.comcast.net/~erniew
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list