diff --git a/ChangeLog b/ChangeLog index 27b5aaee6..b196c2768 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-05-04 Jose Faria + + * gdk/Pixbuf.custom : new width/height ctor overloads. + * gdk/PixbufLoader.custom : new width/height ctor overloads. + 2005-05-04 Mike Kestner * autogen.sh : error out with bootstrap help message. diff --git a/doc/en/Gdk/Pixbuf.xml b/doc/en/Gdk/Pixbuf.xml index 31e67e170..b020d0fb0 100644 --- a/doc/en/Gdk/Pixbuf.xml +++ b/doc/en/Gdk/Pixbuf.xml @@ -1200,6 +1200,48 @@ Gdk.Pixbuf p = new Pixbuf (null, "image.jpg"); Compile with: +mcs -resource:image.jpg sample.cs + + + + + + + Constructor + + + + + + + + + Constructor for images embedded in an assembly when a specific size is required. + The that contains the image. + +If the value is , the image will be looked up on the calling assembly. + The name given as the resource in the assembly + The required width for the pixbuf + The required height for the pixbuf + The created from the resource stream + + + This method is used to construct a from an embedded resource in an assembly with a specific size. + + + Typically this is used when application developers want to distribute images in a single executable. + + +If the assembly parameter is , the image will be looked up on the calling assembly. + + +For example: + + +Gdk.Pixbuf p = new Pixbuf (null, "image.jpg", 10, 10); + + Compile with: + mcs -resource:image.jpg sample.cs @@ -1234,9 +1276,9 @@ mcs -resource:image.jpg sample.cs Makes a new Pixbuf object from a . - a + a containing the image a - Useful for creating a Pixbuf from an image file that resides in memory. + Useful for creating a Pixbuf from an image file that resides in a stream. @@ -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); + + + + + + + Constructor + + + + + + + + Makes a new Pixbuf object from a with a given size. + a containing the image + a specifying the required width + a specifying the required height + a + Useful for creating a Pixbuf with a specific size from an image file that resides in a stream. + + + +/* 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); + + + + + + + Constructor + + + + + + Makes a new Pixbuf object from a . + a containing the image + a + Useful for creating a Pixbuf from an image file in memory. + + + +/* 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); + + + + + + + Constructor + + + + + + + + Makes a new Pixbuf object from a with a given size. + a containing the image + a specifying the required width + a specifying the required height + a + Useful for creating a Pixbuf with a specific size from an image file in memory. + + + +/* 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); @@ -1699,4 +1824,4 @@ Gdk.Pixbuf pb = new Gdk.Pixbuf(memorystream); - \ No newline at end of file + diff --git a/doc/en/Gdk/PixbufLoader.xml b/doc/en/Gdk/PixbufLoader.xml index 56f3df919..d0c41cf07 100644 --- a/doc/en/Gdk/PixbufLoader.xml +++ b/doc/en/Gdk/PixbufLoader.xml @@ -480,11 +480,29 @@ namespace GtkDemo Loads a Pixbuf from a . - a + a containing the image. a See also + + + Constructor + + + + + + + + Loads a Pixbuf from a , creating it with a specific size. + a containing the image. + a specifying the required width. + a specifying the required height. + a + See also + + Constructor @@ -494,14 +512,118 @@ namespace GtkDemo - Loads a Pixbuf embedded in an assembly + Loads a Pixbuf embedded in an assembly. The that contains the image. If the value is , the image will be looked up on the calling assembly. - The name given as the resource in the assembly + The name given as the resource in the assembly. a for the resource stream See also + + + Constructor + + + + + + + + + Loads a Pixbuf embedded in an assembly with a specific size. + The that contains the image. + +If the value is , the image will be looked up on the calling assembly. + The name given as the resource in the assembly. + The required width of the pixbuf. + The required height of the pixbuf. + a for the resource stream + See also + + + + + Constructor + + + + + + Loads a Pixbuf in a buffer. + The containing the image. + a for the buffer. + See also + + + + + Constructor + + + + + + + + Loads a Pixbuf in a buffer with a specific size. + The containing the image. + The required width of the pixbuf. + The required height of the pixbuf. + a for the buffer. + See also + + + + + Constructor + + + + + + + + To be added + a + a + a + a + To be added + + + + + Constructor + + + + + + To be added + a + a + To be added + + + + + Constructor + + + + + + + + To be added + a + a + a + a + To be added + + - \ No newline at end of file + diff --git a/doc/en/Gtk.DotNet/Graphics.xml b/doc/en/Gtk.DotNet/Graphics.xml index c994ec10d..c7cf8b686 100644 --- a/doc/en/Gtk.DotNet/Graphics.xml +++ b/doc/en/Gtk.DotNet/Graphics.xml @@ -65,5 +65,23 @@ class PrettyGraphic : DrawingArea { + + + Method + + System.Drawing.Graphics + + + + + + + To be added + a + a + a + To be added + + \ No newline at end of file diff --git a/gdk/Pixbuf.custom b/gdk/Pixbuf.custom index 79dc3bb20..818967475 100644 --- a/gdk/Pixbuf.custom +++ b/gdk/Pixbuf.custom @@ -6,7 +6,8 @@ // Mike Kestner // Duncan Mak // Gonzalo Paniagua Javier -// Martin Willemoes Hansen +// Martin Willemoes Hansen +// Jose Faria // // 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) { diff --git a/gdk/PixbufLoader.custom b/gdk/PixbufLoader.custom index 4e60246a8..e9819d7ff 100644 --- a/gdk/PixbufLoader.custom +++ b/gdk/PixbufLoader.custom @@ -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) {