diff --git a/ChangeLog b/ChangeLog index 624fab680..0b66e66d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-11-18 Mike Kestner + + * gdk/Pixbuf.custom : resurrect the stream/resource ctors. rename + LoadResource to LoadFromResource for the string overload. + * gdk/PixbufLoader.custom: add an internal prop to get an unwrapped + pixbuf handle. + 2003-11-17 Gonzalo Paniagua Javier * gdk/Pixbuf.custom: diff --git a/gdk/Pixbuf.custom b/gdk/Pixbuf.custom index 39c5805fd..f6b65aee3 100644 --- a/gdk/Pixbuf.custom +++ b/gdk/Pixbuf.custom @@ -15,7 +15,10 @@ // // This code is inserted after the automatically generated code. - static private Pixbuf LoadFromStream (System.IO.Stream input) + [DllImport("libgobject-2.0-0.dll")] + static extern void g_object_ref (IntPtr handle); + + private void LoadFromStream (System.IO.Stream input) { PixbufLoader loader = new PixbufLoader (); byte [] buffer = new byte [8192]; @@ -25,30 +28,38 @@ loader.Write (buffer, (uint) n); loader.Close (); - return loader.Pixbuf; + Raw = loader.PixbufHandle; + if (Raw == IntPtr.Zero) + throw new ArgumentException ("Unable to load pixbuf from stream"); + g_object_ref (Raw); } - static public Pixbuf LoadResource (System.Reflection.Assembly assembly, string resource) + public Pixbuf (System.IO.Stream stream) + { + LoadFromStream (stream); + } + + public Pixbuf (System.Reflection.Assembly assembly, string resource) { if (assembly == null) - return LoadResource (System.Reflection.Assembly.GetCallingAssembly (), resource); + assembly = System.Reflection.Assembly.GetCallingAssembly (); if (resource == null) throw new ArgumentNullException ("resource"); System.IO.Stream s = assembly.GetManifestResourceStream (resource); if (s == null) - return null; - else - return LoadFromStream (s); + throw new ArgumentException ("resource must be a valid resource name of 'assembly'."); + + LoadFromStream (s); } - static public Pixbuf LoadResource (string resource) + static public Pixbuf LoadFromResource (string resource) { if (resource == null) throw new ArgumentNullException ("resource"); - return LoadResource (System.Reflection.Assembly.GetCallingAssembly (), resource); + return new Pixbuf (System.Reflection.Assembly.GetCallingAssembly (), resource); } diff --git a/gdk/PixbufLoader.custom b/gdk/PixbufLoader.custom new file mode 100644 index 000000000..aac3aec92 --- /dev/null +++ b/gdk/PixbufLoader.custom @@ -0,0 +1,14 @@ +// PixbufLoader.custom - Gdk PixbufLoader class customizations +// +// Authors: +// Mike Kestner +// +// (C) 2003 Novell, Inc. +// +// This code is inserted after the automatically generated code. + + internal IntPtr PixbufHandle { + get { + return gdk_pixbuf_loader_get_pixbuf (Handle); + } + }