[Freeciv-Dev] (PR#11516) gdk_pixbuf_new_from_sprite is buggy
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11516 >
This function in gui-gtk-2.0 has a bug I believe.
The pixel data is padded. Each row is not of width gdk_pixbuf_get_width
but has width gdk_pixbuf_get_rowstride. Thus instead of just doing
(pixels += 3, pixels++) each time we should calculate
*pixel = pixels + y * rowstride + 4 * x + 3;
Note that rowstride is the measure in *bytes* not in 4-byte entries, so
the first term doesn't get multiplied by 4. (In my tests the rowstride
was always just 4 * width so there was never any padding. But obviously
we don't want to count on this.)
See
http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#image-data
http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#gdk-pixbuf-get-rowstride
Also I think if !sprite->mask then there is no reason to set an alpha
channel (the flags in the dev version have no transparency so
sprite->mask is actually NULL).
Finally we might want some sort of assertion that
gdk_pixbuf_get_nchannels is 4 and gdk_pixbuf_get_bits_per_channel is 8.
-jason
- [Freeciv-Dev] (PR#11516) gdk_pixbuf_new_from_sprite is buggy,
Jason Short <=
|
|