# Image data
Images can be created and/or manipulated within the Simplygon API using ImageData objects.
Texture images are stored in materials as ImageData objects. The image data objects are always three dimensional but for fewer dimensional representations the non-relevant axes are set to one. A 2d image of 256x256 pixels will thereby be a 3d matrix with dimensions 256x256x1. The dimensions of an ImageData are set with Set{1|2|3}DSize.
The pixels are either stored as 8 (TYPES_ID_UCHAR) or 16 (TYPES_ID_USHORT) bits per channel and the allowed color formats are RGB, RGBA, YUV, CMYK, L and R. The format is selected with AddColors.
To be able to manipulate the image pixels, they are read to an array using GetColors. The tuple size is determined by the color format (tuple size for RGB is 3) and the tuple count is the product of the image dimensions, e.g the number of pixels.
# Supported image formats
Simplygon supports 8 and 16 bits per channel, that is 24 bpp and 48 bpp for RGB and 32 bpp and 64 bpp for RGBA textures.
The Simplygon SDK allows reading and writing of most common image formats liste below.
Format | Description | Extension |
---|---|---|
BMP | Windows or OS/2 Bitmap | BMP |
DDS | DirectX Surface (Load only) | DDS |
JPEG | JPEG - JFIF Compliant | JPG, JIF, JPEG, JPE |
PCX | Zsoft Paintbrush | PCX |
PNG | Portable Network Graphics | PNG |
TARGA | Truevision Targa | TGA, TARGA |
TIFF | Tagged Image File Format | TIF, TIFF |
# Example - SetItem
This example shows how to generate a gradient image pixel by pixel using SetItem while the other example sets all the image data in one call using SetData.
# Example - SetData
This example shows how to set all the image data in one call using SetData.