#include <gr_UnixImage.h>
Public Member Functions | |
GR_UnixImage (const char *pszName) | |
GR_UnixImage (const char *pszName, GdkPixbuf *pPixbif) | |
GR_UnixImage (const char *pszName, GRType imageType) | |
virtual | ~GR_UnixImage () |
virtual bool | convertToBuffer (UT_ConstByteBufPtr &ppBB) const |
virtual bool | convertFromBuffer (const UT_ConstByteBufPtr &pBB, const std::string &mimetype, UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight) |
bool | saveToPNG (const char *szFile) |
virtual bool | hasAlpha (void) const |
virtual UT_sint32 | rowStride (void) const |
virtual GR_Image::GRType | getType (void) const |
GdkPixbuf * | getData (void) const |
void | setData (GdkPixbuf *data) |
virtual void | scaleImageTo (GR_Graphics *pG, const UT_Rect &rec) |
virtual bool | isTransparentAt (UT_sint32 x, UT_sint32 y) |
void | scale (UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight) |
virtual void | cairoSetSource (cairo_t *) |
Protected Member Functions | |
virtual GR_UnixImage * | makeSubimage (const std::string &n, UT_sint32 x, UT_sint32 y, UT_sint32 w, UT_sint32 h) const |
Private Attributes | |
GdkPixbuf * | m_image |
GR_Image::GRType | m_ImageType |
GR_UnixImage::GR_UnixImage | ( | const char * | szName | ) |
From Martin. I spent a LOT of time in class tracking down terrible Memory leaks because the only way to delete a pixbuf from memory is to unref an object of reference count 1. Unfortunately I discovered from experience that some operations appear to leave reference count in an undefined state.
So a note to future hackers in this class. Please keep a close eye on the reference count on the GdkPixbuf's and keep the liberal asserts I've placed.
References m_ImageType, and GR_Image::setName().
Referenced by GR_RSVGVectorImage::renderToSurface().
GR_UnixImage::GR_UnixImage | ( | const char * | pszName, | |
GdkPixbuf * | pPixbif | |||
) |
References m_image, m_ImageType, GR_Image::setDisplaySize(), and GR_Image::setName().
GR_UnixImage::GR_UnixImage | ( | const char * | pszName, | |
GR_Image::GRType | imageType | |||
) |
References m_ImageType, and GR_Image::setName().
void GR_UnixImage::cairoSetSource | ( | cairo_t * | cr | ) | [virtual] |
Implements GR_CairoRasterImage.
Reimplemented in GR_UnixCroppedImage.
References GR_Image::getDisplayHeight(), GR_Image::getDisplayWidth(), m_image, and UT_return_if_fail.
bool GR_UnixImage::convertFromBuffer | ( | const UT_ConstByteBufPtr & | pBB, | |
const std::string & | mimetype, | |||
UT_sint32 | iDisplayWidth, | |||
UT_sint32 | iDisplayHeight | |||
) | [virtual] |
Loads an image from from a byte buffer. Note: If the specified width and/or height does not match the size of the image contained in the byte buffer, some image information will be lost. WARNING: TODO
iDisplayWidth | the width to which the image needs to be scaled. Values are in device units. Setting this to -1 will cause the image not to be scaled. | |
iDisplayheight | the height to which the image needs to be scaled. Values are in device units. Setting this to -1 will cause the image not to be scaled. |
Implements GR_Image.
References m_image, GR_Image::setDisplaySize(), UT_ASSERT, and UT_DEBUGMSG.
bool GR_UnixImage::convertToBuffer | ( | UT_ConstByteBufPtr & | pBB | ) | const [virtual] |
This method fills a byte buffer with a PNG representation of itself. This can be saved in the PT as a data-item and recreated. ppBB is a pointer to a pointer of a byte buffer. It's the callers job to delete it.
Implements GR_Image.
References convCallback(), abicollab::service::error(), m_image, and UT_ASSERT.
GdkPixbuf* GR_UnixImage::getData | ( | void | ) | const [inline] |
Referenced by GR_UnixCroppedImage::cairoSetSource().
GR_Image::GRType GR_UnixImage::getType | ( | void | ) | const [virtual] |
Reimplemented from GR_RasterImage.
References m_ImageType.
bool GR_UnixImage::hasAlpha | ( | void | ) | const [virtual] |
Implements GR_RasterImage.
References m_image, and UT_return_val_if_fail.
Referenced by isTransparentAt().
Returns true if pixel at point (x,y) in device units is transparent.
Implements GR_RasterImage.
References hasAlpha(), m_image, UT_ASSERT, UT_DEBUGMSG, UT_return_val_if_fail, and xxx_UT_DEBUGMSG.
GR_UnixImage * GR_UnixImage::makeSubimage | ( | const std::string & | n, | |
UT_sint32 | x, | |||
UT_sint32 | y, | |||
UT_sint32 | w, | |||
UT_sint32 | h | |||
) | const [protected, virtual] |
Implements GR_CairoRasterImage.
References GR_UnixCroppedImage::crop(), GR_Image::getDisplayHeight(), GR_Image::getDisplayWidth(), m_image, and GR_Image::setDisplaySize().
UT_sint32 GR_UnixImage::rowStride | ( | void | ) | const [virtual] |
References m_image, and UT_return_val_if_fail.
bool GR_UnixImage::saveToPNG | ( | const char * | szFile | ) |
References abicollab::service::error(), m_image, and UT_return_val_if_fail.
References m_image, GR_Image::setDisplaySize(), and UT_return_if_fail.
Referenced by GR_RSVGVectorImage::renderToSurface(), and scaleImageTo().
void GR_UnixImage::scaleImageTo | ( | GR_Graphics * | pG, | |
const UT_Rect & | rec | |||
) | [virtual] |
Scale our image to rectangle given by rec. The dimensions of rec are calculated in logical units.
Reimplemented from GR_Image.
References UT_Rect::height, scale(), GR_Graphics::tdu(), and UT_Rect::width.
void GR_UnixImage::setData | ( | GdkPixbuf * | data | ) | [inline] |
Referenced by GR_UnixCairoGraphics::genImageFromRectangle().
GdkPixbuf* GR_UnixImage::m_image [private] |
Referenced by cairoSetSource(), convertFromBuffer(), convertToBuffer(), GR_UnixImage(), hasAlpha(), isTransparentAt(), makeSubimage(), rowStride(), saveToPNG(), scale(), and ~GR_UnixImage().
GR_Image::GRType GR_UnixImage::m_ImageType [private] |
Referenced by getType(), and GR_UnixImage().