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 12:03:24 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11516 >

And a patch.
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.28
diff -u -r1.28 graphics.c
--- client/gui-gtk-2.0/graphics.c       23 Nov 2004 15:44:10 -0000      1.28
+++ client/gui-gtk-2.0/graphics.c       14 Dec 2004 20:02:22 -0000
@@ -557,27 +557,28 @@
   h = src->height;
   
   /* convert pixmap */
-  dst = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h);
+  dst = gdk_pixbuf_new(GDK_COLORSPACE_RGB, src->mask != NULL, 8, w, h);
   gdk_pixbuf_get_from_drawable(dst, src->pixmap, NULL, 0, 0, 0, 0, w, h);
 
   /* convert mask */
   if (src->mask) {
     GdkImage *img;
-    int x, y;
+    int x, y, rowstride;
     guchar *pixels;
 
     img = gdk_drawable_get_image(src->mask, 0, 0, w, h);
 
     pixels = gdk_pixbuf_get_pixels(dst);
+    rowstride = gdk_pixbuf_get_rowstride(dst);
 
     for (y = 0; y < h; y++) {
       for (x = 0; x < w; x++) {
-       pixels += 3;
+       guchar *pixel = pixels + y * rowstride + x * 4 + 3;
 
        if (gdk_image_get_pixel(img, x, y)) {
-         *pixels++ = 255;
+         *pixel = 255;
        } else {
-         *pixels++ = 0;
+         *pixel = 0;
        }
       }
     }

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