NvImage Class Reference
Image loading, representation and handling Support loading of images from DDS files and data, including cube maps, arrays mipmap levels, formats, etc. More...
#include <NvImage.h>
Classes | |
struct | FormatInfo |
Format handlers descriptor for custom image loading. More... | |
Public Member Functions | |
int32_t | getWidth () const |
The image width in pixels. | |
int32_t | getHeight () const |
The image height in pixels. | |
int32_t | getDepth () const |
The image depth in pixels. | |
int32_t | getMipLevels () const |
The number of miplevels. | |
int32_t | getFaces () const |
The number of cubemap faces. | |
int32_t | getLayers () const |
The number of layers in a texture array. | |
uint32_t | getFormat () const |
The GL format of the image. | |
uint32_t | getInternalFormat () const |
The GL internal format of the image. | |
uint32_t | getType () const |
The GL type of the pixel data. | |
int32_t | getImageSize (int32_t level=0) const |
The size (in bytes) of a selected mipmap level of the image. | |
bool | isCompressed () const |
Whether or not the image is compressed. | |
bool | isCubeMap () const |
Whether or not the image is a cubemap. | |
bool | hasAlpha () const |
Whether or not the image's pixel format has an explicit alpha channel. | |
bool | isArray () const |
Whether or not the image is an array texture. | |
bool | isVolume () const |
Whether or not the image is a volume (3D) image. | |
uint32_t | getDataBlockSize () const |
Get the size of the overall pixel data block for the image. | |
bool | loadImageFromFileData (const uint8_t *fileData, size_t size, const char *fileExt) |
Loads an image from file-formatted data. | |
bool | convertCrossToCubemap () |
Convert a flat "cross" image to a cubemap Convert a suitable image from a cubemap cross to a cubemap. | |
bool | reformatImage (int32_t width, int32_t height, uint32_t format, uint32_t type) |
Replace (destructive to all content) the storage data and format of the image Mainly used by image loaders to resize and reformat an already-created image. | |
bool | setImage (int32_t width, int32_t height, uint32_t format, uint32_t type, const void *data) |
const void * | getLevel (int32_t level) const |
void * | getLevel (int32_t level) |
const void * | getLevel (int32_t level, uint32_t face) const |
void * | getLevel (int32_t level, uint32_t face) |
const void * | getLayerLevel (int32_t level, int32_t slice) const |
void * | getLayerLevel (int32_t level, int32_t slice) |
const uint8_t * | getDataBlock () const |
uint8_t * | getDataBlock () |
uint32_t | getLevelOffset (int32_t level) const |
uint32_t | getLevelOffset (int32_t level, uint32_t face) const |
uint32_t | getLayerLevelOffset (int32_t level, int32_t slice) const |
Static Public Member Functions | |
static void | VerticalFlip (bool flip) |
Sets whether to flip the image vertically. | |
static bool | GetVerticalFlip () |
Returns whether the loader will flip the image vertically. | |
static NvImage * | CreateFromDDSFile (const char *filename) |
Create a new NvImage (no texture) directly from DDS file Uses NvAssetLoaderRead for opening the file. | |
static void | setSupportsBGR (bool bgr) |
Enables or disables automatic swapping of BGR-order images to RGB. | |
static bool | getSupportsBGR () |
Gets the status of automatic swapping of BGR-order images to RGB. | |
static void | setDXTExpansion (bool expand) |
Enables or disables automatic expansion of DXT images to RGBA. | |
static bool | getDXTExpansion () |
Gets the status of automatic DXT expansion. | |
static bool | addFileLoader (const FormatInfo &loader) |
Adds a file loader for the given file extension. | |
Friends | |
bool | TranslateDX10Format (const void *ptr, NvImage &i, int32_t &bytesPerElement, bool &btcCompressed) |
Detailed Description
Image loading, representation and handling Support loading of images from DDS files and data, including cube maps, arrays mipmap levels, formats, etc.The class does NOT encapsulate a rendering texture object, only the client side pixel data that could be used to create such a texture
Member Function Documentation
static bool NvImage::addFileLoader | ( | const FormatInfo & | loader | ) | [static] |
Adds a file loader for the given file extension.
- Parameters:
-
[in] loader the descriptor for the loading system
- Returns:
- true on success or false on failure (no more loader slots or extension already handled)
bool NvImage::convertCrossToCubemap | ( | ) |
Convert a flat "cross" image to a cubemap Convert a suitable image from a cubemap cross to a cubemap.
- Returns:
- true on success or false for unsuitable source images
static NvImage* NvImage::CreateFromDDSFile | ( | const char * | filename | ) | [static] |
Create a new NvImage (no texture) directly from DDS file Uses NvAssetLoaderRead for opening the file.
See the documentation for that package to understand the correct paths
- Parameters:
-
[in] filename the image filename (and path) to load
- Returns:
- a pointer to the NvImage representing the file or null on failure
uint8_t* NvImage::getDataBlock | ( | ) | [inline] |
Get a pointer to the overall pixel data block for the image. The block is contiguous and allows for easy loading into a single pre-allocated memory block for low-level 3D APIs
- Returns:
- a pointer to the data
const uint8_t* NvImage::getDataBlock | ( | ) | const [inline] |
Get a pointer to the overall pixel data block for the image. The block is contiguous and allows for easy loading into a single pre-allocated memory block for low-level 3D APIs
- Returns:
- a pointer to the data
uint32_t NvImage::getDataBlockSize | ( | ) | const [inline] |
Get the size of the overall pixel data block for the image.
The block is contiguous and allows for easy loading into a single pre-allocated memory block for low-level 3D APIs
- Returns:
- the size of the block in bytes
int32_t NvImage::getDepth | ( | ) | const [inline] |
The image depth in pixels.
This is the third dimension of a 3D/volume image, NOT the color-depth
- Returns:
- the depth of the image (0 for images with no depth)
static bool NvImage::getDXTExpansion | ( | ) | [inline, static] |
Gets the status of automatic DXT expansion.
- Returns:
- true if DXT images will be expanded, false if they will be passed through
int32_t NvImage::getFaces | ( | ) | const [inline] |
The number of cubemap faces.
- Returns:
- the number of cubemap faces available for the image (0 for non-cubemap images)
uint32_t NvImage::getFormat | ( | ) | const [inline] |
The GL format of the image.
- Returns:
- the format of the image data (NVIMAGE_RGB, NVIMAGE_BGR, etc)
int32_t NvImage::getHeight | ( | ) | const [inline] |
The image height in pixels.
- Returns:
- the height of the image in pixels
int32_t NvImage::getImageSize | ( | int32_t | level = 0 |
) | const |
The size (in bytes) of a selected mipmap level of the image.
- Returns:
- the Size in bytes of a level of the image
- Parameters:
-
[in] level the mipmap level whose size if to be returned
uint32_t NvImage::getInternalFormat | ( | ) | const [inline] |
The GL internal format of the image.
- Returns:
- the suggested internal format for the data
void* NvImage::getLayerLevel | ( | int32_t | level, | |
int32_t | slice | |||
) |
Get a pointer to the pixel data for a given mipmap level and array slice.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] slice the layer index [0, getLayers)
- Returns:
- a pointer to the data
const void* NvImage::getLayerLevel | ( | int32_t | level, | |
int32_t | slice | |||
) | const |
Get a pointer to the pixel data for a given mipmap level and array slice.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] slice the layer index [0, getLayers)
- Returns:
- a pointer to the data
uint32_t NvImage::getLayerLevelOffset | ( | int32_t | level, | |
int32_t | slice | |||
) | const |
Get an offset in bytes from the block base to the pixel data for a given mipmap level and array slice.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] slice the layer index [0, getLayers)
- Returns:
- the offset in bytes
int32_t NvImage::getLayers | ( | ) | const [inline] |
The number of layers in a texture array.
- Returns:
- the number of layers for use in texture arrays
void* NvImage::getLevel | ( | int32_t | level, | |
uint32_t | face | |||
) |
Get a pointer to the pixel data for a given mipmap level and cubemap face.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] face the cubemap face (NVIMAGE_TEXTURE_CUBE_MAP_*_*)
- Returns:
- a pointer to the data
const void* NvImage::getLevel | ( | int32_t | level, | |
uint32_t | face | |||
) | const |
Get a pointer to the pixel data for a given mipmap level and cubemap face.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] face the cubemap face (NVIMAGE_TEXTURE_CUBE_MAP_*_*)
- Returns:
- a pointer to the data
void* NvImage::getLevel | ( | int32_t | level | ) |
Get a pointer to the pixel data for a given mipmap level.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels)
- Returns:
- a pointer to the data
const void* NvImage::getLevel | ( | int32_t | level | ) | const |
Get a pointer to the pixel data for a given mipmap level.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels)
- Returns:
- a pointer to the data
uint32_t NvImage::getLevelOffset | ( | int32_t | level, | |
uint32_t | face | |||
) | const |
Get an offset in bytes from the block base to the pixel data for a given mipmap level and array slice.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels) [in] slice the layer index [0, getLayers)
- Returns:
- the offset in bytes
uint32_t NvImage::getLevelOffset | ( | int32_t | level | ) | const |
Get an offset in bytes from the block base to the pixel data for a given mipmap level.
- Parameters:
-
[in] level the mipmap level [0, getMipLevels)
- Returns:
- the offset in bytes
int32_t NvImage::getMipLevels | ( | ) | const [inline] |
The number of miplevels.
- Returns:
- the number of mipmap levels available for the image
static bool NvImage::getSupportsBGR | ( | ) | [inline, static] |
Gets the status of automatic swapping of BGR-order images to RGB.
- Returns:
- true if BGR images will be swapped, false if they will be passed through
uint32_t NvImage::getType | ( | ) | const [inline] |
The GL type of the pixel data.
- Returns:
- the type of the image data
static bool NvImage::GetVerticalFlip | ( | ) | [inline, static] |
Returns whether the loader will flip the image vertically.
By default, the image library places the origin of images at the lower-left corner, to make it map exactly to OpenGL screen coords. This might make it incompatible with the texture coordinate conventions of an imported model that places its origin at the upper-left corner (D3D/DDS). In that case, doing a flip during loading could be desirable.
- Returns:
- true if flip is enabled.
int32_t NvImage::getWidth | ( | ) | const [inline] |
The image width in pixels.
- Returns:
- the width of the image in pixels
bool NvImage::hasAlpha | ( | ) | const |
Whether or not the image's pixel format has an explicit alpha channel.
- Returns:
- boolean whether the image has explicit alpha channel
bool NvImage::isArray | ( | ) | const [inline] |
Whether or not the image is an array texture.
- Returns:
- boolean whether the image represents a texture array
bool NvImage::isCompressed | ( | ) | const |
Whether or not the image is compressed.
- Returns:
- boolean whether the data is a crompressed format
bool NvImage::isCubeMap | ( | ) | const [inline] |
Whether or not the image is a cubemap.
- Returns:
- boolean whether the image represents a cubemap
bool NvImage::isVolume | ( | ) | const [inline] |
Whether or not the image is a volume (3D) image.
- Returns:
- boolean whether the image represents a volume
bool NvImage::loadImageFromFileData | ( | const uint8_t * | fileData, | |
size_t | size, | |||
const char * | fileExt | |||
) |
Loads an image from file-formatted data.
Initialize an image from file-formatted memory; only DDS files are supported
- Parameters:
-
[in] fileData the block of memory representing the entire image file [in] size the size of the data block in bytes [in] fileExt the file extension string; must be "dds"
- Returns:
- true on success, false on failure
bool NvImage::reformatImage | ( | int32_t | width, | |
int32_t | height, | |||
uint32_t | format, | |||
uint32_t | type | |||
) |
Replace (destructive to all content) the storage data and format of the image Mainly used by image loaders to resize and reformat an already-created image.
- Parameters:
-
[in] width of the new image [in] height of the new image [in] format NVIMAGE_ format of the new image [in] type NVIMAGE_ type of the component data in the new image
- Returns:
- true on success or false for failure
static void NvImage::setDXTExpansion | ( | bool | expand | ) | [inline, static] |
Enables or disables automatic expansion of DXT images to RGBA.
- Parameters:
-
[in] expand true enables DXT-to-RGBA expansion. False passes DXT images through as-is
static void NvImage::setSupportsBGR | ( | bool | bgr | ) | [inline, static] |
Enables or disables automatic swapping of BGR-order images to RGB.
- Parameters:
-
[in] bgr true allows BGR directly. False causes the loader to reformat to RGB
static void NvImage::VerticalFlip | ( | bool | flip | ) | [static] |
Sets whether to flip the image vertically.
By default, the image library places the origin of images at the lower-left corner, to make it map exactly to OpenGL screen coords. This might make it incompatible with the texture coordinate conventions of an imported model that places its origin at the upper-left corner (D3D/DDS). In that case, doing a flip during loading could be desirable. Note: for ASTC textures, flip is not supported and "VerticalFlip(false)" is required.
- Parameters:
-
[in] flip true if flip is required.
The documentation for this class was generated from the following file: