2003-11-18 Mike Kestner <mkestner@ximian.com>

* 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.

svn path=/trunk/gtk-sharp/; revision=20183
This commit is contained in:
Mike Kestner 2003-11-18 19:10:36 +00:00
parent d209d0b695
commit 45faa30e22
3 changed files with 41 additions and 9 deletions

View file

@ -1,3 +1,10 @@
2003-11-18 Mike Kestner <mkestner@ximian.com>
* 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 <gonzalo@ximian.com>
* gdk/Pixbuf.custom:

View file

@ -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);
}

14
gdk/PixbufLoader.custom Normal file
View file

@ -0,0 +1,14 @@
// PixbufLoader.custom - Gdk PixbufLoader class customizations
//
// Authors:
// Mike Kestner <mkestner@ximian.com>
//
// (C) 2003 Novell, Inc.
//
// This code is inserted after the automatically generated code.
internal IntPtr PixbufHandle {
get {
return gdk_pixbuf_loader_get_pixbuf (Handle);
}
}