This class implements an array of 2D image structures. More...
#include <CMultiImage.h>
Public Member Functions | |
cMultiImage () | |
Default constructor of cMultiImage. More... | |
virtual | ~cMultiImage () |
Destructor of cMultiImage. More... | |
cMultiImagePtr | copy () |
This method creates a copy itself. More... | |
bool | allocate (const unsigned int a_width, const unsigned int a_height, const unsigned int a_slices, const GLenum a_format=GL_RGB, const GLenum a_type=GL_UNSIGNED_BYTE) |
This method allocates a new multi image array by defining its size, pixel format and pixel type. More... | |
void | erase () |
This method deletes all image data from memory. More... | |
virtual unsigned int | getImageCount () const |
This method returns the number of images stored. More... | |
bool | convert (const unsigned int a_newFormat) |
This method converts the image to a new format passed as argument. More... | |
virtual unsigned long | getCurrentIndex () |
This method returns the index number of the current image. More... | |
virtual bool | selectImage (unsigned long a_index) |
This method sets the current image. More... | |
bool | addImage (cImage &a_image, unsigned long a_index=-1) |
This method adds an image to the set if size and format are compatible. More... | |
bool | removeImage (unsigned long a_index) |
This method removes an image from the set. More... | |
virtual void | setTransparentColor (const cColorb &a_color, const unsigned char a_transparencyLevel) |
This method defines a pixel color for all images to be transparent. More... | |
virtual void | setTransparentColor (const unsigned char a_r, const unsigned char a_g, const unsigned char a_b, const unsigned char a_transparencyLevel) |
This method defines a pixel color to be transparent for all images. More... | |
virtual void | setTransparency (const unsigned char a_transparencyLevel) |
This method defines a transparent level to all pixels of image set. More... | |
virtual void | flipHorizontal () |
This method flips all images horizontally. More... | |
virtual void | getVoxelLocation (const cVector3d &a_texCoord, int &a_voxelX, int &a_voxelY, int &a_voxelZ, bool a_clampToImageSize=true) const |
This method retrieves the nearest voxel location from a texture coordinate. More... | |
virtual void | getVoxelLocationInterpolated (const cVector3d &a_texCoord, double &a_voxelX, double &a_voxelY, double &a_voxelZ, bool a_clampToImageSize=true) const |
This method retrieves the voxel location from a texture coordinate. More... | |
virtual unsigned char * | getVoxelData (const unsigned int a_x, const unsigned int a_y, const unsigned int a_z) const |
This method returns a pointer to voxel memory data. More... | |
virtual bool | getVoxelColor (const unsigned int a_x, const unsigned int a_y, const unsigned int a_z, cColorb &a_color) const |
This method returns the color of an image voxel at location (x,y,z). More... | |
virtual bool | getVoxelColor (const unsigned int a_x, const unsigned int a_y, const unsigned int a_z, cColorf &a_color) const |
This method returns the color of an image voxel at location (x,y,z). More... | |
virtual bool | getVoxelColorInterpolated (const double a_x, const double a_y, const double a_z, cColorb &a_color) const |
This method returns the interpolated color of an image voxel at location (x,y,z). More... | |
virtual bool | getVoxelColorInterpolated (const double a_x, const double a_y, const double a_z, cColorf &a_color) const |
This method returns the interpolated color of an image voxel at location (x,y,z). More... | |
virtual void | setVoxelColor (const unsigned int a_x, const unsigned int a_y, const unsigned int a_z, const cColorb &a_color) |
This method sets the color of an image voxel at location (x,y,z). More... | |
virtual void | setVoxelColor (const unsigned int a_x, const unsigned int a_y, const unsigned int a_z, const unsigned char a_r, const unsigned char a_g, const unsigned char a_b) |
This method sets the color of an image voxel at location (x,y,z). More... | |
virtual void | setVoxelColor (const unsigned int a_x, const unsigned int a_y, const unsigned int a_z, const unsigned char a_grayLevel) |
This method sets the gray level of an image voxel at location (x,y,z). More... | |
unsigned char * | getArray () |
This method returns a pointer to the actual image data array. Use with care! More... | |
virtual bool | loadFromFile (const std::string &a_filename) |
This method loads an image file. More... | |
virtual int | loadFromFiles (const std::vector< std::string > &a_filename) |
This method loads an image set from a set of files. More... | |
virtual int | loadFromFiles (const std::string &a_basename, const std::string &a_extension, unsigned long a_max=9999) |
This method loads an image set from a set of similarly named images. More... | |
virtual bool | addFromFile (const std::string &a_filename, unsigned long a_index=-1) |
This method adds an image file to the set if size and format are compatible. More... | |
virtual bool | saveToFiles (const std::string &a_basename, const std::string &a_extension) |
This method saves all images to a set of files. More... | |
Public Member Functions inherited from chai3d::cImage | |
cImage () | |
Default constructor of cImage. More... | |
cImage (const unsigned int a_width, const unsigned int a_height, const GLenum a_format=GL_RGB, const GLenum a_type=GL_UNSIGNED_BYTE) | |
Constructor of cImage. Initializes an image by passing its width, height, pixel format and pixel type. More... | |
virtual | ~cImage () |
Destructor of cImage. More... | |
cImagePtr | copy () |
This method creates a copy itself. More... | |
bool | allocate (const unsigned int a_width, const unsigned int a_height, const GLenum a_format=GL_RGB, const GLenum a_type=GL_UNSIGNED_BYTE) |
This method allocates a new image by defining its size, pixel format and pixel type. More... | |
void | erase () |
This method deletes all image data from memory. More... | |
bool | isInitialized () const |
This method returns true if the image has been allocated in memory, false otherwise. More... | |
void | setSize (const unsigned int a_width, const unsigned int a_height) |
This method sets and allocates the size of the image by defining its width and height. More... | |
unsigned int | getWidth () const |
This method returns the width of the image. More... | |
unsigned int | getHeight () const |
This method returns the height of the image. More... | |
GLenum | getFormat () const |
This method returns the pixel format of the image (GL_RGB, GL_RGBA, GL_LUMINANCE for instance). More... | |
GLenum | getType () const |
This method returns the pixel data type. (GL_UNSIGNED_BYTE, GL_UNSIGNED_INT for instance). More... | |
unsigned int | getBitsPerPixel () const |
This method returns the number of bits per pixel used to store this image. More... | |
unsigned int | getBytesPerPixel () const |
This method returns the number of bytes per pixel used to store this image. More... | |
unsigned int | getSizeInBytes () const |
This method returns the size in bytes of the current image. More... | |
bool | convert (const unsigned int a_newFormat) |
This method converts the image to a new format passed as argument. More... | |
cImage * | getImage () |
This method returns a pointer to this cImage object. More... | |
virtual unsigned char * | getData () |
This method returns a pointer to the actual image data. Use with care! More... | |
virtual void | setData (unsigned char *a_data, const unsigned int a_dataSizeInBytes, const bool a_dealloc=false) |
This method modifies the pointer to the actual image data. Use with care! More... | |
bool | setProperties (const unsigned int a_width, const unsigned int a_height, const GLenum a_format, const GLenum a_type) |
This method overrides the properties of the image. Use with care! More... | |
virtual void | clear () |
This method clears all image pixels with a black color. More... | |
virtual void | clear (const cColorb &a_color) |
This method clears all image pixels with a color passed as argument. More... | |
virtual void | clear (const unsigned char a_r, const unsigned char a_g, const unsigned char a_b, const unsigned char a_a=0xff) |
This method clears all image pixels with a color passed as argument. More... | |
virtual void | clear (const unsigned char a_grayLevel) |
This method clears all image pixels with a level of gray passed as argument. More... | |
virtual void | getPixelLocation (const cVector3d &a_texCoord, int &a_pixelX, int &a_pixelY, bool a_clampToImageSize=true) const |
This method retrieves the nearest pixel location from a texture coordinate. More... | |
virtual void | getPixelLocationInterpolated (const cVector3d &a_texCoord, double &a_pixelX, double &a_pixelY, bool a_clampToImageSize=true) const |
This method retrieves a pixel location from a texture coordinate. More... | |
virtual bool | getPixelColor (const unsigned int a_x, const unsigned int a_y, cColorb &a_color) const |
This method returns the color of a pixel at location (x,y). More... | |
virtual bool | getPixelColor (const unsigned int a_x, const unsigned int a_y, cColorf &a_color) const |
This method returns the color of a pixel at location (x,y). More... | |
virtual bool | getPixelColorInterpolated (const double a_x, const double a_y, cColorb &a_color) const |
This method returns the interpolated color of an image pixel at location (x,y). More... | |
virtual bool | getPixelColorInterpolated (const double a_x, const double a_y, cColorf &a_color) const |
This method returns the interpolated color of an image pixel at location (x,y). More... | |
virtual void | setPixelColor (const unsigned int a_x, const unsigned int a_y, const cColorb &a_color) |
This method sets the color of a pixel at location (x,y). More... | |
virtual void | setPixelColor (const unsigned int a_x, const unsigned int a_y, const unsigned char a_r, const unsigned char a_g, const unsigned char a_b) |
This method sets the color of a pixel at location (x,y). More... | |
virtual void | setPixelColor (const unsigned int a_x, const unsigned int a_y, const unsigned char a_grayLevel) |
This method sets the gray scale of a pixel at location (x,y). More... | |
void | copyTo (const unsigned int a_sourcePosX, const unsigned int a_sourcePosY, const unsigned int a_sourceSizeX, const unsigned int a_sourceSizeY, cImagePtr a_destImage, const unsigned int a_destPosX=0, const unsigned int a_destPosY=0) |
This method copies a section of this current image to a destination image. More... | |
void | copyTo (cImagePtr a_destImage, const unsigned int a_destPosX=0, const unsigned int a_destPosY=0) |
This method copies the entire image to a destination image. More... | |
virtual bool | saveToFile (const std::string &a_filename) |
This method saves an image file by passing a filename as argument. More... | |
std::string | getFilename () const |
This method returns the filename from which this image was last loaded or saved. More... | |
Static Public Member Functions | |
static cMultiImagePtr | create () |
Shared cMultiImage allocator. More... | |
Static Public Member Functions inherited from chai3d::cImage | |
static cImagePtr | create () |
Shared cImage allocator. More... | |
static int | queryBytesPerPixel (const GLenum a_format, const GLenum a_type) |
This method queries the number of bytes per pixel for a given format. More... | |
Protected Member Functions | |
void | defaults () |
This method initializes all member variables. More... | |
void | cleanup () |
This method deletes memory and rid ourselves of any image previously stored. More... | |
virtual bool | addFromFilePrealloc (const std::string &a_filename, unsigned long a_index) |
Add an image file to a preallocated set if size and format are compatible. More... | |
bool | addImagePrealloc (cImage &a_image, unsigned long a_index) |
Add an image to a preallocated set if size and format are compatible. More... | |
Protected Member Functions inherited from chai3d::cImage | |
void | defaults () |
This method initializes all member variables. More... | |
void | cleanup () |
This method deletes memory and rid ourselves of any image previously stored. More... | |
Protected Attributes | |
unsigned char * | m_array |
The image array data that holds all images contiguously. More... | |
unsigned long | m_imageCount |
Number of images contained in the structure. More... | |
unsigned long | m_currentIndex |
Index of the currently selected image. More... | |
Protected Attributes inherited from chai3d::cImage | |
std::string | m_filename |
Image filename. More... | |
unsigned int | m_width |
Width in pixels of the current image. More... | |
unsigned int | m_height |
Height in pixels of the current image. More... | |
GLenum | m_format |
Pixel format of the image (GL_RGB, GL_RGBA, GL_LUMINANCE). More... | |
GLenum | m_type |
Pixel data type. (GL_UNSIGNED_BYTE, GL_UNSIGNED_INT). More... | |
unsigned int | m_bytesPerPixel |
Number of bytes per pixel. More... | |
unsigned char * | m_data |
The image data itself. More... | |
unsigned int | m_memorySize |
Size of current image in bytes. More... | |
bool | m_allocated |
If true, then the image has been allocated in memory, false otherwise. More... | |
bool | m_responsibleForMemoryAllocation |
If true, then this object actually performed the memory allocation for this object. More... | |
Additional Inherited Members | |
Public Attributes inherited from chai3d::cImage | |
cColorb | m_borderColor |
Returned color when accessing pixels located outside of the image. More... | |
cMultiImage provides a child class to cImage that handles multiple images with similar properties (size and format). Each image can be used either as a slice of a volume representation, or a frame of a time lapse. The images are treated as a set of pixel arrays, all sharing common properties and geometry. All pixel arrays are guaranteed to be allocated contiguously in a single memory array.
chai3d::cMultiImage::cMultiImage | ( | ) |
Default constructor of cMultiImage.
|
virtual |
Destructor of cMultiImage.
|
inlinestatic |
cMultiImagePtr chai3d::cMultiImage::copy | ( | ) |
This method creates a copy of itself.
bool chai3d::cMultiImage::allocate | ( | const unsigned int | a_width, |
const unsigned int | a_height, | ||
const unsigned int | a_slices, | ||
const GLenum | a_format = GL_RGB , |
||
const GLenum | a_type = GL_UNSIGNED_BYTE |
||
) |
Allocate a new image by defining its width, height and pixel format.
a_width | Width of images. |
a_height | Height of images. |
a_slices | Number of images in the set. |
a_format | Pixel format. Accepted values are: GL_LUMINANCE, GL_RGB, GL_RGBA |
a_type | Pixel type. Accepted values are: GL_UNSIGNED_BYTE, GL_UNSIGNED_INT |
|
inline |
|
inlinevirtual |
Reimplemented from chai3d::cImage.
bool chai3d::cMultiImage::convert | ( | const unsigned int | a_newFormat | ) |
This method converts all images in the set into a new pixel format.
a_newFormat | New desired pixel format: GL_LUMINANCE, GL_RGB, GL_RGBA. |
|
inlinevirtual |
Reimplemented from chai3d::cImage.
|
virtual |
This method select the image from the set that will be displayed by the cImage parent object.
Reimplemented from chai3d::cImage.
bool chai3d::cMultiImage::addImage | ( | cImage & | a_image, |
unsigned long | a_index = -1 |
||
) |
This method adds an image to the image set. If it is the first image, it will define the properties of the whole set. Otherwise, this method checks that the new image matches the properties of the images already in the set. If the image properties do not match, the image is ignored.
a_image | The image to be added to the image set. |
a_index | The index in the set where the image should be added. By default, the image is added at the end of the set. |
bool chai3d::cMultiImage::removeImage | ( | unsigned long | a_index | ) |
This method removes an image from the image set.
a_index | Index of the image to remove from the set. |
|
virtual |
This method defines a voxel color to be transparent for all images in the set. If the images are not in GL_RGBA format, they are first converted in order to enable pixel transparency capabilities.
a_color | Selected pixel color. |
a_transparencyLevel | Transparency level. |
Reimplemented from chai3d::cImage.
|
inlinevirtual |
Reimplemented from chai3d::cImage.
|
virtual |
This method assigns a transparent value to all pixels of this image set. If the images are not in GL_RGBA format, they are first converted in order to enable pixel transparency capabilities.
a_transparencyLevel | Transparency level. |
Reimplemented from chai3d::cImage.
|
virtual |
This method flips all images horizontally.
Reimplemented from chai3d::cImage.
|
virtual |
This method returns the nearest voxel from a texture coordinate.
a_texCoord | Texture coordinate. |
a_voxelX | Return value for voxel coordinate X. |
a_voxelY | Return value for voxel coordinate Y. |
a_voxelZ | Return value for voxel coordinate Z. |
a_clampToImageSize | If true then pixel value is clamped to image size. |
Reimplemented from chai3d::cImage.
|
virtual |
This method retrieves the voxel location from a texture coordinate.
a_texCoord | Texture coordinate. |
a_voxelX | Return value for voxel coordinate X. |
a_voxelY | Return value for voxel coordinate Y. |
a_voxelZ | Return value for voxel coordinate Z. |
a_clampToImageSize | If true then pixel value is clamped to image size. |
Reimplemented from chai3d::cImage.
|
virtual |
This method returns a pointer to voxel memory data.
a_x | X coordinate of the voxel. |
a_y | Y coordinate of the voxel. |
a_z | Z coordinate of the voxel. |
|
virtual |
This method returns the color of a voxel by passing its x, y and z coordinates.
a_x | X coordinate of the voxel. |
a_y | Y coordinate of the voxel. |
a_z | Z coordinate of the voxel. |
a_color | Return color of the voxel. |
Reimplemented from chai3d::cImage.
|
virtual |
This method returns the color of a voxel by passing its x, y and z coordinates.
a_x | X coordinate of the voxel. |
a_y | Y coordinate of the voxel. |
a_z | Z coordinate of the voxel. |
a_color | Return color of the voxel. |
|
virtual |
This method returns the interpolated color of an image voxel at location (x,y,z).
a_x | X coordinate of the voxel. |
a_y | Y coordinate of the voxel. |
a_z | Z coordinate of the voxel. |
a_color | Return color of the voxel. |
Reimplemented from chai3d::cImage.
|
virtual |
This method returns the interpolated color of an image voxel at location (x,y,z).
a_x | X coordinate of the voxel. |
a_y | Y coordinate of the voxel. |
a_z | Z coordinate of the voxel. |
a_color | Return color of the voxel. |
Reimplemented from chai3d::cImage.
|
virtual |
This method sets the color of a voxel.
a_x | X coordinate of the voxel. |
a_y | Y coordinate of the voxel. |
a_z | Z coordinate of the voxel. |
a_color | New color of the voxel. |
Reimplemented from chai3d::cImage.
|
inlinevirtual |
Reimplemented from chai3d::cImage.
|
virtual |
This method sets the color of a voxel.
a_x | X coordinate of the voxel. |
a_y | Y coordinate of the voxel. |
a_z | Z coordinate of the voxel. |
a_grayLevel | New luminance value of the voxel. |
Reimplemented from chai3d::cImage.
|
inline |
|
virtual |
This method loads an image from the specified file. The method returns true if all goes well. Note that regardless of whether it succeeds, this over-writes any image that had previously been loaded by this object.
a_filename | Image filename. |
Reimplemented from chai3d::cImage.
|
virtual |
This method loads a set of images from a set of files. The filenames are contained in a vector, and the files are loaded in the order they are stored in the vector.
The first image defines the properties of the whole set. Each subsequent image must match the properties of the first image, otherwise it will be ignored. This routine erases and replaces any previous content.
a_filename | The vector containing the filenames. |
|
virtual |
This method loads a set of images from a set of files. The filenames are defined by the basename, a numeric index and the extension. The files are loaded chronologically. The numeric index in the file names match the number of digits of the a_max argument. The first image defines the properties of the whole set. Each subsequent image must match the properties of the first image, otherwise it will be ignored. This routine erases and replaces any previous content.
E.g. loadFromFiles("img", "png", 18) will attempt to load: "img0.png", "img00.png", "img1.png", "img01.png", ..., "img10.png", "img11.png", ...
a_basename | The common path and filename component of the files. |
a_extension | The images file extension. |
a_max | The maximum number of files to search for. |
|
virtual |
This method adds an image to the image set. If it is the first image, it will define the properties of the whole set. Otherwise, this method checks that the new image matches the properties of the images already in the set. If the image properties do not match, the image is ignored.
a_filename | The path and filename of the image to be added to the set. |
a_index | The index in the set where the image should be added. By default, the image is added at the end of the set. |
|
virtual |
This method saves all 3D imaging data as a set of 2D images. The filenames are define by the basename, a numeric index and the extension. The files are saved chronologically and the number index is generated automatically for each file.
E.g. saveToFiles("img", "png")
a_basename | The common path and filename component of the files. |
a_extension | The images file extension. |
|
protected |
This method initializes internal variables.
|
protected |
This method frees memory that was used for image data, and re-initialize internal variables.
|
protectedvirtual |
This method adds an image file to a preallocated image set. The set must be preallocated by calling loadFromFiles(). This method checks that the new image matches the properties of the images already in the set. If the image properties do not match, the image is not loaded and an error is returned.
a_filename | The path and filename of the image to be added to the set. |
a_index | The index in the set where the image should be added. By default, the image is added at the end of the set. |
|
protected |
This method adds an image to a preallocated image set. The set must be preallocated by calling loadFromFiles(). This method checks that the new image matches the properties of the images already in the set. If the image properties do not match, the image is not loaded and an error is returned.
a_image | The image to be added to the image set. |
a_index | The index in the set where the image should be added. By default, the image is added at the end of the set. |
|
protected |
|
protected |
|
protected |