2005-05-04 Jose Faria <spigaz@gmail.com>

* gdk/Pixbuf.custom : new width/height ctor overloads.
	* gdk/PixbufLoader.custom : new width/height ctor overloads.

svn path=/trunk/gtk-sharp/; revision=44131
This commit is contained in:
Mike Kestner 2005-05-06 14:24:44 +00:00
parent 642980e0bb
commit 080c68ac6a
6 changed files with 354 additions and 12 deletions

View file

@ -1,3 +1,8 @@
2005-05-04 Jose Faria <spigaz@gmail.com>
* gdk/Pixbuf.custom : new width/height ctor overloads.
* gdk/PixbufLoader.custom : new width/height ctor overloads.
2005-05-04 Mike Kestner <mkestner@novell.com>
* autogen.sh : error out with bootstrap help message.

View file

@ -1200,6 +1200,48 @@ Gdk.Pixbuf p = new Pixbuf (null, "image.jpg");
</code>
</example><para>Compile with:</para><example>
<code lang="Compilation">
mcs -resource:image.jpg sample.cs
</code>
</example></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Pixbuf (System.Reflection.Assembly assembly, string resource, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="assembly" Type="System.Reflection.Assembly" />
<Parameter Name="resource" Type="System.String" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>Constructor for images embedded in an assembly when a specific size is required.</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>
<param name="width">The required width for the pixbuf</param>
<param name="height">The required height for the pixbuf</param>
<returns>The <see cref="T:Gdk.Pixbuf" /> created from the resource stream</returns>
<remarks>
<para>
This method is used to construct a <see cref="T:Gdk.Pixbuf" /> from an embedded resource in an assembly with a specific size.
</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.Pixbuf p = new Pixbuf (null, "image.jpg", 10, 10);
</code>
</example><para>Compile with:</para><example>
<code lang="Compilation">
mcs -resource:image.jpg sample.cs
</code>
</example></remarks>
@ -1234,9 +1276,9 @@ mcs -resource:image.jpg sample.cs
</Parameters>
<Docs>
<summary>Makes a new Pixbuf object from a <see cref="T:System.IO.Stream" />.</summary>
<param name="stream">a <see cref="T:System.IO.Stream" /></param>
<param name="stream">a <see cref="T:System.IO.Stream" /> containing the image</param>
<returns>a <see cref="T:Gdk.Pixbuf" /></returns>
<remarks>Useful for creating a Pixbuf from an image file that resides in memory.
<remarks>Useful for creating a Pixbuf from an image file that resides in a stream.
<example>
<code lang="C#">
@ -1248,6 +1290,89 @@ System.IO.MemoryStream memorystream = new System.IO.MemoryStream(buffer);
/* create a pixbuf from the stream as if it was a file */
Gdk.Pixbuf pb = new Gdk.Pixbuf(memorystream);
</code>
</example></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Pixbuf (System.IO.Stream stream, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="stream" Type="System.IO.Stream" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>Makes a new Pixbuf object from a <see cref="T:System.IO.Stream" /> with a given size.</summary>
<param name="stream">a <see cref="T:System.IO.Stream" /> containing the image</param>
<param name="width"> a <see cref="T:System.Int32" /> specifying the required width</param>
<param name="height"> a <see cref="T:System.Int32" /> specifying the required height</param>
<returns>a <see cref="T:Gdk.Pixbuf" /></returns>
<remarks>Useful for creating a Pixbuf with a specific size from an image file that resides in a stream.
<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 a pixbuf from the stream as if it was a file */
Gdk.Pixbuf pb = new Gdk.Pixbuf(memorystream, 10, 10);
</code>
</example></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Pixbuf (byte [] buffer);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="buffer" Type="System.Byte[]" />
</Parameters>
<Docs>
<summary>Makes a new Pixbuf object from a <see cref="T:System.Byte[]" />.</summary>
<param name="buffer">a <see cref="T:System.Byte[]" /> containing the image</param>
<returns>a <see cref="T:Gdk.Pixbuf" /></returns>
<remarks>Useful for creating a Pixbuf from an image file in memory.
<example>
<code lang="C#">
/* buffer containing an image */
System.Byte[] buffer = new System.Byte[256];
/* create a pixbuf from the buffer as if it was a file */
Gdk.Pixbuf pb = new Gdk.Pixbuf(buffer);
</code>
</example></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Pixbuf (byte [] buffer, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="buffer" Type="System.Byte[]" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>Makes a new Pixbuf object from a <see cref="T:System.Byte[]" /> with a given size.</summary>
<param name="buffer">a <see cref="T:System.Byte[]" /> containing the image</param>
<param name="width"> a <see cref="T:System.Int32" /> specifying the required width</param>
<param name="height"> a <see cref="T:System.Int32" /> specifying the required height</param>
<returns>a <see cref="T:Gdk.Pixbuf" /></returns>
<remarks>Useful for creating a Pixbuf with a specific size from an image file in memory.
<example>
<code lang="C#">
/* buffer containing an image */
System.Byte[] buffer = new System.Byte[256];
/* create a pixbuf from the buffer as if it was a file */
Gdk.Pixbuf pb = new Gdk.Pixbuf(buffer, 10, 10);
</code>
</example></remarks>
</Docs>
@ -1699,4 +1824,4 @@ Gdk.Pixbuf pb = new Gdk.Pixbuf(memorystream);
</Docs>
</Member>
</Members>
</Type>
</Type>

View file

@ -480,11 +480,29 @@ namespace GtkDemo
</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>
<param name="stream">a <see cref="T:System.IO.Stream" /> containing the image.</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.IO.Stream stream, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="stream" Type="System.IO.Stream" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>Loads a Pixbuf from a <see cref="T:System.IO.Stream" />, creating it with a specific size.</summary>
<param name="stream">a <see cref="T:System.IO.Stream" /> containing the image.</param>
<param name="width">a <see cref="T:System.Int32" /> specifying the required width.</param>
<param name="height">a <see cref="T:System.Int32" /> specifying the required height.</param>
<returns>a <see cref="T:Gdk.PixbufLoader" /></returns>
<remarks>See also <see cref="C:Gdk.Pixbuf(System.IO.Stream, int, int)" /></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public PixbufLoader (System.Reflection.Assembly assembly, string resource);" />
<MemberType>Constructor</MemberType>
@ -494,14 +512,118 @@ namespace GtkDemo
<Parameter Name="resource" Type="System.String" />
</Parameters>
<Docs>
<summary>Loads a Pixbuf embedded in an assembly</summary>
<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>
<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>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public PixbufLoader (System.Reflection.Assembly assembly, string resource, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="assembly" Type="System.Reflection.Assembly" />
<Parameter Name="resource" Type="System.String" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>Loads a Pixbuf embedded in an assembly with a specific size.</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>
<param name="width">The required width of the pixbuf.</param>
<param name="height">The required height of the pixbuf.</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, int, int)" /></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public PixbufLoader (byte [] buffer);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="buffer" Type="System.Byte[]" />
</Parameters>
<Docs>
<summary>Loads a Pixbuf in a buffer.</summary>
<param name="buffer">The <see cref="T:System.Byte[]" /> containing the image.</param>
<returns>a <see cref="T:Gdk.PixbufLoader" /> for the buffer.</returns>
<remarks>See also <see cref="C:Gdk.Pixbuf(System.Byte[])" /></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public PixbufLoader (byte [] buffer, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="buffer" Type="System.Byte[]" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>Loads a Pixbuf in a buffer with a specific size.</summary>
<param name="buffer">The <see cref="T:System.Byte[]" /> containing the image.</param>
<param name="width">The required width of the pixbuf.</param>
<param name="height">The required height of the pixbuf.</param>
<returns>a <see cref="T:Gdk.PixbufLoader" /> for the buffer.</returns>
<remarks>See also <see cref="C:Gdk.Pixbuf(System.Byte[], int, int)" /></remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public PixbufLoader (string file, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="file" Type="System.String" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="file">a <see cref="T:System.String" /></param>
<param name="width">a <see cref="T:System.Int32" /></param>
<param name="height">a <see cref="T:System.Int32" /></param>
<returns>a <see cref="T:Gdk.PixbufLoader" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public PixbufLoader (byte [] buffer);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="buffer" Type="System.Byte[]" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="buffer">a <see cref="T:System.Byte" /></param>
<returns>a <see cref="T:Gdk.PixbufLoader" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public PixbufLoader (byte [] buffer, int width, int height);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="buffer" Type="System.Byte[]" />
<Parameter Name="width" Type="System.Int32" />
<Parameter Name="height" Type="System.Int32" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="buffer">a <see cref="T:System.Byte" /></param>
<param name="width">a <see cref="T:System.Int32" /></param>
<param name="height">a <see cref="T:System.Int32" /></param>
<returns>a <see cref="T:Gdk.PixbufLoader" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
</Members>
</Type>
</Type>

View file

@ -65,5 +65,23 @@ class PrettyGraphic : DrawingArea {
</example></remarks>
</Docs>
</Member>
<Member MemberName="FromDrawable">
<MemberSignature Language="C#" Value="public static System.Drawing.Graphics FromDrawable (Gdk.Drawable drawable, bool double_buffered);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Drawing.Graphics</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="drawable" Type="Gdk.Drawable" />
<Parameter Name="double_buffered" Type="System.Boolean" />
</Parameters>
<Docs>
<summary>To be added</summary>
<param name="drawable">a <see cref="T:Gdk.Drawable" /></param>
<param name="double_buffered">a <see cref="T:System.Boolean" /></param>
<returns>a <see cref="T:System.Drawing.Graphics" /></returns>
<remarks>To be added</remarks>
</Docs>
</Member>
</Members>
</Type>

View file

@ -6,7 +6,8 @@
// Mike Kestner <mkestner@ximian.com>
// Duncan Mak <duncan@ximian.com>
// Gonzalo Paniagua Javier <gonzalo@ximian.com>
// Martin Willemoes Hansen <mwh@sysrq.dk>
// Martin Willemoes Hansen <mwh@sysrq.dk>
// Jose Faria <spigaz@gmail.com>
//
// Copyright (c) 2002 Vladimir Vukicevic
// Copyright (c) 2003 Ximian, Inc. (Miguel de Icaza)
@ -101,13 +102,31 @@
}
public Pixbuf (System.IO.Stream stream) : base (new PixbufLoader (stream).PixbufHandle) {}
public Pixbuf (System.IO.Stream stream, int width, int height) : base(new PixbufLoader (stream, width, height).PixbufHandle) {}
public Pixbuf (System.Reflection.Assembly assembly, string resource) : base (IntPtr.Zero)
{
if (assembly == null)
assembly = System.Reflection.Assembly.GetCallingAssembly ();
Raw = new PixbufLoader (assembly, resource).PixbufHandle;
Raw = new PixbufLoader (CheckAssembly(assembly), resource).PixbufHandle;
}
private System.Reflection.Assembly CheckAssembly(System.Reflection.Assembly assembly)
{
if (assembly == null)
return System.Reflection.Assembly.GetCallingAssembly ();
else
return assembly;
}
public Pixbuf (System.Reflection.Assembly assembly, string resource, int width, int height) : base (IntPtr.Zero)
{
Raw = new PixbufLoader (CheckAssembly(assembly), resource, width, height).PixbufHandle;
}
public Pixbuf (byte[] buffer) : base(new PixbufLoader (buffer).PixbufHandle) {}
public Pixbuf (byte[] buffer, int width, int height) : base(new PixbufLoader (buffer, width, height).PixbufHandle) {}
static public Pixbuf LoadFromResource (string resource)
{

View file

@ -50,7 +50,22 @@
Write (buffer, (uint) n);
}
public PixbufLoader (string file, int width, int height) : this ()
{
SetSize(width, height);
using(System.IO.FileStream stream = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
InitFromStream(stream);
}
}
public PixbufLoader (System.IO.Stream stream) : this ()
{
InitFromStream(stream);
}
private void InitFromStream (System.IO.Stream stream)
{
try {
LoadFromStream (stream);
@ -58,8 +73,19 @@
Close ();
}
}
public PixbufLoader (System.IO.Stream stream, int width, int height) : this()
{
SetSize(width, height);
InitFromStream(stream);
}
public PixbufLoader (System.Reflection.Assembly assembly, string resource) : this ()
{
InitFromAssemblyResource(assembly, resource);
}
private void InitFromAssemblyResource(System.Reflection.Assembly assembly, string resource)
{
try {
if (assembly == null)
@ -77,6 +103,33 @@
Close ();
}
}
public PixbufLoader (System.Reflection.Assembly assembly, string resource, int width, int height) : this ()
{
SetSize(width, height);
InitFromAssemblyResource(assembly, resource);
}
public PixbufLoader (byte[] buffer) : this()
{
InitFromBuffer(buffer);
}
private void InitFromBuffer (byte[] buffer)
{
try {
Write (buffer, (uint)buffer.Length);
} finally {
Close ();
}
}
public PixbufLoader (byte[] buffer, int width, int height) : this()
{
SetSize(width, height);
InitFromBuffer(buffer);
}
static public PixbufLoader LoadFromResource (string resource)
{