gdk-sharpGtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details.GLib.ObjectGLib.IIconIn memory image handling and representation.
The class is used to represent an image in
memory, typically on the client side (this is different from that represents a server-side image). The in-memory representation uses either a three
byte RGB representation or a four byte RGBA representation.
Pixbufs can be created from a number of sources: image files
in an assorted set of file formats (png, tiff, jpg, gif, xpm,
pcx, ico, xpm, xbm); Drawables (which can be windows on the X
server, or off-screen images in the X server) or in-memory
images.
A pixbuf can be rendered, scaled or composited into another
pixbuf, into a window on the X server, or on a drawable in the
X server. Various rendering methods are provided for this
purpose.
Pixbufs can also be saved to a number of different file
formats.
An example that composites two images next to each other.
// Compile with: mcs -pkg:gtk-sharp PixmapComposite.cs
// Usage: PixmapComposite.exe image-1.jpg image-2.jpg composite.jpg
using Gdk;
using System;
public class PixmapComposite
{
public static void Main (string [] args)
{
// Check arguments, this takes three.
if (args.Length < 3)
throw new Exception ("USAGE: image1Filename image2Filename "
+ "compositeFilename");
// Figure out the output type
string type = "jpeg";
if (args [2].ToLower ().EndsWith (".jpg"))
type = "jpeg";
else if (args [2].ToLower ().EndsWith (".png"))
type = "png";
else
throw new Exception ("Only JPG and PNG images are supported for "
+ "the composite image");
// Init the system
Gdk.Global.InitCheck(ref args);
// Load the images
Pixbuf image1 = new Pixbuf (args [0]);
Pixbuf image2 = new Pixbuf (args [1]);
// Create the composite image
Colorspace colorspace = image1.Colorspace;
bool hasAlpha = image1.HasAlpha;
int bitsPerSample = image1.BitsPerSample;
Pixbuf composite = new Pixbuf (colorspace,
hasAlpha,
bitsPerSample,
image1.Width + image2.Width,
image1.Height);
// Composite the images on the central one
image1.Composite (composite,
0, 0, image1.Width, image1.Height,
0.0, 0.0, 1.0, 1.0,
InterpType.Hyper,
255);
image2.Composite (composite,
image1.Width, 0, image2.Width, image2.Height,
image1.Width, 0.0, 1.0, 1.0,
InterpType.Hyper,
255);
// Write out the image as a JPG
composite.Save (args [2], type);
}
}
Constructor
a containing the image in one of the formats recognized by Pixbuf (png, tiff, jpeg, etc).
Makes a new Pixbuf object from a containing an encoded image.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
Pointer to the C object.
Internal constructorThis is an internal constructor, and should not be used by user code.Constructor
a containing the image
Makes a new Pixbuf object from a .Useful for creating a Pixbuf 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);
Constructor
Filename with the image
Creates Pixbuf from image file.
Creates a new pixbuf by loading an image from a file. The
file format is detected automatically (multiple formats are
supported: JPG, PNG, TIFF, XPM, XBM). If the file is not
found, a will be thrown.
Constructor
a Public constructor.Constructor
To be added.
To be added.
To be added.To be added.Constructor
To be added.
To be added.
Constructor for pixbufs that that have embedded images created with the gdk-pixbuf-source program.This is used to create pixbufs from images that have been embedded using the gdk-pixbuf-csource command line tool. Constructor
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
Constructor for images embedded in an assembly
This method is used to construct a from an embedded resource in an assembly.
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");
Compile with:
mcs -resource:image.jpg sample.cs
Constructor
a containing the image
a specifying the required width
a specifying the required height
Makes a new Pixbuf object from a with a given size.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);
Constructor
The length in bytes of the data to be read.
A serialized structure, generated with .
If true, the "data" parameter will be copied and the copy will be used for the Pixbuf. If false, the data will be used as is and the Pixbuf will be dependent on it.
Construct a pixbuf from a serialized structureNoneConstructor
The length in bytes of the data to be read.
The raw data representing the serialized structure.
If true, the "data" parameter will be copied and the copy will be used for the Pixbuf. If false, the data will be used as is and the Pixbuf will be dependent on it.
Construct a pixbuf from a serialized structure.NoneConstructor
a containing the image
a specifying the required width
a specifying the required height
Makes a new Pixbuf object from a with a given size.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
a
a
a To be addedTo be addedConstructor
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
Constructor for images embedded in an assembly when a specific size is required.
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
Constructor
a
a
a
a To be addedTo be addedConstructor
The colorspace ()
Whether the image should have transparency information.
Number of bits per color sample.
Width of image in pixels.
Height of image in pixels.
Constructor
Creates a new structure and allocates a buffer
for it. The buffer has an optimal rowstride. Note that the
buffer is not cleared; you will have to fill it completely
yourself.
Constructor
The containing .
X coord in src_pixbuf
Y coord in src_pixbuf
Width of region in src_pixbuf
Height of region in src_pixbuf
Creates a sub-Pixbuf from an existing one.
Creates a new pixbuf which represents a sub-region of
. The new pixbuf shares its
pixels with the original pixbuf, so writing to one affects
both. The new pixbuf holds a reference to , so will
not be finalized until the new pixbuf is finalized.
Constructor
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.To be added.Constructor
The data that contains the image in RGB or RGBA format.
Whether the data contains an alpha channel (RGBA format).
Currently only 8 is supported (1 byte per channel).
Width of the image in pixels.
Height of the image in pixels.
The rowstride is the number of bytes consumed by a single row in the image.
Public constructor.The image must be in RGB format or RGBA format, where each channel takes one byte.Constructor
The data that contains the image in RGB or RGBA format.
The for the image data.
Whether the data contains an alpha channel (RGBA format).
Currently only 8 is supported (1 byte per channel).
Width of the image in pixels.
Height of the image in pixels.
The rowstride is the number of bytes consumed by a single row in the image.
Public constructor.The image must be in RGB format or RGBA format, where each channel takes one byte.Constructor
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.To be added.Constructor
The data that contains the image in RGB or RGBA format.
The for the image data.
Whether the data contains an alpha channel (RGBA format).
Currently only 8 is supported (1 byte per channel).
Width of the image in pixels.
Height of the image in pixels.
The rowstride is the number of bytes consumed by a single row in the image.
A routine to invoke when the reference count to this image reaches zero.
Public constructor; creates a new from an in-memory RGB or RGBA buffer.The image must be in RGB format or RGBA format, where each channel takes one byte.
For performance reasons sometimes images have some padding at the end of each row, this is done to ensure that access to the data is aligned. The argument is the size in bytes of each row. If no padding is added the is just: * (3 + ).
MethodGdk.Pixbuf
Whether to set a color to zero
opacity. If this is , then the (r, g, b) arguments will be ignored.
Red value to substitute
Green value to substitute
Blue value to substitute
Adds an alpha channel to the PixbufA new pixbuf with an alpha channel.
Takes an existing pixbuf and adds an alpha channel to
it. If the existing pixbuf already had an alpha channel,
the channel values are copied from the original;
otherwise, the alpha channel is initialized to 255 (full
opacity).
If is , then the color specified by (, , )
will be assigned zero opacity. That is, if you pass (255,
255, 255) for the substitute color, all white pixels will
become fully transparent.
The original image is not modified, a copy of the image is
made and returned.
MethodGdk.PixbufApplies an embedded orientation transform.Returns a new pixbuf, or the existing one if no transform exists.PropertyGLib.Property("bits-per-sample")System.Int32Number of bits per color sample in a pixbuf.The number of bits per color sample in the pixbufNone.MethodSystem.ObjectTo be added.To be added.To be added.PropertyGLib.Property("colorspace")Gdk.ColorspaceThe colorspace for this PixbufThe colorspace used by this Pixbuf
Currently Pixbuf only support the RGB colorspace.
MethodSystem.Void
The destination Pixbuf to render to.
The left coordinate for region to render
The top coordinate for region to render
The width of the region to render
The height of the region to render
The offset in the X direction (currently rounded to an integer)
The offset in the Y direction (currently rounded to an integer)
The scale factor in the X direction
The scale factor in the Y direction
The interpolation type for the transformation.
Overall alpha for source image (0..255)
Scale and Compose a Pixbuf
Creates a transformation of the Pixbuf by scaling by
and
then translating by and
, then composites the rectangle
(, ,
, ) of the resulting image onto the
destination image.
MethodSystem.Void
The destination Pixbuf to render to.
The left coordinate for region to render
The top coordinate for region to render
The width of the region to render
The height of the region to render
The offset in the X direction (currently rounded to an integer)
The offset in the Y direction (currently rounded to an integer)
The scale factor in the X direction
The scale factor in the Y direction
The interpolation type for the transformation.
Overall alpha for source image (0..255)
The X offset for the checkboard (origin of checkboard is at -check_x, -check_y)
The Y offset for the checkboard
The size of checks in the checkboard (must be a power of two)
The color of check at upper left
The color of the other check
Scale and Compose a Pixbuf with control over the checks
Creates a transformation of the Pixbuf by scaling by
and
then translating by and
, then composites the rectangle
( ,,
, ) of the resulting image with a
checkboard of the colors and
and renders it onto the
destination image.
The and encode the color in 32-bit RGB format.
MethodGdk.Pixbuf
The width of destination image
The height of destination image
The interpolation type for the transformation.
Overall alpha for source image (0..255)
The size of checks in the checkboard (must be a power of two)
The color of check at upper left
The color of the other check
Scaling with checkboard rendering
The new Pixbuf, or if not enough
memory could be allocated for it.
Creates a new Pixbuf by scaling to
x
and compositing the result with a checkboard
of colors and .
The colors must be in RGB format.
MethodGdk.PixbufCopies the Pixbuf
A copy of the data in the Pixbuf, or on failure
MethodSystem.Void
Source X coordinate within src_pixbuf.
Source Y coordinate within src_pixbuf
Width of the area to copy.
Height of the area to copy.
Destination Pixbuf.
X coordinate within dest_pixbuf.
Y coordinate within dest_pixbuf.
Copies a region from one Pixbuf to another
Copies a rectangular area from src_pixbuf to
dest_pixbuf. Conversion of pixbuf formats is done
automatically.
MethodSystem.Boolean
To be added.
To be added.To be added.To be added.MethodSystem.Int32To be addeda MethodSystem.Void
RGBA value for the pixel to set (0xffffffff is opaque white, 0x00000000 transparent black)
Fills a pixbuf with a single color
Clears a pixbuf to the given RGBA value, converting the
RGBA value into the pixbuf's pixel format. The alpha will
be ignored if the Pixbuf does not have an alpha channel.
MethodGdk.Pixbuf to flip horizontally, to flip vertically.
Flips a pixbuf horizontally or vertically.A .PropertyGdk.PixbufFormat[]To be addeda MethodGdk.Pixbuf
Source Gdk.Pixdata
Whether to make a private copy of the data
Creates a Pixbuf from a Pixdata
The return value is an initialized Pixbuf class
This creates a Pixbuf from a class that implements the
Gdk.Pixdata interface.
MethodGdk.PixbufFormat
a
a
a To be addeda To be addedMethodSystem.String
the key to lookup
Looks up an option in the PixbufThe value associated with the
Looks up key in the list of options that may have been
attached to the pixbuf when it was loaded.
PropertyGLib.GTypeGType Property.a Returns the native value for .PropertyGLib.Property("has-alpha")System.BooleanReturns whether the Pixbuf contains an alpha channel if the image contains an Alpha
channel, otherwise.
The Pixbuf object handles images in either the RGB format,
or the RGBA format. The alpha channel value is a value
between 0 and 255 and controls the opacity of a given pixel.
PropertyGLib.Property("height")System.Int32Height of the imageThe height in pixels of the image
See also the , and for more information about
the layout of the image.
MethodGdk.Pixbuf
the name of the resource
Loads a pixbuf from a resource file.a
This loads a pixbuf from a resource in the calling assembly. This is equivalent to
using the
constructor with a assembly.
PropertyGLib.Property("n-channels")System.Int32The number of channels on a PixbufReturns the number of channels on a Pixbuf
The possible values are 3 (for RGB encoding) and 4 (for RGB
with an alpha transparency channel encoding).
PropertySystem.IntPtrThe pixels contained by this Pixbuf object.a , pointer to the underlying C dataMethodSystem.ObsoleteGdk.PixbufTo be addeda To be addedMethodGdk.Pixbuf
The angle to rotate by.
Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.A .PropertyGLib.Property("rowstride")System.Int32Rowstride of the PixbufThe rowstride property for the Pixbuf
Queries the rowstride of a pixbuf. The rowstring is the
number of bytes occupied by a row of pixels. Sometimes
for alignment purposes, the rowstride might be bigger than
the actual width of the image. Applications that
manually process data from the image would scan lines by
adding the value of the Rowstride.
MethodSystem.Void
Target Pixbuf where the resulting image is stored
saturation factor
whether to pixelation will take place
Saturation and pixelation of a Pixbuf
Modifies saturation and optionally pixelates the Pixbuf,
placing the result in . may be the same Pixbuf with no ill
effects. If is 1.0 then
saturation is not changed. If it's less than 1.0,
saturation is reduced (the image is darkened); if greater
than 1.0, saturation is increased (the image is
brightened). If is , then pixels are faded in a checkerboard
pattern to create a pixelated image. src and dest must
have the same image format, size, and rowstride.
MethodSystem.Boolean
a , name of the file to save
a , file format to save in ("jpeg" and "png" are supported).
Saves pixbuf to a file.a The Gtk+ version of this call supports a text string of
arguments, which Gtk# currently does not include. (TODO: explain
the difference between Save and Savev, in light of this API
difference.)
MethodSystem.Byte[]
an image type, such as png, jpeg, or ico
Saves to a buffer.a Throws a if the save is not successful.MethodSystem.Byte[]
an image type, such as png, jpeg, or ico
an array of option keys.
an array of option values.
Saves to a buffer.a >The and should contain key/value pairs. See for more details. Throws a if the save is not successful.MethodSystem.Void
a
an image type, such as png, jpeg, or ico
Save using a callback delegate.Throws a if the save is not successful.MethodSystem.Void
a
an image type, such as png, jpeg, or ico
an array of option keys
an array of option values
Save using a callback delegate.The and should contain key/value pairs. See for more details. Throws a if the save is not successful.MethodSystem.Boolean
Name of the file where the image will be saved
The file type to save (one of "ani", "bmp", "gif", "ico", "jpeg", "pcx", "png", "pnm", "ras", "tga", "tiff" "wbmp", "xpm" or "xbm")
Options that are passed to the save module.
Values for each key
Saves pixbuf to a file.A MethodSystem.Void
The destination Pixbuf where the results
are rendered
The left coordinate for region to render
The top coordinate for region to render
The width of the region to render
The height of the region to render
The offset in the X direction (currently rounded to an integer)
The offset in the Y direction (currently rounded to an integer)
The scale factor in the X direction
The scale factor in the Y direction
The interpolation type for the transformation.
Scale transformation.
Creates a transformation of the Pixbuf by scaling to
and
then translating by and
, then renders the rectangle
(, ,
, ) of the resulting image onto the
destination image replacing the previous contents.
Try to use , this
function is the industrial-strength power tool you can
fall back to if is
not powerful enough.
MethodGdk.Pixbuf
The width of destination image
The height of destination image
The interpolation type for the transformation
Scales a Pixbuf
A new Pixbuf object, or if no
memory is available for the transformation.
Create a new GdkPixbuf containing a copy of src scaled to
x . It leaves the current Pixbuf
unaffected. should be if you want maximum
speed (but when scaling down is usually unusably
ugly). The default should
be which offers
reasonable quality and speed.
You can scale a sub-portion of the Pixbuf by creating a
sub-pixbuf using a Pixbuf constructor.
For more complicated scale/compositions see and MethodSystem.StringTo be added.To be added.To be added.MethodSystem.ObsoleteSystem.VoidTo be addedTo be addedPropertyGLib.Property("width")System.Int32The width of the imageThe width in pixels of the image
This is the width of the image in pixels. See the property as well.