* gdk/PixbufLoader.custom: Implement System.IO.Stream and
resource-file constructors (using code formerly in Pixbuf.custom) * gdk/Pixbuf.custom: Redo the stream and resource ctors in terms of the PixbufLoader ones. * gdk/PixbufAnimation.custom: Add stream and resource ctors * gtk/Image.custom: Add stream and resource ctors svn path=/trunk/gtk-sharp/; revision=42463
This commit is contained in:
parent
e3a26238b6
commit
475b44e7ba
11 changed files with 353 additions and 49 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2005-03-31 Dan Winship <danw@novell.com>
|
||||
|
||||
* gdk/PixbufLoader.custom: Implement System.IO.Stream and
|
||||
resource-file constructors (using code formerly in Pixbuf.custom)
|
||||
|
||||
* gdk/Pixbuf.custom: Redo the stream and resource ctors in terms
|
||||
of the PixbufLoader ones.
|
||||
|
||||
* gdk/PixbufAnimation.custom: Add stream and resource ctors
|
||||
|
||||
* gtk/Image.custom: Add stream and resource ctors
|
||||
|
||||
2005-03-31 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* glib/ManagedValue.cs : add null/NULL guarding to Copy, Free,
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2005-04-01 Dan Winship <danw@novell.com>
|
||||
|
||||
* en/Gdk/Pixbuf.xml:
|
||||
* en/Gdk/PixbufAnimation.xml:
|
||||
* en/Gdk/PixbufLoader.xml:
|
||||
* en/Gtk/Image.xml: document new/updated stream/resource constructors
|
||||
|
||||
2005-03-15 Dan Winship <danw@novell.com>
|
||||
|
||||
* en/Gtk/NodeStore.xml (AddNode):
|
||||
|
|
|
@ -1215,10 +1215,14 @@ mcs -resource:image.jpg sample.cs
|
|||
<Parameter Name="resource" Type="System.String" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads a pixbuf from a resource string.</summary>
|
||||
<param name="resource">a <see cref="T:System.String" /></param>
|
||||
<summary>Loads a pixbuf from a resource file.</summary>
|
||||
<param name="resource">the name of the resource</param>
|
||||
<returns>a <see cref="T:Gdk.Pixbuf" /></returns>
|
||||
<remarks>TODO: Clarify.</remarks>
|
||||
<remarks>
|
||||
This loads a pixbuf from a resource in the calling assembly. This is equivalent to
|
||||
using the <see cref="C:Gdk.Pixbuf(System.Reflection.Assembly, System.String)" />
|
||||
constructor with a <see langword="null" /> assembly.
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
|
|
|
@ -245,5 +245,90 @@
|
|||
<remarks>To be added</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="LoadFromResource">
|
||||
<MemberSignature Language="C#" Value="public static Gdk.PixbufAnimation LoadFromResource (string resource);" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>Gdk.PixbufAnimation</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="resource" Type="System.String" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads a pixbuf from a resource file.</summary>
|
||||
<param name="resource">the name of the resource</param>
|
||||
<returns>a <see cref="T:Gdk.PixbufAnimation" /></returns>
|
||||
<remarks>
|
||||
This loads an animation from a resource in the calling assembly. This is equivalent to
|
||||
using the <see cref="C:Gdk.PixbufAnimation(System.Reflection.Assembly, System.String)" />
|
||||
constructor with a <see langword="null" /> assembly.
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
<MemberSignature Language="C#" Value="public PixbufAnimation (System.IO.Stream stream);" />
|
||||
<MemberType>Constructor</MemberType>
|
||||
<ReturnValue />
|
||||
<Parameters>
|
||||
<Parameter Name="stream" Type="System.IO.Stream" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Makes a new animation object from a <see cref="T:System.IO.Stream" />.</summary>
|
||||
<param name="stream">a <see cref="T:System.IO.Stream" /></param>
|
||||
<returns>a <see cref="T:Gdk.PixbufAnimation" /></returns>
|
||||
<remarks>Useful for creating an animation from an image file that resides in memory.
|
||||
|
||||
<example>
|
||||
<code lang="C#">
|
||||
/* buffer containing an image */
|
||||
System.Byte[] buffer = new System.Byte[256];
|
||||
|
||||
/* create a memory stream to the buffer */
|
||||
System.IO.MemoryStream memorystream = new System.IO.MemoryStream(buffer);
|
||||
|
||||
/* create an animation from the stream as if it was a file */
|
||||
Gdk.PixbufAnimation pba = new Gdk.PixbufAnimation(memorystream);
|
||||
</code>
|
||||
</example></remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
<MemberSignature Language="C#" Value="public PixbufAnimation (System.Reflection.Assembly assembly, string resource);" />
|
||||
<MemberType>Constructor</MemberType>
|
||||
<ReturnValue />
|
||||
<Parameters>
|
||||
<Parameter Name="assembly" Type="System.Reflection.Assembly" />
|
||||
<Parameter Name="resource" Type="System.String" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Constructor for images embedded in an assembly</summary>
|
||||
<param name="assembly">The <see cref="T:System.Reflection.Assembly" /> that contains the image.
|
||||
<para>
|
||||
If the value is <see langword="null" />, the image will be looked up on the calling assembly.</para></param>
|
||||
<param name="resource">The name given as the resource in the assembly</param>
|
||||
<returns>The <see cref="T:Gdk.PixbufAnimation" /> created from the resource stream</returns>
|
||||
<remarks>
|
||||
<para>
|
||||
This method is used to construct a <see cref="T:Gdk.PixbufAnimation" /> from an embedded resource in an assembly.
|
||||
</para>
|
||||
<para>
|
||||
Typically this is used when application developers want to distribute images in a single executable.
|
||||
</para>
|
||||
|
||||
If the assembly parameter is <see langword="null" />, the image will be looked up on the calling assembly.
|
||||
|
||||
<para>
|
||||
For example:
|
||||
</para><example>
|
||||
<code lang="C#">
|
||||
Gdk.PixbufAnimation p = new PixbufAnimation (null, "anim.gif");
|
||||
</code>
|
||||
</example><para>Compile with:</para><example>
|
||||
<code lang="Compilation">
|
||||
mcs -resource:anim.gif sample.cs
|
||||
</code>
|
||||
</example></remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
|
@ -450,5 +450,58 @@ namespace GtkDemo
|
|||
<remarks>To be added</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="LoadFromResource">
|
||||
<MemberSignature Language="C#" Value="public static Gdk.PixbufLoader LoadFromResource (string resource);" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>Gdk.PixbufLoader</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="resource" Type="System.String" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads a pixbuf from a resource file.</summary>
|
||||
<param name="resource">the name of the resource</param>
|
||||
<returns>a <see cref="T:Gdk.PixbufLoader" /></returns>
|
||||
<remarks>
|
||||
This creates a pixbuf loader to load from a resource in the calling assembly.
|
||||
This is equivalent to using the
|
||||
<see cref="C:Gdk.PixbufLoader(System.Reflection.Assembly, System.String)" />
|
||||
constructor with a <see langword="null" /> assembly.
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
<MemberSignature Language="C#" Value="public PixbufLoader (System.IO.Stream stream);" />
|
||||
<MemberType>Constructor</MemberType>
|
||||
<ReturnValue />
|
||||
<Parameters>
|
||||
<Parameter Name="stream" Type="System.IO.Stream" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads a Pixbuf from a <see cref="T:System.IO.Stream" />.</summary>
|
||||
<param name="stream">a <see cref="T:System.IO.Stream" /></param>
|
||||
<returns>a <see cref="T:Gdk.PixbufLoader" /></returns>
|
||||
<remarks>See also <see cref="C:Gdk.Pixbuf(System.IO.Stream)" /></remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
<MemberSignature Language="C#" Value="public PixbufLoader (System.Reflection.Assembly assembly, string resource);" />
|
||||
<MemberType>Constructor</MemberType>
|
||||
<ReturnValue />
|
||||
<Parameters>
|
||||
<Parameter Name="assembly" Type="System.Reflection.Assembly" />
|
||||
<Parameter Name="resource" Type="System.String" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads a Pixbuf embedded in an assembly</summary>
|
||||
<param name="assembly">The <see cref="T:System.Reflection.Assembly" /> that contains the image.
|
||||
<para>
|
||||
If the value is <see langword="null" />, the image will be looked up on the calling assembly.</para></param>
|
||||
<param name="resource">The name given as the resource in the assembly</param>
|
||||
<returns>a <see cref="T:Gdk.PixbufLoader" /> for the resource stream</returns>
|
||||
<remarks>See also <see cref="C:Gdk.Pixbuf(System.Reflection.Assembly,System.String)" /></remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
||||
</Type>
|
|
@ -445,7 +445,7 @@ masked by the given <see cref="Gdk.Pixmap" />.</summary>
|
|||
</ReturnValue>
|
||||
<Docs>
|
||||
<summary>The type of representation being used by the
|
||||
<see cref="T:Gtk.Image"/>
|
||||
<see cref="T:Gtk.Image" />
|
||||
to store image data. If the Image has no image data,
|
||||
the return value will be <see cref="P:Gtk.ImageType.Empty" />.
|
||||
</summary>
|
||||
|
@ -580,10 +580,11 @@ masked by the given <see cref="Gdk.Pixmap" />.</summary>
|
|||
<Parameter Name="mask" Type="Gdk.Pixmap" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Same functionality as <see cref="M:Gtk.Image.SetFromImage"/>.</summary>
|
||||
<summary>Same functionality as <see cref="M:Gtk.Image.SetFromImage" />.</summary>
|
||||
<param name="val">a <see cref="T:Gdk.Image" /></param>
|
||||
<param name="mask">a <see cref="T:Gdk.Pixmap" /></param>
|
||||
<remarks></remarks>
|
||||
<remarks>
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="Get">
|
||||
|
@ -598,15 +599,15 @@ masked by the given <see cref="Gdk.Pixmap" />.</summary>
|
|||
</Parameters>
|
||||
<Docs>
|
||||
<summary>
|
||||
Gets the <see cref="T:Gdk.Image"/> and mask being
|
||||
displayed by the <see cref="T:Gtk.Image"/>.
|
||||
Gets the <see cref="T:Gdk.Image" /> and mask being
|
||||
displayed by the <see cref="T:Gtk.Image" />.
|
||||
</summary>
|
||||
<param name="val">a <see cref="T:Gdk.Image" /></param>
|
||||
<param name="mask">a <see cref="T:Gdk.Pixmap" /></param>
|
||||
<remarks>
|
||||
The storage type of the image must be
|
||||
<see cref="T:Gtk.ImageType.Empty"/>.
|
||||
or <see cref="T:Gtk.ImageType.Image"/>.
|
||||
<see cref="T:Gtk.ImageType.Empty" />.
|
||||
or <see cref="T:Gtk.ImageType.Image" />.
|
||||
(see <see cref="P:Gtk.Image.StorageType" />).
|
||||
</remarks>
|
||||
</Docs>
|
||||
|
@ -683,5 +684,67 @@ masked by the given <see cref="Gdk.Pixmap" />.</summary>
|
|||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="LoadFromResource">
|
||||
<MemberSignature Language="C#" Value="public static Gtk.Image LoadFromResource (string resource);" />
|
||||
<MemberType>Method</MemberType>
|
||||
<ReturnValue>
|
||||
<ReturnType>Gtk.Image</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="resource" Type="System.String" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads an image from a resource file.</summary>
|
||||
<param name="resource">the name of the resource</param>
|
||||
<returns>a <see cref="T:Gtk.Image" /></returns>
|
||||
<remarks>
|
||||
This load an image from a resource in the calling assembly. This is
|
||||
equivalent to using the
|
||||
<see cref="C:Gtk.Image(System.Reflection.Assembly, System.String)" />
|
||||
constructor with a <see langword="null" /> assembly.
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
<MemberSignature Language="C#" Value="public Image (System.IO.Stream stream);" />
|
||||
<MemberType>Constructor</MemberType>
|
||||
<ReturnValue />
|
||||
<Parameters>
|
||||
<Parameter Name="stream" Type="System.IO.Stream" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads an image from a <see cref="T:System.IO.Stream" />.</summary>
|
||||
<param name="stream">a <see cref="T:System.IO.Stream" /></param>
|
||||
<returns>a <see cref="T:Gtk.Image" /></returns>
|
||||
<remarks>
|
||||
This is equivalent to calling <see cref="C:Gdk.Pixbuf(System.IO.Stream)" />
|
||||
or <see cref="C:Gdk.PixbufAnimation(System.IO.Stream)" /> and then creating
|
||||
an <see cref="T:Gtk.Image" /> from the resulting pixbuf.
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
<MemberSignature Language="C#" Value="public Image (System.Reflection.Assembly assembly, string resource);" />
|
||||
<MemberType>Constructor</MemberType>
|
||||
<ReturnValue />
|
||||
<Parameters>
|
||||
<Parameter Name="assembly" Type="System.Reflection.Assembly" />
|
||||
<Parameter Name="resource" Type="System.String" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Loads an image embedded in an assembly</summary>
|
||||
<param name="assembly">The <see cref="T:System.Reflection.Assembly" /> that contains the image.
|
||||
<para>
|
||||
If the value is <see langword="null" />, the image will be looked up on the calling assembly.</para></param>
|
||||
<param name="resource">The name given as the resource in the assembly</param>
|
||||
<returns>a <see cref="T:Gtk.Image" /></returns>
|
||||
<remarks>
|
||||
This is equivalent to calling
|
||||
<see cref="C:Gdk.Pixbuf(System.Reflection.Assembly,System.String)" /> or
|
||||
<see cref="C:Gdk.PixbufAnimation(System.Reflection.Assembly,System.String)" />
|
||||
and then creating an <see cref="T:Gtk.Image" /> from the resulting pixbuf.
|
||||
</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
||||
</Type>
|
|
@ -41,6 +41,7 @@ customs = \
|
|||
Keymap.custom \
|
||||
Pixmap.custom \
|
||||
Pixbuf.custom \
|
||||
PixbufAnimation.custom \
|
||||
PixbufLoader.custom \
|
||||
Pixdata.custom \
|
||||
Point.custom \
|
||||
|
|
|
@ -92,54 +92,20 @@
|
|||
gdk_pixbuf_render_to_drawable_alpha(Handle, drawable.Handle, src_x, src_y, dest_x, dest_y, width, height, (int) alpha_mode, alpha_threshold, (int) dither, x_dither, y_dither);
|
||||
}
|
||||
|
||||
[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];
|
||||
int n;
|
||||
|
||||
while ((n = input.Read (buffer, 0, 8192)) != 0)
|
||||
loader.Write (buffer, (uint) n);
|
||||
|
||||
loader.Close ();
|
||||
Raw = loader.PixbufHandle;
|
||||
if (Raw == IntPtr.Zero)
|
||||
throw new ArgumentException ("Unable to load pixbuf from stream");
|
||||
g_object_ref (Raw);
|
||||
}
|
||||
|
||||
public Pixbuf (System.IO.Stream stream) : base (IntPtr.Zero)
|
||||
{
|
||||
LoadFromStream (stream);
|
||||
}
|
||||
public Pixbuf (System.IO.Stream stream) : base (new PixbufLoader (stream).PixbufHandle) {}
|
||||
|
||||
public Pixbuf (System.Reflection.Assembly assembly, string resource) : base (IntPtr.Zero)
|
||||
{
|
||||
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 must be a valid resource name of 'assembly'.");
|
||||
|
||||
LoadFromStream (s);
|
||||
Raw = new PixbufLoader (assembly, resource).PixbufHandle;
|
||||
}
|
||||
|
||||
static public Pixbuf LoadFromResource (string resource)
|
||||
{
|
||||
if (resource == null)
|
||||
throw new ArgumentNullException ("resource");
|
||||
|
||||
return new Pixbuf (System.Reflection.Assembly.GetCallingAssembly (), resource);
|
||||
}
|
||||
|
||||
|
||||
[DllImport("libgdk_pixbuf-2.0-0.dll")]
|
||||
static extern IntPtr gdk_pixbuf_scale_simple(IntPtr raw, int dest_width, int dest_height, int interp_type);
|
||||
|
||||
|
|
33
gdk/PixbufAnimation.custom
Normal file
33
gdk/PixbufAnimation.custom
Normal file
|
@ -0,0 +1,33 @@
|
|||
// PixbufAnimation.custom - GdkPixbufAnimation class customizations
|
||||
//
|
||||
// Copyright (c) 2005 Novell, Inc.
|
||||
//
|
||||
// This code is inserted after the automatically generated code.
|
||||
//
|
||||
// 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.
|
||||
|
||||
public PixbufAnimation (System.IO.Stream stream) : base (new PixbufLoader (stream).AnimationHandle) {}
|
||||
|
||||
public PixbufAnimation (System.Reflection.Assembly assembly, string resource) : base (IntPtr.Zero)
|
||||
{
|
||||
if (assembly == null)
|
||||
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
||||
Raw = new PixbufLoader (assembly, resource).AnimationHandle;
|
||||
}
|
||||
|
||||
static public PixbufAnimation LoadFromResource (string resource)
|
||||
{
|
||||
return new PixbufAnimation (System.Reflection.Assembly.GetCallingAssembly (), resource);
|
||||
}
|
|
@ -21,9 +21,18 @@
|
|||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern IntPtr g_object_ref (IntPtr handle);
|
||||
|
||||
internal IntPtr PixbufHandle {
|
||||
get {
|
||||
return gdk_pixbuf_loader_get_pixbuf (Handle);
|
||||
return g_object_ref (gdk_pixbuf_loader_get_pixbuf (Handle));
|
||||
}
|
||||
}
|
||||
|
||||
internal IntPtr AnimationHandle {
|
||||
get {
|
||||
return g_object_ref (gdk_pixbuf_loader_get_animation (Handle));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,3 +41,40 @@
|
|||
return this.Write (bytes, (uint) bytes.Length);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -54,3 +54,37 @@
|
|||
GLib.Marshaller.Free (native);
|
||||
}
|
||||
|
||||
void LoadFromStream (System.IO.Stream stream)
|
||||
{
|
||||
try {
|
||||
Gdk.PixbufAnimation anim = new Gdk.PixbufAnimation (stream);
|
||||
if (anim.IsStaticImage)
|
||||
Pixbuf = anim.StaticImage;
|
||||
else
|
||||
PixbufAnimation = anim;
|
||||
} catch {
|
||||
Stock = Gtk.Stock.MissingImage;
|
||||
}
|
||||
}
|
||||
|
||||
public Image (System.IO.Stream stream) : this ()
|
||||
{
|
||||
LoadFromStream (stream);
|
||||
}
|
||||
|
||||
public Image (System.Reflection.Assembly assembly, string resource) : this ()
|
||||
{
|
||||
if (assembly == null)
|
||||
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
||||
|
||||
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 Image LoadFromResource (string resource)
|
||||
{
|
||||
return new Image (System.Reflection.Assembly.GetCallingAssembly (), resource);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue