Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2269) crop_sprite fix for XAW
Home

[Freeciv-Dev] (PR#2269) crop_sprite fix for XAW

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2269) crop_sprite fix for XAW
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Wed, 6 Nov 2002 20:38:58 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This patch is a subset of Vasco's original "PNG for XAW" patch.  It 
changes crop_sprite so that it checks to see if the sprite has a mask 
before cropping.  It is very similar to the changes that have already 
been made for GTK and GTK2 clients.

This will be applied first.  Then what is left will be the pure PNG changes.

jason

Index: client/gui-xaw/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/graphics.c,v
retrieving revision 1.39
diff -u -r1.39 graphics.c
--- client/gui-xaw/graphics.c   7 Aug 2002 11:21:43 -0000       1.39
+++ client/gui-xaw/graphics.c   7 Nov 2002 04:34:18 -0000
@@ -62,6 +62,7 @@
 Cursor nuke_cursor;
 Cursor patrol_cursor;
 
+static struct Sprite *ctor_sprite(Pixmap mypixmap, int width, int height);
 static struct Sprite *ctor_sprite_mask(Pixmap mypixmap, Pixmap mask, 
                                       int width, int height);
 
@@ -167,22 +168,27 @@
 struct Sprite *crop_sprite(struct Sprite *source,
                           int x, int y, int width, int height)
 {
-  GC plane_gc;
-  Pixmap mypixmap, mask;
+  Pixmap mypixmap;
 
   mypixmap = XCreatePixmap(display, root_window,
                           width, height, display_depth);
   XCopyArea(display, source->pixmap, mypixmap, civ_gc, 
            x, y, width, height, 0, 0);
 
-  mask = XCreatePixmap(display, root_window, width, height, 1);
-
-  plane_gc = XCreateGC(display, mask, 0, NULL);
-  XCopyArea(display, source->mask, mask, plane_gc, 
-           x, y, width, height, 0, 0);
-  XFreeGC(display, plane_gc);
-
-  return ctor_sprite_mask(mypixmap, mask, width, height);
+  if (source->has_mask) {
+    GC plane_gc;
+    Pixmap mask;
+
+    mask = XCreatePixmap(display, root_window, width, height, 1);
+
+    plane_gc = XCreateGC(display, mask, 0, NULL);
+    XCopyArea(display, source->mask, mask, plane_gc, 
+             x, y, width, height, 0, 0);
+    XFreeGC(display, plane_gc);
+    return ctor_sprite_mask(mypixmap, mask, width, height);
+  } else {
+    return ctor_sprite(mypixmap, width, height);
+  }
 }
 
 /***************************************************************************
@@ -257,7 +263,6 @@
   XFreePixmap(display, mask);
 }
 
-#ifdef UNUSED
 /***************************************************************************
 ...
 ***************************************************************************/
@@ -270,7 +275,6 @@
   mysprite->has_mask=0;
   return mysprite;
 }
-#endif
 
 /***************************************************************************
 ...

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