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)); }
213 const unsigned int a_y,
218 const unsigned int a_y,
223 const unsigned int a_y,
224 const unsigned char a_r,
225 const unsigned char a_g,
230 const unsigned int a_y,
231 const unsigned char a_grayLevel);
235 const unsigned char a_transparencyLevel);
239 const unsigned char a_g,
240 const unsigned char a_b,
241 const unsigned char a_transparencyLevel);
264 const unsigned int a_y,
265 const unsigned int a_z,
273 const unsigned int a_y,
274 const unsigned int a_z,
282 const unsigned int a_y,
283 const unsigned int a_z,
284 const unsigned char a_r,
285 const unsigned char a_g,
286 const unsigned char a_b)
294 const unsigned int a_y,
295 const unsigned int a_z,
296 const unsigned char a_grayLevel)
309 void copyTo(
const unsigned int a_sourcePosX,
310 const unsigned int a_sourcePosY,
311 const unsigned int a_sourceSizeX,
312 const unsigned int a_sourceSizeY,
313 cImagePtr a_destImage,
314 const unsigned int a_destPosX = 0,
315 const unsigned int a_destPosY = 0);
318 void copyTo(cImagePtr a_destImage,
319 const unsigned int a_destPosX = 0,
320 const unsigned int a_destPosY = 0);
356 virtual bool loadFromFile(
const std::string& a_filename);
359 virtual bool saveToFile(
const std::string& a_filename);
This class implements a 3D vector.
Definition: CVector3d.h:85
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:263
cImage * getImage()
This method returns a pointer to this cImage object.
Definition: CImage.h:170
virtual void getPixelLocation(const cVector3d a_texCoord, int &a_pixelX, int &a_pixelY) const
This method retrieves a pixel location from a texture coordinate.
Definition: CImage.cpp:938
virtual bool saveToFile(const std::string &a_filename)
This method saves an image file by passing a filename as argument.
Definition: CImage.cpp:1330
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:1117
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:1250
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:1162
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:293
std::string getFilename() const
This method returns the filename from which this image was last loaded or saved.
Definition: CImage.h:362
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:959
bool m_allocated
If true, then the image has been allocated in memory, false otherwise.
Definition: CImage.h:420
unsigned int m_bytesPerPixel
Number of bytes per pixel.
Definition: CImage.h:411
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:414
unsigned int m_height
Height in pixels of the current image.
Definition: CImage.h:402
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:399
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:1018
std::string m_filename
Image filename.
Definition: CImage.h:396
unsigned int getHeight() const
This method returns the height of the image.
Definition: CImage.h:138
virtual void getVoxelLocation(const cVector3d a_texCoord, int &a_voxelX, int &a_voxelY, int &a_voxelZ)
This method retrieves a voxel location from a texture coordinate.
Definition: CImage.h:257
virtual bool selectImage(unsigned long a_index)
This method sets the current image. For cImage objects, this value is always 0.
Definition: CImage.h:336
GLenum m_format
Pixel format of the image (GL_RGB, GL_RGBA, GL_LUMINANCE).
Definition: CImage.h:405
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:372
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:408
bool m_responsibleForMemoryAllocation
If true, then this object actually performed the memory allocation for this object.
Definition: CImage.h:423
unsigned int m_memorySize
Size of current image in bytes.
Definition: CImage.h:417
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:330
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
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:272
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:222
GLenum getFormat() const
This method returns the pixel format of the image (GL_RGB, GL_RGBA, GL_LUMINANCE for instance)...
Definition: CImage.h:141
This class implements a 2D image data structure.
Definition: CImage.h:83
virtual void flipHorizontal()
This method flips this image horizontally.
Definition: CImage.cpp:1195
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:281
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