This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::Image Class

Header:#include <UnigineImage.h>

Interface for handling textures and other images.

Image Class

Members


static ImagePtr create()

Default constructor. An empty instance with default parameters is created.

static ImagePtr create(const char * name)

Arguments

  • const char * name

static ImagePtr create(const Ptr<Image> & image)

Arguments

  • const Ptr<Image> & image

int set(int channel, int value)

Sets a value for a given image channel. Compressed and combined image formats are not supported.

Arguments

  • int channel - Channel number in range of 0 to (number of channels - 1).
  • int value - Value in range of 0 to 255 for 8-bit formats and in range of 0 to 65535 for 16-bit formats.

Return value

Returns 1 if the value is set successfully; otherwise, 0.

void set2D(int x, int y, const Image::Pixel & p)

Sets a color for a given pixel of a 2D image. Compressed formats are not supported.

Arguments

  • int x - X coordinate of a pixel.
  • int y - Y coordinate of a pixel.
  • const Image::Pixel & p - Color with components normalized in range from 0 to 1.

Image::Pixel get2D(int x, int y)

Returns a color of a given pixel of a 2D image. Compressed formats are not supported.

Arguments

  • int x - X integer coordinate of a pixel in range [0; width].
  • int y - Y integer coordinate of a pixel in range [0; height].

Return value

Color of the target pixel normalized in range [0;1]. Each component is an integer value.

Image::Pixel get2D(float x, float y)

Returns a color of a given pixel of a 2D image. Compressed formats are not supported.

Arguments

  • float x - X integer coordinate of a pixel in range [0; width].
  • float y - Y integer coordinate of a pixel in range [0; height].

Return value

Color of the target pixel normalized in range [0;1]. Each component is an integer value.

void set2DArray(int x, int y, int layer, const Image::Pixel & p)

Sets a color of a given pixel. The image must be a 2D image array. Compressed formats are not supported.

Arguments

  • int x - X coordinate of a pixel.
  • int y - Y coordinate of a pixel.
  • int layer - Image layer number.
  • const Image::Pixel & p - Color with components normalized in range from 0 to 1.

Image::Pixel get2DArray(int x, int y, int layer)

Returns a color of a given pixel. The image must be a 2D texture array. Compressed formats are not supported. If float coordinates are provided, linear interpolation is used to get a color sample.

Arguments

  • int x - X integer coordinate of a pixel in range [0;width].
  • int y - Y integer coordinate of a pixel in range [0;height].
  • int layer - Image layer number.

Return value

Color of the target pixel with components normalized in range from 0 to 1.

Image::Pixel get2DArray(float x, float y, int layer)

Returns a color of a given pixel. The image must be a 2D image array. Compressed formats are not supported.

Arguments

  • float x - X integer coordinate of a pixel in range [0;width].
  • float y - Y integer coordinate of a pixel in range [0;height].
  • int layer - Image layer number.

Return value

Color of the target pixel with components normalized in range from 0 to 1.

void set2DSmooth(int x, int y, const Image::Pixel & p)

Arguments

  • int x
  • int y
  • const Image::Pixel & p

Image::Pixel get2DSmooth(float x, float y, int use_half_pixel_offset = 0)

Arguments

  • float x
  • float y
  • int use_half_pixel_offset

int is2DType()

Returns a value indicating if the image is 2D image.

Return value

Returns 1 if the image is 2D; otherwise, 0.

void set3D(int x, int y, int z, const Image::Pixel & p)

Sets a color of a given pixel of a 3D image. Compressed formats are not supported.

Arguments

  • int x - X coordinate of a pixel.
  • int y - Y coordinate of a pixel.
  • int z - Z coordinate of a pixel.
  • const Image::Pixel & p - Color with components normalized in range from 0 to 1.

Image::Pixel get3D(float x, float y, float z)

Returns a color of a given pixel of a 3D image. Compressed formats are not supported.

Arguments

  • float x - X integer coordinate of a pixel in range [0;width].
  • float y - X integer coordinate of a pixel in range [0;width].
  • float z - X integer coordinate of a pixel in range [0;width].

Return value

Color of the target pixel with components normalized in range from 0 to 1.

Image::Pixel get3D(int x, int y, int z)

Returns a color of a given pixel of a 3D image. Compressed formats are not supported.

Arguments

  • int x - X integer coordinate of a pixel in range [0;width].
  • int y - Y integer coordinate of a pixel in range [0;height].
  • int z - Z integer coordinate of a pixel in range [0;depth].

Return value

Color of the target pixel with components normalized in range from 0 to 1.

void set3DSmooth(int x, int y, int z, const Image::Pixel & p)

Arguments

  • int x
  • int y
  • int z
  • const Image::Pixel & p

Image::Pixel get3DSmooth(float x, float y, float z)

Arguments

  • float x
  • float y
  • float z

int is3DType()

Returns a value indicating if the image is 3D image.

Return value

Returns 1 if the image is 3D; otherwise, 0.

int isArrayType()

Returns a value indicating if the image is Array image.

Return value

Returns 1 if the image is Array; otherwise, 0.

int getBlockSize()

Returns the compressed image block size.

Return value

Block size in bytes.

int isCombinedFormat()

Returns a value indicating if the image is stored in a combined format (RGB565, RGBA4, RGB5A1 or RGB10A2).

Return value

Returns 1 if the image is in combined format; otherwise, 0.

int isCompressedFormat()

Returns a value indicating if the image is stored in a compressed format (DXT1, DXT3, DXT5, ATI1, ATI2, ZLC1 or ZLC2).

Return value

Returns 1 if the image is in a compressed format; otherwise, 0.

void setCube(int x, int y, int face, const Image::Pixel & p)

Sets a color of a given pixel. The image must be of the Cube type. Compressed formats are not supported.

Arguments

  • int x - X coordinate of a pixel.
  • int y - Y coordinate of a pixel.
  • int face - Face number in range from 0 to 5.
  • const Image::Pixel & p - Color with components normalized in range from 0 to 1.

Image::Pixel getCube(const Math::vec3 & direction)

Returns a color of a given pixel. The image must be of the Cube type. Compressed formats are not supported.

Arguments

  • const Math::vec3 & direction - Cube direction vector used for color sampling.

Return value

Color with components normalized in range from 0 to 1.

Image::Pixel getCube(float x, float y, int face)

Returns a color of a given pixel. The image must be of the Cube type. Compressed formats are not supported.

Arguments

  • float x - X integer coordinate of a pixel in range [0;width].
  • float y - Y integer coordinate of a pixel in range [0;height].
  • int face - Face number in range from 0 to 5.

Return value

Color with components normalized in range from 0 to 1.

Image::Pixel getCube(int x, int y, int face)

Returns a color of a given pixel. The image must be of the Cube type. Compressed formats are not supported.

Arguments

  • int x - X integer coordinate of a pixel in range [0;width].
  • int y - Y integer coordinate of a pixel in range [0;height].
  • int face - Face number in range from 0 to 5.

Return value

Color with components normalized in range from 0 to 1.

void setCubeArray(int x, int y, int face, int layer, const Image::Pixel & p)

Sets a color of a given pixel. The image must be of the Cube Array type. Compressed formats are not supported.

Arguments

  • int x - X coordinate of a pixel.
  • int y - Y coordinate of a pixel.
  • int face - Face number in range from 0 to 5.
  • int layer - Image layer number.
  • const Image::Pixel & p - Color with components normalized in range from 0 to 1.

Image::Pixel getCubeArray(const Math::vec3 & direction, int layer)

Arguments

  • const Math::vec3 & direction - Cube direction vector used for color sampling.
  • int layer - Image layer number.

Return value

Color with components normalized in range from 0 to 1.

Image::Pixel getCubeArray(int v1, int v2, int face, int layer)

Returns a color of a given pixel. The image must be of the Cube Array type. Compressed formats are not supported.

Arguments

  • int v1 - X integer coordinate of a pixel in range [0;width].
  • int v2 - Y integer coordinate of a pixel in range [0;height].
  • int face - Face number in range from 0 to 5.
  • int layer - Image layer number.

Return value

Color with components normalized in range from 0 to 1.

Image::Pixel getCubeArray(float v1, float v2, int face, int layer)

Returns a color of a given pixel. The image must be of the Cube Array type. Compressed formats are not supported.

Arguments

  • float v1 - X integer coordinate of a pixel in range [0;width].
  • float v2 - Y integer coordinate of a pixel in range [0;height].
  • int face - Face number in range from 0 to 5.
  • int layer - Image layer number.

Return value

Color with components normalized in range from 0 to 1.

int isCubeType()

Returns a value indicating if the image is Cube image.

Return value

Returns 1 if the image is Cube; otherwise, 0.

int getDepth(int level = 0)

Returns the image depth on a given mipmap level.

Arguments

  • int level - Mipmap level in range of 0 to the total number of mipmaps. This is an optional argument.

Return value

Image depth if the image exists (its depth is larger than 0); otherwise, 1.

int isFloatFormat()

Returns a value indicating if the image is stored in a float format (R32F, RG32F, RGB32F or RGBA32F).

Return value

Returns 1 if the image is in float format; otherwise, 0 is returned.

int getFormat()

Returns a numerical code of the image format.

Return value

Numerical code of the image format. See the Unigine::Image:: Enumeration with FORMAT_* prefixes.

const char * getFormatName()

Returns an image format name. For more details about image formats see the article on ImageDDS tool.

Return value

Format name. The following values can be returned: R8, RG8, RGB8, RGBA8, R16, RG16, RGB16, RGBA16, R16F, RG16F, RGB16F, RGBA16F, R32F, RG32F, RGB32F, RGBA32F, RGB565, RGBA4, RGB5A1, RGB10A2, DXT1, DXT3, DXT5, ATI1, ATI2, ZLC1, ZLC2.

int isHalfFormat()

Returns a value indicating if the image is stored in a half-float format (R16F, RG16F, RGB16F or RGBA16F).

Return value

Returns 1 if the image is in half-float format; otherwise, 0.

int getHeight(int level = 0)

Returns the image height on a given mipmap level.

Arguments

  • int level - Mipmap level in range from 0 to the total number of mipmaps. This is an optional argument.

Return value

Image height if the image exists (its height is larger than 0); otherwise, 1.

int isLoaded()

Returns a value indicating whether the image is loaded.

Return value

Returns 1 if the image is loaded successfully; otherwise, 0.

int getNumChannels()

Returns the number of channels.

Return value

Number of channels.

int getNumFaces()

Returns a number of faces in the image.

Return value

Number of faces.

int getNumLayers()

Returns a number of layers in the image.

Return value

Number of layers.

int getNumMipmaps()

Returns a number of mipmaps stored with the image.

Return value

Number of mipmap levels.

size_t getOffset(int level)

Returns the image offset on a given mipmap level.

Arguments

  • int level - Mipmap level in range from 0 to the total number of mipmaps.

Return value

Image offset in bytes.

int isOwner()

void setPixels(unsigned char * pixels)

Arguments

  • unsigned char * pixels

void setPixels(const Ptr<Blob> & blob)

Adds the image to the blob.

Arguments

  • const Ptr<Blob> & blob - The image to be added.

unsigned char * getPixels()

Returns the pointer to the array of pixels.

Return value

Pointer to the array of pixels.

void getPixels(const Ptr<Blob> & blob)

Returns the pointer to the array of pixels.

Arguments

  • const Ptr<Blob> & blob - The target image.

unsigned char * getPixels2D(int level = 0)

Returns the pointer to the array of pixels with the given mipmap level for the 2D image.

Arguments

  • int level - Mipmap level in range from 0 to the total number of mipmaps. This is an optional argument.

Return value

Pointer to the array of pixels.

unsigned char * getPixels2DArray(int layer, int level = 0)

Returns the pointer to the array of pixels with the given mipmap level and image layer for the 2D Array image.

Arguments

  • int layer - Number of the image layer.
  • int level - Mipmap level in range from 0 to the total number of mipmaps. This is an optional argument.

Return value

Pointer to the array of pixels.

unsigned char * getPixels3D(int level = 0)

Returns the pointer to the array of pixels with the given mipmap level for the 3D image.

Arguments

  • int level - Mipmap level in range from 0 to the total number of mipmaps. This is an optional argument.

Return value

Pointer to the array of pixels.

unsigned char * getPixelsCube(int face, int level = 0)

Returns the pointer to the array of pixels with the given mipmap level for the cube image.

Arguments

  • int face - Face number in range from 0 to 5.
  • int level - Mipmap level in range from 0 to the total number of mipmaps. This is an optional argument.

Return value

Pointer to the array of pixels.

unsigned char * getPixelsCubeArray(int face, int layer, int level = 0)

Returns the pointer to the array of pixels with the given mipmap level and image layer for the Cube Array image.

Arguments

  • int face - Face number in range from 0 to 5.
  • int layer - Number of the image layer.
  • int level - Mipmap level in range from 0 to the total number of mipmaps. This is an optional argument.

Return value

Pointer to the array of pixels.

int getPixelSize()

Returns the uncompressed image pixel size.

Return value

Pixel size in bytes.

int isRawFormat()

Returns a value indicating if the image is uncompressed (stored in R8, RG8, RGB8, RGBA8, R16, RG16, RGB16, RGBA16, R16F, RG16F, RGB16F, RGBA16F, R32F, RG32F, RGB32F, RGBA32F, RGB565, RGBA4, RGB5A1 or RGB10A2 format).

Return value

Returns 1 if the image is uncompressed; otherwise, 0.

size_t getSize()

Returns the current image size.

Return value

Image size in bytes.

size_t getSize(int level)

Returns the current image size.

Arguments

  • int level - Mipmap level in range from 0 to the total number of mipmaps.

Return value

Image size in bytes.

size_t getStride(int level = 0)

Returns the image stride on a given mipmap level.

Arguments

  • int level - Mipmap level in range from 0 to the total number of mipmaps.

Return value

Image stride in bytes.

int getType()

Returns a numerical code of the image type.

Return value

Numerical code of the image type: 0 for a 2D image, 1 for a 3D image, 2 for a cube image, 3 for a 2D Array. See the Unigine::Image:: Enumeration with IMAGE_* prefixes.

const char * getTypeName()

Returns an image type name.

Return value

Image type name: 2D for a 2D image, 3D for a 3D image, Cube for a cube image, 2D_Array for a 2D Array.

int isUCharFormat()

Returns a value indicating if the image is stored in an unsigned char format (R8, RG8, RGB8, RGBA8, DXT1, DXT3, DXT5, ATI1 or ATI2).

Return value

Returns 1 if the image is in unsigned char format; otherwise, 0.

int isUShortFormat()

Returns a value indicating if the image is stored in an unsigned short format (R16, RG16, RGB16 or RGBA16).

Return value

Returns 1 if the image is in unsigned short format; otherwise, 0.

int getWidth(int level = 0)

Returns the image width on a given mipmap level.

Arguments

  • int level - Mipmap level in range from 0 to the total number of mipmaps. This is an optional argument.

Return value

Image width if the image exists (its width is larger than 0); otherwise, 1.

int isZCompressedFormat()

Returns a value indicating if the image is stored in a ZLIB compressed format (ZLC1 or ZLC2).

Return value

Returns 1 if the image is in a z compressed format; otherwise, 0.

int blend(const Ptr<Image> & image, int x0, int y0, int x1, int y1, int width, int height, float scale = 1.0f, int safe = 0)

Blends a region of a specified image with a specified region of the current image. Compressed, combined, half-float and float formats are not supported. Images of different formats can be blended as follows:
  • R8 with R8, RG8;
  • RG8 with RG8, RGB8;
  • RGB8 with RGB8, RGBA8;
  • RGBA8 with RGBA8 only;
  • R16 with R16, RG16;
  • RG16 with RG16, RGB16;
  • RGB16 with RGB16, RGBA16;
  • RGBA16 with RGBA16 only;

Arguments

  • const Ptr<Image> & image - Source image to be blended with the current image.
  • int x0 - X coordinate of a position in the current image.
  • int y0 - Y coordinate of a position in the current image.
  • int x1 - X coordinate of a position in a source image, which is blended with the current image.
  • int y1 - Y coordinate of a position in a source image, which is blended with the current image.
  • int width - Width of the blending region.
  • int height - Height of the blending region.
  • float scale - Scale of blending:
    • If blended images are of the same format, the blended image is multiplied by scale value and is added to the destination image.
    • If a source image has one more channel compared to the current one, it will serve as alpha value. This channel value is multiplied by scale and is used to alpha blend the images.
    • The default scale value is 1.0f.
  • int safe - Safe blending with respect to destination image boundaries.

Return value

Returns 1 if blending is successful; otherwise, 0.

int blur(int size)

Filters the image using two-pass Gaussian blur. Only the 2D or cube image can be resized. Compressed and combined image formats are not supported.

Arguments

  • int size - Blur filter size. It is the number of neighbouring source pixels (from all sides) that are averaged for each blurred destination pixel. For example, if blur = 2, two pixels from each side are and the blurring kernel is 5x5 pixels.

Return value

Returns 1 if the image is blurred successfully or the size of blur filter is 0; otherwise, 0.

void clear()

Clears all data associated with the image and resets its type, format, size to default. Also the number of image layers and mipmaps is set to 1.

int combine(int new_format = -1)

Converts the image to a combined format. The following conversions are available:
  • RGB8 to RGB565
  • RGBA8 to RGBA4 if the format is specified as RGBA4; otherwise, RGBA8 is converted to RGB5A1 by default
  • RGBA16 to RGB10A2

Arguments

  • int new_format - Combined format to convert the image into. This is an optional argument. If no format is specified, default conversion will be performed.

Return value

Returns 1 if the image is successfully converted to the combined format; otherwise, 0.

int combineMipmaps()

Combines the loaded 2D image with the mipmap image. Only one mipmap image can be combined. Compressed image formats cannot be combined.

Return value

Returns 1 if the image and mipmaps are combined successfully; otherwise, 0.

int compare(const Ptr<Image> & image, int x0, int y0, int x1, int y1, int width, int height, int threshold = 0)

Compares a region of a specified image with a specified region of the current image. Compressed, combined, half-float and float formats are not supported.

Arguments

  • const Ptr<Image> & image - Source image to compare the loaded image with.
  • int x0 - X coordinate on the loaded image.
  • int y0 - Y coordinate on the loaded image.
  • int x1 - X coordinate on the source image.
  • int y1 - Y coordinate on the source image.
  • int width - Width of a region to compare.
  • int height - Height of a region to compare.
  • int threshold - A threshold to compare.

Return value

Returns 1 if the regions match; otherwise, 0.

int compress(int new_format = -1)

Converts the image to a compressed format. The following conversions are available:
  • ZLC1 to ZLC1
  • ZLC2 to ZLC2

Arguments

  • int new_format - Format that the image should be converted to.

Return value

Returns 1 if the image is compressed successfully; otherwise, 0.

int convertToFormat(int new_format)

Converts the image to a specified format. To see all of the possible conversions, see the convertToFormat() function in the article on Image Class in the UnigineScript Core Library section.

Arguments

Return value

Returns 1 if the image is converted successfully; otherwise, 0.

int convertToType(int type)

Converts the image to a specified type. The following conversions are possible:
  1. 2D (height should be proportional to width) to 3D. Target dimensions are width × height × height/width.
  2. 2D (height should divide by four, width should divide by three) to cube image.
  3. 3D to 2D. Target dimensions are width × height*depth.
  4. 3D to 2D image array. Target dimensions are width × height.
  5. Cube to 2D. Target dimensions are width*4 × height*3.
  6. Cube to 2D image array. Target dimensions are width × height.
  7. 2D image array to 2D. Target dimensions are width × height*number of image layers.

Arguments

Return value

Returns 1 if the image is converted successfully; otherwise, 0.

int copy(const Ptr<Image> & image, int layer)

Copies a specified layer between images.

Arguments

  • const Ptr<Image> & image - Source image.
  • int layer - Layer number.

Return value

Returns 1 if the layer is copied successfully; otherwise, 0.

int copy(const Ptr<Image> & image, int x_dst, int y_dst, int x_src, int y_src, int width, int height, int safe = 0)

Copies a specified layer between images.

Arguments

  • const Ptr<Image> & image - Source image, from which a region will be copied.
  • int x_dst - X coordinate of a position in the image, where data will be copied to.
  • int y_dst - Y coordinate of a position in the image, where data will be copied to.
  • int x_src - X coordinate of a position in a source image, where data will be copied from.
  • int y_src - Y coordinate of a position in a source image, where data will be copied from.
  • int width - Width of an image region to copy.
  • int height - Height of an image region to copy.
  • int safe - Safe copying with respect to destination image boundaries.

Return value

Returns 1 if the layer is copied successfully; otherwise, 0.

int copy(const Ptr<Image> & image, int channel, int index)

Copies a specified layer between images.

Arguments

  • const Ptr<Image> & image - Source image.
  • int channel - Destination channel.
  • int index - Source channel.

Return value

Returns 1 if the layer is copied successfully; otherwise, 0.

int create2D(int width, int height, int format, int num_mipmaps = 1, int clear = 1, int allocate = 1)

Creates an empty 2D image.

Arguments

  • int width - Desired width.
  • int height - Desired height.
  • int format - Desired format. See the IMAGE_FORMAT_* variables.
  • int num_mipmaps - Number of mipmaps to create. This is an optional argument. If the value is smaller than 1, an assertion is raised.
  • int clear - Positive number to fill the image with black color, 0 not to fill. This optional argument can be set to 0 if new data will fully overwrite the data existing in the memory.
  • int allocate - Positive number to allocate memory for the created image. This value should be always set to 1.

Return value

Returns 1 if the 2D image is created successfully; otherwise, 0.

int create2DArray(int width, int height, int num_layers, int format, int num_mipmaps = 1, int clear = 1, int allocate = 1)

Create a 2D Array image.

Arguments

  • int width - Desired width.
  • int height - Desired height.
  • int num_layers - Number of texture layers.
  • int format - Desired format. See the IMAGE_FORMAT_* variables.
  • int num_mipmaps - Number of mipmaps to create. This is an optional argument. If the value is smaller than 1, an assertion is raised.
  • int clear - Positive number to fill the texture array with black color, 0 not to fill. This optional argument can be set to 0 if new data will fully overwrite the data existing in the memory.
  • int allocate - Positive number to allocate memory for the created image. This value should be always set to 1.

Return value

Returns 1 if the 2D Array image is created successfully; otherwise, 0.

int create3D(int width, int height, int depth, int format, int num_mipmaps = 1, int clear = 1, int allocate = 1)

Creates an empty 3D image.

Arguments

  • int width - Desired width.
  • int height - Desired height.
  • int depth - Desired depth.
  • int format - Desired format. See the IMAGE_FORMAT_* variables.
  • int num_mipmaps - Number of mipmaps to create. This is an optional argument. If the value is smaller than 1, an assertion is raised.
  • int clear - Positive number to fill the image with black color, 0 not to fill. This optional argument can be set to 0 if new data will fully overwrite the data existing in the memory.
  • int allocate - Positive number to allocate memory for the created image. This value should be always set to 1.

Return value

Returns 1 if the 3D image is created successfully; otherwise, 0.

int createCube(int width, int height, int format, int num_mipmaps = 1, int clear = 1, int allocate = 1)

Creates an empty cube image.

Arguments

  • int width - Image width, in pixels.
  • int height - Image height, in pixels.
  • int format - Texture format. See the IMAGE_FORMAT_* variables.
  • int num_mipmaps - Number of mipmaps to create. This is an optional argument.
  • int clear - 1 to fill the image with black color, 0 is not to fill. This optional argument can be set to 0 if new data will fully overwrite the data existing in the memory.
  • int allocate - 1 to allocate memory for the created image. This value should be always set to 1.

Return value

Returns 1 if the Cube image is created successfully; otherwise, 0.

int createCubeArray(int width, int height, int num_layers, int format, int num_mipmaps = 1, int clear = 1, int allocate = 1)

Create a Cube Array image.

Arguments

  • int width - Image width, in pixels.
  • int height - Image height, in pixels.
  • int num_layers - Number of image layers.
  • int format - Texture format. See the IMAGE_FORMAT_* variables.
  • int num_mipmaps - Number of mipmaps to create. This is an optional argument.
  • int clear - 1 to fill the image with black color, 0 is not to fill. This optional argument can be set to 0 if new data will fully overwrite the data existing in the memory.
  • int allocate - 1 to allocate memory for the created image. This value should be always set to 1.

Return value

Returns 1 if the Cube Array image is created successfully; otherwise, 0.

int createMipmaps(int filter = FILTER_LINEAR, float gamma = 1.0f)

Generates mipmaps for the image. Mipmaps cannot be created for compressed and combined image formats.

Arguments

  • int filter - Filter type to be used: box or point. The default filter is box. See the Unigine::Image Enumerations with FILTER_* prefixes at the end of the article.
  • float gamma - Gamma correction value. If 1 is provided, no gamma correction is applied. This is an optional argument.

Return value

Returns 1 if the mipmaps are generated successfully; otherwise, 0.

int decombine()

Converts the image from the combined format to a correct one. The following conversions are available:
  • RGB565 to RGB8
  • RGBA4 to RGBA8
  • RGB5A1 to RGBA8
  • RGB10A2 to RGBA16

Return value

Returns 1 if the image is converted successfully; otherwise, 0.

int decombineMipmaps()

Decombines the loaded 2D image and the mipmap images. The number of mipmaps must be larger than 1. Compressed image formats cannot be decombined.

Return value

Returns 1 if the mipmaps are decombined successfully; otherwise, 0.

int decompress()

Decompresses the image from the compressed format to a correct one. The following conversions are available:
  • DXT1 to RGBA8
  • DXT1 without alpha data to RGB8
  • DXT3 to RGBA8
  • DXT5 to RGBA8
  • ATI1 to R8
  • ATI2 to RG8

Return value

Returns 1 if the image is decompressed successfully; otherwise, 0.

int extrude(int pixels)

Extrudes a contour of the image in the alpha=0 region on the given number of pixels. Only images of the RGBA8 and RGBA16 formats can be extruded.

Arguments

  • int pixels - Number of contour pixels.

Return value

Returns 1 if the image contour is extruded successfully; otherwise, 0.

int flipX()

Flips the 2D image horizontally. Compressed and combined image formats are not supported.

Return value

Returns 1 if the image is flipped successfully; otherwise, 0.

int flipY()

Flips the 2D image vertically. Compressed and combined image formats are not supported.

Return value

Returns 1 if the image is flipped successfully; otherwise, 0.

void grab()

int info(const char * name)

Returns an information about a given image.

Arguments

  • const char * name - Name of the image file. The following file formats are supported: TGA, JPG, PNG, DDS.

Return value

Returns 1 if the image exists; otherwise, 0.

int invert()

Inverts the image value. Only R8, RG8, RGB8, RGBA8, R16, RG16, RGB16, RGBA16, R32F, RG32F, RGB32F and RGBA32F formats can be inverted.

Return value

Returns 1 if the image is inverted successfully; otherwise, 0.

int load(const char * file, int offset)

Loads an image from a specified file.

Arguments

  • const char * file - Name of the image file.
  • int offset - Mipmap offset value for the loaded image.

Return value

Returns 1 if the image is loaded successfully; otherwise, 0.

int load(const char * file)

Loads an image from a specified file.

Arguments

  • const char * file - Name of the image file. The following file formats are supported: TGA, JPG, PNG, DDS, PSD, PPM, PGM, HDR, SGI.

Return value

Returns 1 if the image is loaded successfully; otherwise, 0.

int normalize()

Creates a three-component normal map out of the image.

Return value

Returns 1 if the normal map is created successfully; otherwise, 0.

void release()

int resize(int new_width, int new_height, int filter = FILTER_LINEAR)

Resizes the image. Only the 2D or cube image can be resized. Compressed and combined image formats cannot be resized.

Arguments

  • int new_width - New image width.
  • int new_height - New image height.
  • int filter - Quality setting, accepts one of the FILTER_* values.

Return value

Returns 1 if the image is resized successfully; otherwise, 0.

int rotate(int angle)

Rotates the image by a given angle (with the step of 90 degrees). Only the 2D or cube image can be rotated. Compressed and combined image formats cannot be rotated.

Arguments

  • int angle - Angle that is multiplied by the step (angle * 90) to set the image rotation degree.

Return value

Returns 1 if the image is rotated successfully; otherwise, 0.

int save(const char * name, float quality)

Saves the image to a specified file. The following file formats are supported:
  • DDS
  • JPG
  • PNG
  • PSD
  • TGA

Arguments

  • const char * name - Name of the file (with the specified extension) to save image data.
  • float quality - Quality of JPG compression in range [0;1]. The default value is 0.85f.

Return value

Returns 1 if the image is saved successfully; otherwise, 0.

int save(const char * name)

Saves the image to a specified file. The following file formats are supported:
  • DDS
  • JPG
  • PNG
  • PSD
  • TGA

Arguments

  • const char * name

Return value

Returns 1 if the image is saved successfully; otherwise, 0.

int sign()

Converts the image from unsigned type to signed char. Only R8, RG8, RGB8, RGBA8, R16, RG16, RGB16, RGBA16, ATI1 and ATI2 formats can be converted.

Return value

Returns 1 if the image is converted successfully; otherwise, 0.

int swap(int channel, int index)

Swaps two channels of the image.

Arguments

  • int channel - First channel number in range of 0 to (number of channels - 1).
  • int index - Second channel number in range of 0 to (number of channels - 1).

Return value

Returns 1 if the values are swapped successfully; otherwise, 0.

int FILTER_LINEAR

Description

A linear mipmap filter.

int FILTER_POINT

Description

A point mipmap filter.

int FORMAT_ATI1

Description

An ATI1 compressed image file format. Compresses single-channel images by a factor of 2:1 compared to R8. Compression is the same as the one used for alpha data in the DXT5 format. Supported by all graphics cards compatible with DirectX 10; additionally, all ATI graphics cards since X800.

int FORMAT_ATI2

Description

An ATI2 compressed image file format. Compresses two-channel images by a factor of 2:1 compared to RG8. Compression for each channel is the same as the one used for alpha data in the DXT5 format. Supported by all graphics cards compatible with DirectX 10; additionally, all ATI graphics cards since X800.

int FORMAT_DXT1

Description

A DXT1 compressed image file format. Compresses RGB images by a factor of 6:1 compared to RGB8. Uses 4×4 blocks for color interpolation and stores color values in 16 bits per pixel (R5:G6:B5). Can also store 1-bit alpha data; in this case, compresses images by a factor of 8:1 compared to RGBA8. This format is not recommended for storing normal maps.

int FORMAT_DXT3

Description

A DXT3 compressed image file format. Compresses RGBA images by a factor of 4:1 compared to RGBA8. Stores RGB color values as the DXT1 format and uses four more bits for alpha data. Color values are interpreted as not having been pre-multiplied by alpha. Alpha values are not interpolated. Recommended for images with sharp alpha transitions.

int FORMAT_DXT5

Description

A DXT5 compressed image file format. Compresses RGBA images by a factor of 4:1 compared to RGBA8. Stores RGB color values as the DXT1 format and uses four more bits for alpha data. Color values are interpreted as not having been pre-multiplied by alpha. Alpha values are interpolated. Recommended for images with smooth alpha transitions.

int FORMAT_R16

Description

Non-compressed unsigned format. Stores data in one 16-bit channel (red).

int FORMAT_R16F

Description

Non-compressed float format. Stores data in one 16-bit channel (red).

int FORMAT_R32F

Description

Non-compressed float format. Stores data in one 32-bit channel (red).

int FORMAT_R8

Description

Non-compressed unsigned format. Stores data in one 8-bit channel (red).

int FORMAT_RG16

Description

Non-compressed unsigned format. Stores data in two 16-bit channels (red, green).

int FORMAT_RG16F

Description

Non-compressed float format. Stores data in two 16-bit channels (red, green).

int FORMAT_RG32F

Description

Non-compressed float format. Stores data in two 32-bit channels (red, green).

int FORMAT_RG8

Description

Non-compressed unsigned format. Stores data in two 8-bit channels (red, green).

int FORMAT_RGB10A2

Description

Combined unsigned format. Stores data in three 10-bit channels (red, green, blue) and one 2-bit channel (alpha).

int FORMAT_RGB16

Description

Non-compressed unsigned format. Stores data in three 16-bit channels (red, green, blue).

int FORMAT_RGB16F

Description

Non-compressed float format. Stores data in three 16-bit channels (red, green, blue).

int FORMAT_RGB32F

Description

Non-compressed float format. Stores data in three 32-bit channels (red, green, blue).

int FORMAT_RGB565

Description

Combined unsigned format. Stores 16 bit color values without alpha.

int FORMAT_RGB5A1

Description

Combined unsigned format. Stores data in three 5-bit channels (red, green, blue) and one 1-bit channel (alpha).

int FORMAT_RGB8

Description

Non-compressed unsigned format. Stores data in three 8-bit channels (red, green, blue).

int FORMAT_RGBA16

Description

Non-compressed unsigned format. Stores data in four 16-bit channels (red, green, blue, alpha).

int FORMAT_RGBA16F

Description

Non-compressed float format. Stores data in four 16-bit channels (red, green, blue, alpha).

int FORMAT_RGBA32F

Description

Non-compressed float format. Stores data in four 32-bit channels (red, green, blue, alpha).

int FORMAT_RGBA4

Description

Combined unsigned format. Stores data in four 4-bit channels (red, green, blue, alpha).

int FORMAT_RGBA8

Description

Non-compressed unsigned format. Stores data in four 8-bit channels (red, green, blue, alpha).

int FORMAT_ZLC1

Description

Compressed format used for images stored in the system memory (based on zlib library). It is used for fast compression (for example, in run-time).

int FORMAT_ZLC2

Description

Compressed format used for images stored in the system memory (based on zlib library). It is used when a smaller file size is required, if compared to ZLC1 format.

int IMAGE_2D

Description

A 2D texture.

int IMAGE_2D_ARRAY

Description

A 2D texture array. Each texture of the array has its own mipmap levels, which is the difference between it and a 3D image.

int IMAGE_3D

Description

A 3D texture.

int IMAGE_CUBE

Description

A cube texture.

int IMAGE_CUBE_ARRAY

Description

A cube texture array.
Notice
Not supported on OpenGLES 3.0.
Last update: 2017-07-03
Build: ()