All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzc_image.h File Reference

Image component. More...

Typedefs

typedef kzsError(* KzuImageLoadImageCallback )(struct KzcInputStream *inputStream, void *userData, struct KzcImage **out_image)
 Function type definition for function that can load an image reference from .KZB input stream. More...
 

Enumerations

enum  KzcImageResizeFilter { KZC_IMAGE_RESIZE_FILTER_NEAREST_NEIGHBOR, KZC_IMAGE_RESIZE_FILTER_BILINEAR, KZC_IMAGE_RESIZE_FILTER_WEIGHTED_AVERAGE }
 List of possible resizing filters. More...
 

Functions

KANZI_API kzsError kzcImageCreate (const struct KzcMemoryManager *memoryManager, struct KzcImage **out_image)
 Creates an image with no data. More...
 
KANZI_API kzsException kzcImageLoadPNG (const struct KzcMemoryManager *memoryManager, struct KzcInputStream *inputStream, kzBool flipInternally, struct KzcImage **out_image)
 Loads image from PNG file. More...
 
KANZI_API kzsException kzcImageLoadJPEG (const struct KzcMemoryManager *memoryManager, struct KzcInputStream *inputStream, kzBool flipInternally, struct KzcImage **out_image)
 Loads image from JPEG file. More...
 
KANZI_API kzsError kzcImageLoadRAW (const KzcMemoryManager *memoryManager, KzcInputStream *inputStream, kzBool flipInternally, kzUint width, kzUint height, kanzi::GraphicsFormat colorFormat, KzcImage **out_image)
 Loads image from RAW format. More...
 
KANZI_API kzsError kzcImageLoadMemory (const KzcMemoryManager *memoryManager, unsigned int width, unsigned int height, kanzi::GraphicsFormat format, const void *data, KzcImage **out_image)
 Loads image from memory. More...
 
KANZI_API kzsError kzcImageLoadMemoryAssignData (const KzcMemoryManager *memoryManager, kzUint width, kzUint height, kanzi::GraphicsFormat colorFormat, void *data, struct KzcImage **out_image)
 Creates image from data, data not copied. More...
 
KANZI_API kzsException kzcImageLoadResource (const struct KzcMemoryManager *memoryManager, kzString resourcePath, struct KzcImage **out_image)
 Loads image from resource. More...
 
KANZI_API kzsException kzcImageLoadFile (const struct KzcMemoryManager *memoryManager, kzString filePath, struct KzcImage **out_image)
 Loads image from file. More...
 
KANZI_API kzsException kzcImageLoadResourceFlipped (const struct KzcMemoryManager *memoryManager, kzString resourcePath, struct KzcImage **out_image)
 Loads image from resource. More...
 
KANZI_API kzsException kzcImageLoadFileFlipped (const struct KzcMemoryManager *memoryManager, kzString filePath, struct KzcImage **out_image)
 Loads image from file. More...
 
KANZI_API kzsError kzcImageCreateMipmapImage (const struct KzcMemoryManager *memoryManager, kzUint levelCount, struct KzcImage *const *mipmapImages, struct KzcImage **out_image)
 Creates mipmap image out of list of mipmap images. More...
 
KANZI_API kzsError kzcImageDelete (struct KzcImage *image)
 Deletes image. More...
 
KANZI_API kzsException kzcImageLoadPNGFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flipInternally)
 Loads PNG image from KZB. More...
 
KANZI_API kzsError kzcImageLoadJPEGFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flipInternally)
 Loads JPEG image from KZB. More...
 
KANZI_API kzsError kzcImageLoadETCFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flippedInternally)
 Loads ETC image from KZB. More...
 
KANZI_API kzsError kzcImageLoadDXTFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flippedInternally)
 Loads DXT image from KZB. More...
 
KANZI_API kzsError kzcImageLoadATCFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flippedInternally)
 Loads ATC compressed image from KZB. More...
 
KANZI_API kzsError kzcImageLoadPVRTCFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flippedInternally)
 Loads PVRTC compressed image from KZB. More...
 
KANZI_API kzsError kzcImageLoadRaw2DFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flipInternally)
 Loads RAW 2D image from KZB. More...
 
KANZI_API kzsError kzcImageLoadRawZlib2DFromKZB (struct KzcImage *image, struct KzcInputStream *inputStream, kzBool flipInternally)
 Loads RAW Zlib 2D image from KZB. More...
 
KANZI_API kzsError kzcImageCopySubImage (const struct KzcImage *targetImage, const struct KzcImage *sourceImage, kzUint targetRectX, kzUint targetRectY, kzUint sourceRectX, kzUint sourceRectY, kzUint width, kzUint height)
 Copies data from sourceImage to targetImage. More...
 
KANZI_API kzsError kzcImageCopySubImageData (const struct KzcImage *targetImage, void *sourceData, kzUint targetRectX, kzUint targetRectY, kzUint sourceRectX, kzUint sourceRectY, kzUint sourceImageWidth, kzUint width, kzUint height)
 Copies sourceImage data to targetImage. More...
 
KANZI_API kzsError kzcImageSavePNG (const struct KzcImage *image, struct KzcOutputStream *outputStream)
 Saves an image to an output stream in the PNG format. More...
 
KANZI_API kzsError kzcImageSaveJPEG (const struct KzcImage *image, struct KzcOutputStream *outputStream, kzFloat quality)
 Saves an image to an output stream in the JPEG format. More...
 
KANZI_API kzsError kzcImageSaveRAW (const struct KzcImage *image, struct KzcOutputStream *outputStream)
 Saves raw image to specific output stream. More...
 
KANZI_API kzUint kzcImageGetWidth (const struct KzcImage *image)
 Returns image width. More...
 
KANZI_API kzUint kzcImageGetHeight (const struct KzcImage *image)
 Returns image height. More...
 
KANZI_API void kzcImageSetFlippedInternally (struct KzcImage *image, kzBool flipped)
 Sets a flag to indicate that the data in the image is vertically flipped. More...
 
KANZI_API kzBool kzcImageIsFlippedInternally (const struct KzcImage *image)
 Returns the flag which indicates if the data in the image is vertically flipped or not. More...
 
KANZI_API void kzcImageSetPremultipliedAlpha (struct KzcImage *image, kzBool premultipliedAlpha)
 Sets a flag to indicate that the RGB data in the image has premultiplied alpha. More...
 
KANZI_API kzBool kzcImageIsPremultipliedAlpha (const struct KzcImage *image)
 Returns the flag which indicates if the RGB data in the image has premultiplied alpha. More...
 
KANZI_API kanzi::GraphicsFormat kzcImageGetDataFormat (const struct KzcImage *image)
 Returns color format from image. More...
 
KANZI_API void * kzcImageGetData (const struct KzcImage *image)
 Returns image data from image. More...
 
KANZI_API kzUint kzcImageGetMipmapLevelCount (const struct KzcImage *image)
 Gets mipmap level count from image. More...
 
KANZI_API struct KzcImagekzcImageGetMipmapLevel (const struct KzcImage *image, kzUint mipmapLevelIndex)
 Gets mipmap level from image. More...
 
KANZI_API kzBool kzcImageIsMipmapImage (const struct KzcImage *image)
 Returns if this image is mipmap image. More...
 
KANZI_API kzsError kzcImageCopy (const struct KzcMemoryManager *memoryManager, const struct KzcImage *sourceImage, struct KzcImage **out_targetImage)
 Copy operator for image. More...
 
KANZI_API kzsException kzcImageConvert (struct KzcImage *sourceImage, kanzi::GraphicsFormat colorFormat)
 Converts an image to the specified image data format. More...
 
KANZI_API kzsError kzcImageConvertToETC (KzcImage *sourceImage, kanzi::GraphicsFormat compressionMode)
 Converts an image to the ETC compressed format. More...
 
KANZI_API kzsError kzcImageSetName (struct KzcImage *image, kzString name)
 Sets name for the image. More...
 
KANZI_API kzString kzcImageGetName (const struct KzcImage *image)
 Gets name of the image. More...
 
KANZI_API kzsException kzcImageBlit (const struct KzcImage *destination, const struct KzcImage *source, kzUint sourceOffsetX, kzUint sourceOffsetY, kzUint destOffsetX, kzUint destOffsetY, kzUint width, kzUint height)
 Blit an image into another. More...
 
KANZI_API kzsError kzcImageResize (struct KzcImage *image, kzUint newWidth, kzUint newHeight, KzcImageResizeFilter resizeFilter)
 Resizes image by specified parameters. More...
 
KANZI_API kzsError kzcImageCrop (struct KzcImage *image, kzUint x, kzUint y, kzUint width, kzUint height)
 Crops image by using (x, y, width, height) area. More...
 
KANZI_API kzsError kzcImageFlipVertically (const struct KzcImage *image)
 Flips image vertically. More...
 
KANZI_API kzsError kzcImagePremultiplyAlpha (const struct KzcImage *image)
 Pre-multiplies the RGB data of the image with the alpha component. More...
 
KANZI_API kzsError kzcImageCreateMipmapLevels (struct KzcImage *image)
 Creates mipmap levels for the given image. More...
 
KANZI_API kzsError kzcImageAssignMipmapLevels (struct KzcImage *image, kzUint levelCount, struct KzcImage *const *mipmapImages)
 Assigns mipmap levels for the given images. More...
 
KANZI_API kzsError kzcImageCreateMipmapImages (const struct KzcMemoryManager *memoryManager, const struct KzcImage *image, struct KzcImage ***out_mipmapImages)
 Creates mipmap images from source image and returns them. More...
 
KANZI_API kzBool kzcImageIsCompressedFormat (const struct KzcImage *image)
 Returns is image is in compressed format. More...
 
KANZI_API kzBool kzcImageIsDataFormatCompressed (kanzi::GraphicsFormat dataFormat)
 Returns if image data format is in compressed format. More...
 
KANZI_API kzsError kzcImageConvertFor (KzcImage *image, unsigned int usageFlags)
 Convert image for requested usage flags. More...
 

Detailed Description

Image component.

Handles loading and saving images.

Copyright 2008-2020 by Rightware. All rights reserved.

Typedef Documentation

typedef kzsError(* KzuImageLoadImageCallback)(struct KzcInputStream *inputStream, void *userData, struct KzcImage **out_image)

Function type definition for function that can load an image reference from .KZB input stream.

Enumeration Type Documentation

List of possible resizing filters.

Enumerator
KZC_IMAGE_RESIZE_FILTER_NEAREST_NEIGHBOR 

Nearest neighbor filter.

KZC_IMAGE_RESIZE_FILTER_BILINEAR 

Bilinear filter.

KZC_IMAGE_RESIZE_FILTER_WEIGHTED_AVERAGE 

Weighted average filter.

Function Documentation

KANZI_API kzsError kzcImageCreate ( const struct KzcMemoryManager memoryManager,
struct KzcImage **  out_image 
)

Creates an image with no data.

KANZI_API kzsException kzcImageLoadPNG ( const struct KzcMemoryManager memoryManager,
struct KzcInputStream inputStream,
kzBool  flipInternally,
struct KzcImage **  out_image 
)

Loads image from PNG file.

Color format is output in either RGB8 or RGBA8. The image is optionally flipped on load (to conform with OpenGL default texture coordinates).

KANZI_API kzsException kzcImageLoadJPEG ( const struct KzcMemoryManager memoryManager,
struct KzcInputStream inputStream,
kzBool  flipInternally,
struct KzcImage **  out_image 
)

Loads image from JPEG file.

Color format is output in RGB8. The image is optionally flipped on load (to conform with OpenGL default texture coordinates).

KANZI_API kzsError kzcImageLoadRAW ( const KzcMemoryManager memoryManager,
KzcInputStream inputStream,
kzBool  flipInternally,
kzUint  width,
kzUint  height,
kanzi::GraphicsFormat  colorFormat,
KzcImage **  out_image 
)

Loads image from RAW format.

Width, height and format needs to be specified manually. Throws error if dimension and format mismatches the RAW file size. The image is optionally flipped on load (to conform with OpenGL default texture coordinates).

KANZI_API kzsError kzcImageLoadMemory ( const KzcMemoryManager memoryManager,
unsigned int  width,
unsigned int  height,
kanzi::GraphicsFormat  format,
const void *  data,
KzcImage **  out_image 
)

Loads image from memory.

Data is copied.

KANZI_API kzsError kzcImageLoadMemoryAssignData ( const KzcMemoryManager memoryManager,
kzUint  width,
kzUint  height,
kanzi::GraphicsFormat  colorFormat,
void *  data,
struct KzcImage **  out_image 
)

Creates image from data, data not copied.

KANZI_API kzsException kzcImageLoadResource ( const struct KzcMemoryManager memoryManager,
kzString  resourcePath,
struct KzcImage **  out_image 
)

Loads image from resource.

PNG and JPEG are supported. If the image will be used as a 2D texture, consider using kzcImageLoadResourceFlipped instead.

KANZI_API kzsException kzcImageLoadFile ( const struct KzcMemoryManager memoryManager,
kzString  filePath,
struct KzcImage **  out_image 
)

Loads image from file.

PNG and JPEG are supported. If the image will be used as a 2D texture, consider using kzcImageLoadFileFlipped instead.

KANZI_API kzsException kzcImageLoadResourceFlipped ( const struct KzcMemoryManager memoryManager,
kzString  resourcePath,
struct KzcImage **  out_image 
)

Loads image from resource.

PNG and JPEG are supported. This function flips the image data vertically while loading to make it compatible with OpenGL 2D textures. If this function is used instead of kzcImageLoadResource, deploying the image to a 2D texture will be faster and use less memory.

KANZI_API kzsException kzcImageLoadFileFlipped ( const struct KzcMemoryManager memoryManager,
kzString  filePath,
struct KzcImage **  out_image 
)

Loads image from file.

PNG and JPEG are supported. This function flips the image data vertically while loading to make it compatible with OpenGL 2D textures. If this function is used instead of kzcImageLoadFile, deploying the image to a 2D texture will be faster and use less memory.

KANZI_API kzsError kzcImageCreateMipmapImage ( const struct KzcMemoryManager memoryManager,
kzUint  levelCount,
struct KzcImage *const *  mipmapImages,
struct KzcImage **  out_image 
)

Creates mipmap image out of list of mipmap images.

KANZI_API kzsError kzcImageDelete ( struct KzcImage image)

Deletes image.

KANZI_API kzsException kzcImageLoadPNGFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flipInternally 
)

Loads PNG image from KZB.

KANZI_API kzsError kzcImageLoadJPEGFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flipInternally 
)

Loads JPEG image from KZB.

KANZI_API kzsError kzcImageLoadETCFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flippedInternally 
)

Loads ETC image from KZB.

KANZI_API kzsError kzcImageLoadDXTFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flippedInternally 
)

Loads DXT image from KZB.

KANZI_API kzsError kzcImageLoadATCFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flippedInternally 
)

Loads ATC compressed image from KZB.

KANZI_API kzsError kzcImageLoadPVRTCFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flippedInternally 
)

Loads PVRTC compressed image from KZB.

KANZI_API kzsError kzcImageLoadRaw2DFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flipInternally 
)

Loads RAW 2D image from KZB.

KANZI_API kzsError kzcImageLoadRawZlib2DFromKZB ( struct KzcImage image,
struct KzcInputStream inputStream,
kzBool  flipInternally 
)

Loads RAW Zlib 2D image from KZB.

KANZI_API kzsError kzcImageCopySubImage ( const struct KzcImage targetImage,
const struct KzcImage sourceImage,
kzUint  targetRectX,
kzUint  targetRectY,
kzUint  sourceRectX,
kzUint  sourceRectY,
kzUint  width,
kzUint  height 
)

Copies data from sourceImage to targetImage.

Data is copied from sourceImage area [sourceRectX, sourceRectY, sourceRectX + width, sourceRectY + height] to targetImage area [targetRectX, targetRectY, targetRectX + width, targetRectY + height] Error is returned if area is out of bounds of image.

KANZI_API kzsError kzcImageCopySubImageData ( const struct KzcImage targetImage,
void *  sourceData,
kzUint  targetRectX,
kzUint  targetRectY,
kzUint  sourceRectX,
kzUint  sourceRectY,
kzUint  sourceImageWidth,
kzUint  width,
kzUint  height 
)

Copies sourceImage data to targetImage.

KANZI_API kzsError kzcImageSavePNG ( const struct KzcImage image,
struct KzcOutputStream outputStream 
)

Saves an image to an output stream in the PNG format.

The only supported image formats are KZC_IMAGE_DATA_FORMAT_RGB_888 and KZC_IMAGE_DATA_FORMAT_RGBA_8888. Output stream must be closed manually.

KANZI_API kzsError kzcImageSaveJPEG ( const struct KzcImage image,
struct KzcOutputStream outputStream,
kzFloat  quality 
)

Saves an image to an output stream in the JPEG format.

Output stream must be closed manually. Quality within range [0,1]

KANZI_API kzsError kzcImageSaveRAW ( const struct KzcImage image,
struct KzcOutputStream outputStream 
)

Saves raw image to specific output stream.

Output image will be in raw byte format.

KANZI_API kzUint kzcImageGetWidth ( const struct KzcImage image)

Returns image width.

KANZI_API kzUint kzcImageGetHeight ( const struct KzcImage image)

Returns image height.

KANZI_API void kzcImageSetFlippedInternally ( struct KzcImage image,
kzBool  flipped 
)

Sets a flag to indicate that the data in the image is vertically flipped.

KANZI_API kzBool kzcImageIsFlippedInternally ( const struct KzcImage image)

Returns the flag which indicates if the data in the image is vertically flipped or not.

KANZI_API void kzcImageSetPremultipliedAlpha ( struct KzcImage image,
kzBool  premultipliedAlpha 
)

Sets a flag to indicate that the RGB data in the image has premultiplied alpha.

KANZI_API kzBool kzcImageIsPremultipliedAlpha ( const struct KzcImage image)

Returns the flag which indicates if the RGB data in the image has premultiplied alpha.

KANZI_API kanzi::GraphicsFormat kzcImageGetDataFormat ( const struct KzcImage image)

Returns color format from image.

KANZI_API void* kzcImageGetData ( const struct KzcImage image)

Returns image data from image.

KANZI_API kzUint kzcImageGetMipmapLevelCount ( const struct KzcImage image)

Gets mipmap level count from image.

KANZI_API struct KzcImage* kzcImageGetMipmapLevel ( const struct KzcImage image,
kzUint  mipmapLevelIndex 
)

Gets mipmap level from image.

KANZI_API kzBool kzcImageIsMipmapImage ( const struct KzcImage image)

Returns if this image is mipmap image.

KANZI_API kzsError kzcImageCopy ( const struct KzcMemoryManager memoryManager,
const struct KzcImage sourceImage,
struct KzcImage **  out_targetImage 
)

Copy operator for image.

KANZI_API kzsException kzcImageConvert ( struct KzcImage sourceImage,
kanzi::GraphicsFormat  colorFormat 
)

Converts an image to the specified image data format.

Parameters
sourceImageThe image to convert.
colorFormatThe image data format to convert to. Compressed formats are not supported.
Returns
KZS_SUCCESS on success.
KANZI_API kzsError kzcImageConvertToETC ( KzcImage sourceImage,
kanzi::GraphicsFormat  compressionMode 
)

Converts an image to the ETC compressed format.

Parameters
sourceImageThe image to convert.
[in]compressionModemode to use for compression. See kzc_etc.h for possible values.
Returns
KZS_SUCCESS on success.
KANZI_API kzsError kzcImageSetName ( struct KzcImage image,
kzString  name 
)

Sets name for the image.

KANZI_API kzString kzcImageGetName ( const struct KzcImage image)

Gets name of the image.

KZ_NULL if not assigned.

KANZI_API kzsException kzcImageBlit ( const struct KzcImage destination,
const struct KzcImage source,
kzUint  sourceOffsetX,
kzUint  sourceOffsetY,
kzUint  destOffsetX,
kzUint  destOffsetY,
kzUint  width,
kzUint  height 
)

Blit an image into another.

The images must have the same format. Only the image data format KZC_IMAGE_DATA_FORMAT_RGBA_8888 is supported.

Parameters
destinationThe image to write to.
sourceThe image to read from.
sourceOffsetXX offset to the source.
sourceOffsetYY offset to the source.
destOffsetXX offset to the destination.
destOffsetYY offset to the destination.
widthThe width (in pixels) to blit.
heightThe height (in pixels) to blit.
Returns
KZS_SUCCESS on success.
KANZI_API kzsError kzcImageResize ( struct KzcImage image,
kzUint  newWidth,
kzUint  newHeight,
KzcImageResizeFilter  resizeFilter 
)

Resizes image by specified parameters.

If the image is a mipmap image, all the mipmap levels are lost.

KANZI_API kzsError kzcImageCrop ( struct KzcImage image,
kzUint  x,
kzUint  y,
kzUint  width,
kzUint  height 
)

Crops image by using (x, y, width, height) area.

KANZI_API kzsError kzcImageFlipVertically ( const struct KzcImage image)

Flips image vertically.

KANZI_API kzsError kzcImagePremultiplyAlpha ( const struct KzcImage image)

Pre-multiplies the RGB data of the image with the alpha component.

KANZI_API kzsError kzcImageCreateMipmapLevels ( struct KzcImage image)

Creates mipmap levels for the given image.

KANZI_API kzsError kzcImageAssignMipmapLevels ( struct KzcImage image,
kzUint  levelCount,
struct KzcImage *const *  mipmapImages 
)

Assigns mipmap levels for the given images.

KANZI_API kzsError kzcImageCreateMipmapImages ( const struct KzcMemoryManager memoryManager,
const struct KzcImage image,
struct KzcImage ***  out_mipmapImages 
)

Creates mipmap images from source image and returns them.

KANZI_API kzBool kzcImageIsCompressedFormat ( const struct KzcImage image)

Returns is image is in compressed format.

KANZI_API kzBool kzcImageIsDataFormatCompressed ( kanzi::GraphicsFormat  dataFormat)

Returns if image data format is in compressed format.

KANZI_API kzsError kzcImageConvertFor ( KzcImage image,
unsigned int  usageFlags 
)

Convert image for requested usage flags.