new function gdk_pixmap_copy



	Here's a patch to add a new utility function gdk_pixmap_copy.
It would be used instead of gdk_pixmap_ref if you wanted to alter
one of thw two copies.

							Ron Steinke


diff -ru gtk+-1.3.2/gdk/gdkpixmap.c gtk+-1.3.2.local/gdk/gdkpixmap.c
--- gtk+-1.3.2/gdk/gdkpixmap.c	Wed Oct 25 15:38:56 2000
+++ gtk+-1.3.2.local/gdk/gdkpixmap.c	Tue Nov 28 10:39:46 2000
@@ -112,6 +112,7 @@
                                          gint             y,
                                          gint             width,
                                          gint             height);
+GdkPixmap* gdk_pixmap_copy              (GdkPixmap *pixmap);
 
 
 static GdkVisual*   gdk_pixmap_real_get_visual   (GdkDrawable *drawable);
@@ -549,5 +550,29 @@
 {
   return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
 						transparent_color, data);
+}
+
+GdkPixmap*
+gdk_pixmap_copy(GdkPixmap *pixmap)
+{
+  GdkPixmap *pixmap_out;
+  GdkGC *gc;
+  gint width, height, depth;
+
+  g_return_val_if_fail(pixmap != NULL, NULL);
+
+  gdk_drawable_get_size(pixmap, &width, &height);
+
+  depth = gdk_drawable_get_depth(pixmap);
+
+  pixmap_out = gdk_pixmap_new(NULL, width, height, depth);
+
+  gc = gdk_gc_new(pixmap);
+
+  gdk_draw_drawable(pixmap_out, gc, pixmap, 0, 0, 0, 0, width, height);
+
+  gdk_gc_unref(gc);
+
+  return pixmap_out;
 }
 
diff -ru gtk+-1.3.2/gdk/gdkpixmap.h gtk+-1.3.2.local/gdk/gdkpixmap.h
--- gtk+-1.3.2/gdk/gdkpixmap.h	Wed Aug 30 19:04:21 2000
+++ gtk+-1.3.2.local/gdk/gdkpixmap.h	Tue Nov 28 10:32:32 2000
@@ -73,6 +73,7 @@
 					 GdkBitmap  **mask,
 					 GdkColor    *transparent_color,
 					 gchar     **data);
+GdkPixmap* gdk_pixmap_copy             (GdkPixmap *pixmap);
 
 #ifdef __cplusplus
 }




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]