GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
Glip::Modules::ImageBuffer Class Reference

Host-side image buffer. More...

#include <ImageBuffer.hpp>

Inheritance diagram for Glip::Modules::ImageBuffer:
Inheritance graph

Public Member Functions

 ImageBuffer (const HdlAbstractTextureFormat &format, int _alignment=1)
 ImageBuffer constructor. More...
 
 ImageBuffer (void *buffer, const HdlAbstractTextureFormat &format, int _alignment=1)
 ImageBuffer proxy constructor. More...
 
 ImageBuffer (HdlTexture &texture, int _alignment=1)
 ImageBuffer constructor. More...
 
 ImageBuffer (const ImageBuffer &image)
 ImageBuffer copy constructor. More...
 
const HdlTextureFormatDescriptorgetDescriptor (void) const
 Get the descriptor of the GL mode. More...
 
void * getPtr (void)
 Get access to the buffer. More...
 
const void * getPtr (void) const
 Get access to the buffer. More...
 
HdlDynamicTablegetTable (void)
 Access the underlying table. More...
 
const HdlDynamicTablegetTable (void) const
 Access the underlying table. More...
 
void setMinFilter (GLenum mf)
 Sets the texture's minification parameter. More...
 
void setMagFilter (GLenum mf)
 Sets the texture's magnification parameter. More...
 
void setSWrapping (GLenum m)
 Sets the texture's S wrapping parameter. More...
 
void setTWrapping (GLenum m)
 Sets the texture's T wrapping parameter. More...
 
const ImageBufferoperator<< (HdlTexture &texture)
 Copy a texture to this buffer and the following properties : minification and magnification filters, S and T wrapping modes. More...
 
const ImageBufferoperator<< (const ImageBuffer &image)
 Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes. More...
 
const ImageBufferoperator<< (const void *bytes)
 Copy an array. More...
 
const ImageBufferoperator>> (HdlTexture &texture) const
 Write buffer to a texture and the following properties : minification and magnification filters, S and T wrapping modes. More...
 
const ImageBufferoperator>> (ImageBuffer &image) const
 Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes. More...
 
const ImageBufferoperator>> (void *bytes) const
 Copy an array. More...
 
long long get (const int &x, const int &y, const GLenum &channel) const
 Get an element from the array. The output type is much larger than any possible type and the value from buffer is not stretched except if the buffer is in single or double floating point precision. More...
 
void set (const long long &value, const int &x, const int &y, const GLenum &channel)
 Set an element in the array. The value is clamped to fit the precision of the buffer or normalized if the buffer is in single or double floating point precision. More...
 
float getNormalized (const int &x, const int &y, const GLenum &channel) const
 Get an element from the array. The output is between 0.0f and 1.0f. More...
 
void setNormalized (const float &value, const int &x, const int &y, const GLenum &channel)
 Set an element in the array. The value is clamped to the range [0.0f, 1.0f] and stretched to the buffer precision. More...
 
void write (const std::string &filename, const std::string &comment="") const
 Write an image buffer to a RAW file. The raw file contain all image information, plus texture setting and an optional comment. Raise an exception if any error occurs. More...
 
- Public Member Functions inherited from Glip::CoreGL::HdlAbstractTextureFormat
int getWidth (void) const
 
int getHeight (void) const
 
int getNumPixels (void) const
 
int getNumChannels (void) const
 
int getNumElements (void) const
 
int getAlignment (void) const
 
int getPixelSize (void) const
 
virtual size_t getRowSize (void) const
 
virtual size_t getSize (void) const
 
int getChannelDepth (void) const
 
GLenum getGLMode (void) const
 
GLenum getGLDepth (void) const
 
GLenum getMinFilter (void) const
 
GLenum getMagFilter (void) const
 
int getBaseLevel (void) const
 
int getMaxLevel (void) const
 
GLenum getSWrapping (void) const
 
GLenum getTWrapping (void) const
 
bool isCompressed (void) const
 
bool isFloatingPoint (void) const
 
const HdlTextureFormatDescriptorgetFormatDescriptor (void) const
 
bool operator== (const HdlAbstractTextureFormat &) const
 
bool operator!= (const HdlAbstractTextureFormat &) const
 
bool isCompatibleWith (const HdlAbstractTextureFormat &) const
 Check if the two formats share the same memory characteristics (sizes, number of channels, byte per pixel, internal GL mode, same mipmap levels). More...
 
HdlAbstractTextureFormat getCompressedFormat (void) const
 Get the equivalent, but compressed, format. More...
 
HdlAbstractTextureFormat getUncompressedFormat (void) const
 Get the equivalent, but uncompressed, format. More...
 
bool isCorrespondingCompressedFormat (const HdlAbstractTextureFormat &) const
 Check if this and f share the same memory parameters except that the mode for f is the corresponding compressed mode of this. More...
 
virtual unsigned int getSetting (GLenum param) const
 Obtain a setting value based on its GL name. More...
 

Static Public Member Functions

static ImageBufferload (const std::string &filename, std::string *comment=NULL)
 Load an image buffer from a RAW file. The raw file contain all image information, plus texture setting and an optional comment. More...
 
- Static Public Member Functions inherited from Glip::CoreGL::HdlAbstractTextureFormat
static int getMaxSize (void)
 Returns the maximum size for a texture. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Glip::CoreGL::HdlAbstractTextureFormat
 HdlAbstractTextureFormat (int _width, int _height, GLenum _mode, GLenum _depth, GLenum _minFilter=GL_NEAREST, GLenum _magFilter=GL_NEAREST, GLenum _wraps=GL_CLAMP, GLenum _wrapt=GL_CLAMP, int _baseLevel=0, int _maxLevel=0)
 HdlAbstractTextureFormat Construtor. More...
 
 HdlAbstractTextureFormat (const HdlAbstractTextureFormat &copy)
 HdlAbstractTextureFormat Construtor. More...
 
void setAlignment (int _alignment)
 Set the alignment for this format. More...
 

Detailed Description

Host-side image buffer.

Constructor & Destructor Documentation

ImageBuffer::ImageBuffer ( const HdlAbstractTextureFormat format,
int  _alignment = 1 
)

ImageBuffer constructor.

Parameters
formatThe format of this buffer (or the equivalent uncompressed format).
_alignmentForce the memory alignment to either 1, 4 or 8 bytes.
ImageBuffer::ImageBuffer ( void *  buffer,
const HdlAbstractTextureFormat format,
int  _alignment = 1 
)

ImageBuffer proxy constructor.

Parameters
bufferThe buffer to point to, this memory table will NOT be deleted when this object is destroyed.
formatThe format of this buffer (or the equivalent uncompressed format).
_alignmentForce the memory alignment to either 1, 4 or 8 bytes.
ImageBuffer::ImageBuffer ( HdlTexture texture,
int  _alignment = 1 
)

ImageBuffer constructor.

Parameters
textureCopy the format and data of the this texture.
_alignmentForce the memory alignment to either 1, 4 or 8 bytes.
ImageBuffer::ImageBuffer ( const ImageBuffer image)

ImageBuffer copy constructor.

Parameters
imageImage buffer to copy.

Member Function Documentation

long long ImageBuffer::get ( const int &  x,
const int &  y,
const GLenum &  channel 
) const

Get an element from the array. The output type is much larger than any possible type and the value from buffer is not stretched except if the buffer is in single or double floating point precision.

Parameters
xX-axis coordinate (along the width).
yY-axis coordinate (along the height).
channelThe channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE).
Returns
The corresponding value.
const HdlTextureFormatDescriptor & ImageBuffer::getDescriptor ( void  ) const

Get the descriptor of the GL mode.

Returns
A HdlTextureFormatDescriptor object reference.
float ImageBuffer::getNormalized ( const int &  x,
const int &  y,
const GLenum &  channel 
) const

Get an element from the array. The output is between 0.0f and 1.0f.

Parameters
xX-axis coordinate (along the width).
yY-axis coordinate (along the height).
channelThe channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE).
Returns
The corresponding value.
void * ImageBuffer::getPtr ( void  )

Get access to the buffer.

Returns
A pointer to the buffer array.
const void * ImageBuffer::getPtr ( void  ) const

Get access to the buffer.

Returns
A pointer to the buffer array.
HdlDynamicTable & ImageBuffer::getTable ( void  )

Access the underlying table.

Returns
A reference to the storage table in use.
const HdlDynamicTable & ImageBuffer::getTable ( void  ) const

Access the underlying table.

Returns
A constant reference to the storage table in use.
ImageBuffer * ImageBuffer::load ( const std::string &  filename,
std::string *  comment = NULL 
)
static

Load an image buffer from a RAW file. The raw file contain all image information, plus texture setting and an optional comment.

Parameters
filenameThe file name (and path).
commentIf the pointer is non-null and if there is a comment in the file, the comment will be written in the tarted string.
Returns
A pointer to an ImageBuffer object. The user has the responsability to release the memory (with delete). Raise an exception if any error occurs.
const ImageBuffer & ImageBuffer::operator<< ( HdlTexture texture)

Copy a texture to this buffer and the following properties : minification and magnification filters, S and T wrapping modes.

Parameters
textureThe texture to copy.
Returns
This.
const ImageBuffer & ImageBuffer::operator<< ( const ImageBuffer image)

Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes.

Parameters
imageThe buffer to copy.
Returns
This.
const ImageBuffer & ImageBuffer::operator<< ( const void *  bytes)

Copy an array.

Parameters
bytesThe buffer to copy (assumed to be of size HdlAbstractTextureFormat::getSize()).
Returns
This.
const ImageBuffer & ImageBuffer::operator>> ( HdlTexture texture) const

Write buffer to a texture and the following properties : minification and magnification filters, S and T wrapping modes.

Parameters
textureThe texture to be written.
Returns
This.
const ImageBuffer & ImageBuffer::operator>> ( ImageBuffer image) const

Copy a buffer and the following properties : minification and magnification filters, S and T wrapping modes.

Parameters
imageThe buffer to be written.
Returns
This.
const ImageBuffer & ImageBuffer::operator>> ( void *  bytes) const

Copy an array.

Parameters
bytesThe buffer to copy (assumed to be of size HdlAbstractTextureFormat::getSize()).
Returns
This.
void ImageBuffer::set ( const long long &  value,
const int &  x,
const int &  y,
const GLenum &  channel 
)

Set an element in the array. The value is clamped to fit the precision of the buffer or normalized if the buffer is in single or double floating point precision.

Parameters
valueThe input value.
xX-axis coordinate (along the width).
yY-axis coordinate (along the height).
channelThe channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE).
void ImageBuffer::setMagFilter ( GLenum  mf)

Sets the texture's magnification parameter.

Parameters
mfThe new magnification filter (e.g. GL_NEAREST or GL_LINEAR, only these two options are accepted).
void ImageBuffer::setMinFilter ( GLenum  mf)

Sets the texture's minification parameter.

Parameters
mfThe new minification filter (e.g. GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST or GL_LINEAR_MIPMAP_LINEAR).
void ImageBuffer::setNormalized ( const float &  value,
const int &  x,
const int &  y,
const GLenum &  channel 
)

Set an element in the array. The value is clamped to the range [0.0f, 1.0f] and stretched to the buffer precision.

Parameters
valueThe input value.
xX-axis coordinate (along the width).
yY-axis coordinate (along the height).
channelThe channel (GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA or GL_LUMINANCE).
void ImageBuffer::setSWrapping ( GLenum  m)

Sets the texture's S wrapping parameter.

Parameters
mThe new S wrapping parameter (e.g. GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT)
void ImageBuffer::setTWrapping ( GLenum  m)

Sets the texture's T wrapping parameter.

Parameters
mThe new T wrapping parameter (e.g. GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT)
void ImageBuffer::write ( const std::string &  filename,
const std::string &  comment = "" 
) const

Write an image buffer to a RAW file. The raw file contain all image information, plus texture setting and an optional comment. Raise an exception if any error occurs.

Parameters
filenameThe file name (and path).
commentSave this comment to the file (the current limit is a 1MB string).

The documentation for this class was generated from the following files: