Inkscape
Vector Graphics Editor
|
Class to hold image data for raster images. More...
#include <cairo-utils.h>
Public Types | |
enum | PixelFormat { PF_CAIRO = 1 , PF_GDK = 2 , PF_LAST } |
Public Member Functions | |
Pixbuf (cairo_surface_t *s) | |
Create a pixbuf from a Cairo surface. | |
Pixbuf (GdkPixbuf *pb) | |
Create a pixbuf from a GdkPixbuf. | |
Pixbuf (Inkscape::Pixbuf const &other) | |
~Pixbuf () | |
Pixbuf * | cropTo (const Geom::IntRect &area) const |
Create a new Pixbuf with the image cropped to the given area. | |
GdkPixbuf * | getPixbufRaw (bool convert_format=true) |
Converts the pixbuf to GdkPixbuf pixel format. | |
GdkPixbuf * | getPixbufRaw () const |
cairo_surface_t * | getSurfaceRaw () |
Converts the pixbuf to Cairo pixel format and returns an image surface which can be used as a source. | |
cairo_surface_t * | getSurfaceRaw () const |
Cairo::RefPtr< Cairo::Surface > | getSurface () |
int | width () const |
int | height () const |
int | rowstride () const |
guchar const * | pixels () const |
guchar * | pixels () |
void | markDirty () |
bool | hasMimeData () const |
guchar const * | getMimeData (gsize &len, std::string &mimetype) const |
Retrieves the original compressed data for the surface, if any. | |
std::string const & | originalPath () const |
time_t | modificationTime () const |
PixelFormat | pixelFormat () const |
void | ensurePixelFormat (PixelFormat fmt) |
Convert the internal pixel format between CAIRO and GDK formats. | |
Static Public Member Functions | |
static void | ensure_pixbuf (GdkPixbuf *pb) |
Converts GdkPixbuf's data back to its native format. | |
static void | ensure_argb32 (GdkPixbuf *pb) |
Converts GdkPixbuf's data to premultiplied ARGB. | |
static Pixbuf * | create_from_data_uri (gchar const *uri, double svgdpi=0) |
static Pixbuf * | create_from_file (std::string const &fn, double svgddpi=0) |
static Pixbuf * | create_from_buffer (std::string const &, double svgddpi=0, std::string const &fn="") |
Private Member Functions | |
void | _ensurePixelsARGB32 () |
void | _ensurePixelsPixbuf () |
void | _forceAlpha () |
void | _setMimeData (guchar *data, gsize len, Glib::ustring const &format) |
Static Private Member Functions | |
static Pixbuf * | create_from_buffer (gchar *&&, gsize, double svgddpi=0, std::string const &fn="") |
static Geom::Affine | get_embedded_orientation (GdkPixbuf *buf) |
Gets any available orientation data and returns it as an affine. | |
static GdkPixbuf * | apply_embedded_orientation (GdkPixbuf *buf) |
Private Attributes | |
GdkPixbuf * | _pixbuf |
cairo_surface_t * | _surface |
time_t | _mod_time |
std::string | _path |
PixelFormat | _pixel_format |
bool | _cairo_store |
Class to hold image data for raster images.
Allows easy interoperation with GdkPixbuf and Cairo.
Definition at line 31 of file cairo-utils.h.
Enumerator | |
---|---|
PF_CAIRO | |
PF_GDK | |
PF_LAST |
Definition at line 33 of file cairo-utils.h.
|
explicit |
Create a pixbuf from a Cairo surface.
The constructor takes ownership of the passed surface, so it should not be destroyed.
Definition at line 89 of file cairo-utils.cpp.
|
explicit |
Create a pixbuf from a GdkPixbuf.
The constructor takes ownership of the passed GdkPixbuf reference, so it should not be unrefed.
Definition at line 104 of file cairo-utils.cpp.
References _forceAlpha(), _pixbuf, and _surface.
Inkscape::Pixbuf::Pixbuf | ( | Inkscape::Pixbuf const & | other | ) |
Definition at line 117 of file cairo-utils.cpp.
Inkscape::Pixbuf::~Pixbuf | ( | ) |
Definition at line 128 of file cairo-utils.cpp.
References _cairo_store, _pixbuf, and _surface.
|
private |
|
private |
|
private |
|
private |
Definition at line 576 of file cairo-utils.cpp.
References _surface, data, and len.
Referenced by create_from_buffer(), and create_from_data_uri().
Definition at line 306 of file cairo-utils.cpp.
References buf.
Referenced by create_from_buffer(), and create_from_data_uri().
|
staticprivate |
Definition at line 354 of file cairo-utils.cpp.
References _path, _setMimeData(), apply_embedded_orientation(), buf, SPDocument::createNewDocFromMem(), data, fmt, Inkscape::Preferences::get(), get_embedded_orientation(), Inkscape::Preferences::getDouble(), getPixbufRaw(), Geom::identity(), len, sp_generate_internal_bitmap(), and Inkscape::Util::Quantity::value().
|
static |
Definition at line 344 of file cairo-utils.cpp.
References create_from_buffer().
Referenced by create_from_buffer(), create_from_file(), SPImage::getBrokenImage(), FontInstance::PixBuf(), and SPImage::readImage().
|
static |
Definition at line 182 of file cairo-utils.cpp.
References _setMimeData(), apply_embedded_orientation(), buf, SPDocument::createNewDocFromMem(), data, extract_uri_data(), fmt, Inkscape::Preferences::get(), get_embedded_orientation(), Inkscape::Preferences::getDouble(), getPixbufRaw(), Geom::identity(), RASTER, sp_generate_internal_bitmap(), SVG, and Inkscape::Util::Quantity::value().
Referenced by SPImage::readImage().
|
static |
Definition at line 267 of file cairo-utils.cpp.
References _mod_time, create_from_buffer(), data, and len.
Referenced by Inkscape::Extension::Internal::GdkpixbufInput::open(), Inkscape::Extension::Internal::Svg::open(), SPImage::readImage(), and SPFeImage::try_load_image().
Pixbuf * Inkscape::Pixbuf::cropTo | ( | const Geom::IntRect & | area | ) | const |
Create a new Pixbuf with the image cropped to the given area.
Definition at line 163 of file cairo-utils.cpp.
References _pixbuf, _pixel_format, ensure_pixbuf(), Geom::GenericRect< C >::height(), Geom::GenericRect< C >::left(), PF_CAIRO, Geom::GenericRect< C >::top(), and Geom::GenericRect< C >::width().
|
static |
Converts GdkPixbuf's data to premultiplied ARGB.
This function will convert a GdkPixbuf in place into Cairo's native pixel format. Note that this is a hack intended to save memory. When the pixbuf is in Cairo's format, using it with GTK will result in corrupted drawings.
Definition at line 619 of file cairo-utils.cpp.
References convert_pixels_pixbuf_to_argb32().
Referenced by ensurePixelFormat().
|
static |
Converts GdkPixbuf's data back to its native format.
Once this is done, the pixbuf can be used with GTK again.
Definition at line 632 of file cairo-utils.cpp.
References convert_pixels_argb32_to_pixbuf().
Referenced by cropTo(), and ensurePixelFormat().
void Inkscape::Pixbuf::ensurePixelFormat | ( | PixelFormat | fmt | ) |
Convert the internal pixel format between CAIRO and GDK formats.
Definition at line 600 of file cairo-utils.cpp.
References _pixbuf, _pixel_format, ensure_argb32(), ensure_pixbuf(), fmt, PF_CAIRO, and PF_GDK.
Referenced by getPixbufRaw(), getSurfaceRaw(), and SPImage::update().
|
staticprivate |
Gets any available orientation data and returns it as an affine.
Definition at line 317 of file cairo-utils.cpp.
References buf, and Geom::identity().
Referenced by create_from_buffer(), and create_from_data_uri().
guchar const * Inkscape::Pixbuf::getMimeData | ( | gsize & | len, |
std::string & | mimetype | ||
) | const |
Retrieves the original compressed data for the surface, if any.
The returned data belongs to the object and should not be freed.
Definition at line 527 of file cairo-utils.cpp.
References _surface, data, and len.
Referenced by sp_embed_image().
GdkPixbuf * Inkscape::Pixbuf::getPixbufRaw | ( | ) | const |
Definition at line 476 of file cairo-utils.cpp.
References _pixbuf, _pixel_format, and PF_GDK.
GdkPixbuf * Inkscape::Pixbuf::getPixbufRaw | ( | bool | convert_format = true | ) |
Converts the pixbuf to GdkPixbuf pixel format.
The returned pixbuf can be used e.g. in calls to gdk_pixbuf_save().
Definition at line 468 of file cairo-utils.cpp.
References _pixbuf, ensurePixelFormat(), and PF_GDK.
Referenced by create_from_buffer(), create_from_data_uri(), and sp_embed_image().
Cairo::RefPtr< Cairo::Surface > Inkscape::Pixbuf::getSurface | ( | ) |
Definition at line 520 of file cairo-utils.cpp.
References getSurfaceRaw().
cairo_surface_t * Inkscape::Pixbuf::getSurfaceRaw | ( | ) |
Converts the pixbuf to Cairo pixel format and returns an image surface which can be used as a source.
The returned surface is owned by the GdkPixbuf and should not be freed. Calling this function causes the pixbuf to be unsuitable for use with GTK drawing functions until ensurePixelFormat(Pixbuf::PIXEL_FORMAT_PIXBUF) is called.
Definition at line 490 of file cairo-utils.cpp.
References _surface, ensurePixelFormat(), and PF_CAIRO.
Referenced by getSurface(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_to_raster(), and Inkscape::Extension::Internal::CairoRenderContext::renderImage().
cairo_surface_t * Inkscape::Pixbuf::getSurfaceRaw | ( | ) | const |
Definition at line 496 of file cairo-utils.cpp.
References _pixel_format, _surface, and PF_CAIRO.
bool Inkscape::Pixbuf::hasMimeData | ( | ) | const |
int Inkscape::Pixbuf::height | ( | ) | const |
Definition at line 551 of file cairo-utils.cpp.
References _pixbuf.
Referenced by SPImage::description(), and Inkscape::Extension::Internal::CairoRenderContext::renderImage().
void Inkscape::Pixbuf::markDirty | ( | ) |
Definition at line 563 of file cairo-utils.cpp.
References _surface.
|
inline |
Definition at line 63 of file cairo-utils.h.
References _mod_time.
|
inline |
Definition at line 62 of file cairo-utils.h.
References _path.
|
inline |
Definition at line 65 of file cairo-utils.h.
References _pixel_format.
Referenced by Inkscape::Extension::Internal::PrintEmf::create_brush(), Inkscape::Extension::Internal::PrintWmf::create_brush(), and Inkscape::Extension::Internal::PrintEmf::create_pen().
guchar * Inkscape::Pixbuf::pixels | ( | ) |
Definition at line 560 of file cairo-utils.cpp.
References _pixbuf.
guchar const * Inkscape::Pixbuf::pixels | ( | ) | const |
Definition at line 557 of file cairo-utils.cpp.
References _pixbuf.
Referenced by Inkscape::Extension::Internal::PrintEmf::create_brush(), Inkscape::Extension::Internal::PrintWmf::create_brush(), and Inkscape::Extension::Internal::PrintEmf::create_pen().
int Inkscape::Pixbuf::rowstride | ( | ) | const |
Definition at line 554 of file cairo-utils.cpp.
References _pixbuf.
int Inkscape::Pixbuf::width | ( | ) | const |
Definition at line 548 of file cairo-utils.cpp.
References _pixbuf.
Referenced by SPImage::description(), and Inkscape::Extension::Internal::CairoRenderContext::renderImage().
|
private |
Definition at line 89 of file cairo-utils.h.
Referenced by ~Pixbuf().
|
private |
Definition at line 86 of file cairo-utils.h.
Referenced by create_from_file(), and modificationTime().
|
private |
Definition at line 87 of file cairo-utils.h.
Referenced by create_from_buffer(), and originalPath().
|
private |
Definition at line 84 of file cairo-utils.h.
Referenced by _forceAlpha(), cropTo(), ensurePixelFormat(), getPixbufRaw(), getPixbufRaw(), height(), Pixbuf(), pixels(), pixels(), rowstride(), width(), and ~Pixbuf().
|
private |
Definition at line 88 of file cairo-utils.h.
Referenced by cropTo(), ensurePixelFormat(), getPixbufRaw(), getSurfaceRaw(), and pixelFormat().
|
private |
Definition at line 85 of file cairo-utils.h.
Referenced by _setMimeData(), getMimeData(), getSurfaceRaw(), getSurfaceRaw(), markDirty(), Pixbuf(), and ~Pixbuf().