Main Page Widgets Namespaces Book

# Gdk::Pixbuf Class Reference

Inheritance diagram for Gdk::Pixbuf:

[legend]
List of all members.

## Public Types

typedef sigc::slot< void, const guint8* > | SlotDestroyData
typedef Glib::SListHandle< Glib::RefPtr<PixbufFormat>, PixbufFormatTraits > | SListHandle_PixbufFormat

## Public Member Functions

virtual | ~Pixbuf ()
GdkPixbuf* | gobj ()
| Provides access to the underlying C GObject.
const GdkPixbuf* | gobj () const
| Provides access to the underlying C GObject.
GdkPixbuf* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::RefPtr<Pixbuf> | copy () const
Colorspace | get_colorspace () const
int | get_n_channels () const
bool | get_has_alpha () const
int | get_bits_per_sample () const
guint8* | get_pixels () const
int | get_width () const
int | get_height () const
int | get_rowstride () const
void | fill (guint32 pixel)
void | save (const std::string& filename, const Glib::ustring& type)
| Save an image file.
void | save (const std::string& filename, const Glib::ustring& type, const Glib::StringArrayHandle& option_keys, const Glib::StringArrayHandle& option_values)
| Save an image file.
Glib::RefPtr<Gdk::Pixbuf> | add_alpha (bool substitute_color, guint8 r, guint8 g, guint8 b) const
void | copy_area (int src_x, int src_y, int width, int height, const Glib::RefPtr<Gdk::Pixbuf>& dest_pixbuf, int dest_x, int dest_y) const
void | saturate_and_pixelate (const Glib::RefPtr<Gdk::Pixbuf>& dest, float saturation, bool pixelate) const
void | scale (const Glib::RefPtr<Gdk::Pixbuf>& dest, 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) const
void | composite (const Glib::RefPtr<Gdk::Pixbuf>& dest, 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) const
void | composite_color (const Glib::RefPtr<Gdk::Pixbuf>& dest, 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, guint32 color1, guint32 color2) const
Glib::RefPtr<Gdk::Pixbuf> | scale_simple (int dest_width, int dest_height, InterpType interp_type) const
Glib::RefPtr<Gdk::Pixbuf> | composite_color_simple (int dest_width, int dest_height, InterpType interp_type, int overall_alpha, int check_size, guint32 color1, guint32 color2) const
void | render_threshold_alpha (const Glib::RefPtr<Gdk::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 a pixbuf and thresholds them to produce a bi-level alpha mask that can be used as a clipping mask for a drawable.
void | render_to_drawable (const Glib::RefPtr<Drawable>& drawable, const Glib::RefPtr<Gdk::GC>& gc, int src_x, int src_y, int dest_x, int dest_y, int width, int height, RgbDither dither, int x_dither, int y_dither)
| Renders a rectangular portion of a pixbuf to a drawable while using the specified GC.
void | render_to_drawable_alpha (const Glib::RefPtr<Drawable>& drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height, PixbufAlphaMode alpha_mode, int alpha_threshold, RgbDither dither, int x_dither, int y_dither)
| Renders a rectangular portion of a pixbuf to a drawable.
void | render_pixmap_and_mask_for_colormap (const Glib::RefPtr<Colormap>& colormap, Glib::RefPtr<Pixmap>& pixmap_return, Glib::RefPtr<Bitmap>& mask_return, int alpha_threshold)
void | render_pixmap_and_mask (Glib::RefPtr<Pixmap>& pixmap_return, Glib::RefPtr<Bitmap>& mask_return, int alpha_threshold)
Glib::ustring | get_option (const Glib::ustring& key) const

## Static Public Member Functions

Glib::RefPtr<Pixbuf> | create (const Glib::RefPtr<Drawable>& src, const Glib::RefPtr<Colormap>& cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
Glib::RefPtr<Pixbuf> | create (const Glib::RefPtr<Image>& src, const Glib::RefPtr<Colormap>& cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
Glib::RefPtr<Pixbuf> | create (Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height)
Glib::RefPtr<Pixbuf> | create_subpixbuf (const Glib::RefPtr<Pixbuf>& src_pixbuf, int src_x, int src_y, int width, int height)
Glib::RefPtr<Pixbuf> | create_from_file (const std::string& filename)
| Load an image file.
Glib::RefPtr<Pixbuf> | create_from_data (const guint8* data, Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride)
| Creates a new Gdk::Pixbuf out of in-memory image data.
Glib::RefPtr<Pixbuf> | create_from_data (const guint8* data, Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, const SlotDestroyData& destroy_slot)
| Creates a new Gdk::Pixbuf out of in-memory image data.
Glib::RefPtr<Pixbuf> | create_from_xpm_data (const char* const* data)
Glib::RefPtr<Pixbuf> | create_from_inline (int data_length, const guint8* data, bool copy_pixels=false)
| Create a Gdk::Pixbuf from a flat representation that is suitable for storing as inline data in a program.
SListHandle_PixbufFormat | get_formats ()

## Protected Member Functions

| Pixbuf (const Glib::RefPtr<Drawable>& src, const Glib::RefPtr<Colormap>& cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
| Pixbuf (const Glib::RefPtr<Image>& src, const Glib::RefPtr<Colormap>& cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr<Gdk::Pixbuf> | wrap (GdkPixbuf* object, bool take_copy=false)

## Member Typedef Documentation

typedef Glib::SListHandle<Glib::RefPtr<PixbufFormat>, PixbufFormatTraits> Gdk::Pixbuf::SListHandle_PixbufFormat

typedef sigc::slot<void, const guint8*> Gdk::Pixbuf::SlotDestroyData

## Constructor & Destructor Documentation

virtual Gdk::Pixbuf::~Pixbuf | ( |  | ) | `[virtual]`

Gdk::Pixbuf::Pixbuf | ( | const Glib::RefPtr<Drawable>& | src,
|  | const Glib::RefPtr<Colormap>& | cmap,
|  | int | src_x,
|  | int | src_y,
|  | int | dest_x,
|  | int | dest_y,
|  | int | width,
|  | int | height
| ) | `[protected]`

Gdk::Pixbuf::Pixbuf | ( | const Glib::RefPtr<Image>& | src,
|  | const Glib::RefPtr<Colormap>& | cmap,
|  | int | src_x,
|  | int | src_y,
|  | int | dest_x,
|  | int | dest_y,
|  | int | width,
|  | int | height
| ) | `[protected]`

## Member Function Documentation

Glib::RefPtr<Gdk::Pixbuf> Gdk::Pixbuf::add_alpha | ( | bool | substitute_color,
|  | guint8 | r,
|  | guint8 | g,
|  | guint8 | b
| ) | const

void Gdk::Pixbuf::composite | ( | const Glib::RefPtr<Gdk::Pixbuf>& | dest,
|  | 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
| ) | const

void Gdk::Pixbuf::composite_color | ( | const Glib::RefPtr<Gdk::Pixbuf>& | dest,
|  | 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,
|  | guint32 | color1,
|  | guint32 | color2
| ) | const

Glib::RefPtr<Gdk::Pixbuf> Gdk::Pixbuf::composite_color_simple | ( | int | dest_width,
|  | int | dest_height,
|  | InterpType | interp_type,
|  | int | overall_alpha,
|  | int | check_size,
|  | guint32 | color1,
|  | guint32 | color2
| ) | const

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::copy | ( |  | ) | const

void Gdk::Pixbuf::copy_area | ( | int | src_x,
|  | int | src_y,
|  | int | width,
|  | int | height,
|  | const Glib::RefPtr<Gdk::Pixbuf>& | dest_pixbuf,
|  | int | dest_x,
|  | int | dest_y
| ) | const

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create | ( | Colorspace | colorspace,
|  | bool | has_alpha,
|  | int | bits_per_sample,
|  | int | width,
|  | int | height
| ) | `[static]`

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create | ( | const Glib::RefPtr<Image>& | src,
|  | const Glib::RefPtr<Colormap>& | cmap,
|  | int | src_x,
|  | int | src_y,
|  | int | dest_x,
|  | int | dest_y,
|  | int | width,
|  | int | height
| ) | `[static]`

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create | ( | const Glib::RefPtr<Drawable>& | src,
|  | const Glib::RefPtr<Colormap>& | cmap,
|  | int | src_x,
|  | int | src_y,
|  | int | dest_x,
|  | int | dest_y,
|  | int | width,
|  | int | height
| ) | `[static]`

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create_from_data | ( | const guint8* | data,
|  | Colorspace | colorspace,
|  | bool | has_alpha,
|  | int | bits_per_sample,
|  | int | width,
|  | int | height,
|  | int | rowstride,
|  | const SlotDestroyData& | destroy_slot
| ) | `[static]`

Creates a new Gdk::Pixbuf out of in-memory image data.

Currently only RGB images with 8 bits per sample are supported.

Parameters:

  | 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 rows.
  | destroy_slot | Slot used to free the data when the pixbuf's reference count drops to zero.

Returns:
  A newly-created Gdk::Pixbuf object.

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create_from_data | ( | const guint8* | data,
|  | Colorspace | colorspace,
|  | bool | has_alpha,
|  | int | bits_per_sample,
|  | int | width,
|  | int | height,
|  | int | rowstride
| ) | `[static]`

Creates a new Gdk::Pixbuf out of in-memory image data.

Currently only RGB images with 8 bits per sample are supported.

Parameters:

  | 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 rows.

Returns:
  A newly-created Gdk::Pixbuf object.

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create_from_file | ( | const std::string& | filename | ) | `[static]`

Load an image file.

Exceptions:

  | Glib::FileError |
  | Gdk::PixbufError |

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create_from_inline | ( | int | data_length,
|  | const guint8* | data,
|  | bool | copy_pixels = `false`
| ) | `[static]`

Create a Gdk::Pixbuf 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, 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.

Parameters:

  | data_length | Length in bytes of the data argument.
  | data | Byte data containing a serialized GdkPixdata structure.
  | copy_pixels | Whether to copy the pixel data, or use direct pointers to data for the resulting pixbuf.

Exceptions:

  | Gdk::PixbufError |

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create_from_xpm_data | ( | const char *const* | data | ) | `[static]`

Glib::RefPtr<Pixbuf> Gdk::Pixbuf::create_subpixbuf | ( | const Glib::RefPtr<Pixbuf>& | src_pixbuf,
|  | int | src_x,
|  | int | src_y,
|  | int | width,
|  | int | height
| ) | `[static]`

Parameters:

  | src_pixbuf | A Gdk::Pixbuf.
  | 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 .

void Gdk::Pixbuf::fill | ( | guint32 | pixel | ) |

int Gdk::Pixbuf::get_bits_per_sample | ( |  | ) | const

Colorspace Gdk::Pixbuf::get_colorspace | ( |  | ) | const

SListHandle_PixbufFormat Gdk::Pixbuf::get_formats | ( |  | ) | `[static]`

bool Gdk::Pixbuf::get_has_alpha | ( |  | ) | const

int Gdk::Pixbuf::get_height | ( |  | ) | const

int Gdk::Pixbuf::get_n_channels | ( |  | ) | const

Glib::ustring Gdk::Pixbuf::get_option | ( | const Glib::ustring& | key | ) | const

guint8* Gdk::Pixbuf::get_pixels | ( |  | ) | const

int Gdk::Pixbuf::get_rowstride | ( |  | ) | const

int Gdk::Pixbuf::get_width | ( |  | ) | const

const GdkPixbuf* Gdk::Pixbuf::gobj | ( |  | ) | const`[inline]`

| Provides access to the underlying C GObject. Reimplemented from Glib::ObjectBase.

GdkPixbuf* Gdk::Pixbuf::gobj | ( |  | ) | `[inline]`

| Provides access to the underlying C GObject. Reimplemented from Glib::ObjectBase.

GdkPixbuf* Gdk::Pixbuf::gobj_copy | ( |  | ) |

| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gdk::Pixbuf::render_pixmap_and_mask | ( | Glib::RefPtr<Pixmap>& | pixmap_return,
|  | Glib::RefPtr<Bitmap>& | mask_return,
|  | int | alpha_threshold
| ) |

void Gdk::Pixbuf::render_pixmap_and_mask_for_colormap | ( | const Glib::RefPtr<Colormap>& | colormap,
|  | Glib::RefPtr<Pixmap>& | pixmap_return,
|  | Glib::RefPtr<Bitmap>& | mask_return,
|  | int | alpha_threshold
| ) |

void Gdk::Pixbuf::render_threshold_alpha | ( | const Glib::RefPtr<Gdk::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 a pixbuf and thresholds them to produce a bi-level alpha mask that can be used as a clipping mask for a drawable.

Parameters:

  | 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::render_to_drawable | ( | const Glib::RefPtr<Drawable>& | drawable,
|  | const Glib::RefPtr<Gdk::GC>& | gc,
|  | int | src_x,
|  | int | src_y,
|  | int | dest_x,
|  | int | dest_y,
|  | int | width,
|  | int | height,
|  | RgbDither | dither,
|  | int | x_dither,
|  | int | y_dither
| ) |

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.

Deprecated: This function is obsolete. Use gdk_draw_pixbuf() instead.

Parameters:

  | 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::render_to_drawable_alpha | ( | const Glib::RefPtr<Drawable>& | drawable,
|  | int | src_x,
|  | int | src_y,
|  | int | dest_x,
|  | int | dest_y,
|  | int | width,
|  | int | height,
|  | PixbufAlphaMode | alpha_mode,
|  | int | alpha_threshold,
|  | RgbDither | dither,
|  | int | x_dither,
|  | int | y_dither
| ) |

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-`0` 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.

Deprecated: This function is obsolete. Use gdk_draw_pixbuf() instead.

Parameters:

  | 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.

void Gdk::Pixbuf::saturate_and_pixelate | ( | const Glib::RefPtr<Gdk::Pixbuf>& | dest,
|  | float | saturation,
|  | bool | pixelate
| ) | const

void Gdk::Pixbuf::save | ( | const std::string& | filename,
|  | const Glib::ustring& | type,
|  | const Glib::StringArrayHandle& | option_keys,
|  | const Glib::StringArrayHandle& | option_values
| ) |

Save an image file.

Exceptions:

  | Glib::FileError |
  | Gdk::PixbufError |

void Gdk::Pixbuf::save | ( | const std::string& | filename,
|  | const Glib::ustring& | type
| ) |

Save an image file.

Exceptions:

  | Glib::FileError |
  | Gdk::PixbufError |

void Gdk::Pixbuf::scale | ( | const Glib::RefPtr<Gdk::Pixbuf>& | dest,
|  | 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
| ) | const

Glib::RefPtr<Gdk::Pixbuf> Gdk::Pixbuf::scale_simple | ( | int | dest_width,
|  | int | dest_height,
|  | InterpType | interp_type
| ) | const

## Friends And Related Function Documentation

Glib::RefPtr<Gdk::Pixbuf> wrap | ( | GdkPixbuf* | object,
|  | bool | take_copy = `false`
| ) | `[related]`

Parameters:

  | object | The C instance
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- pixbuf.h