2003-11-18 19:10:36 +00:00
|
|
|
// PixbufLoader.custom - Gdk PixbufLoader class customizations
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Mike Kestner <mkestner@ximian.com>
|
|
|
|
//
|
2004-06-25 18:42:19 +00:00
|
|
|
// Copyright (c) 2003 Novell, Inc.
|
2003-11-18 19:10:36 +00:00
|
|
|
//
|
|
|
|
// This code is inserted after the automatically generated code.
|
2004-06-25 18:42:19 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the Lesser GNU General
|
|
|
|
// Public License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
2003-11-18 19:10:36 +00:00
|
|
|
|
2005-04-01 14:54:12 +00:00
|
|
|
[DllImport("libgobject-2.0-0.dll")]
|
|
|
|
static extern IntPtr g_object_ref (IntPtr handle);
|
|
|
|
|
2003-11-18 19:10:36 +00:00
|
|
|
internal IntPtr PixbufHandle {
|
|
|
|
get {
|
2005-04-01 14:54:12 +00:00
|
|
|
return g_object_ref (gdk_pixbuf_loader_get_pixbuf (Handle));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
internal IntPtr AnimationHandle {
|
|
|
|
get {
|
|
|
|
return g_object_ref (gdk_pixbuf_loader_get_animation (Handle));
|
2003-11-18 19:10:36 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-24 23:08:56 +00:00
|
|
|
|
|
|
|
public bool Write (byte[] bytes)
|
|
|
|
{
|
|
|
|
return this.Write (bytes, (uint) bytes.Length);
|
|
|
|
}
|
|
|
|
|
2005-04-01 14:54:12 +00:00
|
|
|
private void LoadFromStream (System.IO.Stream input)
|
|
|
|
{
|
|
|
|
byte [] buffer = new byte [8192];
|
|
|
|
int n;
|
|
|
|
|
|
|
|
while ((n = input.Read (buffer, 0, 8192)) != 0)
|
|
|
|
Write (buffer, (uint) n);
|
|
|
|
Close ();
|
|
|
|
}
|
|
|
|
|
|
|
|
public PixbufLoader (System.IO.Stream stream) : this ()
|
|
|
|
{
|
|
|
|
LoadFromStream (stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
public PixbufLoader (System.Reflection.Assembly assembly, string resource) : this ()
|
|
|
|
{
|
|
|
|
if (assembly == null)
|
|
|
|
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
|
|
|
|
|
|
|
if (resource == null)
|
|
|
|
throw new ArgumentNullException ("resource");
|
|
|
|
|
|
|
|
System.IO.Stream s = assembly.GetManifestResourceStream (resource);
|
|
|
|
if (s == null)
|
|
|
|
throw new ArgumentException ("'" + resource + "' is not a valid resource name of assembly '" + assembly + "'.");
|
|
|
|
|
|
|
|
LoadFromStream (s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static public PixbufLoader LoadFromResource (string resource)
|
|
|
|
{
|
|
|
|
if (resource == null)
|
|
|
|
throw new ArgumentNullException ("resource");
|
|
|
|
|
|
|
|
return new PixbufLoader (System.Reflection.Assembly.GetCallingAssembly (), resource);
|
|
|
|
}
|