64 typedef std::shared_ptr<cImage>
cImagePtr;
95 cImage(
const unsigned int a_width,
96 const unsigned int a_height,
97 const GLenum a_format = GL_RGB,
98 const GLenum a_type = GL_UNSIGNED_BYTE);
104 static cImagePtr
create() {
return (std::make_shared<cImage>()); }
117 bool allocate(
const unsigned int a_width,
118 const unsigned int a_height,
119 const GLenum a_format = GL_RGB,
120 const GLenum a_type = GL_UNSIGNED_BYTE);
132 void setSize(
const unsigned int a_width,
const unsigned int a_height);
156 bool convert(
const unsigned int a_newFormat);
160 const GLenum a_type);
176 virtual void setData(
unsigned char* a_data,
177 const unsigned int a_dataSizeInBytes,
178 const bool a_dealloc =
false);
182 const unsigned int a_height,
183 const GLenum a_format,
184 const GLenum a_type);
194 virtual void clear();
200 virtual void clear(
const unsigned char a_r,
201 const unsigned char a_g,
202 const unsigned char a_b,
203 const unsigned char a_a = 0xff) {
clear(
cColorb(a_r, a_g, a_b, a_a)); }
206 virtual void clear(
const unsigned char a_grayLevel) {
clear(
cColorb(a_grayLevel, a_grayLevel, a_grayLevel)); }
209 virtual void getPixelLocation(
const cVector3d& a_texCoord,
int& a_pixelX,
int& a_pixelY,
bool a_clampToImageSize =
true)
const;
216 const unsigned int a_y,
221 const unsigned int a_y,
236 const unsigned int a_y,
241 const unsigned int a_y,
242 const unsigned char a_r,
243 const unsigned char a_g,
248 const unsigned int a_y,
249 const unsigned char a_grayLevel);
253 const unsigned char a_transparencyLevel);
257 const unsigned char a_g,
258 const unsigned char a_b,
259 const unsigned char a_transparencyLevel);
275 virtual void getVoxelLocation(
const cVector3d& a_texCoord,
int& a_voxelX,
int& a_voxelY,
int& a_voxelZ,
bool a_clampToImageSize =
true)
const 290 const unsigned int a_y,
291 const unsigned int a_z,
317 const unsigned int a_y,
318 const unsigned int a_z,
326 const unsigned int a_y,
327 const unsigned int a_z,
328 const unsigned char a_r,
329 const unsigned char a_g,
330 const unsigned char a_b)
338 const unsigned int a_y,
339 const unsigned int a_z,
340 const unsigned char a_grayLevel)
353 void copyTo(
const unsigned int a_sourcePosX,
354 const unsigned int a_sourcePosY,
355 const unsigned int a_sourceSizeX,
356 const unsigned int a_sourceSizeY,
357 cImagePtr a_destImage,
358 const unsigned int a_destPosX = 0,
359 const unsigned int a_destPosY = 0);
362 void copyTo(cImagePtr a_destImage,
363 const unsigned int a_destPosX = 0,
364 const unsigned int a_destPosY = 0);
400 virtual bool loadFromFile(
const std::string& a_filename);
403 virtual bool saveToFile(
const std::string& a_filename);
This class implements a 3D vector.
Definition: CVector3d.h:88
virtual void clear()
This method clears all image pixels with a black color.
Definition: CImage.cpp:865
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!
Definition: CImage.cpp:407
bool convert(const unsigned int a_newFormat)
This method converts the image to a new format passed as argument.
Definition: CImage.cpp:357
GLenum getType() const
This method returns the pixel data type. (GL_UNSIGNED_BYTE, GL_UNSIGNED_INT for instance).
Definition: CImage.h:144
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).
Definition: CImage.h:289
cImage * getImage()
This method returns a pointer to this cImage object.
Definition: CImage.h:170
virtual bool saveToFile(const std::string &a_filename)
This method saves an image file by passing a filename as argument.
Definition: CImage.cpp:1504
unsigned int getBitsPerPixel() const
This method returns the number of bits per pixel used to store this image.
Definition: CImage.h:147
bool isInitialized() const
This method returns true if the image has been allocated in memory, false otherwise.
Definition: CImage.h:129
virtual void setTransparentColor(const cColorb &a_color, const unsigned char a_transparencyLevel)
This method defines a specific pixel color to be transparent.
Definition: CImage.cpp:1291
void cleanup()
This method deletes memory and rid ourselves of any image previously stored.
Definition: CImage.cpp:150
unsigned int getSizeInBytes() const
This method returns the size in bytes of the current image.
Definition: CImage.h:153
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.
Definition: CImage.cpp:174
virtual bool loadFromFile(const std::string &a_filename)
This method loads an image file by passing a filename as argument.
Definition: CImage.cpp:1424
unsigned int getWidth() const
This method returns the width of the image.
Definition: CImage.h:135
static cImagePtr create()
Shared cImage allocator.
Definition: CImage.h:104
const bool C_SUCCESS
Function returns successfully.
Definition: CConstants.h:77
void defaults()
This method initializes all member variables.
Definition: CImage.cpp:114
virtual void setTransparency(const unsigned char a_transparencyLevel)
This method defines a transparency value to be applied to all image pixels.
Definition: CImage.cpp:1336
virtual unsigned int getImageCount() const
This method returns the number of images stored. (1 only for class cImage).
Definition: CImage.h:126
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).
Definition: CImage.h:337
std::string getFilename() const
This method returns the filename from which this image was last loaded or saved.
Definition: CImage.h:406
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).
Definition: CImage.cpp:1003
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). ...
Definition: CImage.h:307
bool m_allocated
If true, then the image has been allocated in memory, false otherwise.
Definition: CImage.h:464
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).
Definition: CImage.cpp:1085
unsigned int m_bytesPerPixel
Number of bytes per pixel.
Definition: CImage.h:455
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!
Definition: CImage.cpp:840
unsigned char * m_data
The image data itself.
Definition: CImage.h:458
unsigned int m_height
Height in pixels of the current image.
Definition: CImage.h:446
static int queryBytesPerPixel(const GLenum a_format, const GLenum a_type)
This method queries the number of bytes per pixel for a given format.
Definition: CImage.cpp:274
unsigned int m_width
Width in pixels of the current image.
Definition: CImage.h:443
const bool C_ERROR
Function returns with an error.
Definition: CConstants.h:74
This class defines a color using a GLubyte representation for each component.
Definition: CColor.h:1184
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).
Definition: CImage.cpp:1192
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.
Definition: CImage.h:282
std::string m_filename
Image filename.
Definition: CImage.h:440
unsigned int getHeight() const
This method returns the height of the image.
Definition: CImage.h:138
virtual bool selectImage(unsigned long a_index)
This method sets the current image. For cImage objects, this value is always 0.
Definition: CImage.h:380
GLenum m_format
Pixel format of the image (GL_RGB, GL_RGBA, GL_LUMINANCE).
Definition: CImage.h:449
virtual ~cImage()
Destructor of cImage.
Definition: CImage.cpp:102
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.
Definition: CImage.h:200
cColorb m_borderColor
Returned color when accessing pixels located outside of the image.
Definition: CImage.h:416
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
Implements color properties.
std::shared_ptr< cImage > cImagePtr
Definition: CImage.h:63
GLenum m_type
Pixel data type. (GL_UNSIGNED_BYTE, GL_UNSIGNED_INT).
Definition: CImage.h:452
bool m_responsibleForMemoryAllocation
If true, then this object actually performed the memory allocation for this object.
Definition: CImage.h:467
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.
Definition: CImage.cpp:971
unsigned int m_memorySize
Size of current image in bytes.
Definition: CImage.h:461
virtual unsigned long getCurrentIndex()
This method returns the index number of the current image. For cImage objects, the value is always 0...
Definition: CImage.h:374
void erase()
This method deletes all image data from memory.
Definition: CImage.h:123
virtual void clear(const unsigned char a_grayLevel)
This method clears all image pixels with a level of gray passed as argument.
Definition: CImage.h:206
Definition: CAudioBuffer.cpp:56
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.
Definition: CImage.cpp:939
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.
Definition: CImage.cpp:234
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).
Definition: CImage.h:316
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).
Definition: CImage.h:240
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.
Definition: CImage.h:275
GLenum getFormat() const
This method returns the pixel format of the image (GL_RGB, GL_RGBA, GL_LUMINANCE for instance)...
Definition: CImage.h:141
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). ...
Definition: CImage.h:298
This class implements a 2D image data structure.
Definition: CImage.h:83
virtual void flipHorizontal()
This method flips this image horizontally.
Definition: CImage.cpp:1369
cImagePtr copy()
This method creates a copy itself.
Definition: CImage.cpp:250
virtual unsigned char * getData()
This method returns a pointer to the actual image data. Use with care!
Definition: CImage.h:173
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).
Definition: CImage.h:325
cImage()
Default constructor of cImage.
Definition: CImage.cpp:66
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.
Definition: CImage.cpp:450
unsigned int getBytesPerPixel() const
This method returns the number of bytes per pixel used to store this image.
Definition: CImage.h:150