gdk.Pixbuf.Pixbuf Class Reference

List of all members.

Detailed Description

Description These functions allow to render pixbufs on drawables.

Pixbufs are client-side images. For details on how to create and manipulate pixbufs, see the GdkPixbuf API documentation.


Public Member Functions

GdkPixbufgetPixbufStruct ()
 this (GdkPixbuf *gdkPixbuf)
 Sets our main struct and passes it to the parent class.
void renderThresholdAlpha (GdkBitmap *bitmap, int srcX, int srcY, int destX, int destY, int width, int height, int alphaThreshold)
 Takes the opacity values in a rectangular portion of a pixbuf and thresholds them to produce a bi-level alpha mask that can be used as a clipping mask for a drawable.
void renderToDrawable (GdkDrawable *drawable, GdkGC *gc, int srcX, int srcY, int destX, int destY, int width, int height, GdkRgbDither dither, int xDither, int yDither)
 Warning gdk_pixbuf_render_to_drawable has been deprecated since version 2.4 and should not be used in newly-written code.
void renderToDrawableAlpha (GdkDrawable *drawable, int srcX, int srcY, int destX, int destY, int width, int height, GdkPixbufAlphaMode alphaMode, int alphaThreshold, GdkRgbDither dither, int xDither, int yDither)
 Warning gdk_pixbuf_render_to_drawable_alpha has been deprecated since version 2.4 and should not be used in newly-written code.
void renderPixmapAndMask (GdkPixmap **pixmapReturn, GdkBitmap **maskReturn, int alphaThreshold)
 Creates a pixmap and a mask bitmap which are returned in the pixmap_return and mask_return arguments, respectively, and renders a pixbuf and its corresponding thresholded alpha mask to them.
void renderPixmapAndMaskForColormap (GdkColormap *colormap, GdkPixmap **pixmapReturn, GdkBitmap **maskReturn, int alphaThreshold)
 Creates a pixmap and a mask bitmap which are returned in the pixmap_return and mask_return arguments, respectively, and renders a pixbuf and its corresponding tresholded alpha mask to them.
GdkPixbufgetFromDrawable (GdkDrawable *src, GdkColormap *cmap, int srcX, int srcY, int destX, int destY, int width, int height)
 Transfers image data from a GdkDrawable and converts it to an RGB(A) representation inside a GdkPixbuf.
GdkPixbufgetFromImage (GdkImage *src, GdkColormap *cmap, int srcX, int srcY, int destX, int destY, int width, int height)
 Same as gdk_pixbuf_get_from_drawable() but gets the pixbuf from an image.
 this (char *data, GdkColorspace colorspace, int hasAlpha, int bitsPerSample, int width, int height, int rowstride, GdkPixbufDestroyNotify destroyFn, void *destroyFnData)
 Creates a new GdkPixbuf out of in-memory image data.
 this (char **data)
 Creates a new pixbuf by parsing XPM data in memory.
 this (int dataLength, byte *data, int copyPixels, GError **error)
 Create a GdkPixbuf from a flat representation that is suitable for storing as inline data in a program.
 this (int srcX, int srcY, int width, int height)
 Creates a new pixbuf which represents a sub-region of src_pixbuf.
Pixbuf copy ()
 Creates a new GdkPixbuf with a copy of the information in the specified pixbuf.
GdkColorspace getColorspace ()
 Queries the color space of a pixbuf.
int getNChannels ()
 Queries the number of channels of a pixbuf.
int getHasAlpha ()
 Queries whether a pixbuf has an alpha channel (opacity information).
int getBitsPerSample ()
 Queries the number of bits per color sample in a pixbuf.
chargetPixels ()
 Queries a pointer to the pixel data of a pixbuf.
int getWidth ()
 Queries the width of a pixbuf.
int getHeight ()
 Queries the height of a pixbuf.
int getRowstride ()
 Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row and the start of the next row.
char[] getOption (char[] key)
 Looks up key in the list of options that may have been attached to the pixbuf when it was loaded.
 this (char[] filename, GError **error)
 Creates a new pixbuf by loading an image from a file.
 this (char[] filename, int width, int height, GError **error)
 Creates a new pixbuf by loading an image from a file.
 this (char[] filename, int width, int height, int preserveAspectRatio, GError **error)
 Creates a new pixbuf by loading an image from a file.
int savev (char[] filename, char[] type, char **optionKeys, char **optionValues, GError **error)
 Saves pixbuf to a file in type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
int save (char[] filename, char[] type, GError **error,...)
 Saves pixbuf to a file in format type.
int saveToCallback (GdkPixbufSaveFunc saveFunc, void *userData, char[] type, GError **error,...)
 Saves pixbuf in format type by feeding the produced data to a callback.
int saveToCallbackv (GdkPixbufSaveFunc saveFunc, void *userData, char[] type, char **optionKeys, char **optionValues, GError **error)
 Saves pixbuf to a callback in format type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
int saveToBuffer (char **buffer, uint *bufferSize, char[] type, GError **error,...)
 Saves pixbuf to a new buffer in format type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".
int saveToBufferv (char **buffer, uint *bufferSize, char[] type, char **optionKeys, char **optionValues, GError **error)
 Saves pixbuf to a new buffer in format type, which is currently "jpeg", "tiff", "png", "ico" or "bmp".
Pixbuf scaleSimple (int destWidth, int destHeight, GdkInterpType interpType)
 Create a new GdkPixbuf containing a copy of src scaled to dest_width x dest_height.
void scale (Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType)
 Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then renders the rectangle (dest_x, dest_y, dest_width, dest_height) of the resulting image onto the destination image replacing the previous contents.
Pixbuf compositeColorSimple (int destWidth, int destHeight, GdkInterpType interpType, int overallAlpha, int checkSize, uint color1, uint color2)
 Creates a new GdkPixbuf by scaling src to dest_width x dest_height and compositing the result with a checkboard of colors color1 and color2.
void composite (Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType, int overallAlpha)
 Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y.
void compositeColor (Pixbuf dest, int destX, int destY, int destWidth, int destHeight, double offsetX, double offsetY, double scaleX, double scaleY, GdkInterpType interpType, int overallAlpha, int checkX, int checkY, int checkSize, uint color1, uint color2)
 Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then composites the rectangle (dest_x ,dest_y, dest_width, dest_height) of the resulting image with a checkboard of the colors color1 and color2 and renders it onto the destination image.
Pixbuf rotateSimple (GdkPixbufRotation angle)
 Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.
Pixbuf flip (int horizontal)
 Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf.
Pixbuf addAlpha (int substituteColor, char r, char g, char b)
 Takes an existing pixbuf and adds an alpha channel to it.
void copyArea (int srcX, int srcY, int width, int height, Pixbuf destPixbuf, int destX, int destY)
 Copies a rectangular area from src_pixbuf to dest_pixbuf.
void saturateAndPixelate (Pixbuf dest, float saturation, int pixelate)
 Modifies saturation and optionally pixelates src, placing the result in dest.
void fill (uint pixel)
 Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf's pixel format.

Static Public Member Functions

static GType getType ()

Protected Member Functions

void * getStruct ()
 the main Gtk struct as a void*

Protected Attributes

GdkPixbufgdkPixbuf
 the main Gtk struct


Constructor & Destructor Documentation

gdk.Pixbuf.Pixbuf.this ( GdkPixbuf gdkPixbuf  ) 

Sets our main struct and passes it to the parent class.

gdk.Pixbuf.Pixbuf.this ( char data,
GdkColorspace  colorspace,
int  hasAlpha,
int  bitsPerSample,
int  width,
int  height,
int  rowstride,
GdkPixbufDestroyNotify  destroyFn,
void *  destroyFnData 
)

Creates a new GdkPixbuf out of in-memory image data.

Currently only RGB images with 8 bits per sample are supported. data: Image data in 8-bit/sample packed format. colorspace: Colorspace for the image data. has_alpha: Whether the data has an opacity channel. bits_per_sample: Number of bits per sample. width: Width of the image in pixels. height: Height of the image in pixels. rowstride: Distance in bytes between row starts. destroy_fn: Function used to free the data when the pixbuf's reference count drops to zero, or NULL if the data should not be freed. destroy_fn_data: Closure data to pass to the destroy notification function. Returns: A newly-created GdkPixbuf structure with a reference count of 1.

gdk.Pixbuf.Pixbuf.this ( char **  data  ) 

Creates a new pixbuf by parsing XPM data in memory.

This data is commonly the result of including an XPM file into a program's C source. data: Pointer to inline XPM data. Returns: A newly-created pixbuf with a reference count of 1.

gdk.Pixbuf.Pixbuf.this ( int  dataLength,
byte *  data,
int  copyPixels,
GError **  error 
)

Create a GdkPixbuf from a flat representation that is suitable for storing as inline data in a program.

This is useful if you want to ship a program with images, but don't want to depend on any external files. GTK+ ships with a program called gdk-pixbuf-csource which allows for conversion of GdkPixbufs into such a inline representation. In almost all cases, you should pass the --raw flag to gdk-pixbuf-csource. A sample invocation would be: gdk-pixbuf-csource --raw --name=myimage_inline myimage.png For the typical case where the inline pixbuf is read-only static data, you don't need to copy the pixel data unless you intend to write to it, so you can pass FALSE for copy_pixels. (If you pass --rle to gdk-pixbuf-csource, a copy will be made even if copy_pixels is FALSE, so using this option is generally a bad idea.) If you create a pixbuf from const inline data compiled into your program, it's probably safe to ignore errors and disable length checks, since things will always succeed: pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL); For non-const inline data, you could get out of memory. For untrusted inline data located at runtime, you could have corrupt inline data in addition. data_length: Length in bytes of the data argument or -1 to disable length checks data: Byte data containing a serialized GdkPixdata structure copy_pixels: Whether to copy the pixel data, or use direct pointers data for the resulting pixbuf error: GError return location, may be NULL to ignore errors Returns: A newly-created GdkPixbuf structure with a reference, count of 1, or NULL if an error occurred.

gdk.Pixbuf.Pixbuf.this ( int  srcX,
int  srcY,
int  width,
int  height 
)

Creates a new pixbuf which represents a sub-region of src_pixbuf.

The new pixbuf shares its pixels with the original pixbuf, so writing to one affects both. The new pixbuf holds a reference to src_pixbuf, so src_pixbuf will not be finalized until the new pixbuf is finalized. src_pixbuf: a GdkPixbuf src_x: X coord in src_pixbuf src_y: Y coord in src_pixbuf width: width of region in src_pixbuf height: height of region in src_pixbuf Returns: a new pixbuf

gdk.Pixbuf.Pixbuf.this ( char[]  filename,
GError **  error 
)

Creates a new pixbuf by loading an image from a file.

The file format is detected automatically. If NULL is returned, then error will be set. Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains. filename: Name of file to load, in the GLib file name encoding error: Return location for an error Returns: A newly-created pixbuf with a reference count of 1, or NULL if any of several error conditions occurred: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.

gdk.Pixbuf.Pixbuf.this ( char[]  filename,
int  width,
int  height,
GError **  error 
)

Creates a new pixbuf by loading an image from a file.

The file format is detected automatically. If NULL is returned, then error will be set. Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains. The image will be scaled to fit in the requested size, preserving the image's aspect ratio. filename: Name of file to load, in the GLib file name encoding width: The width the image should have or -1 to not constrain the width height: The height the image should have or -1 to not constrain the height error: Return location for an error Returns: A newly-created pixbuf with a reference count of 1, or NULL if any of several error conditions occurred: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data. Since 2.4

gdk.Pixbuf.Pixbuf.this ( char[]  filename,
int  width,
int  height,
int  preserveAspectRatio,
GError **  error 
)

Creates a new pixbuf by loading an image from a file.

The file format is detected automatically. If NULL is returned, then error will be set. Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains. The image will be scaled to fit in the requested size, optionally preserving the image's aspect ratio. When preserving the aspect ratio, a width of -1 will cause the image to be scaled to the exact given height, and a height of -1 will cause the image to be scaled to the exact given width. When not preserving aspect ratio, a width or height of -1 means to not scale the image at all in that dimension. Negative values for width and height are allowed since 2.8. filename: Name of file to load, in the GLib file name encoding width: The width the image should have or -1 to not constrain the width height: The height the image should have or -1 to not constrain the height preserve_aspect_ratio: TRUE to preserve the image's aspect ratio error: Return location for an error Returns: A newly-created pixbuf with a reference count of 1, or NULL if any of several error conditions occurred: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data. Since 2.6


Member Function Documentation

Pixbuf gdk.Pixbuf.Pixbuf.addAlpha ( int  substituteColor,
char  r,
char  g,
char  b 
)

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 substitute_color is TRUE, then the color specified by (r, g, b) will be assigned zero opacity. That is, if you pass (255, 255, 255) for the substitute color, all white pixels will become fully transparent. pixbuf: A GdkPixbuf. substitute_color: Whether to set a color to zero opacity. If this is FALSE, then the (r, g, b) arguments will be ignored. r: Red value to substitute. g: Green value to substitute. b: Blue value to substitute. Returns: A newly-created pixbuf with a reference count of 1.

void gdk.Pixbuf.Pixbuf.composite ( Pixbuf  dest,
int  destX,
int  destY,
int  destWidth,
int  destHeight,
double  offsetX,
double  offsetY,
double  scaleX,
double  scaleY,
GdkInterpType  interpType,
int  overallAlpha 
)

Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y.

This gives an image in the coordinates of the destination pixbuf. The rectangle (dest_x, dest_y, dest_width, dest_height) is then composited onto the corresponding rectangle of the original destination image. When the destination rectangle contains parts not in the source image, the data at the edges of the source image is replicated to infinity. Figure1.Compositing of pixbufs src: a GdkPixbuf dest: the GdkPixbuf into which to render the results dest_x: the left coordinate for region to render dest_y: the top coordinate for region to render dest_width: the width of the region to render dest_height: the height of the region to render offset_x: the offset in the X direction (currently rounded to an integer) offset_y: the offset in the Y direction (currently rounded to an integer) scale_x: the scale factor in the X direction scale_y: the scale factor in the Y direction interp_type: the interpolation type for the transformation. overall_alpha: overall alpha for source image (0..255)

void gdk.Pixbuf.Pixbuf.compositeColor ( Pixbuf  dest,
int  destX,
int  destY,
int  destWidth,
int  destHeight,
double  offsetX,
double  offsetY,
double  scaleX,
double  scaleY,
GdkInterpType  interpType,
int  overallAlpha,
int  checkX,
int  checkY,
int  checkSize,
uint  color1,
uint  color2 
)

Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then composites the rectangle (dest_x ,dest_y, dest_width, dest_height) of the resulting image with a checkboard of the colors color1 and color2 and renders it onto the destination image.

See gdk_pixbuf_composite_color_simple() for a simpler variant of this function suitable for many tasks. src: a GdkPixbuf dest: the GdkPixbuf into which to render the results dest_x: the left coordinate for region to render dest_y: the top coordinate for region to render dest_width: the width of the region to render dest_height: the height of the region to render offset_x: the offset in the X direction (currently rounded to an integer) offset_y: the offset in the Y direction (currently rounded to an integer) scale_x: the scale factor in the X direction scale_y: the scale factor in the Y direction interp_type: the interpolation type for the transformation. overall_alpha: overall alpha for source image (0..255) check_x: the X offset for the checkboard (origin of checkboard is at -check_x, -check_y) check_y: the Y offset for the checkboard check_size: the size of checks in the checkboard (must be a power of two) color1: the color of check at upper left color2: the color of the other check

Pixbuf gdk.Pixbuf.Pixbuf.compositeColorSimple ( int  destWidth,
int  destHeight,
GdkInterpType  interpType,
int  overallAlpha,
int  checkSize,
uint  color1,
uint  color2 
)

Creates a new GdkPixbuf by scaling src to dest_width x dest_height and compositing the result with a checkboard of colors color1 and color2.

src: a GdkPixbuf dest_width: the width of destination image dest_height: the height of destination image interp_type: the interpolation type for the transformation. overall_alpha: overall alpha for source image (0..255) check_size: the size of checks in the checkboard (must be a power of two) color1: the color of check at upper left color2: the color of the other check Returns: the new GdkPixbuf, or NULL if not enough memory could be allocated for it.

Pixbuf gdk.Pixbuf.Pixbuf.copy (  ) 

Creates a new GdkPixbuf with a copy of the information in the specified pixbuf.

pixbuf: A pixbuf. Returns: A newly-created pixbuf with a reference count of 1, or NULL if not enough memory could be allocated. See Also gdk_pixbuf_finalize().

void gdk.Pixbuf.Pixbuf.copyArea ( int  srcX,
int  srcY,
int  width,
int  height,
Pixbuf  destPixbuf,
int  destX,
int  destY 
)

Copies a rectangular area from src_pixbuf to dest_pixbuf.

Conversion of pixbuf formats is done automatically. src_pixbuf: Source pixbuf. src_x: Source X coordinate within src_pixbuf. src_y: Source Y coordinate within src_pixbuf. width: Width of the area to copy. height: Height of the area to copy. dest_pixbuf: Destination pixbuf. dest_x: X coordinate within dest_pixbuf. dest_y: Y coordinate within dest_pixbuf.

void gdk.Pixbuf.Pixbuf.fill ( uint  pixel  ) 

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 doesn't have an alpha channel. pixbuf: a GdkPixbuf pixel: RGBA pixel to clear to (0xffffffff is opaque white, 0x00000000 transparent black) See Also GdkPixbuf

Pixbuf gdk.Pixbuf.Pixbuf.flip ( int  horizontal  ) 

Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf.

src: a GdkPixbuf horizontal: TRUE to flip horizontally, FALSE to flip vertically Returns: a new pixbuf. Since 2.6 See Also GdkRGB.

int gdk.Pixbuf.Pixbuf.getBitsPerSample (  ) 

Queries the number of bits per color sample in a pixbuf.

pixbuf: A pixbuf. Returns: Number of bits per color sample.

GdkColorspace gdk.Pixbuf.Pixbuf.getColorspace (  ) 

Queries the color space of a pixbuf.

pixbuf: A pixbuf. Returns: Color space.

GdkPixbuf* gdk.Pixbuf.Pixbuf.getFromDrawable ( GdkDrawable src,
GdkColormap cmap,
int  srcX,
int  srcY,
int  destX,
int  destY,
int  width,
int  height 
)

Transfers image data from a GdkDrawable and converts it to an RGB(A) representation inside a GdkPixbuf.

In other words, copies image data from a server-side drawable to a client-side RGB(A) buffer. This allows you to efficiently read individual pixels on the client side. If the drawable src has no colormap (gdk_drawable_get_colormap() returns NULL), then a suitable colormap must be specified. Typically a GdkWindow or a pixmap created by passing a GdkWindow to gdk_pixmap_new() will already have a colormap associated with it. If the drawable has a colormap, the cmap argument will be ignored. If the drawable is a bitmap (1 bit per pixel pixmap), then a colormap is not required; pixels with a value of 1 are assumed to be white, and pixels with a value of 0 are assumed to be black. For taking screenshots, gdk_colormap_get_system() returns the correct colormap to use. If the specified destination pixbuf dest is NULL, then this function will create an RGB pixbuf with 8 bits per channel and no alpha, with the same size specified by the width and height arguments. In this case, the dest_x and dest_y arguments must be specified as 0. If the specified destination pixbuf is not NULL and it contains alpha information, then the filled pixels will be set to full opacity (alpha = 255). If the specified drawable is a pixmap, then the requested source rectangle must be completely contained within the pixmap, otherwise the function will return NULL. For pixmaps only (not for windows) passing -1 for width or height is allowed to mean the full width or height of the pixmap. If the specified drawable is a window, and the window is off the screen, then there is no image data in the obscured/offscreen regions to be placed in the pixbuf. The contents of portions of the pixbuf corresponding to the offscreen region are undefined. If the window you're obtaining data from is partially obscured by other windows, then the contents of the pixbuf areas corresponding to the obscured regions are undefined. If the target drawable is not mapped (typically because it's iconified/minimized or not on the current workspace), then NULL will be returned. If memory can't be allocated for the return value, NULL will be returned instead. (In short, there are several ways this function can fail, and if it fails it returns NULL; so check the return value.) This function calls gdk_drawable_get_image() internally and converts the resulting image to a GdkPixbuf, so the documentation for gdk_drawable_get_image() may also be relevant. dest: Destination pixbuf, or NULL if a new pixbuf should be created. src: Source drawable. cmap: A colormap if src doesn't have one set. src_x: Source X coordinate within drawable. src_y: Source Y coordinate within drawable. dest_x: Destination X coordinate in pixbuf, or 0 if dest is NULL. dest_y: Destination Y coordinate in pixbuf, or 0 if dest is NULL. width: Width in pixels of region to get. height: Height in pixels of region to get. Returns: The same pixbuf as dest if it was non-NULL, or a newly-created pixbuf with a reference count of 1 if no destination pixbuf was specified, or NULL on error

GdkPixbuf* gdk.Pixbuf.Pixbuf.getFromImage ( GdkImage src,
GdkColormap cmap,
int  srcX,
int  srcY,
int  destX,
int  destY,
int  width,
int  height 
)

Same as gdk_pixbuf_get_from_drawable() but gets the pixbuf from an image.

dest: Destination pixbuf, or NULL if a new pixbuf should be created. src: Source GdkImage. cmap: A colormap, or NULL to use the one for src src_x: Source X coordinate within drawable. src_y: Source Y coordinate within drawable. dest_x: Destination X coordinate in pixbuf, or 0 if dest is NULL. dest_y: Destination Y coordinate in pixbuf, or 0 if dest is NULL. width: Width in pixels of region to get. height: Height in pixels of region to get. Returns: dest, newly-created pixbuf if dest was NULL, NULL on error

int gdk.Pixbuf.Pixbuf.getHasAlpha (  ) 

Queries whether a pixbuf has an alpha channel (opacity information).

pixbuf: A pixbuf. Returns: TRUE if it has an alpha channel, FALSE otherwise.

int gdk.Pixbuf.Pixbuf.getHeight (  ) 

Queries the height of a pixbuf.

pixbuf: A pixbuf. Returns: Height in pixels.

int gdk.Pixbuf.Pixbuf.getNChannels (  ) 

Queries the number of channels of a pixbuf.

pixbuf: A pixbuf. Returns: Number of channels.

char [] gdk.Pixbuf.Pixbuf.getOption ( char[]  key  ) 

Looks up key in the list of options that may have been attached to the pixbuf when it was loaded.

pixbuf: a GdkPixbuf key: a nul-terminated string. Returns: the value associated with key. This is a nul-terminated string that should not be freed or NULL if key was not found. Property Details The "bits-per-sample" property "bits-per-sample" gint : Read / Write / Construct Only The number of bits per sample. Currently only 8 bit per sample are supported. Allowed values: [1,16] Default value: 8

GdkPixbuf* gdk.Pixbuf.Pixbuf.getPixbufStruct (  ) 

char* gdk.Pixbuf.Pixbuf.getPixels (  ) 

Queries a pointer to the pixel data of a pixbuf.

pixbuf: A pixbuf. Returns: A pointer to the pixbuf's pixel data. Please see the section called Image Data for information about how the pixel data is stored in memory.

int gdk.Pixbuf.Pixbuf.getRowstride (  ) 

Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row and the start of the next row.

pixbuf: A pixbuf. Returns: Distance between row starts.

void* gdk.Pixbuf.Pixbuf.getStruct (  )  [protected]

the main Gtk struct as a void*

static GType gdk.Pixbuf.Pixbuf.getType (  )  [static]


gdk_pixbuf_new () GdkPixbuf* gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height); Creates a new GdkPixbuf 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. colorspace: Color space for image. has_alpha: Whether the image should have transparency information. bits_per_sample: Number of bits per color sample. width: Width of image in pixels. height: Height of image in pixels. Returns: A newly-created GdkPixbuf with a reference count of 1, or NULL if not enough memory could be allocated for the image buffer.

int gdk.Pixbuf.Pixbuf.getWidth (  ) 

Queries the width of a pixbuf.

pixbuf: A pixbuf. Returns: Width in pixels.

void gdk.Pixbuf.Pixbuf.renderPixmapAndMask ( GdkPixmap **  pixmapReturn,
GdkBitmap **  maskReturn,
int  alphaThreshold 
)

Creates a pixmap and a mask bitmap which are returned in the pixmap_return and mask_return arguments, respectively, and renders a pixbuf and its corresponding thresholded alpha mask to them.

This is merely a convenience function; applications that need to render pixbufs with dither offsets or to given drawables should use gdk_draw_pixbuf() and gdk_pixbuf_render_threshold_alpha(). The pixmap that is created is created for the colormap returned by gdk_rgb_get_colormap(). You normally will want to instead use the actual colormap for a widget, and use gdk_pixbuf_render_pixmap_and_mask_for_colormap(). If the pixbuf does not have an alpha channel, then *mask_return will be set to NULL. pixbuf: A pixbuf. pixmap_return: Location to store a pointer to the created pixmap, or NULL if the pixmap is not needed. mask_return: Location to store a pointer to the created mask, or NULL if the mask is not needed. alpha_threshold: Threshold value for opacity values.

void gdk.Pixbuf.Pixbuf.renderPixmapAndMaskForColormap ( GdkColormap colormap,
GdkPixmap **  pixmapReturn,
GdkBitmap **  maskReturn,
int  alphaThreshold 
)

Creates a pixmap and a mask bitmap which are returned in the pixmap_return and mask_return arguments, respectively, and renders a pixbuf and its corresponding tresholded alpha mask to them.

This is merely a convenience function; applications that need to render pixbufs with dither offsets or to given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha(). The pixmap that is created uses the GdkColormap specified by colormap. This colormap must match the colormap of the window where the pixmap will eventually be used or an error will result. If the pixbuf does not have an alpha channel, then *mask_return will be set to NULL. pixbuf: A pixbuf. colormap: A GdkColormap pixmap_return: Location to store a pointer to the created pixmap, or NULL if the pixmap is not needed. mask_return: Location to store a pointer to the created mask, or NULL if the mask is not needed. alpha_threshold: Threshold value for opacity values.

void gdk.Pixbuf.Pixbuf.renderThresholdAlpha ( GdkBitmap bitmap,
int  srcX,
int  srcY,
int  destX,
int  destY,
int  width,
int  height,
int  alphaThreshold 
)

Takes the opacity values in a rectangular portion of a pixbuf and thresholds them to produce a bi-level alpha mask that can be used as a clipping mask for a drawable.

pixbuf: A pixbuf. bitmap: Bitmap where the bilevel mask will be painted to. src_x: Source X coordinate. src_y: source Y coordinate. dest_x: Destination X coordinate. dest_y: Destination Y coordinate. width: Width of region to threshold, or -1 to use pixbuf width height: Height of region to threshold, or -1 to use pixbuf height alpha_threshold: Opacity values below this will be painted as zero; all other values will be painted as one.

void gdk.Pixbuf.Pixbuf.renderToDrawable ( GdkDrawable drawable,
GdkGC gc,
int  srcX,
int  srcY,
int  destX,
int  destY,
int  width,
int  height,
GdkRgbDither  dither,
int  xDither,
int  yDither 
)

Warning gdk_pixbuf_render_to_drawable has been deprecated since version 2.4 and should not be used in newly-written code.

This function is obsolete. Use gdk_draw_pixbuf() instead. Renders a rectangular portion of a pixbuf to a drawable while using the specified GC. This is done using GdkRGB, so the specified drawable must have the GdkRGB visual and colormap. Note that this function will ignore the opacity information for images with an alpha channel; the GC must already have the clipping mask set if you want transparent regions to show through. For an explanation of dither offsets, see the GdkRGB documentation. In brief, the dither offset is important when re-rendering partial regions of an image to a rendered version of the full image, or for when the offsets to a base position change, as in scrolling. The dither matrix has to be shifted for consistent visual results. If you do not have any of these cases, the dither offsets can be both zero. pixbuf: A pixbuf. drawable: Destination drawable. gc: GC used for rendering. src_x: Source X coordinate within pixbuf. src_y: Source Y coordinate within pixbuf. dest_x: Destination X coordinate within drawable. dest_y: Destination Y coordinate within drawable. width: Width of region to render, in pixels, or -1 to use pixbuf width height: Height of region to render, in pixels, or -1 to use pixbuf height dither: Dithering mode for GdkRGB. x_dither: X offset for dither. y_dither: Y offset for dither.

void gdk.Pixbuf.Pixbuf.renderToDrawableAlpha ( GdkDrawable drawable,
int  srcX,
int  srcY,
int  destX,
int  destY,
int  width,
int  height,
GdkPixbufAlphaMode  alphaMode,
int  alphaThreshold,
GdkRgbDither  dither,
int  xDither,
int  yDither 
)

Warning gdk_pixbuf_render_to_drawable_alpha has been deprecated since version 2.4 and should not be used in newly-written code.

This function is obsolete. Use gdk_draw_pixbuf() instead. Renders a rectangular portion of a pixbuf to a drawable. The destination drawable must have a colormap. All windows have a colormap, however, pixmaps only have colormap by default if they were created with a non-NULL window argument. Otherwise a colormap must be set on them with gdk_drawable_set_colormap. On older X servers, rendering pixbufs with an alpha channel involves round trips to the X server, and may be somewhat slow. pixbuf: A pixbuf. drawable: Destination drawable. src_x: Source X coordinate within pixbuf. src_y: Source Y coordinates within pixbuf. dest_x: Destination X coordinate within drawable. dest_y: Destination Y coordinate within drawable. width: Width of region to render, in pixels, or -1 to use pixbuf width. height: Height of region to render, in pixels, or -1 to use pixbuf height. alpha_mode: Ignored. Present for backwards compatibility. alpha_threshold: Ignored. Present for backwards compatibility dither: Dithering mode for GdkRGB. x_dither: X offset for dither. y_dither: Y offset for dither.

Pixbuf gdk.Pixbuf.Pixbuf.rotateSimple ( GdkPixbufRotation  angle  ) 

Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.

src: a GdkPixbuf angle: the angle to rotate by Returns: a new pixbuf Since 2.6

void gdk.Pixbuf.Pixbuf.saturateAndPixelate ( Pixbuf  dest,
float  saturation,
int  pixelate 
)

Modifies saturation and optionally pixelates src, placing the result in dest.

src and dest may be the same pixbuf with no ill effects. If saturation is 1.0 then saturation is not changed. If it's less than 1.0, saturation is reduced (the image turns toward grayscale); if greater than 1.0, saturation is increased (the image gets more vivid colors). If pixelate is TRUE, 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. src: source image dest: place to write modified version of src saturation: saturation factor pixelate: whether to pixelate

int gdk.Pixbuf.Pixbuf.save ( char[]  filename,
char[]  type,
GError **  error,
  ... 
)

Saves pixbuf to a file in format type.

By default, "jpeg", "png", "ico" and "bmp" are possible file formats to save in, but more formats may be installed. The list of all writable formats can be determined in the following way: void add_if_writable (GdkPixbufFormat *data, GSList **list) { if (gdk_pixbuf_format_is_writable (data)) *list = g_slist_prepend (*list, data); } GSList *formats = gdk_pixbuf_get_formats (); GSList *writable_formats = NULL; g_slist_foreach (formats, add_if_writable, writable_formats); g_slist_free (formats); If error is set, FALSE will be returned. Possible errors include those in the GDK_PIXBUF_ERROR domain and those in the G_FILE_ERROR domain. The variable argument list should be NULL-terminated; if not empty, it should contain pairs of strings that modify the save parameters. For example: gdk_pixbuf_save (pixbuf, handle, "jpeg", error, "quality", "100", NULL); Currently only few parameters exist. JPEG images can be saved with a "quality" parameter; its value should be in the range [0,100]. Text chunks can be attached to PNG images by specifying parameters of the form "tEXt::key", where key is an ASCII string of length 1-79. The values are UTF-8 encoded strings. The PNG compression level can be specified using the "compression" parameter; it's value is in an integer in the range of [0,9]. ICO images can be saved in depth 16, 24, or 32, by using the "depth" parameter. When the ICO saver is given "x_hot" and "y_hot" parameters, it produces a CUR instead of an ICO. pixbuf: a GdkPixbuf. filename: name of file to save. type: name of file format. error: return location for error, or NULL ...: list of key-value save options Returns: whether an error was set

int gdk.Pixbuf.Pixbuf.saveToBuffer ( char **  buffer,
uint bufferSize,
char[]  type,
GError **  error,
  ... 
)

Saves pixbuf to a new buffer in format type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".

This is a convenience function that uses gdk_pixbuf_save_to_callback() to do the real work. Note that the buffer is not nul-terminated and may contain embedded nuls. If error is set, FALSE will be returned and string will be set to NULL. Possible errors include those in the GDK_PIXBUF_ERROR domain. See gdk_pixbuf_save() for more details. pixbuf: a GdkPixbuf. buffer: location to receive a pointer to the new buffer. buffer_size: location to receive the size of the new buffer. type: name of file format. error: return location for error, or NULL ...: list of key-value save options Returns: whether an error was set Since 2.4

int gdk.Pixbuf.Pixbuf.saveToBufferv ( char **  buffer,
uint bufferSize,
char[]  type,
char **  optionKeys,
char **  optionValues,
GError **  error 
)

Saves pixbuf to a new buffer in format type, which is currently "jpeg", "tiff", "png", "ico" or "bmp".

See gdk_pixbuf_save_to_buffer() for more details. pixbuf: a GdkPixbuf. buffer: location to receive a pointer to the new buffer. buffer_size: location to receive the size of the new buffer. type: name of file format. option_keys: name of options to set, NULL-terminated option_values: values for named options error: return location for error, or NULL Returns: whether an error was set Since 2.4

int gdk.Pixbuf.Pixbuf.saveToCallback ( GdkPixbufSaveFunc  saveFunc,
void *  userData,
char[]  type,
GError **  error,
  ... 
)

Saves pixbuf in format type by feeding the produced data to a callback.

Can be used when you want to store the image to something other than a file, such as an in-memory buffer or a socket. If error is set, FALSE will be returned. Possible errors include those in the GDK_PIXBUF_ERROR domain and whatever the save function generates. See gdk_pixbuf_save() for more details. pixbuf: a GdkPixbuf. save_func: a function that is called to save each block of data that the save routine generates. user_data: user data to pass to the save function. type: name of file format. error: return location for error, or NULL ...: list of key-value save options Returns: whether an error was set Since 2.4

int gdk.Pixbuf.Pixbuf.saveToCallbackv ( GdkPixbufSaveFunc  saveFunc,
void *  userData,
char[]  type,
char **  optionKeys,
char **  optionValues,
GError **  error 
)

Saves pixbuf to a callback in format type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".

If error is set, FALSE will be returned. See gdk_pixbuf_save_to_callback() for more details. pixbuf: a GdkPixbuf. save_func: a function that is called to save each block of data that the save routine generates. user_data: user data to pass to the save function. type: name of file format. option_keys: name of options to set, NULL-terminated option_values: values for named options error: return location for error, or NULL Returns: whether an error was set Since 2.4

int gdk.Pixbuf.Pixbuf.savev ( char[]  filename,
char[]  type,
char **  optionKeys,
char **  optionValues,
GError **  error 
)

Saves pixbuf to a file in type, which is currently "jpeg", "png", "tiff", "ico" or "bmp".

If error is set, FALSE will be returned. See gdk_pixbuf_save() for more details. pixbuf: a GdkPixbuf. filename: name of file to save. type: name of file format. option_keys: name of options to set, NULL-terminated option_values: values for named options error: return location for error, or NULL Returns: whether an error was set

void gdk.Pixbuf.Pixbuf.scale ( Pixbuf  dest,
int  destX,
int  destY,
int  destWidth,
int  destHeight,
double  offsetX,
double  offsetY,
double  scaleX,
double  scaleY,
GdkInterpType  interpType 
)

Creates a transformation of the source image src by scaling by scale_x and scale_y then translating by offset_x and offset_y, then renders the rectangle (dest_x, dest_y, dest_width, dest_height) of the resulting image onto the destination image replacing the previous contents.

Try to use gdk_pixbuf_scale_simple() first, this function is the industrial-strength power tool you can fall back to if gdk_pixbuf_scale_simple() isn't powerful enough. src: a GdkPixbuf dest: the GdkPixbuf into which to render the results dest_x: the left coordinate for region to render dest_y: the top coordinate for region to render dest_width: the width of the region to render dest_height: the height of the region to render offset_x: the offset in the X direction (currently rounded to an integer) offset_y: the offset in the Y direction (currently rounded to an integer) scale_x: the scale factor in the X direction scale_y: the scale factor in the Y direction interp_type: the interpolation type for the transformation.

Pixbuf gdk.Pixbuf.Pixbuf.scaleSimple ( int  destWidth,
int  destHeight,
GdkInterpType  interpType 
)

Create a new GdkPixbuf containing a copy of src scaled to dest_width x dest_height.

Leaves src unaffected. interp_type should be GDK_INTERP_NEAREST if you want maximum speed (but when scaling down GDK_INTERP_NEAREST is usually unusably ugly). The default interp_type should be GDK_INTERP_BILINEAR which offers reasonable quality and speed. You can scale a sub-portion of src by creating a sub-pixbuf pointing into src; see gdk_pixbuf_new_subpixbuf(). For more complicated scaling/compositing see gdk_pixbuf_scale() and gdk_pixbuf_composite(). src: a GdkPixbuf dest_width: the width of destination image dest_height: the height of destination image interp_type: the interpolation type for the transformation. Returns: the new GdkPixbuf, or NULL if not enough memory could be allocated for it.


Member Data Documentation

GdkPixbuf* gdk.Pixbuf.Pixbuf.gdkPixbuf [protected]

the main Gtk struct


SourceForge.net Logo DSource.org Logo digitalmars.com Logo