[Gtk-sharp-list] [patch] Add PixelsPtr property to Gdk.Pixbuf

Vladimir Vukicevic vladimir@pobox.com
Mon, 17 May 2004 19:33:02 -0700


Hey folks,

The patch below adds a new PixelsPtr property to Pixbuf, which returns
the same as the Pixels property, except as an IntPtr.  This is to
allow C# code to take the pixel data pointer and pass it to more
unmanaged code (non-Gtk), without having to go through an

IntPtr foo;
unsafe { foo = pixbuf.Pixels; }

Let me know if this is okay to commit (or any suggestions on a better
way of doing this :)

    - Vlad

Index: ChangeLog
===================================================================
RCS file: /cvs/public/gtk-sharp/ChangeLog,v
retrieving revision 1.806
diff -u -u -r1.806 ChangeLog
--- ChangeLog	17 May 2004 17:51:59 -0000	1.806
+++ ChangeLog	18 May 2004 01:38:16 -0000
@@ -1,3 +1,8 @@
+2004-05-17  Vladimir Vukicevic  <vladimir@pobox.com>
+
+	* gdk/Pixbuf.custom: Add Pixbuf.PixelsPtr, returning an IntPtr instead
+	of a byte *.
+
 2004-05-17  Mike Kestner  <mkestner@ximian.com>
 
 	* generator/SignalHandler.cs : fix some broken/redundant generation in
Index: gdk/Pixbuf.custom
===================================================================
RCS file: /cvs/public/gtk-sharp/gdk/Pixbuf.custom,v
retrieving revision 1.18
diff -u -u -r1.18 Pixbuf.custom
--- gdk/Pixbuf.custom	7 Apr 2004 19:15:00 -0000	1.18
+++ gdk/Pixbuf.custom	18 May 2004 01:38:16 -0000
@@ -151,6 +151,13 @@
                 	}
                 }
 
+                public unsafe IntPtr PixelsPtr {
+                	get {
+                		byte *ret = gdk_pixbuf_get_pixels (Handle);
+                		return (IntPtr) ret;
+                	}
+                }
+
 		[DllImport("libgdk_pixbuf-2.0-0.dll")]
 		static extern IntPtr gdk_pixbuf_get_formats();