mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-25 19:05:43 +00:00
58f6f01d45
we need to ref this object once we have a pointer to it or not. By default this is set to true -- constructors and other functions where we do own the object need to set this to false before setting the "Raw" property. Also added Unref and RefCount methods. * glue/object.c, glue/type.c: some utility functions for refcounting support * gdk/Pixbuf.custom: manually wrap a few functions so that the refcount ends up being correct at the end (need an extra Unref) * api/gdk-api.xml, sources/Gdk.metadata: metadata updates for hiding manually-wrapped Pixbuf stuff svn path=/trunk/gtk-sharp/; revision=8913
65 lines
2.3 KiB
Plaintext
65 lines
2.3 KiB
Plaintext
IntPtr LoadFromStream (System.IO.Stream input)
|
|
{
|
|
PixbufLoader loader = new PixbufLoader ();
|
|
byte [] buffer = new byte [8192];
|
|
|
|
int n;
|
|
|
|
while ((n = input.Read (buffer, 0, 8192)) != 0)
|
|
loader.Write (buffer, (uint) n);
|
|
loader.Close ();
|
|
|
|
return loader.Pixbuf.Handle;
|
|
}
|
|
|
|
public Pixbuf (System.IO.Stream input)
|
|
{
|
|
Raw = LoadFromStream (input);
|
|
}
|
|
|
|
public Pixbuf (System.Reflection.Assembly assembly, string resource)
|
|
{
|
|
if (assembly == null)
|
|
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
|
|
|
System.IO.Stream s;
|
|
Pixbuf p = null;
|
|
using (s = assembly.GetManifestResourceStream (resource))
|
|
Raw = LoadFromStream (s);
|
|
}
|
|
|
|
// scale_simple, composite_color_simple, and addalpha do a gdk_pixbuf_new on the
|
|
// return first, and we also ref it
|
|
// in the GetObject. So get rid of one extra reference.
|
|
|
|
|
|
[DllImport("gdk_pixbuf-2.0")]
|
|
static extern IntPtr gdk_pixbuf_scale_simple(IntPtr raw, int dest_width, int dest_height, int interp_type);
|
|
|
|
public Gdk.Pixbuf ScaleSimple(int dest_width, int dest_height, Gdk.InterpType interp_type) {
|
|
IntPtr raw_ret = gdk_pixbuf_scale_simple(Handle, dest_width, dest_height, (int) interp_type);
|
|
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
|
ret.Unref ();
|
|
return ret;
|
|
}
|
|
|
|
[DllImport("gdk_pixbuf-2.0")]
|
|
static extern IntPtr gdk_pixbuf_composite_color_simple(IntPtr raw, int dest_width, int dest_height, int interp_type, int overall_alpha, int check_size, uint color1, uint color2);
|
|
|
|
public Gdk.Pixbuf CompositeColorSimple(int dest_width, int dest_height, Gdk.InterpType interp_type, int overall_alpha, int check_size, uint color1, uint color2) {
|
|
IntPtr raw_ret = gdk_pixbuf_composite_color_simple(Handle, dest_width, dest_height, (int) interp_type, overall_alpha, check_size, color1, color2);
|
|
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
|
ret.Unref ();
|
|
return ret;
|
|
}
|
|
|
|
[DllImport("gdk_pixbuf-2.0")]
|
|
static extern IntPtr gdk_pixbuf_add_alpha(IntPtr raw, bool substitute_color, byte r, byte g, byte b);
|
|
|
|
public Gdk.Pixbuf AddAlpha(bool substitute_color, byte r, byte g, byte b) {
|
|
IntPtr raw_ret = gdk_pixbuf_add_alpha(Handle, substitute_color, r, g, b);
|
|
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
|
ret.Unref ();
|
|
return ret;
|
|
}
|