OGRE-Next
2.3
Object-Oriented Graphics Rendering Engine
|
Class representing an image file. More...
#include <OgreImage2.h>
Public Types | |
enum | Filter { FILTER_NEAREST , FILTER_LINEAR , FILTER_BILINEAR , FILTER_BOX , FILTER_TRIANGLE , FILTER_BICUBIC , FILTER_GAUSSIAN , FILTER_GAUSSIAN_HIGH } |
Public Member Functions | |
Image2 () | |
Image2 (const Image2 &img) | |
Copy-constructor - copies all the data from the target image. More... | |
virtual | ~Image2 () |
void | _setAutoDelete (bool autoDelete) |
void | convertFromTexture (TextureGpu *texture, uint8 minMip, uint8 maxMip, bool automaticResolve=true) |
Synchronously downloads the selected mips from a TextureGpu into this Image. More... | |
void | createEmptyImage (uint32 width, uint32 height, uint32 depthOrSlices, TextureTypes::TextureTypes textureType, PixelFormatGpu format, uint8 numMipmaps=1u) |
Convenience function. More... | |
void | createEmptyImageLike (const TextureGpu *texture) |
Same as createEmptyImage, but retrieves all metadata parameters from the input texture. More... | |
DataStreamPtr | encode (const String &formatextension, uint8 mipLevel, uint8 numMipmaps) |
Encode the image and return a stream to the data. More... | |
void | flipAroundX () |
Flips (mirrors) the image around the X-axis. More... | |
void | flipAroundY () |
Flips (mirrors) the image around the Y-axis. More... | |
void | freeMemory () |
Delete all the memory held by this image, if owned by this image (not dynamic) More... | |
bool | generateMipmaps (bool gammaCorrected, Filter filter=FILTER_BILINEAR) |
Generates the mipmaps for this image. More... | |
bool | getAutoDelete () const |
size_t | getBytesPerImage (uint8 mipLevel) const |
size_t | getBytesPerRow (uint8 mipLevel) const |
ColourValue | getColourAt (size_t x, size_t y, size_t z, uint8 mipLevel=0) const |
Get colour value from a certain location in the image. More... | |
TextureBox | getData (uint8 mipLevel) const |
Returns a pointer to the internal image buffer. More... | |
uint32 | getDepth () const |
For TypeCube & TypeCubeArray, this value returns 1. More... | |
uint32 | getDepthOrSlices () const |
uint32 | getHeight () const |
uint8 | getNumMipmaps () const |
uint32 | getNumSlices () const |
For TypeCube this value returns 6. More... | |
PixelFormatGpu | getPixelFormat () const |
void * | getRawBuffer () |
size_t | getSizeBytes () const |
Returns total size in bytes used in GPU by this texture including mipmaps. More... | |
TextureTypes::TextureTypes | getTextureType () const |
uint32 | getWidth () const |
void | load (const String &filename, const String &groupName) |
Loads an image file. More... | |
void | load (DataStreamPtr &stream, const String &type=BLANKSTRING) |
Loads an image file from a stream. More... | |
void | loadDynamicImage (void *pData, bool autoDelete, const Image2 *image) |
void | loadDynamicImage (void *pData, bool autoDelete, const TextureGpu *texture) |
Convenience function. More... | |
void | loadDynamicImage (void *pData, uint32 width, uint32 height, uint32 depthOrSlices, TextureTypes::TextureTypes textureType, PixelFormatGpu format, bool autoDelete, uint8 numMipmaps=1u) |
Stores a pointer to raw data in memory. More... | |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, const char *, int, const char *) |
void | operator delete (void *ptr, void *) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *ptr, const char *, int, const char *) |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, const char *file, int line, const char *func) |
operator new, with debug line info More... | |
void * | operator new (size_t sz, void *ptr) |
placement operator new More... | |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
array operator new, with debug line info More... | |
Image2 & | operator= (const Image2 &img) |
Assignment operator - copies all the data from the target image. More... | |
void | resize (uint32 width, uint32 height, Filter filter=FILTER_BILINEAR) |
Resize a 2D image, applying the appropriate filter. More... | |
void | save (const String &filename, uint8 mipLevel, uint8 numMipmaps) |
Save the image as a file. More... | |
void | setColourAt (const ColourValue &cv, size_t x, size_t y, size_t z, uint8 mipLevel=0) |
Set colour value at a certain location in the image. More... | |
void | uploadTo (TextureGpu *texture, uint8 minMip, uint8 maxMip, uint32 dstZorSliceStart=0u, uint32 srcDepthOrSlices=0u) |
Synchronously uploads the selected mips from this Image into a TextureGpu. More... | |
Static Public Member Functions | |
static void | copyContentsToMemory (TextureGpu *srcTexture, TextureBox srcBox, TextureBox dstBox, PixelFormatGpu dstFormat, bool automaticResolve=true) |
Synchronously downloads the mip 0 from a TextureGpu into the TextureBox. More... | |
static bool | getDownsamplerFunctions (PixelFormatGpu format, void **imageDownsampler2D, void **imageDownsampler3D, void **imageDownsamplerCube, void **imageBlur2D, bool gammaCorrected, uint32 depthOrSlices, TextureTypes::TextureTypes textureType, Filter filter) |
Sets the proper downsampler functions to generate mipmaps. More... | |
static String | getFileExtFromMagic (DataStreamPtr &stream) |
Static function to get an image type string from a stream via magic numbers. More... | |
static void | scale (const TextureBox &src, PixelFormatGpu srcFormat, TextureBox &dst, PixelFormatGpu dstFormat, Filter filter=FILTER_BILINEAR) |
Scale a 1D, 2D or 3D image volume. More... | |
static bool | supportsSwMipmaps (PixelFormatGpu format, uint32 depthOrSlices, TextureTypes::TextureTypes textureType, Filter filter) |
Class representing an image file.
enum Ogre::Image2::Filter |
Ogre::Image2::Image2 | ( | ) |
Ogre::Image2::Image2 | ( | const Image2 & | img | ) |
Copy-constructor - copies all the data from the target image.
|
virtual |
void Ogre::Image2::_setAutoDelete | ( | bool | autoDelete | ) |
void Ogre::Image2::convertFromTexture | ( | TextureGpu * | texture, |
uint8 | minMip, | ||
uint8 | maxMip, | ||
bool | automaticResolve = true |
||
) |
Synchronously downloads the selected mips from a TextureGpu into this Image.
This function is for convenience for when going async is not important.
minMip | First mipmap to download, inclusive. |
maxMip | Last mipmap to download, inclusive. |
automaticResolve | When true, we will take care of resolving explicit MSAA textures if necessary, so that the download from GPU works fine. |
|
static |
Synchronously downloads the mip 0 from a TextureGpu into the TextureBox.
This function is for convenience for when going async is not important.
srcBox | Source region of source texture to download. Only x, y, z, sliceStart, width, height, depth, numSlices fields are used. |
dstBox | Together with dstFormat describes the destination memory region. It is explicitly allowed for this region to be non-contiguous. |
dstFormat | Together with dstBox describes the destination memory region. This format is not required to be the same as the format of the source texture, it could be any supported by bulkPixelConversion, including 24bpp formats. |
automaticResolve | When true, we will take care of resolving explicit MSAA textures if necessary, so that the download from GPU works fine. |
void Ogre::Image2::createEmptyImage | ( | uint32 | width, |
uint32 | height, | ||
uint32 | depthOrSlices, | ||
TextureTypes::TextureTypes | textureType, | ||
PixelFormatGpu | format, | ||
uint8 | numMipmaps = 1u |
||
) |
Convenience function.
Same as Image2::loadDynamicImage, but allocates an uninitialized pointer to store all data and call loadDynamicImage with it
void Ogre::Image2::createEmptyImageLike | ( | const TextureGpu * | texture | ) |
Same as createEmptyImage, but retrieves all metadata parameters from the input texture.
DataStreamPtr Ogre::Image2::encode | ( | const String & | formatextension, |
uint8 | mipLevel, | ||
uint8 | numMipmaps | ||
) |
Encode the image and return a stream to the data.
formatextension | An extension to identify the image format to encode into, e.g. "jpg" or "png" |
void Ogre::Image2::flipAroundX | ( | ) |
Flips (mirrors) the image around the X-axis.
flip axis | originalimg|gmilanigiro 00000000000|00000000000 00000000000|00000000000 00000000000|00000000000 00000000000|00000000000 00000000000|00000000000
void Ogre::Image2::flipAroundY | ( | ) |
Flips (mirrors) the image around the Y-axis.
originalimg 00000000000 00000000000 00000000000 00000000000 00000000000 ------------> flip axis 00000000000 00000000000 00000000000 00000000000 00000000000 originalimg
void Ogre::Image2::freeMemory | ( | ) |
Delete all the memory held by this image, if owned by this image (not dynamic)
bool Ogre::Image2::generateMipmaps | ( | bool | gammaCorrected, |
Filter | filter = FILTER_BILINEAR |
||
) |
Generates the mipmaps for this image.
For Cubemaps, the filtering is seamless; and a gaussian filter is recommended although it's slow.
gammaCorrected | True if the filter should be applied in linear space. |
filter | The type of filter to use. |
bool Ogre::Image2::getAutoDelete | ( | ) | const |
size_t Ogre::Image2::getBytesPerImage | ( | uint8 | mipLevel | ) | const |
size_t Ogre::Image2::getBytesPerRow | ( | uint8 | mipLevel | ) | const |
ColourValue Ogre::Image2::getColourAt | ( | size_t | x, |
size_t | y, | ||
size_t | z, | ||
uint8 | mipLevel = 0 |
||
) | const |
Get colour value from a certain location in the image.
TextureBox Ogre::Image2::getData | ( | uint8 | mipLevel | ) | const |
Returns a pointer to the internal image buffer.
uint32 Ogre::Image2::getDepth | ( | ) | const |
For TypeCube & TypeCubeArray, this value returns 1.
uint32 Ogre::Image2::getDepthOrSlices | ( | ) | const |
|
static |
Sets the proper downsampler functions to generate mipmaps.
format | |
imageDownsampler2D | [out] |
imageDownsampler3D | [out] |
imageDownsamplerCube | [out] |
imageBlur2D | [out] |
gammaCorrected | When true, force gamma correction on. If this value is false but format is of the sRGB family, gamma correction will still be used. |
depthOrSlices | Required to properly calculate the return value |
textureType | Required to properly calculate the return value |
filter |
|
static |
Static function to get an image type string from a stream via magic numbers.
uint32 Ogre::Image2::getHeight | ( | ) | const |
uint8 Ogre::Image2::getNumMipmaps | ( | ) | const |
uint32 Ogre::Image2::getNumSlices | ( | ) | const |
For TypeCube this value returns 6.
For TypeCubeArray, value returns numSlices * 6u.
PixelFormatGpu Ogre::Image2::getPixelFormat | ( | ) | const |
|
inline |
size_t Ogre::Image2::getSizeBytes | ( | ) | const |
Returns total size in bytes used in GPU by this texture including mipmaps.
TextureTypes::TextureTypes Ogre::Image2::getTextureType | ( | ) | const |
uint32 Ogre::Image2::getWidth | ( | ) | const |
Loads an image file.
filename | Name of an image file to load. |
groupName | Name of the resource group to search for the image |
void Ogre::Image2::load | ( | DataStreamPtr & | stream, |
const String & | type = BLANKSTRING |
||
) |
Loads an image file from a stream.
stream | The source data. |
type | The type of the image. Used to decide what decompression codec to use. Can be left blank if the stream data includes a header to identify the data. |
void Ogre::Image2::loadDynamicImage | ( | void * | pData, |
bool | autoDelete, | ||
const Image2 * | image | ||
) |
void Ogre::Image2::loadDynamicImage | ( | void * | pData, |
bool | autoDelete, | ||
const TextureGpu * | texture | ||
) |
Convenience function.
Same as Image2::loadDynamicImage, but retrieves all metadata parameters from the input texture
void Ogre::Image2::loadDynamicImage | ( | void * | pData, |
uint32 | width, | ||
uint32 | height, | ||
uint32 | depthOrSlices, | ||
TextureTypes::TextureTypes | textureType, | ||
PixelFormatGpu | format, | ||
bool | autoDelete, | ||
uint8 | numMipmaps = 1u |
||
) |
Stores a pointer to raw data in memory.
The pixel format has to be specified.
data | The data pointer. Must've been allocated with OGRE_MALLOC_SIMD( sizeBytes, MEMCATEGORY_RESOURCE ); and sizeBytes assumes a pitch with row alignment = 4u; Use PixelFormatGpuUtils::getSizeBytes( width, 1u, 1u, 1u, pixelFormat, 4u ); to get the pitch. |
width | Width of image |
height | Height of image |
depthOrSlices | Image Depth. For 3D images, it's the depth. For cubemaps it must be 6. For cubemap arrays it must be 6 x num_arrays. For the rest it must be 1. |
textureType | The type of the texture. |
format | Pixel Format |
autoDelete | If memory associated with this buffer is to be destroyed with the Image object. Note: it's important that if you set this option to true, that you allocated the memory using OGRE_MALLOC_SIMD with a category of MEMCATEGORY_RESOURCE to ensure the freeing of memory matches up. |
numMipmaps | The number of mipmaps the image data has inside. A value of 0 is invalid. |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
operator new, with debug line info
|
inlineinherited |
placement operator new
|
inlineinherited |
|
inlineinherited |
array operator new, with debug line info
Assignment operator - copies all the data from the target image.
void Ogre::Image2::resize | ( | uint32 | width, |
uint32 | height, | ||
Filter | filter = FILTER_BILINEAR |
||
) |
Resize a 2D image, applying the appropriate filter.
Save the image as a file.
|
static |
Scale a 1D, 2D or 3D image volume.
src | PixelBox containing the source pointer, dimensions and format |
dst | PixelBox containing the destination pointer, dimensions and format |
filter | Which filter to use |
void Ogre::Image2::setColourAt | ( | const ColourValue & | cv, |
size_t | x, | ||
size_t | y, | ||
size_t | z, | ||
uint8 | mipLevel = 0 |
||
) |
Set colour value at a certain location in the image.
|
static |
void Ogre::Image2::uploadTo | ( | TextureGpu * | texture, |
uint8 | minMip, | ||
uint8 | maxMip, | ||
uint32 | dstZorSliceStart = 0u , |
||
uint32 | srcDepthOrSlices = 0u |
||
) |
Synchronously uploads the selected mips from this Image into a TextureGpu.
This function is for convenience for when going async is not important.
texture | Texture to upload to. Must have the same resolution and same pixel format family as this Image. For simplicity, you can't upload mip 0 of this image into mip 1. |
minMip | First mipmap to upload, inclusive. |
maxMip | Last mipmap to upload, inclusive. |
dstZorSliceStart | Destination offset in the texture (e.g. when dstZorSliceStart = 5, it uploads N slices between [5; 5+N) ) |
srcDepthOrSlices | How many slices from this Image2 to upload. Zero to upload all of them. |