Image is the basic runtime primitive to load, hold, and convert image data in memory. More...
#include <kanzi/core.ui/bitmap/bitmap_image.hpp>
Public Member Functions | |
void | convert (GraphicsFormat newFormat) |
Converts the graphics format of the image data. More... | |
void | flip (ImageFlipAxis axis) |
Flip data over an axis. More... | |
void | flipHorizontally () |
Flips an image horizontally. More... | |
void | flipVertically () |
Flips an image vertically. More... | |
void | generateMipmaps () |
Generates mipmap images for an image. The size of the smallest mipmap image is 1x1 pixels. More... | |
byte * | getData () |
Returns a pointer to the raw image data in memory. More... | |
byte * | getData (size_t mipmapLevel) |
Returns a pointer to the raw image data at a specific mipmap level. More... | |
const byte * | getData () const |
Returns a const pointer to the raw image data in memory. More... | |
const byte * | getData (size_t mipmapLevel) const |
Returns a const pointer to the raw image data at a specific mipmap level. More... | |
GraphicsFormat | getDataFormat () const |
Returns the pixel data format of an image. More... | |
GraphicsFormat | getDataFormat (size_t mipmapLevel) const |
Returns the pixel data format at specified mipmap level. More... | |
size_t | getDataSize () const |
Returns the size of image data in bytes. More... | |
size_t | getDataSize (size_t mipmapLevel) const |
Returns the size of image data at a specific mipmap level in bytes. More... | |
unsigned int | getHeight () const |
Returns the height of an image in pixels. More... | |
unsigned int | getHeight (size_t mipmapLevel) const |
Returns the height of a an image in pixels at specific mipmap level. More... | |
size_t | getMipmapLevelCount () const |
Returns the count of mipmap levels held by this image. More... | |
string_view | getName () const |
Gets the name of an image. More... | |
unsigned int | getWidth () const |
Returns the width of an image in pixels. More... | |
unsigned int | getWidth (size_t mipmapLevel) const |
Returns the width of a an image in pixels at specific mipmap level. More... | |
bool | isCompressedFormat () const |
Returns whether an image uses a compressed format. More... | |
void | premultiplyAlpha () |
Premultiplies the color and luminance channels by the alpha channel. More... | |
void | resetData (unsigned int newWidth, unsigned int newHeight, GraphicsFormat newFormat) |
Resets an image with a new width, height, and data format. More... | |
void | resize (unsigned int newWidth, unsigned int newHeight, ImageResizeFilter resizeFilter) |
Resizes the image and discards any existing mipmap images. More... | |
void | setName (string_view name) |
Sets the name for an image. More... | |
Static Public Member Functions | |
static BitmapImageUniquePtr | createCopy (const BitmapImage &image) |
Creates a copy of an image. More... | |
static BitmapImageUniquePtr | createEmpty (unsigned int width, unsigned int height, GraphicsFormat format, string_view name="") |
Creates an empty image, initializes all pixel data to zero. More... | |
static BitmapImageUniquePtr | createEmptyMipmapped (unsigned int width, unsigned int height, GraphicsFormat format, string_view name="") |
Creates an empty image with empty mipmaps, initializes all pixel data to zero. More... | |
static BitmapImageUniquePtr | createFromMemory (unsigned int width, unsigned int height, GraphicsFormat format, const byte *data, string_view name="") |
Creates an image by copying the pixel data from memory. More... | |
static BitmapImageUniquePtr | createFromMemoryFlipped (unsigned int width, unsigned int height, GraphicsFormat format, const byte *data, ImageFlipAxis axis, string_view name="") |
Creates an image by copying the pixel data from memory. More... | |
static BitmapImageUniquePtr | createMipmapped (BitmapImageVector mipmapImages) |
Creates a mipmapped image from a vector of mipmap level images. More... | |
Protected Member Functions | |
BitmapImage () | |
Constructs an image with all members set to zero. More... | |
BitmapImage (unsigned int width, unsigned int height, GraphicsFormat format, bool mipmaps, string_view name="") | |
Constructs an image with data set to all zeroes. More... | |
void | setMipmapLevels (BitmapImageVector images) |
Replaces the mipmap level images for an image. More... | |
Static Protected Member Functions | |
static BitmapImageUniquePtr | createCopyMoveData (BitmapImage *other) |
Kanzi internally uses this function to create a copy of an image by moving over the image data. More... | |
Image is the basic runtime primitive to load, hold, and convert image data in memory.
Each image has width, height, pixel format, image data in memory, and can contain mipmap images.
To display an image, you must create a texture instance from that image. When you do so, you must transfer the ownership of the image to the texture instance using Texture::CreateInfo2D.
To load an image from a file and make a texture out of it:
To create an image from pixel data in memory:
|
explicitprotected |
Constructs an image with all members set to zero.
|
explicitprotected |
Constructs an image with data set to all zeroes.
width | Width of the image in pixels. |
height | Height of the image in pixels. |
format | Graphics format to use. |
mipmaps | Indicates whether to allocate data for mipmaps. |
name | (Optional) A name for the image. |
unsigned int kanzi::BitmapImage::getWidth | ( | ) | const |
Returns the width of an image in pixels.
unsigned int kanzi::BitmapImage::getWidth | ( | size_t | mipmapLevel | ) | const |
Returns the width of a an image in pixels at specific mipmap level.
mipmapLevel | The wanted mipmap level, 0 being base level. |
unsigned int kanzi::BitmapImage::getHeight | ( | ) | const |
Returns the height of an image in pixels.
unsigned int kanzi::BitmapImage::getHeight | ( | size_t | mipmapLevel | ) | const |
Returns the height of a an image in pixels at specific mipmap level.
mipmapLevel | The wanted mipmap level, 0 being base level. |
void kanzi::BitmapImage::resetData | ( | unsigned int | newWidth, |
unsigned int | newHeight, | ||
GraphicsFormat | newFormat | ||
) |
Resets an image with a new width, height, and data format.
This function discards the current image data.
newWidth | New width of the image in pixels. |
newHeight | New height of the image in pixels. |
newFormat | New pixel format for the image. |
GraphicsFormat kanzi::BitmapImage::getDataFormat | ( | ) | const |
Returns the pixel data format of an image.
GraphicsFormat kanzi::BitmapImage::getDataFormat | ( | size_t | mipmapLevel | ) | const |
Returns the pixel data format at specified mipmap level.
mipmapLevel | The wanted mipmap level, 0 being base level. |
byte* kanzi::BitmapImage::getData | ( | ) |
Returns a pointer to the raw image data in memory.
byte* kanzi::BitmapImage::getData | ( | size_t | mipmapLevel | ) |
Returns a pointer to the raw image data at a specific mipmap level.
mipmapLevel | The wanted mipmap level, 0 being base level. |
const byte* kanzi::BitmapImage::getData | ( | ) | const |
Returns a const pointer to the raw image data in memory.
const byte* kanzi::BitmapImage::getData | ( | size_t | mipmapLevel | ) | const |
Returns a const pointer to the raw image data at a specific mipmap level.
mipmapLevel | The wanted mipmap level, 0 being base level. |
size_t kanzi::BitmapImage::getDataSize | ( | ) | const |
Returns the size of image data in bytes.
size_t kanzi::BitmapImage::getDataSize | ( | size_t | mipmapLevel | ) | const |
Returns the size of image data at a specific mipmap level in bytes.
mipmapLevel | The wanted mipmap level, 0 being base level. |
size_t kanzi::BitmapImage::getMipmapLevelCount | ( | ) | const |
Returns the count of mipmap levels held by this image.
For the images that have only the base level and no mipmaps, the level count is 1. This function never returns 0.
void kanzi::BitmapImage::setName | ( | string_view | name | ) |
Sets the name for an image.
Images can have empty names and the names do not have to be unique.
name | The name of the image. |
string_view kanzi::BitmapImage::getName | ( | ) | const |
Gets the name of an image.
Images can have empty names and the names do not have to be unique.
bool kanzi::BitmapImage::isCompressedFormat | ( | ) | const |
Returns whether an image uses a compressed format.
You cannot resize or flip compressed images.
void kanzi::BitmapImage::resize | ( | unsigned int | newWidth, |
unsigned int | newHeight, | ||
ImageResizeFilter | resizeFilter | ||
) |
Resizes the image and discards any existing mipmap images.
You cannot resize images that use a compressed format. To check whether an image uses a compressed format, use the isCompressedFormat function.
newWidth | New width of the image in pixels. |
newHeight | New height of the image in pixels. |
resizeFilter | The resize filter to use. This affects the quality of the resized image. |
void kanzi::BitmapImage::flip | ( | ImageFlipAxis | axis | ) |
Flip data over an axis.
You cannot flip images that use a compressed format. To check whether an image uses a compressed format, use the isCompressedFormat function.
axis | Axis to flip over. |
|
inline |
Flips an image horizontally.
|
inline |
Flips an image vertically.
void kanzi::BitmapImage::premultiplyAlpha | ( | ) |
Premultiplies the color and luminance channels by the alpha channel.
void kanzi::BitmapImage::generateMipmaps | ( | ) |
Generates mipmap images for an image. The size of the smallest mipmap image is 1x1 pixels.
void kanzi::BitmapImage::convert | ( | GraphicsFormat | newFormat | ) |
Converts the graphics format of the image data.
newFormat | The graphics format to which you want to convert the image data. |
|
static |
Creates a copy of an image.
Allocates and rewrites all image data, including mipmaps.
image | The image you want to copy. |
|
static |
Creates an image by copying the pixel data from memory.
width | The width in pixels. |
height | The height in pixels. |
format | The graphics format. |
data | The pixel data to copy. Must cover the width * height * bytes_per_pixel of memory. |
name | (Optional) A name for the image. |
|
static |
Creates an image by copying the pixel data from memory.
width | The width in pixels. |
height | The height in pixels. |
format | The graphics format. |
data | The pixel data to copy. Must cover the width * height * bytes_per_pixel of memory. |
axis | Axis to flip over. |
name | (Optional) A name for the image. |
|
static |
Creates an empty image, initializes all pixel data to zero.
width | The width in pixels. |
height | The height in pixels. |
format | The graphics format. |
name | (Optional) A name for the image. |
|
static |
Creates an empty image with empty mipmaps, initializes all pixel data to zero.
width | The width in pixels. |
height | The height in pixels. |
format | The graphics format. |
name | (Optional) A name for the image. |
|
static |
Creates a mipmapped image from a vector of mipmap level images.
The first image in the vector is the base level image. The sizes of each consecutive image must be scaled down by the power of two. For example, if the base level image is 128x128, then the sizes of the following images must be 64x64, 32x32, 16x16, 8x8, 4x4, 2x2, and 1x1.
mipmapImages | The mipmap images. |
|
protected |
Replaces the mipmap level images for an image.
images | The mipmap images, including the base level image. |
|
staticprotected |
Kanzi internally uses this function to create a copy of an image by moving over the image data.
This invalidates the original image.
[in,out] | other | The image to copy. |