[Freeciv-Dev] (PR#12267) gdk_pixbuf_new_from_sprite doesn't work for spr
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12267 >
If you put alpha levels into a sprite that has
gdk_pixbuf_new_from_sprite called on it (such as some of the city
styles) it doesn't work. The reason is that gdk_pixbuf_new_from_sprite
assumes the sprite is a pixbuf-and-mask form. The result is a pixbuf
"assert" and a garbled image.
This patch fixes it. gdk_pixbuf_new_from_sprite is removed entirely.
However there still seems to be a problem with this code in dialogs.c.
When the pixbuf uses alpha levels the bounding-box crop doesn't seem to
work properly.
-jason
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.90
diff -u -r1.90 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 6 Feb 2005 21:39:09 -0000 1.90
+++ client/gui-gtk-2.0/dialogs.c 16 Feb 2005 05:30:56 -0000
@@ -1766,7 +1766,8 @@
last = city_styles[i].tiles_num-1;
s = crop_blankspace(sprites.city.tile[i][last]);
- img = gdk_pixbuf_new_from_sprite(s);
+ img = sprite_get_pixbuf(s);
+ g_object_ref(img);
free_sprite(s);
gtk_list_store_set(store, &it, 0, i, 1, img, 2,
get_city_style_name(i), -1);
Index: client/gui-gtk-2.0/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/graphics.c,v
retrieving revision 1.35
diff -u -r1.35 graphics.c
--- client/gui-gtk-2.0/graphics.c 8 Feb 2005 18:02:43 -0000 1.35
+++ client/gui-gtk-2.0/graphics.c 16 Feb 2005 05:30:57 -0000
@@ -515,9 +515,12 @@
}
/*********************************************************************
- Converts a sprite to a GdkPixbuf.
+ Converts a pixmap/mask sprite to a GdkPixbuf.
+
+ This is just a helper function for sprite_get_pixbuf(). Most callers
+ should use that function instead.
*********************************************************************/
-GdkPixbuf *gdk_pixbuf_new_from_sprite(SPRITE *src)
+static GdkPixbuf *gdk_pixbuf_new_from_pixmap_sprite(SPRITE *src)
{
GdkPixbuf *dst;
int w, h;
@@ -570,7 +573,7 @@
}
if (!sprite->pixbuf) {
- sprite->pixbuf = gdk_pixbuf_new_from_sprite(sprite);
+ sprite->pixbuf = gdk_pixbuf_new_from_pixmap_sprite(sprite);
}
return sprite->pixbuf;
}
Index: client/gui-gtk-2.0/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/graphics.h,v
retrieving revision 1.11
diff -u -r1.11 graphics.h
--- client/gui-gtk-2.0/graphics.h 1 Feb 2005 01:08:45 -0000 1.11
+++ client/gui-gtk-2.0/graphics.h 16 Feb 2005 05:30:57 -0000
@@ -55,8 +55,6 @@
int *start_y, int *end_x, int *end_y);
SPRITE *crop_blankspace(SPRITE *s);
-GdkPixbuf *gdk_pixbuf_new_from_sprite(SPRITE *src);
-
/********************************************************************
Note: a sprite cannot be changed after these functions are called!
********************************************************************/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12267) gdk_pixbuf_new_from_sprite doesn't work for sprites with alpha,
Jason Short <=
|
|