Tizen Native API  4.0
Image Util Encode/Decode

The Image Util Encode/Decode APIs provides functions for encoding and decoding of images .

Required Header

#include <image_util.h>

Overview

Image Util API provides support for encoding and decoding of images. The API allows :

  • Encoding of a JPEG/PNG/GIF/BMP image.
  • Decoding of a JPEG/PNG/GIF/BMP image. Encoding supports gif images including the animated, but decoding gif does not support the animated.

The decoding of a jpeg/png/gif/bmp image located at a given path, to a buffer can be done by calling #image_util_decode_run() function and decoding of a jpeg image on memory can be done by calling #image_util_decode_set_output_buffer(). Similarly, for encoding #image_util_encode_run() and #image_util_encode_set_output_buffer() functions can be called to encode an image buffer to a jpeg/png/gif/bmp image and a buffer respectively.

Foreach Operations

FOREACH CALLBACK DESCRIPTION
image_util_foreach_supported_colorspace() image_util_supported_colorspace_cb() Supported JPEG/PNG/GIF/BMP encoding/decoding colorspace

Functions

int image_util_foreach_supported_jpeg_colorspace (image_util_supported_jpeg_colorspace_cb callback, void *user_data) TIZEN_DEPRECATED_API
 Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one.
int image_util_foreach_supported_colorspace (image_util_type_e image_type, image_util_supported_colorspace_cb callback, void *user_data)
 Retrieves all supported image encoding/decoding colorspace by invoking a callback function once for each one.

Typedefs

typedef bool(* image_util_supported_jpeg_colorspace_cb )(image_util_colorspace_e colorspace, void *user_data)
 Called once for each supported JPEG encode/decode colorspace.
typedef bool(* image_util_supported_colorspace_cb )(image_util_colorspace_e colorspace, void *user_data)
 Called once for each supported image encode/decode colorspace.
typedef void(* image_util_decode_completed_cb )(int error_code, void *user_data, unsigned long width, unsigned long height, unsigned long long size)
 Called when Image-util decoding is finished just before returning the output.
typedef void(* image_util_encode_completed_cb )(int error_code, void *user_data, unsigned long long size)
 Called when Image-util encoding is finished just before returning the output.
typedef void * image_util_decode_h
 Image-util decoding handle.
typedef void * image_util_encode_h
 Image-util encoding handle.

Typedef Documentation

typedef void(* image_util_decode_completed_cb)(int error_code, void *user_data, unsigned long width, unsigned long height, unsigned long long size)

Called when Image-util decoding is finished just before returning the output.

Since :
3.0
Remarks:
The output will be stored in the pointer set using image_util_decode_set_output_buffer() after this callback.
The callback is called in a separate thread(not in the main loop).
Parameters:
[in]error_codeThe error code of image util decoding IMAGE_UTIL_ERROR_NONE Successful IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
[in]user_dataThe user data passed from the callback registration function
[in]widthWidth of the decoded image
[in]heightHeight of the decoded image
[in]sizeSize of the decoded image
Precondition:
image_util_decode_run() will invoke this function.
typedef void* image_util_decode_h

Image-util decoding handle.

Since :
3.0
typedef void(* image_util_encode_completed_cb)(int error_code, void *user_data, unsigned long long size)

Called when Image-util encoding is finished just before returning the output.

Since :
3.0
Remarks:
The output will be stored in the pointer set using image_util_encode_set_output_buffer() or image_util_encode_set_output_path() after this callback.
The callback is called in a separate thread(not in the main loop).
Parameters:
[in]error_codeThe error code of image util encoding IMAGE_UTIL_ERROR_NONE Successful IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
[in]user_dataThe user data passed from the callback registration function
[in]sizeSize of the encoded image
Precondition:
image_util_encode_run() will invoke this function.
typedef void* image_util_encode_h

Image-util encoding handle.

Since :
3.0
typedef bool(* image_util_supported_colorspace_cb)(image_util_colorspace_e colorspace, void *user_data)

Called once for each supported image encode/decode colorspace.

Since :
3.0
Parameters:
[in]colorspaceThe colorspace
[in]user_dataThe user data passed from the foreach function
Returns:
true to continue with the next iteration of the loop,
otherwise false to break out of the loop
Precondition:
image_util_foreach_supported_colorspace() invokes this callback.
See also:
image_util_foreach_supported_colorspace()
image_util_encode_create()
image_util_decode_create()
typedef bool(* image_util_supported_jpeg_colorspace_cb)(image_util_colorspace_e colorspace, void *user_data)

Called once for each supported JPEG encode/decode colorspace.

Deprecated:
Deprecated since 3.0. Use image_util_supported_colorspace_cb() instead.
Since :
2.3
Parameters:
[in]colorspaceThe colorspace
[in]user_dataThe user data passed from the foreach function
Returns:
true to continue with the next iteration of the loop,
otherwise false to break out of the loop
Precondition:
image_util_foreach_supported_jpeg_colorspace() invokes this callback.
See also:
image_util_foreach_supported_jpeg_colorspace()
image_util_encode_jpeg()
image_util_encode_jpeg_to_memory()
image_util_decode_jpeg()
image_util_decode_jpeg_from_memory()

Enumeration Type Documentation

Enumeration for PNG compression values.

Since :
3.0
Enumerator:
IMAGE_UTIL_PNG_COMPRESSION_0 

No compression

IMAGE_UTIL_PNG_COMPRESSION_1 

Compression Level 1. Best speed

IMAGE_UTIL_PNG_COMPRESSION_2 

Compression Level 2

IMAGE_UTIL_PNG_COMPRESSION_3 

Compression Level 3

IMAGE_UTIL_PNG_COMPRESSION_4 

Compression Level 4

IMAGE_UTIL_PNG_COMPRESSION_5 

Compression Level 5

IMAGE_UTIL_PNG_COMPRESSION_6 

Compression Level 6

IMAGE_UTIL_PNG_COMPRESSION_7 

Compression Level 7

IMAGE_UTIL_PNG_COMPRESSION_8 

Compression Level 8

IMAGE_UTIL_PNG_COMPRESSION_9 

Compression Level 9. Best compression

Enumeration for scale decoding.

Since :
2.4
Enumerator:
IMAGE_UTIL_DOWNSCALE_1_1 

1/1 downscale

IMAGE_UTIL_DOWNSCALE_1_2 

1/2 downscale

IMAGE_UTIL_DOWNSCALE_1_4 

1/4 downscale

IMAGE_UTIL_DOWNSCALE_1_8 

1/8 downscale

Enumeration for Image types.

Since :
3.0
Enumerator:
IMAGE_UTIL_JPEG 

Image format JPEG

IMAGE_UTIL_PNG 

Image format PNG

IMAGE_UTIL_GIF 

Image format GIF

IMAGE_UTIL_BMP 

Image format BMP


Function Documentation

Retrieves all supported image encoding/decoding colorspace by invoking a callback function once for each one.

Since :
3.0
Parameters:
[in]image_typeThe type of supported image for which to create encode/decode handle
[in]callbackThe callback function to invoke
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
IMAGE_UTIL_ERROR_NONESuccessful
IMAGE_UTIL_ERROR_INVALID_PARAMETERInvalid parameter
Postcondition:
This function invokes image_util_supported_colorspace_cb() repeatedly to retrieve each supported image encoding/decoding colorspace.
See also:
image_util_supported_colorspace_cb()
image_util_encode_create()
image_util_decode_create()

Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one.

Deprecated:
Deprecated since 3.0. Use image_util_foreach_supported_colorspace() instead.
Since :
2.3
Parameters:
[in]callbackThe callback function to invoke
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
IMAGE_UTIL_ERROR_NONESuccessful
IMAGE_UTIL_ERROR_INVALID_PARAMETERInvalid parameter
Postcondition:
This function invokes image_util_supported_jpeg_colorspace_cb() repeatedly to retrieve each supported JPEG encoding/decoding colorspace.
See also:
image_util_supported_jpeg_colorspace_cb()
image_util_encode_jpeg()
image_util_encode_jpeg_to_memory()
image_util_decode_jpeg()
image_util_decode_jpeg_from_memory()