Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Ogre::PixelUtil Class Reference

Some utility functions for packing and unpacking pixel data. More...

#include <OgrePixelFormat.h>

List of all members.

Static Public Member Functions

size_t getNumElemBytes (PixelFormat format)
 Returns the size in bytes of an element of the given pixel format.

size_t getNumElemBits (PixelFormat format)
 Returns the size in bits of an element of the given pixel format.

size_t getMemorySize (size_t width, size_t height, size_t depth, PixelFormat format)
 Returns the size in memory of a region with the given extents and pixel format with consecutive memory layout.

unsigned int getFlags (PixelFormat format)
 Returns the property flags for this pixel format.

bool hasAlpha (PixelFormat format)
 Shortcut method to determine if the format has an alpha component.

bool isFloatingPoint (PixelFormat format)
 Shortcut method to determine if the format is floating point.

bool isCompressed (PixelFormat format)
 Shortcut method to determine if the format is compressed.

bool isDepth (PixelFormat format)
 Shortcut method to determine if the format is a depth format.

bool isNativeEndian (PixelFormat format)
 Shortcut method to determine if the format is in native endian format.

bool isLuminance (PixelFormat format)
 Shortcut method to determine if the format is a luminance format.

bool isValidExtent (size_t width, size_t height, size_t depth, PixelFormat format)
 Return wether a certain image extent is valid for this image format.

void getBitDepths (PixelFormat format, int rgba[4])
 Gives the number of bits (RGBA) for a format.

void getBitMasks (PixelFormat format, uint32 rgba[4])
 Gives the masks for the R, G, B and A component.

String getFormatName (PixelFormat srcformat)
 Gets the name of an image format.

bool isAccessible (PixelFormat srcformat)
 Returns wether the format can be packed or unpacked with the packColour() and unpackColour() functions.

PixelComponentType getComponentType (PixelFormat fmt)
 Returns the component type for a certain pixel format.

size_t getComponentCount (PixelFormat fmt)
 Returns the component count for a certain pixel format.

void packColour (const ColourValue &colour, const PixelFormat pf, const void *dest)
 Pack a colour value to memory.

void packColour (const uint8 r, const uint8 g, const uint8 b, const uint8 a, const PixelFormat pf, const void *dest)
 Pack a colour value to memory.

void packColour (const float r, const float g, const float b, const float a, const PixelFormat pf, const void *dest)
 Pack a colour value to memory.

void unpackColour (ColourValue *colour, PixelFormat pf, const void *src)
 Unpack a colour value from memory.

void unpackColour (uint8 *r, uint8 *g, uint8 *b, uint8 *a, PixelFormat pf, const void *src)
 Unpack a colour value from memory.

void unpackColour (float *r, float *g, float *b, float *a, PixelFormat pf, const void *src)
 Unpack a colour value from memory.

void bulkPixelConversion (void *src, PixelFormat srcFormat, void *dest, PixelFormat dstFormat, unsigned int count)
 Convert consecutive pixels from one format to another.

void bulkPixelConversion (const PixelBox &src, const PixelBox &dst)
 Convert pixels from one format to another.


Detailed Description

Some utility functions for packing and unpacking pixel data.

Definition at line 260 of file OgrePixelFormat.h.


Member Function Documentation

void Ogre::PixelUtil::bulkPixelConversion const PixelBox src,
const PixelBox dst
[static]
 

Convert pixels from one format to another.

No dithering or filtering is being done. Converting from RGB to luminance takes the R channel.

Parameters:
src PixelBox containing the source pixels, pitches and format
dst PixelBox containing the destination pixels, pitches and format
Remarks:
The source and destination boxes must have the same dimensions. In case the source and destination format match, a plain copy is done.

void Ogre::PixelUtil::bulkPixelConversion void *  src,
PixelFormat  srcFormat,
void *  dest,
PixelFormat  dstFormat,
unsigned int  count
[static]
 

Convert consecutive pixels from one format to another.

No dithering or filtering is being done. Converting from RGB to luminance takes the R channel. In case the source and destination format match, just a copy is done.

Parameters:
src Pointer to source region
srcFormat Pixel format of source region
dst Pointer to destination region
dstFormat Pixel format of destination region

void Ogre::PixelUtil::getBitDepths PixelFormat  format,
int  rgba[4]
[static]
 

Gives the number of bits (RGBA) for a format.

See remarks.

Remarks:
For non-colour formats (dxt, depth) this returns [0,0,0,0].

void Ogre::PixelUtil::getBitMasks PixelFormat  format,
uint32  rgba[4]
[static]
 

Gives the masks for the R, G, B and A component.

Note:
Only valid for native endian formats

size_t Ogre::PixelUtil::getComponentCount PixelFormat  fmt  )  [static]
 

Returns the component count for a certain pixel format.

Returns 3(no alpha) or 4 (has alpha) in case there is no clear component type like with compressed formats.

PixelComponentType Ogre::PixelUtil::getComponentType PixelFormat  fmt  )  [static]
 

Returns the component type for a certain pixel format.

Returns PCT_BYTE in case there is no clear component type like with compressed formats. This is one of PCT_BYTE, PCT_SHORT, PCT_FLOAT16, PCT_FLOAT32.

unsigned int Ogre::PixelUtil::getFlags PixelFormat  format  )  [static]
 

Returns the property flags for this pixel format.

Returns:
A bitfield combination of PFF_HASALPHA, PFF_ISCOMPRESSED, PFF_FLOAT, PFF_DEPTH, PFF_NATIVEENDIAN, PFF_LUMINANCE
Remarks:
This replaces the seperate functions for formatHasAlpha, formatIsFloat, ...

String Ogre::PixelUtil::getFormatName PixelFormat  srcformat  )  [static]
 

Gets the name of an image format.

size_t Ogre::PixelUtil::getMemorySize size_t  width,
size_t  height,
size_t  depth,
PixelFormat  format
[static]
 

Returns the size in memory of a region with the given extents and pixel format with consecutive memory layout.

Parameters:
width The width of the area
height The height of the area
depth The depth of the area
format The format of the area
Returns:
The size in bytes
Remarks:
In case that the format is non-compressed, this simply returns width*height*depth*PixelUtil::getNumElemBytes(format). In the compressed case, this does serious magic.

size_t Ogre::PixelUtil::getNumElemBits PixelFormat  format  )  [static]
 

Returns the size in bits of an element of the given pixel format.

Returns:
The size in bits of an element. See Remarks.
Remarks:
Passing PF_UNKNOWN will result in returning a size of 0 bits.

Referenced by Ogre::D3D9RenderTexture::rebind().

size_t Ogre::PixelUtil::getNumElemBytes PixelFormat  format  )  [static]
 

Returns the size in bytes of an element of the given pixel format.

Returns:
The size in bytes of an element. See Remarks.
Remarks:
Passing PF_UNKNOWN will result in returning a size of 0 bytes.

bool Ogre::PixelUtil::hasAlpha PixelFormat  format  )  [static]
 

Shortcut method to determine if the format has an alpha component.

bool Ogre::PixelUtil::isAccessible PixelFormat  srcformat  )  [static]
 

Returns wether the format can be packed or unpacked with the packColour() and unpackColour() functions.

This is generally not true for compressed and depth formats as they are special. It can only be true for formats with a fixed element size.

Returns:
true if yes, otherwise false

bool Ogre::PixelUtil::isCompressed PixelFormat  format  )  [static]
 

Shortcut method to determine if the format is compressed.

bool Ogre::PixelUtil::isDepth PixelFormat  format  )  [static]
 

Shortcut method to determine if the format is a depth format.

bool Ogre::PixelUtil::isFloatingPoint PixelFormat  format  )  [static]
 

Shortcut method to determine if the format is floating point.

bool Ogre::PixelUtil::isLuminance PixelFormat  format  )  [static]
 

Shortcut method to determine if the format is a luminance format.

bool Ogre::PixelUtil::isNativeEndian PixelFormat  format  )  [static]
 

Shortcut method to determine if the format is in native endian format.

bool Ogre::PixelUtil::isValidExtent size_t  width,
size_t  height,
size_t  depth,
PixelFormat  format
[static]
 

Return wether a certain image extent is valid for this image format.

Parameters:
width The width of the area
height The height of the area
depth The depth of the area
format The format of the area
Remarks:
For non-compressed formats, this is always true. For DXT formats, only sizes with a width and height multiple of 4 and depth 1 are allowed.

void Ogre::PixelUtil::packColour const float  r,
const float  g,
const float  b,
const float  a,
const PixelFormat  pf,
const void *  dest
[static]
 

Pack a colour value to memory.

Parameters:
r,g,b,a The four colour components, range 0.0f to 1.0f (an exception to this case exists for floating point pixel formats, which don't clamp to 0.0f..1.0f)
pf Pixelformat in which to write the colour
dest Destination memory location

void Ogre::PixelUtil::packColour const uint8  r,
const uint8  g,
const uint8  b,
const uint8  a,
const PixelFormat  pf,
const void *  dest
[static]
 

Pack a colour value to memory.

Parameters:
r,g,b,a The four colour components, range 0x00 to 0xFF
pf Pixelformat in which to write the colour
dest Destination memory location

void Ogre::PixelUtil::packColour const ColourValue colour,
const PixelFormat  pf,
const void *  dest
[static]
 

Pack a colour value to memory.

Parameters:
colour The colour
pf Pixelformat in which to write the colour
dest Destination memory location

void Ogre::PixelUtil::unpackColour float *  r,
float *  g,
float *  b,
float *  a,
PixelFormat  pf,
const void *  src
[static]
 

Unpack a colour value from memory.

Parameters:
r,g,b,a The colour is returned here (as float)
pf Pixelformat in which to read the colour
src Source memory location

void Ogre::PixelUtil::unpackColour uint8 r,
uint8 g,
uint8 b,
uint8 a,
PixelFormat  pf,
const void *  src
[static]
 

Unpack a colour value from memory.

Parameters:
r,g,b,a The colour is returned here (as byte)
pf Pixelformat in which to read the colour
src Source memory location
Remarks:
This function returns the colour components in 8 bit precision, this will lose precision when coming from PF_A2R10G10B10 or floating point formats.

void Ogre::PixelUtil::unpackColour ColourValue colour,
PixelFormat  pf,
const void *  src
[static]
 

Unpack a colour value from memory.

Parameters:
colour The colour is returned here
pf Pixelformat in which to read the colour
src Source memory location


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

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:41:40 2006