golib  0.5
goPlot::Object2DImage Class Reference

Image object. More...

#include <object2dimage.h>

Public Types

enum  { ARGB32 = 0, RGB24, A8, A1 }
 

Public Member Functions

void setImage (unsigned char *image, int format, int width, int height, int stride)
 Set image. More...
 
int format () const
 
void createImage (int format, int width, int height)
 Creates an image of (width x height) More...
 
unsigned char * data ()
 Get the data pointer. More...
 
int width () const
 Get image width. More...
 
int height () const
 Get image height. More...
 
int stride () const
 Get the stride in bytes. More...
 
virtual void draw ()
 
- Public Member Functions inherited from goPlot::Object2D
virtual void setContext (cairo_t *c)
 
const Trafo2Dtransform () const
 
void setTransform (const Trafo2D &T)
 
cairo_t * context ()
 
const cairo_t * context () const
 
bool visible () const
 
void setVisible (bool t)
 
void applyTransform (cairo_t *cr)
 

Detailed Description

Image object.

Note
Set the transform with setTransform() sensibly, so the dimensions fit in the graph this object is added to.

Member Function Documentation

◆ createImage()

void goPlot::Object2DImage::createImage ( int  format,
int  width,
int  height 
)

Creates an image of (width x height)

Note
The allocated data has stride stride(). It is found with cairo_format_stride_for_width. Keep this in mind when working with the data!
Parameters
formatFormat (see setImage)
widthWidth
heightHeight

◆ data()

unsigned char * goPlot::Object2DImage::data ( )

Get the data pointer.

Returns
Data pointer.

◆ height()

int goPlot::Object2DImage::height ( ) const

Get image height.

Returns
Height in pixels

◆ setImage()

void goPlot::Object2DImage::setImage ( unsigned char *  image,
int  format,
int  width,
int  height,
int  stride 
)

Set image.

Parameters
imageImage data (must match the format)
formatFormat, one of ARGB32, RGB24, A8, A1 (analog to Cairo)
widthWidth of the image
heightHeight of the image
strideStride (number of bytes in each row)

◆ stride()

int goPlot::Object2DImage::stride ( ) const

Get the stride in bytes.

Returns
Stride (number of bytes per row).

◆ width()

int goPlot::Object2DImage::width ( ) const

Get image width.

Returns
Width in pixels

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