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:
parent
d209d0b695
commit
45faa30e22
3 changed files with 41 additions and 9 deletions
|
@ -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>
|
2003-11-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
|
||||||
|
|
||||||
* gdk/Pixbuf.custom:
|
* gdk/Pixbuf.custom:
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
//
|
//
|
||||||
// This code is inserted after the automatically generated code.
|
// 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 ();
|
PixbufLoader loader = new PixbufLoader ();
|
||||||
byte [] buffer = new byte [8192];
|
byte [] buffer = new byte [8192];
|
||||||
|
@ -25,30 +28,38 @@
|
||||||
loader.Write (buffer, (uint) n);
|
loader.Write (buffer, (uint) n);
|
||||||
|
|
||||||
loader.Close ();
|
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)
|
if (assembly == null)
|
||||||
return LoadResource (System.Reflection.Assembly.GetCallingAssembly (), resource);
|
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
||||||
|
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
throw new ArgumentNullException ("resource");
|
throw new ArgumentNullException ("resource");
|
||||||
|
|
||||||
System.IO.Stream s = assembly.GetManifestResourceStream (resource);
|
System.IO.Stream s = assembly.GetManifestResourceStream (resource);
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return null;
|
throw new ArgumentException ("resource must be a valid resource name of 'assembly'.");
|
||||||
else
|
|
||||||
return LoadFromStream (s);
|
LoadFromStream (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public Pixbuf LoadResource (string resource)
|
static public Pixbuf LoadFromResource (string resource)
|
||||||
{
|
{
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
throw new ArgumentNullException ("resource");
|
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
14
gdk/PixbufLoader.custom
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue