OGRE 2.1
Object-Oriented Graphics Rendering Engine
|
Some utility functions for packing and unpacking pixel data. More...
#include <OgrePixelFormat.h>
Static Public Member Functions | |
static void | bulkCompressedSubregion (const PixelBox &src, const PixelBox &dst, const Box &dstRegion) |
Emplaces the binary compressed data from src into a subregion of dst. | |
static void | bulkPixelConversion (const PixelBox &src, const PixelBox &dst) |
Convert pixels from one format to another. | |
static void | bulkPixelConversion (void *src, PixelFormat srcFormat, void *dst, PixelFormat dstFormat, unsigned int count) |
Convert consecutive pixels from one format to another. | |
static void | bulkPixelVerticalFlip (const PixelBox &box) |
Flips pixels inplace in vertical direction. | |
static size_t | calculateSizeBytes (uint32 width, uint32 height, uint32 depth, uint32 slices, PixelFormat format, uint8 numMipmaps) |
WARNING: numMipmaps includes the mip 0. | |
static void | convertForNormalMapping (const PixelBox &src, const PixelBox &dst) |
Converts the input source to either PF_R8G8_SNORM or PF_BYTE_LA. | |
static void | getBitDepths (PixelFormat format, int rgba[4]) |
Gives the number of bits (RGBA) for a format. | |
static void | getBitMasks (PixelFormat format, uint64 rgba[4]) |
Gives the masks for the R, G, B and A component. | |
static void | getBitShifts (PixelFormat format, unsigned char rgba[4]) |
Gives the bit shifts for R, G, B and A component. | |
static String | getBNFExpressionOfPixelFormats (bool accessibleOnly=false) |
Gets the BNF expression of the pixel-formats. | |
static size_t | getComponentCount (PixelFormat fmt) |
Returns the component count for a certain pixel format. | |
static PixelComponentType | getComponentType (PixelFormat fmt) |
Returns the component type for a certain pixel format. | |
static uint32 | getCompressedBlockHeight (PixelFormat format, bool apiStrict=true) |
@See getCompressedBlockWidth | |
static uint32 | getCompressedBlockWidth (PixelFormat format, bool apiStrict=true) |
Returns the minimum width for block compressed schemes. | |
static unsigned int | getFlags (PixelFormat format) |
Returns the property flags for this pixel format. | |
static PixelFormat | getFormatForBitDepths (PixelFormat fmt, ushort integerBits, ushort floatBits) |
Returns the similar format but acoording with given bit depths. | |
static PixelFormat | getFormatFromName (const String &name, bool accessibleOnly=false, bool caseSensitive=false) |
Gets the format from given name. | |
static String | getFormatName (PixelFormat srcformat) |
Gets the name of an image format. | |
static uint8 | getMaxMipmapCount (uint32 maxResolution) |
Returns the maximum number of mipmaps given the resolution e.g. | |
static uint8 | getMaxMipmapCount (uint32 width, uint32 height) |
static uint8 | getMaxMipmapCount (uint32 width, uint32 height, uint32 depth) |
static size_t | getMemorySize (uint32 width, uint32 height, uint32 depth, PixelFormat format) |
Returns the size in memory of a region with the given extents and pixel format with consecutive memory layout. | |
static size_t | getNumElemBits (PixelFormat format) |
Returns the size in bits of an element of the given pixel format. | |
static size_t | getNumElemBytes (PixelFormat format) |
Returns the size in bytes of an element of the given pixel format. | |
static bool | hasAlpha (PixelFormat format) |
Shortcut method to determine if the format has an alpha component. | |
static bool | isAccessible (PixelFormat srcformat) |
Returns whether the format can be packed or unpacked with the packColour() and unpackColour() functions. | |
static bool | isCompressed (PixelFormat format) |
Shortcut method to determine if the format is compressed. | |
static bool | isDepth (PixelFormat format) |
Shortcut method to determine if the format is a depth format. | |
static bool | isFloatingPoint (PixelFormat format) |
Shortcut method to determine if the format is floating point. | |
static bool | isInteger (PixelFormat format) |
Shortcut method to determine if the format is integer. | |
static bool | isLuminance (PixelFormat format) |
Shortcut method to determine if the format is a luminance format. | |
static bool | isNativeEndian (PixelFormat format) |
Shortcut method to determine if the format is in native endian format. | |
static bool | isSigned (PixelFormat format) |
Shortcut method to determine if the format is signed. | |
static bool | isValidExtent (size_t width, size_t height, size_t depth, PixelFormat format) |
Return whether a certain image extent is valid for this image format. | |
static void | packColour (const ColourValue &colour, const PixelFormat pf, void *dest) |
Pack a colour value to memory. | |
static void | packColour (const float r, const float g, const float b, const float a, const PixelFormat pf, void *dest) |
Pack a colour value to memory. | |
static void | packColour (const uint8 r, const uint8 g, const uint8 b, const uint8 a, const PixelFormat pf, void *dest) |
Pack a colour value to memory. | |
static void | unpackColour (ColourValue *colour, PixelFormat pf, const void *src) |
Unpack a colour value from memory. | |
static void | unpackColour (float *r, float *g, float *b, float *a, PixelFormat pf, const void *src) |
Unpack a colour value from memory. | |
static void | unpackColour (uint8 *r, uint8 *g, uint8 *b, uint8 *a, PixelFormat pf, const void *src) |
Unpack a colour value from memory. | |
Some utility functions for packing and unpacking pixel data.
|
static |
Emplaces the binary compressed data from src into a subregion of dst.
src | PixelBox containing the source pixels, pitches and format. Data must be consecutive |
dst | PixelBox containing the destination pixels, pitches and format. Data must be consecutive |
dstRegion | The region on dst where src will be emplaced. dstRegion's resolution must match that of src. dstRegion must be within dst's bounds. |
|
static |
Convert pixels from one format to another.
No dithering or filtering is being done. Converting from RGB to luminance takes the R channel.
src | PixelBox containing the source pixels, pitches and format |
dst | PixelBox containing the destination pixels, pitches and format |
|
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.
src | Pointer to source region |
srcFormat | Pixel format of source region |
dst | Pointer to destination region |
dstFormat | Pixel format of destination region |
Flips pixels inplace in vertical direction.
box | PixelBox containing pixels, pitches and format |
|
static |
WARNING: numMipmaps includes the mip 0.
That means numMipmaps > 0, and that you should use texture->getNumMipmaps + 1u
|
static |
Converts the input source to either PF_R8G8_SNORM or PF_BYTE_LA.
dst must be one of either formats.
src | PixelBox containing the source pixels, pitches and format |
dst | PixelBox containing the destination pixels, pitches and format |
|
static |
Gives the number of bits (RGBA) for a format.
See remarks.
|
static |
Gives the masks for the R, G, B and A component.
|
static |
Gives the bit shifts for R, G, B and A component.
Gets the BNF expression of the pixel-formats.
accessibleOnly | If true, only accessible pixel format will take into account, otherwise all pixel formats list in PixelFormat enumeration will being returned. |
|
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.
|
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.
|
static |
@See getCompressedBlockWidth
|
static |
Returns the minimum width for block compressed schemes.
ie. DXT1 compresses in blocks of 4x4 pixels. A texture with a width of 2 is just padded to 4. When building UV atlases composed of already compressed data being stitched together, the block size is very important to know as the resolution of the individual textures must be a multiple of this size.
format | The format to query for. Can be compressed or not. |
apiStrict | When true, obeys the rules of most APIs (i.e. ETC1 can't update subregions according to GLES specs). When false, becomes more practical if manipulating by hand (i.e. ETC1's subregions can be updated just fine by @bulkCompressedSubregion) |
|
static |
Returns the property flags for this pixel format.
|
static |
Returns the similar format but acoording with given bit depths.
fmt | The original foamt. |
integerBits | Preferred bit depth (pixel bits) for integer pixel format. Available values: 0, 16 and 32, where 0 (the default) means as it is. |
floatBits | Preferred bit depth (channel bits) for float pixel format. Available values: 0, 16 and 32, where 0 (the default) means as it is. |
|
static |
Gets the format from given name.
name | The string of format name |
accessibleOnly | If true, non-accessible format will treat as invalid format, otherwise, all supported format are valid. |
caseSensitive | Should be set true if string match should use case sensitivity. |
|
static |
Gets the name of an image format.
Returns the maximum number of mipmaps given the resolution e.g.
at 4x4 there's 2 mipmaps. At 1x1 there's 0 mipmaps.
|
static |
|
static |
Returns the size in memory of a region with the given extents and pixel format with consecutive memory layout.
width | The width of the area |
height | The height of the area |
depth | The depth of the area |
format | The format of the area |
|
static |
Returns the size in bits of an element of the given pixel format.
|
static |
Returns the size in bytes of an element of the given pixel format.
Referenced by Ogre::LinearResampler::scale(), and Ogre::LinearResampler_Float32::scale().
|
static |
Shortcut method to determine if the format has an alpha component.
|
static |
Returns whether 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.
|
static |
Shortcut method to determine if the format is compressed.
|
static |
Shortcut method to determine if the format is a depth format.
|
static |
Shortcut method to determine if the format is floating point.
|
static |
Shortcut method to determine if the format is integer.
|
static |
Shortcut method to determine if the format is a luminance format.
|
static |
Shortcut method to determine if the format is in native endian format.
|
static |
Shortcut method to determine if the format is signed.
|
static |
Return whether a certain image extent is valid for this image format.
width | The width of the area |
height | The height of the area |
depth | The depth of the area |
format | The format of the area |
|
static |
Pack a colour value to memory.
colour | The colour |
pf | Pixelformat in which to write the colour |
dest | Destination memory location |
Referenced by Ogre::LinearResampler::scale().
|
static |
Pack a colour value to memory.
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 |
|
static |
Pack a colour value to memory.
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 |
|
static |
Unpack a colour value from memory.
colour | The colour is returned here |
pf | Pixelformat in which to read the colour |
src | Source memory location |
|
static |
Unpack a colour value from memory.
r | The red channel is returned here (as float) |
g | The blue channel is returned here (as float) |
b | The green channel is returned here (as float) |
a | The alpha channel is returned here (as float) |
pf | Pixelformat in which to read the colour |
src | Source memory location |
|
static |
Unpack a colour value from memory.
r | The red channel is returned here (as byte) |
g | The blue channel is returned here (as byte) |
b | The green channel is returned here (as byte) |
a | The alpha channel is returned here (as byte) |
pf | Pixelformat in which to read the colour |
src | Source memory location |