Main Page | Class Hierarchy | Class List | File List | Class Members

LIBCP::Image Class Reference

represents an image More...

#include <image.h>

Inheritance diagram for LIBCP::Image:

LIBCP::BaseImage LIBCP::DataObject List of all members.

Public Member Functions

Uint8 * pixel (int x, int y)
void lock ()
void unlock ()
int depth ()
int pitch ()
bool isValidPixel (int x, int y)
void setBuffer (void *buffer)
Imageoperator= (Image &i)
void * getBuffer ()

Static Public Member Functions

ImagecreateImage (int width, int height, int type)
ImagecreateImage (void *buffer, int width, int height, int type)

Detailed Description

represents an image


Member Function Documentation

Image * LIBCP::Image::createImage void *  buffer,
int  width,
int  height,
int  type
[static]
 

Creates an image instance from a given image data buffer. buffer is the data buffer. For a color image the data should be aranged as RBG(A) for each pixel. The values are unsigned chars width is the physical width of the image height is the physical height of the image type is one of BaseImage::BINARY, BaseImage::GRAY, BaseImage::COLOR24 or BaseImage::COLOR32 a pointer to the newly create image instance

Image * LIBCP::Image::createImage int  width,
int  height,
int  type
[static]
 

Creates an image instance with empty (black) buffer width is the physical width of the image height is the physical height of the image type is one of BaseImage::BINARY, BaseImage::GRAY, BaseImage::COLOR24 or BaseImage::COLOR32 a pointer to the newly create image instance

int LIBCP::Image::depth  ) 
 

Returns the depth of this image in byte per pixel (1,3 or 4) the depth as integer

void * LIBCP::Image::getBuffer  ) 
 

Returns a pointer to the images data buffer a void pointer

bool LIBCP::Image::isValidPixel int  x,
int  y
 

Checks if the coordinates correspond to a valid pixel in the image x the x coordinate of the pixel to check y the x coordinate of the pixel to check true if the pixel is inside the image, otherwise false

void LIBCP::Image::lock  ) 
 

Locks this image. You should always lock images before performing any operation on it. All build in library functions lock and unlock the image correctly already. So if you are just using library functions, you do not have to worry about it. unlock

Reimplemented from LIBCP::BaseImage.

Image & LIBCP::Image::operator= Image i  ) 
 

The overloaded equal operator for the image class

int LIBCP::Image::pitch  ) 
 

Returns the pitch of this image. The pitch is basicly the width multiplied with the depth. It corresponds to the memory needed for one row of the image. the pitch of the image

Uint8 * LIBCP::Image::pixel int  x,
int  y
 

Returns a pointer to the position in the image buffer where pixel (x,y) is stored. Use pixel(x,y)[0] for the red part of the pixel color. pixel(x,y)[1], pixel(x,y)[2] are green and blue. For images with 32bit depth pixel(x,y)[3] is the alpha value.
Binary or grayscale images pixels are just straight forward adressed as pixel(x,y)[0].
There is no range checking done in this function and adressing pixels outside the image results in segmentation faults. isValidPixel x is the x coordinate of the pixel y is the y coordinate of the pixel a Uint8 (unsigned char) pointer to the pixel

void LIBCP::Image::setBuffer void *  buffer  ) 
 

Sets a new data buffer for this image. Be carefull with that, since no checking for the image width, height and type is done.
In most cases it is better to create a new image instance than to set a new buffer to an existing one. buffer is the new buffer for this image

void LIBCP::Image::unlock  ) 
 

Unlocks this image. You should always lock images before performing any operation on it. All build in library functions lock and unlock the image correctly already. So if you are just using library functions, you do not have to worry about it. lock

Reimplemented from LIBCP::BaseImage.


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:43:53 2004 for libcp by doxygen 1.3.7