Public Member Functions | Protected Member Functions | Private Attributes

GR_UnixImage Class Reference

#include <gr_UnixImage.h>

Inheritance diagram for GR_UnixImage:
GR_CairoRasterImage GR_RasterImage GR_Image GR_UnixCroppedImage

List of all members.

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_UnixImagemakeSubimage (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

Constructor & Destructor Documentation

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 
)
GR_UnixImage::GR_UnixImage ( const char *  pszName,
GR_Image::GRType  imageType 
)

References m_ImageType, and GR_Image::setName().

GR_UnixImage::~GR_UnixImage (  )  [virtual]

References m_image, and UT_ASSERT.


Member Function Documentation

void GR_UnixImage::cairoSetSource ( cairo_t *  cr  )  [virtual]
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

Parameters:
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.
Returns:
true if successful, false otherwise

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]
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().

bool GR_UnixImage::isTransparentAt ( UT_sint32  x,
UT_sint32  y 
) [virtual]

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]
UT_sint32 GR_UnixImage::rowStride ( void   )  const [virtual]

References m_image, and UT_return_val_if_fail.

bool GR_UnixImage::saveToPNG ( const char *  szFile  ) 
void GR_UnixImage::scale ( UT_sint32  iDisplayWidth,
UT_sint32  iDisplayHeight 
)
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]

Member Data Documentation


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