#include <dms/Image.h> Image(void); Image(GLsizei width, GLsizei height, void *data=0); ~Image(void); GLsizei width(void) const; GLsizei height(void) const; void *data(void) const; void setSize(GLsizei width, GLsizei height); void setData(void *); void allocateData(void); void freeData(void);
Image(void) Image(GLsizei width, GLsizei height, void *data=0)
The default constructor sets the image to have 0 width and height, and
a null data pointer.
The alternate constructor can be passed values for the width, heigh, and
data pointer.
Example:
char imagedata[16][16][4]; Image image(16, 16, imagedata);
GLsizei width(void) GLsizei height(void)
Return the width and height of the Image.
void *data(void)
Returns the pixel data pointer for the Image.
void setSize(GLsizei width, GLsizei height)
Defines the width and height of the Image.
void setData(void *data)
Defines the pixel data pointer of the Image.
void allocateData(void)
Internally allocates space for the pixel data pointer, via malloc().
The amount
of space allocated is enough for width() * height() 4 byte
(RGBA) pixels.
If the Image already has a data pointer value, and that
pointer is from a previous call to allocateData(), the previously
allocated data is freed; if the pointer is from setData(),
it is not freed, but its value is lost.
Example:
image.setSize(100, 100); image.allocateData(); memset(image.data(), 0, 100*100*sizeof(unsigned int));
void freeData(void)
Frees the space allocated for the pixel data, via the system function free(). This will be done whether or not the Image allocated the data itself. The data pointer is set to null (0) after the space is freed.