From ae84ad32aea0931328516880d0f4f9e9f6660ec9 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Tue, 25 Jan 2005 17:20:55 +0000 Subject: [PATCH] 2005-01-25 Mike Kestner * gdk/Gdk.metadata : hide all the Pixbuf.SaveTo methods. * gdk/Pixbuf.custom : implement the SaveTo methods. svn path=/trunk/gtk-sharp/; revision=39514 --- ChangeLog | 5 ++ doc/en/Gdk/Pixbuf.xml | 124 +++++++++++++++++++++++++----------------- gdk/Gdk.metadata | 4 ++ gdk/Pixbuf.custom | 51 +++++++++++++++++ 4 files changed, 135 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41483d2f2..dbc3d677d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-01-25 Mike Kestner + + * gdk/Gdk.metadata : hide all the Pixbuf.SaveTo methods. + * gdk/Pixbuf.custom : implement the SaveTo methods. + 2005-01-25 Mike Kestner * gtk/Gtk.metadata : hide all the SignalFunc using Toolbar methods. diff --git a/doc/en/Gdk/Pixbuf.xml b/doc/en/Gdk/Pixbuf.xml index b089a4256..e6f5a1ee1 100644 --- a/doc/en/Gdk/Pixbuf.xml +++ b/doc/en/Gdk/Pixbuf.xml @@ -1409,54 +1409,6 @@ Gdk.Pixbuf pb = new Gdk.Pixbuf(memorystream); To be added - - - Method - - System.Boolean - - - - - - - - - - To be added - a - a - a - a - a - a - To be added - - - - - Method - - System.Boolean - - - - - - - - - - To be added - a - a - a - a - a - a - To be added - - Method @@ -1572,5 +1524,79 @@ Gdk.Pixbuf pb = new Gdk.Pixbuf(memorystream); To be added + + + Method + + System.Byte[] + + + + + + + + Saves to a buffer. + an image type, such as png, jpeg, or ico + an array of option keys. + an array of option values. + a + >The and should contain key/value pairs. See for more details. Throws a if the save is not successful. + + + + + Method + + System.Byte[] + + + + + + Saves to a buffer. + an image type, such as png, jpeg, or ico + a + Throws a if the save is not successful. + + + + + Method + + System.Void + + + + + + + Save using a callback delegate. + a + an image type, such as png, jpeg, or ico + Throws a if the save is not successful. + + + + + Method + + System.Void + + + + + + + + + Save using a callback delegate. + a + an image type, such as png, jpeg, or ico + an array of option keys + an array of option values + The and should contain key/value pairs. See for more details. Throws a if the save is not successful. + + - \ No newline at end of file + diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index f64e06c28..1e5dae9dc 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -84,6 +84,10 @@ out 1 1 + 1 + 1 + 1 + 1 1 1 1 diff --git a/gdk/Pixbuf.custom b/gdk/Pixbuf.custom index 30ad106b3..30bf932cc 100644 --- a/gdk/Pixbuf.custom +++ b/gdk/Pixbuf.custom @@ -252,3 +252,54 @@ return ret; } + [DllImport("libglib-2.0-0.dll")] + static extern void g_free (IntPtr raw); + + [DllImport("libgdk_pixbuf-2.0-0.dll")] + static extern unsafe bool gdk_pixbuf_save_to_bufferv (IntPtr raw, out IntPtr buffer, out uint buffer_size, string type, string[] option_keys, string[] option_values, out IntPtr error); + + string[] NullTerm (string[] src) + { + string[] result = new string [src.Length + 1]; + for (int i = 0; i < src.Length; i++) + result [i] = src [i]; + result [src.Length] = null; + return result; + } + + public unsafe byte[] SaveToBuffer (string type) + { + return SaveToBuffer (type, new string [0], new string [0]); + } + + public unsafe byte[] SaveToBuffer (string type, string[] option_keys, string[] option_values) + { + IntPtr error = IntPtr.Zero; + IntPtr buffer; + uint buffer_size; + if (!gdk_pixbuf_save_to_bufferv (Handle, out buffer, out buffer_size, type, NullTerm (option_keys), NullTerm (option_values), out error)) + throw new GLib.GException (error); + + byte[] result = new byte [buffer_size]; + Marshal.Copy (buffer, result, 0, (int) buffer_size); + g_free (buffer); + return result; + } + + [DllImport("libgdk_pixbuf-2.0-0.dll")] + static extern unsafe bool gdk_pixbuf_save_to_callbackv (IntPtr raw, GdkSharp.PixbufSaveFuncNative save_func, IntPtr user_data, string type, string[] option_keys, string[] option_values, out IntPtr error); + + public unsafe void SaveToCallback (PixbufSaveFunc save_func, string type) + { + SaveToCallback (save_func, type, new string [0], new string [0]); + } + + public unsafe void SaveToCallback (PixbufSaveFunc save_func, string type, string[] option_keys, string[] option_values) + { + GdkSharp.PixbufSaveFuncWrapper save_func_wrapper = null; + save_func_wrapper = new GdkSharp.PixbufSaveFuncWrapper (save_func, this); + IntPtr error = IntPtr.Zero; + if(!gdk_pixbuf_save_to_callbackv (Handle, save_func_wrapper.NativeDelegate, IntPtr.Zero, type, NullTerm (option_keys), NullTerm (option_values), out error)) + throw new GLib.GException (error); + } +