Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

sp::video::ImageBuffer Class Reference
[Texture Mapping]

#include <spImageBuffer.hpp>

Inheritance diagram for sp::video::ImageBuffer:
sp::video::ImageBufferContainer< f32, 1 > sp::video::ImageBufferContainer< u8, 255 > sp::video::ImageBufferContainer< T, DefVal > sp::video::ImageBufferFloat sp::video::ImageBufferUByte

List of all members.

Public Member Functions

virtual ~ImageBuffer ()
dim::point2di getPixelCoord (const dim::point2df &Pos) const
 Converts the given float position into the a real coordinate. Will be clamped to the range [0.0 .. 1.0).
void setPixelColor (const s32 Pos, const color &Color)
 Sets the pixel color at given position.
void setPixelColor (const dim::point2di &Pos, const color &Color)
void setPixelColor (const dim::vector3di &Pos, const color &Color)
void setPixelVector (const s32 Pos, const dim::vector4df &Color)
 Sets the pixel color at given position as float vector.
void setPixelVector (const dim::point2di &Pos, const dim::vector4df &Color)
void setPixelVector (const dim::vector3di &Pos, const dim::vector4df &Color)
color getPixelColor (const s32 Pos) const
 Returns pixel color at given position.
color getPixelColor (const dim::point2di &Pos) const
color getPixelColor (const dim::vector3di &Pos) const
dim::vector4df getPixelVector (const s32 Pos) const
 Returns pixel color at giben position as float vector.
dim::vector4df getPixelVector (const dim::point2di &Pos) const
dim::vector4df getPixelVector (const dim::vector3di &Pos) const
dim::vector4df getInterpolatedPixel (const dim::point2df &Pos) const
void setBuffer (const void *ImageBuffer)
 Sets the new image buffer. The giben array must have the size (in bytes) given by "getBufferSize()".
virtual bool isSizePOT () const
 Returns true if the texture width and height are "Power Of Two" values (2^n: 1, 2, 4, 8, 16 etc.).
virtual dim::size2di getSizePOT () const
 Returns Texture size for a "Power Of Two" dimension (e.g. 120 to 128, 260 to 256 etc.).
virtual void setSizePOT ()
 Resizes the texture to a "Power Of Two" dimension if it is currently not.
virtual void adjustFormatD3D ()
 Adjusts the pixel format to be used for Direct3D. This will change RGB to RGBA and BGR to BGRA.
virtual ImageBuffercopy () const =0
virtual void copy (const ImageBuffer *Other)=0
 Copies the image bufer data into this image buffer. This can also be used to convert from UByte to Float.
virtual bool setFormat (const EPixelFormats Format)=0
 Converts the pixel format and returns true if something has changed.
virtual void setSize (const dim::size2di &Size)=0
 Resizes the image buffer.
virtual bool setDepth (u32 Depth)=0
 Resizes the image buffer for the depth and returns true on success.
virtual void invertColors ()=0
 Inverts all pixel colors.
virtual void flipColors ()=0
 Flips all pixel colors (from RGB to BGR).
virtual void flipImageHorizontal ()=0
 Flips the image on X-axis.
virtual void flipImageVertical ()=0
 Flips the image on Y-axis.
virtual void turnImage (const EImageTurnDegrees Degree)=0
 Turns the image in 90, 180 or 270 degrees.
virtual u32 getDataTypeSize () const =0
 Returns the data type size (in bytes). For unsigned bytes it's 1 and for floats it's 4.
virtual void * getBuffer ()=0
 Returns pointer to the image buffer stored in the RAM. This can be a UByte or Float pointer.
virtual const void * getBuffer () const =0
virtual void setBuffer (const void *ImageBuffer, const dim::point2di &Pos, const dim::size2di &Size)=0
 Sets a new sub-buffer.
virtual void getBuffer (void *ImageBuffer, const dim::point2di &Pos, const dim::size2di &Size) const =0
 Gets a sub-buffer.
virtual bool appendImageBuffer (const ImageBuffer *AdditionalBuffer, bool isAppendBottom=true)=0
virtual void setColorKey (const color &Color, u8 Tolerance=0)
virtual void setColorKey (const dim::point2di &Pos, u8 Alpha=0, u8 Tolerance=0)
 Sets the color key which is get from the pixel at given position.
virtual void setColorKeyAlpha (const EAlphaBlendingTypes Mode=BLENDING_BRIGHT)
virtual void setColorKeyMask (ImageBuffer *MaskImage, const EAlphaBlendingTypes Mode=BLENDING_BRIGHT)
virtual void grayToAlpha ()=0
 Converts the gray values to alpha channel. Among others this is used for textured font.
virtual void createBuffer (const void *InitBuffer=0)=0
virtual void deleteBuffer ()=0
 Deletes the image buffer.
EImageBufferTypes getType () const
dim::size2di getSize () const
 Returns the 2 dimensional size of the image buffer (Width and Height only).
dim::vector3di getSizeVector () const
 Returns the 3 dimensional size of the image buffer (Width, Height and Depth).
u32 getPixelCount () const
 Returns the count of pixels (Width * Height * Depth).
u32 getPixelSize () const
 Returns the count of bytes for one pixel (FormatSize * DataTypeSize).
u32 getBufferSize () const
 Returns the count of bytes for the whole image buffer (PixelCount * PixelSize).
u32 getDepth () const
EPixelFormats getFormat () const
 Returns the pixel format.
u32 getFormatSize () const
 Returns the count of components for the internal pixel format.
bool hasAlphaChannel () const
 Returns true if the image buffer's pixel format has an alpha channel.
color getColorKey () const
 Returns the color key. This is the color which can be blended out by its alpha channel.

Static Public Member Functions

static u32 getFormatSize (const EPixelFormats Format)
 Returns the format size of the giben pixel format (1, 2, 3 or 4). The format size is equivalent to the count of color components.
static bool hasAlphaChannel (const EPixelFormats Format)
 Returns true if the given format has an alpha channel.

Protected Member Functions

 ImageBuffer (const EImageBufferTypes Type)
 ImageBuffer (const EImageBufferTypes Type, const EPixelFormats Format, const dim::size2di &Size, u32 Depth=1)
bool copyBase (const ImageBuffer &Other)
 Copies base data and returns true if something has changed that the image buffer must be re-allocated.

Protected Attributes

EImageBufferTypes Type_
EPixelFormats Format_
 Pixel format (RGB, BGR, RGBA, Gray etc.).
u32 FormatSize_
 Format size (1, 2, 3 or 4).
dim::size2di Size_
 Image buffer size (Always 2 dimensional).
u32 Depth_
 Depth (1, 6 or individual).
color ColorKey_

Detailed Description

This is the ImageBuffer class particular used for the Texture image buffer representation. An ImageBuffer is actually always 2 dimensional. When it is used as a 1 dimensional buffer the vertical axis and the depth are always 0. When it is used as a 3 dimensional buffer for some functions you have to add (Z * Buffer.Height) to the Y axis. This is e.g. for the "setBuffer" function where you can set a sub-buffer (individual part area of the whole buffer). This function only takes a 2D position and size. For e.g. "setPixelColor" you can pass a 1, 2 or 3 dimensional position.

Since:
Version 3.1

Constructor & Destructor Documentation

sp::video::ImageBuffer::~ImageBuffer (  )  [virtual]
sp::video::ImageBuffer::ImageBuffer ( const EImageBufferTypes  Type  )  [protected]
sp::video::ImageBuffer::ImageBuffer ( const EImageBufferTypes  Type,
const EPixelFormats  Format,
const dim::size2di Size,
u32  Depth = 1 
) [protected]

Member Function Documentation

void sp::video::ImageBuffer::adjustFormatD3D (  )  [virtual]

Adjusts the pixel format to be used for Direct3D. This will change RGB to RGBA and BGR to BGRA.

virtual bool sp::video::ImageBuffer::appendImageBuffer ( const ImageBuffer AdditionalBuffer,
bool  isAppendBottom = true 
) [pure virtual]

Appends the given image buffer to this one. The additional image buffer will be resized to fit into this image buffer.

Parameters:
[in] NewFrame Pointer to the additional image buffer object which is to be appended.
[in] isAppendBottom Specifies whether the additional image buffer is to be appended at the bottom or not. If not it will be inserted into the image buffer so that it looks like the image will be appended at the right. This is slower than appending it at the end of the buffer! By default true.
Returns:
True if succeeded. Otherwise the image buffer types are incompatible, i.e. 'Float' and 'UByte'.

Implemented in sp::video::ImageBufferContainer< T, DefVal >, sp::video::ImageBufferContainer< f32, 1 >, and sp::video::ImageBufferContainer< u8, 255 >.

virtual ImageBuffer* sp::video::ImageBuffer::copy (  )  const [pure virtual]

Creates a copy of this image buffer and returns the resulting pointer.

Note:
Don't forget to delete this object!

Implemented in sp::video::ImageBufferFloat, and sp::video::ImageBufferUByte.

virtual void sp::video::ImageBuffer::copy ( const ImageBuffer Other  )  [pure virtual]

Copies the image bufer data into this image buffer. This can also be used to convert from UByte to Float.

Implemented in sp::video::ImageBufferFloat, and sp::video::ImageBufferUByte.

bool sp::video::ImageBuffer::copyBase ( const ImageBuffer Other  )  [protected]

Copies base data and returns true if something has changed that the image buffer must be re-allocated.

virtual void sp::video::ImageBuffer::createBuffer ( const void *  InitBuffer = 0  )  [pure virtual]

Creates the buffer and deletes the old one.

Parameters:
[in] InitBuffer Pointer to the buffer which is to be compied. This must point to a memory buffer with the same size as the image buffer. Otherwise it must be a null pointer. By default null.
See also:
getBufferSize

Implemented in sp::video::ImageBufferContainer< T, DefVal >, sp::video::ImageBufferContainer< f32, 1 >, and sp::video::ImageBufferContainer< u8, 255 >.

virtual void sp::video::ImageBuffer::deleteBuffer (  )  [pure virtual]
virtual void sp::video::ImageBuffer::flipColors (  )  [pure virtual]
virtual void sp::video::ImageBuffer::flipImageHorizontal (  )  [pure virtual]
virtual void sp::video::ImageBuffer::flipImageVertical (  )  [pure virtual]
virtual const void* sp::video::ImageBuffer::getBuffer (  )  const [pure virtual]
virtual void sp::video::ImageBuffer::getBuffer ( void *  ImageBuffer,
const dim::point2di Pos,
const dim::size2di Size 
) const [pure virtual]

Gets a sub-buffer.

Implemented in sp::video::ImageBufferFloat, and sp::video::ImageBufferUByte.

virtual void* sp::video::ImageBuffer::getBuffer (  )  [pure virtual]

Returns pointer to the image buffer stored in the RAM. This can be a UByte or Float pointer.

Implemented in sp::video::ImageBufferContainer< T, DefVal >, sp::video::ImageBufferContainer< f32, 1 >, and sp::video::ImageBufferContainer< u8, 255 >.

u32 sp::video::ImageBuffer::getBufferSize (  )  const [inline]

Returns the count of bytes for the whole image buffer (PixelCount * PixelSize).

color sp::video::ImageBuffer::getColorKey (  )  const [inline]

Returns the color key. This is the color which can be blended out by its alpha channel.

virtual u32 sp::video::ImageBuffer::getDataTypeSize (  )  const [pure virtual]

Returns the data type size (in bytes). For unsigned bytes it's 1 and for floats it's 4.

Implemented in sp::video::ImageBufferContainer< T, DefVal >, sp::video::ImageBufferContainer< f32, 1 >, and sp::video::ImageBufferContainer< u8, 255 >.

u32 sp::video::ImageBuffer::getDepth (  )  const [inline]

Returns the image buffer depth. For 1D and 2D textures it's always 1. For 3D textures it can be individual and for CubeMaps it's always 6.

EPixelFormats sp::video::ImageBuffer::getFormat (  )  const [inline]

Returns the pixel format.

u32 sp::video::ImageBuffer::getFormatSize ( const EPixelFormats  Format  )  [static]

Returns the format size of the giben pixel format (1, 2, 3 or 4). The format size is equivalent to the count of color components.

u32 sp::video::ImageBuffer::getFormatSize (  )  const [inline]

Returns the count of components for the internal pixel format.

dim::vector4df sp::video::ImageBuffer::getInterpolatedPixel ( const dim::point2df Pos  )  const

Returns an interpolated 2D pixel (or rather texel) color. This returns always a smoothed color whether buffer type of 'float' or not.

color sp::video::ImageBuffer::getPixelColor ( const dim::point2di Pos  )  const
color sp::video::ImageBuffer::getPixelColor ( const dim::vector3di Pos  )  const
color sp::video::ImageBuffer::getPixelColor ( const s32  Pos  )  const

Returns pixel color at given position.

dim::point2di sp::video::ImageBuffer::getPixelCoord ( const dim::point2df Pos  )  const

Converts the given float position into the a real coordinate. Will be clamped to the range [0.0 .. 1.0).

u32 sp::video::ImageBuffer::getPixelCount (  )  const [inline]

Returns the count of pixels (Width * Height * Depth).

u32 sp::video::ImageBuffer::getPixelSize (  )  const [inline]

Returns the count of bytes for one pixel (FormatSize * DataTypeSize).

dim::vector4df sp::video::ImageBuffer::getPixelVector ( const dim::vector3di Pos  )  const
dim::vector4df sp::video::ImageBuffer::getPixelVector ( const s32  Pos  )  const

Returns pixel color at giben position as float vector.

dim::vector4df sp::video::ImageBuffer::getPixelVector ( const dim::point2di Pos  )  const
dim::size2di sp::video::ImageBuffer::getSize (  )  const [inline]

Returns the 2 dimensional size of the image buffer (Width and Height only).

dim::size2di sp::video::ImageBuffer::getSizePOT (  )  const [virtual]

Returns Texture size for a "Power Of Two" dimension (e.g. 120 to 128, 260 to 256 etc.).

dim::vector3di sp::video::ImageBuffer::getSizeVector (  )  const [inline]

Returns the 3 dimensional size of the image buffer (Width, Height and Depth).

EImageBufferTypes sp::video::ImageBuffer::getType (  )  const [inline]
virtual void sp::video::ImageBuffer::grayToAlpha (  )  [pure virtual]

Converts the gray values to alpha channel. Among others this is used for textured font.

Implemented in sp::video::ImageBufferContainer< T, DefVal >, sp::video::ImageBufferContainer< f32, 1 >, and sp::video::ImageBufferContainer< u8, 255 >.

bool sp::video::ImageBuffer::hasAlphaChannel (  )  const [inline]

Returns true if the image buffer's pixel format has an alpha channel.

bool sp::video::ImageBuffer::hasAlphaChannel ( const EPixelFormats  Format  )  [static]

Returns true if the given format has an alpha channel.

virtual void sp::video::ImageBuffer::invertColors (  )  [pure virtual]
bool sp::video::ImageBuffer::isSizePOT (  )  const [virtual]

Returns true if the texture width and height are "Power Of Two" values (2^n: 1, 2, 4, 8, 16 etc.).

virtual void sp::video::ImageBuffer::setBuffer ( const void *  ImageBuffer,
const dim::point2di Pos,
const dim::size2di Size 
) [pure virtual]

Sets a new sub-buffer.

Implemented in sp::video::ImageBufferFloat, and sp::video::ImageBufferUByte.

void sp::video::ImageBuffer::setBuffer ( const void *  ImageBuffer  ) 

Sets the new image buffer. The giben array must have the size (in bytes) given by "getBufferSize()".

void sp::video::ImageBuffer::setColorKey ( const dim::point2di Pos,
u8  Alpha = 0,
u8  Tolerance = 0 
) [virtual]

Sets the color key which is get from the pixel at given position.

void sp::video::ImageBuffer::setColorKey ( const color Color,
u8  Tolerance = 0 
) [virtual]

Sets the color key with the given tolerance.

Parameters:
Color,: Color which is to be blended out. The alpha channel specifies the transparency of this color. e.g. when you have a mesh-wire-fence the color between the mesh-wire (normally black {0|0|0} for green {0|255|0}) shall be blended out the color key has to be (0, 0, 0, 0) for black or (0, 255, 0, 0) or green.
Note:
The color key functions only work for the UBYTE image buffers (ImageBufferUByte).

Reimplemented in sp::video::ImageBufferUByte.

void sp::video::ImageBuffer::setColorKeyAlpha ( const EAlphaBlendingTypes  Mode = BLENDING_BRIGHT  )  [virtual]
void sp::video::ImageBuffer::setColorKeyMask ( ImageBuffer MaskImage,
const EAlphaBlendingTypes  Mode = BLENDING_BRIGHT 
) [virtual]
virtual bool sp::video::ImageBuffer::setDepth ( u32  Depth  )  [pure virtual]

Resizes the image buffer for the depth and returns true on success.

Implemented in sp::video::ImageBufferContainer< T, DefVal >, sp::video::ImageBufferContainer< f32, 1 >, and sp::video::ImageBufferContainer< u8, 255 >.

virtual bool sp::video::ImageBuffer::setFormat ( const EPixelFormats  Format  )  [pure virtual]

Converts the pixel format and returns true if something has changed.

Implemented in sp::video::ImageBufferContainer< T, DefVal >, sp::video::ImageBufferContainer< f32, 1 >, and sp::video::ImageBufferContainer< u8, 255 >.

void sp::video::ImageBuffer::setPixelColor ( const dim::point2di Pos,
const color Color 
)
void sp::video::ImageBuffer::setPixelColor ( const dim::vector3di Pos,
const color Color 
)
void sp::video::ImageBuffer::setPixelColor ( const s32  Pos,
const color Color 
)

Sets the pixel color at given position.

void sp::video::ImageBuffer::setPixelVector ( const dim::point2di Pos,
const dim::vector4df Color 
)
void sp::video::ImageBuffer::setPixelVector ( const s32  Pos,
const dim::vector4df Color 
)

Sets the pixel color at given position as float vector.

void sp::video::ImageBuffer::setPixelVector ( const dim::vector3di Pos,
const dim::vector4df Color 
)
virtual void sp::video::ImageBuffer::setSize ( const dim::size2di Size  )  [pure virtual]
void sp::video::ImageBuffer::setSizePOT (  )  [virtual]

Resizes the texture to a "Power Of Two" dimension if it is currently not.

virtual void sp::video::ImageBuffer::turnImage ( const EImageTurnDegrees  Degree  )  [pure virtual]

Member Data Documentation

Depth (1, 6 or individual).

Pixel format (RGB, BGR, RGBA, Gray etc.).

Format size (1, 2, 3 or 4).

Image buffer size (Always 2 dimensional).


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines