Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gdk::Pixbuf Class Reference

A GdkPixbuf C++ wrapper class. More...

#include <xfc/gdk-pixbuf/pixbuf.hh>

Inheritance diagram for Xfc::Gdk::Pixbuf:

Xfc::G::Object Xfc::G::TypeInstance Xfc::Trackable List of all members.

Public Types

Public Member Functions

Constructors
Accessors
Methods
Transformation Methods
GDK Pixbuf Methods

Static Public Member Functions

Constructors

Protected Member Functions

Constructors

Detailed Description

A GdkPixbuf C++ wrapper class.

Pixbuf is an object that contains information describing an image in memory.

The XFC demo program has several examples of using G::Error with Pixbufs. See <demowindow.cc> and <image.cc> in the <demos/gfc-demo> subdirectory.

Note: dynamically allocated objects must either be unreferenced or assigned to a smart pointer. Stack objects are automatically unreferenced when they go out of scope.


Member Typedef Documentation

typedef sigc::slot<bool, const char*, size_t, G::Error*> Xfc::Gdk::Pixbuf::SaveSlot
 

Signature of the callback slot to be called when saving a pixbuf.

Example: Method signature for SaveSlot.

             bool method(const char *buffer, size_t count, G::Error *error);
            
             // buffer: The bytes to be written. 
             // count:  The number of bytes in <EM>buffer</EM>. 
             // error:  The return location for any error.
             // return: true if successful, false (with error set) if failed. 

SaveSlot is called once for each block of bytes that is "written" by one of the overloaded save methods. If successful it should return true. If an error occurs it should set error and return false, in which case the save method will fail with the same error.


Constructor & Destructor Documentation

Xfc::Gdk::Pixbuf::Pixbuf GdkPixbuf *  pixbuf,
bool  owns_reference = true
[explicit, protected]
 

Construct a new Pixbuf from an existing GdkPixbuf.

Parameters:
pixbuf A pointer to a GdkPixbuf.
owns_reference Set false if the initial reference count is floating, set true if it's not.
The pixbuf can be a newly created GdkPixbuf or an existing GdkPixbuf. (see G::Object::Object).

Xfc::Gdk::Pixbuf::Pixbuf const Pixbuf src,
int  src_x,
int  src_y,
int  width,
int  height
 

Constructs a new pixbuf (a sub-pixbuf) which represents a sub-region of src.

Parameters:
src A Pixbuf.
src_x The source X coordinate in src.
src_y The source Y coordinate in src.
width The width of the region in src.
height The height of region in src.
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. Pixbuf is created with a reference count of 1 that the caller owns.

Xfc::Gdk::Pixbuf::Pixbuf const unsigned char *  data,
int  width,
int  height,
int  rowstride,
bool  has_alpha,
GdkPixbufDestroyNotify  destroy_fn = 0,
void *  destroy_fn_data = 0,
int  bits_per_sample = 8,
Colorspace  colorspace = COLORSPACE_RGB
 

Constructs a new pixbuf out of in-memory image data.

Parameters:
data The image data in 8-bit/sample packed format.
width The width of the image in pixels.
height The height of the image in pixels.
rowstride The distance in bytes between rows.
has_alpha Whether the data has an opacity channel.
destroy_fn The 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 The closure data to pass to the destroy notification function.
bits_per_sample The number of bits per sample.
colorspace The Gdk::Colorspace for the image data.
Currently only RGB images with 8 bits per sample are supported. Wrapping an existing pixel buffer is the most basic way to construct a pixbuf. You need to specify the destroy notification function that will be called when the data buffer needs to be freed; this will happen when a Gdk::Pixbuf is finalized by the reference counting functions. If you have a chunk of static data compiled into your application, you can pass in null as the destroy notification function so that the data will not be freed. Pixbuf is created with a reference count of 1 that the caller owns.

Xfc::Gdk::Pixbuf::Pixbuf const char **  data  ) 
 

Constructs a new pixbuf by parsing XPM data in memory.

Parameters:
data A pointer to inline XPM data.
This data is commonly the result of including an XPM file into a program's C source. Pixbuf is created with a reference count of 1 that the caller owns.


Member Function Documentation

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::add_alpha bool  substitute_color,
unsigned char  red,
unsigned char  green,
unsigned char  blue
 

Adds an alpha channel to this pixbuf and returns the result as a new pixbuf.

Parameters:
substitute_color Whether to set a color to zero opacity. If this is false, then the (r, g, b) arguments will be ignored.
red The red value to substitute.
green The green value to substitute.
blue the blue value to substitute.
Returns:
A newly-created pixbuf.
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.

void Xfc::Gdk::Pixbuf::composite const Pixbuf src,
const Rectangle dest_rect,
double  offset_x,
double  offset_y,
double  scale_x,
double  scale_y,
InterpType  interp_type,
int  overall_alpha
 

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_rect of the resulting image onto the destination image.

Parameters:
src The source pixbuf.
dest_rect The rectangular 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 The overall alpha for source image (0..255).

void Xfc::Gdk::Pixbuf::composite const Pixbuf src,
int  dest_x,
int  dest_y,
int  dest_width,
int  dest_height,
double  offset_x,
double  offset_y,
double  scale_x,
double  scale_y,
InterpType  interp_type,
int  overall_alpha
 

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 onto the destination image.

Parameters:
src The source pixbuf.
dest_x The left coordinate for the region to render.
dest_y The top coordinate for the 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 The overall alpha for source image (0..255).

void Xfc::Gdk::Pixbuf::composite_color const Pixbuf src,
const Rectangle dest_rect,
double  offset_x,
double  offset_y,
double  scale_x,
double  scale_y,
InterpType  interp_type,
int  overall_alpha,
const Point check_offset,
int  check_size,
unsigned int  color1,
unsigned int  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_rect of the resulting image with a checkboard of the colors color1 and color2 and renders it onto the destination image.

Parameters:
src The source pixbuf.
dest_rect The rectangular 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 The overall alpha for source image (0..255).
check_offset A Point holding the x, y offset for the checkboard (origin of the checkboard is at -check_offset.x, -check_offset.y).
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.
See composite_color_simple() for a simpler variant of this method suitable for many tasks.

void Xfc::Gdk::Pixbuf::composite_color const Pixbuf src,
int  dest_x,
int  dest_y,
int  dest_width,
int  dest_height,
double  offset_x,
double  offset_y,
double  scale_x,
double  scale_y,
InterpType  interp_type,
int  overall_alpha,
int  check_x,
int  check_y,
int  check_size,
unsigned int  color1,
unsigned int  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.

Parameters:
src The source pixbuf.
dest_x The left coordinate for the region to render.
dest_y The top coordinate for the 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 The 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.
See composite_color_simple() for a simpler variant of this method suitable for many tasks.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::composite_color_simple int  width,
int  height,
InterpType  interp_type,
int  overall_alpha,
int  check_size,
unsigned int  color1,
unsigned int  color2
 

Creates a new pixbuf by scaling this pixbuf to width x height and compositing the result with a checkboard of colors color1 and color2.

Parameters:
width The width of new image.
height The height of new image.
interp_type The interpolation type for the transformation.
overall_alpha The overall alpha for this (source) pixbuf (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:
A smart pointer to the new pixbuf, or null if not enough memory could be allocated for it.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::copy  )  const
 

Creates a new pixbuf from a copy of the information in this pixbuf.

Returns:
A newly created pixbuf, or null if not enough memory could be allocated.
This is not the same as just doing a ref() on the old pixbuf; the copy method will actually duplicate the pixel data in memory and create a new Pixbuf for it.

void Xfc::Gdk::Pixbuf::copy_area const Pixbuf src,
const Rectangle src_rect,
int  dest_x,
int  dest_y
 

Copies a rectangular area from src to this pixbuf; conversion of pixbuf formats is done automatically.

Parameters:
src The source pixbuf.
src_rect The rectangular area within src to copy.
dest_x The destination X coordinate within this pixbuf.
dest_y The destination Y coordinate within this pixbuf.

void Xfc::Gdk::Pixbuf::copy_area const Pixbuf src,
int  src_x,
int  src_y,
int  width,
int  height,
int  dest_x,
int  dest_y
 

Copies a rectangular area from src to this pixbuf; conversion of pixbuf formats is done automatically.

Parameters:
src The source pixbuf.
src_x The source X coordinate within src.
src_y The source Y coordinate within src.
width The width of the area to copy.
height The height of the area to copy.
dest_x The destination X coordinate within this pixbuf.
dest_y The destination Y coordinate within this pixbuf.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::create int  data_length,
const unsigned char *  data,
bool  copy_pixels,
G::Error error = 0
[static]
 

Creates a pixbuf from a flat representation that is suitable for storing as inline data in a program.

Parameters:
data_length The length in bytes of the data argument.
data The byte data containing a serialized GdkPixdata structure.
copy_pixels Set true to copy the pixel data, or use direct pointers data for the resulting pixbuf.
error The G::Error return location, may be null to ignore errors.
Returns:
A newly-created Pixbuf, or null if an error occurred.
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, since things will always succeed. 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.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::create const Image image,
int  x,
int  y,
int  width,
int  height,
Colormap colormap = 0
[static]
 

Creates a new pixbuf from the specified image (see get_from_drawable() for full details).

Parameters:
image The source image.
x The source X coordinate within image.
y The source Y coordinate within image.
width The width in pixels of region to get.
height The height in pixels of region to get.
colormap A colormap if image doesn't have one set.
Returns:
true if successful, false if an error occurs.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::create const Drawable drawable,
int  x,
int  y,
int  width,
int  height,
Colormap colormap = 0
[static]
 

Creates a new pixbuf with image data from a server-side drawable (see get_from_drawable() for full details).

Parameters:
drawable The source drawable.
x The source X coordinate within drawable.
y The source Y coordinate within drawable.
width The width in pixels of region to get.
height The height in pixels of region to get.
colormap A colormap if drawable doesn't have one set.
Returns:
A smart pointer to the new pixbuf, or null if an error occurs; The new pixbuf has no alpha channel.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::create int  width,
int  height,
bool  has_alpha,
int  bits_per_sample = 8,
Colorspace  colorspace = COLORSPACE_RGB
[static]
 

Creates a new (blank) pixbuf with an optimal rowstride and a new buffer.

Parameters:
width The width of the image in pixels.
height The height of the image in pixels.
has_alpha Whether the image should have transparency information.
bits_per_sample The number of bits per color sample.
colorspace The Gdk::Colorspace for the image.
Returns:
A smart pointer to the new pixbuf, or null if not enough memory could be allocated.
Note that the buffer is not cleared; you will have to fill it completely yourself. This is a convenience constructor used to create a pixbuf with an empty buffer. This is equivalent to constructing a pixbuf with a newly allocating data buffer. It computes an optimal rowstride so that rendering can be performed with an efficient algorithm.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::create const String filename,
int  width,
int  height,
bool  preserve_aspect_ratio,
G::Error error = 0
[static]
 

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

Parameters:
filename The name of file to load.
width The width the image should have.
height The height the image should have.
preserve_aspect_ratio Set to true to preserve the image's aspect ratio.
error The return location for an error.
Returns:
A newly-created pixbuf, or null if any of several error conditions occurred.
The file format is detected automatically. If an error occurs, then error will be set and G::Error::get() will return true. 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 its aspect ratio.

Possible error conditions include: 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.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::create const String filename,
G::Error error = 0
[static]
 

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

Parameters:
filename The name of file to load.
error The return location for an error.
Returns:
A newly-created pixbuf, or null if any of several error conditions occurred.
The file format is detected automatically. If an error occurs, then error will be set and G::Error::get() will return true. Possible errors are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.

The image is loaded from the file in a synchronous fashion. This means that the GDK-PIXBUF library takes control of the application while the file is being loaded; from the user's point of view, the application will block until the image is done loading. This constructor can be used by applications in which blocking is acceptable while an image is being loaded. It can also be used to load small images in general. Applications that need progressive loading can use the PixbufLoader functionality instead.

void Xfc::Gdk::Pixbuf::fill unsigned int  pixel  ) 
 

Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf's pixel format.

Parameters:
pixel The RGBA pixel to clear to (0xffffffff is opaque white, 0x00000000 transparent black).
The alpha will be ignored if the pixbuf doesn't have an alpha channel.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::flip bool  horizontal  ) 
 

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

Parameters:
horizontal Set to true to flip horizontally, false to flip vertically.
Returns:
A new pixbuf.

bool Xfc::Gdk::Pixbuf::get_from_drawable const Drawable src,
int  src_x,
int  src_y,
int  dest_x,
int  dest_y,
int  width,
int  height,
Colormap colormap = 0
 

Transfers (copies) image data from a server-side drawable to the client-side RGB(A) buffer inside this pixbuf.

Parameters:
src The source drawable.
src_x The source X coordinate within the src drawable.
src_y The source Y coordinate within the src drawable.
dest_x The destination X coordinate in this pixbuf.
dest_y The destination Y coordinate in this pixbuf.
width The width in pixels of region to get.
height The height in pixels of region to get.
colormap A colormap if src doesn't have one set.
Returns:
true if successful, false if an error occurs.
This allows you to efficiently read individual pixels on the client side. If the drawable is a pixmap, a colormap must be specified. If the src drawable src has no colormap (Gdk::drawable::get_colormap() returns null), then a suitable colormap must be specified. Typically a Gdk::Window or a pixmap created from a Gdk::Window will already have a colormap associated with it. If the drawable has a colormap, the colormap 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 this pixbuf 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 method will return false. 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 false will be returned. If memory can't be allocated for the return value, false will be returned instead.

Note: There are several ways this method can fail, and if it fails it returns false; so check the return value.

This method calls Gdk::Drawable::get_image() internally and converts the resulting image to a Gdk::Pixbuf, so the documentation for Gdk::Drawable::get_image() may also be relevant.

bool Xfc::Gdk::Pixbuf::get_from_image const Image src,
int  src_x,
int  src_y,
int  dest_x,
int  dest_y,
int  width,
int  height,
Colormap colormap = 0
 

Copies image data from an Image to this pixbuf (see get_from_drawable() for details).

Parameters:
src The source image.
src_x The source X coordinate within the src image.
src_y The source Y coordinate within the src image.
dest_x The destination X coordinate within this pixbuf.
dest_y The destination Y coordinate within this pixbuf.
width The width in pixels of region to get.
height The height in pixels of region to get.
colormap A colormap if src doesn't have one set.
Returns:
true if successful, false if an error occurs.

String Xfc::Gdk::Pixbuf::get_option const String key  )  const
 

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

Parameters:
key A String.
Returns:
The value associated with key, or a null String if key was not found.

unsigned char* Xfc::Gdk::Pixbuf::get_pixels  )  const
 

Gets a pointer to the pixel data of a pixbuf.

Returns:
A pointer to the pixbuf's pixel data.

void Xfc::Gdk::Pixbuf::render_pixmap_and_mask Pointer< Pixmap > *  pixmap_return,
Pointer< Bitmap > *  mask_return,
int  alpha_threshold,
Colormap colormap = 0
 

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.

Parameters:
pixmap_return The location to store a pointer to the created pixmap, or null if the pixmap is not needed.
mask_return The location to store a pointer to the created mask, or null if the mask is not needed.
alpha_threshold The threshold value for opacity values.
colormap A Colormap, or null to use the colormap returned by gdk_rgb_get_colormap().
This is merely a convenience method; applications that need to render pixbufs with dither offsets or to given drawables should use render_threshold_alpha() or Gdk::Drawable::draw_pixbuf().

If colormap is null the pixmap is created with the Colormap returned by gdk_rgb_get_colormap(). Normally you will want to use the actual colormap for a widget instead. If the pixbuf does not have an alpha channel, then mask_return will be set to null.

void Xfc::Gdk::Pixbuf::render_threshold_alpha Bitmap bitmap,
int  src_x,
int  src_y,
int  dest_x,
int  dest_y,
int  width,
int  height,
int  alpha_threshold
 

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

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

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::rotate_simple PixbufRotation  angle  ) 
 

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

Parameters:
angle The angle to rotate by.
Returns:
A new pixbuf.

void Xfc::Gdk::Pixbuf::saturate_and_pixelate float  saturation,
bool  pixelate
 

Modifies saturation and optionally pixelates the pixbuf.

Parameters:
saturation The saturation factor.
pixelate Whether to pixelate.
If saturation 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 pixelate is true, then pixels are faded in a checkerboard pattern to create a pixelated image. This pixbuf and src must have the same image format, size, and rowstride.

void Xfc::Gdk::Pixbuf::saturate_and_pixelate const Pixbuf src,
float  saturation,
bool  pixelate
 

Modifies saturation and optionally pixelates src, placing the result this pixbuf.

Parameters:
src The source image.
saturation The saturation factor.
pixelate Whether to pixelate.
If saturation 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 pixelate is true, then pixels are faded in a checkerboard pattern to create a pixelated image. This pixbuf and src must have the same image format, size, and rowstride.

bool Xfc::Gdk::Pixbuf::save char **  buffer,
size_t *  buffer_size,
const char *  type,
char **  option_keys,
char **  option_values,
G::Error error = 0
 

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

Parameters:
buffer The location to receive a pointer to the new buffer.
buffer_size The location to receive the size of the new buffer.
type The name of file format.
option_keys The name of options to set, null-terminated.
option_values The values for the named options.
error The return location for any error, or null.

bool Xfc::Gdk::Pixbuf::save char **  buffer,
size_t *  buffer_size,
const char *  type,
G::Error error,
  ...
 

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

Parameters:
buffer The location to receive a pointer to the new buffer.
buffer_size The location to receive the size of the new buffer.
type The name of file format.
error The return location for any error, or null.
... A variable list of key-value (char* / char*) save options.
Returns:
Whether an error was set.
This is a convenience function that uses gdk_pixbuf_save_to_callback() to do the real work. Note that the buffer is not null-terminated and may contain embedded nulls. If error is set, false will be returned and the string will be set to null. Possible errors include those in the GDK_PIXBUF_ERROR domain.

bool Xfc::Gdk::Pixbuf::save const SaveSlot slot,
const char *  type,
char **  option_keys,
char **  option_values,
G::Error error = 0
 

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

Parameters:
slot A callback slot that is called to save each block of data that the save routine generates.
type The name of file format.
option_keys The name of options to set, null-terminated.
option_values The values for the named options.
error The return location for any error, or null.
Returns:
Whether an error was set.
If error is set, false will be returned.

bool Xfc::Gdk::Pixbuf::save const SaveSlot slot,
const char *  type,
G::Error error,
  ...
 

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

Parameters:
slot A callback slot that is called to save each block of data that the save routine generates.
type The name of file format.
error The return location for any error, or null.
... A variable list of key-value (char* / char*) save options.
Returns:
Whether an error was set.
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.

bool Xfc::Gdk::Pixbuf::save const String filename,
const char *  type,
char **  option_keys,
char **  option_values,
G::Error error = 0
 

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

Parameters:
filename The name of the file to save.
type The name of the file format.
option_keys The name of the options to set, null-terminated;
option_values The values for the named options.
error The return location for any error, or null to ignore errors.
Returns:
true if an error was set.
If error is set, false will be returned. Possible errors include those in the GDK_PIXBUF_ERROR and the G_FILE_ERROR domains.

bool Xfc::Gdk::Pixbuf::save const String filename,
const char *  type,
G::Error error,
  ...
 

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

Parameters:
filename The name of the file to save.
type The name of the file format.
error The return location for any error, or null to ignore errors.
... A variable list of key-value (char* / char*) save options.
Returns:
true if an error was set.
If error is set, false will be returned. Possible errors include those in the GDK_PIXBUF_ERROR and the G_FILE_ERROR domains. The variable argument list should be null-terminated; if not empty, it should contain pairs of character strings that modify the save parameters. For example:
             G::Error error;
             pixbuf->save(filename, "jpeg", &error, "quality", "100", 0);
Currently only a few parameters exist. JPEG images can be saved with a "quality" parameter with a value 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.

void Xfc::Gdk::Pixbuf::scale const Pixbuf src,
const Rectangle dest_rect,
double  offset_x,
double  offset_y,
double  scale_x,
double  scale_y,
InterpType  interp_type
 

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_rect of the resulting image onto the destination image replacing the previous contents.

Parameters:
src The source pixbuf.
dest_rect The rectangular 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.
Try to use scale_simple() first, this method is the industrial-strength power tool you can fall back to if scale_simple() isn't powerful enough.

void Xfc::Gdk::Pixbuf::scale const Pixbuf src,
int  dest_x,
int  dest_y,
int  dest_width,
int  dest_height,
double  offset_x,
double  offset_y,
double  scale_x,
double  scale_y,
InterpType  interp_type
 

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.

Parameters:
src The source pixbuf.
dest_x The left coordinate for the region to render.
dest_y The top coordinate for the 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.
Try to use scale_simple() first, this method is the industrial-strength power tool you can fall back to if scale_simple() isn't powerful enough.

Pointer<Pixbuf> Xfc::Gdk::Pixbuf::scale_simple int  width,
int  height,
InterpType  interp_type
 

Create a new pixbuf containing a copy of this pixbuf scaled to width x height.

Parameters:
width The width of destination image.
height The height of destination image.
interp_type The interpolation type for the transformation.
Returns:
A smart pointer to the new pixbuf, or null if not enough memory could be allocated for it.
Leaves this pixbuf 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 this pixbuf by constructing a sub-pixbuf pointing into this pixbuf.

For more complicated scaling/compositing see scale() and composite().


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3