Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11516) gdk_pixbuf_new_from_sprite is buggy
Home

[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]
Subject: [Freeciv-Dev] (PR#11516) gdk_pixbuf_new_from_sprite is buggy
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 14 Dec 2004 11:20:02 -0800
Reply-to: bugs@xxxxxxxxxxx

<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





[Prev in Thread] Current Thread [Next in Thread]