Tizen Native API
5.0
|
Eet efficiently stores and loads images, including alpha channels and lossy compressions.
Eet can handle both lossy compression with different levels of quality and non-lossy compression with different compression levels. It's also possible, given an image data, to only read its header to get the image information without decoding the entire content for it.
The encode family of functions will take an image raw buffer and its parameters and compress it in memory, returning the new buffer. Likewise, the decode functions will read from the given location in memory and return the uncompressed image.
The read and write functions will, respectively, encode and decode to or from an Eet file, under the specified key.
These functions are fairly low level and the same functionality can be achieved using Evas and Edje, making it much easier to work with images as well as not needing to worry about things like scaling them.
Functions | |
int | eet_data_image_header_read (Eet_File *ef, const char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, Eet_Image_Encoding *lossy) |
Reads just the header data for an image and dont decode the pixels. | |
void * | eet_data_image_read (Eet_File *ef, const char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, Eet_Image_Encoding *lossy) |
Reads image data from the named key in the eet file. | |
int | eet_data_image_read_to_surface (Eet_File *ef, const char *name, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, Eet_Image_Encoding *lossy) |
Reads image data from the named key in the eet file and store it in the given buffer. | |
int | eet_data_image_write (Eet_File *ef, const char *name, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, Eet_Image_Encoding lossy) |
Writes image data to the named key in an eet file. | |
int | eet_data_image_header_decode (const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, Eet_Image_Encoding *lossy) |
Decodes Image data header only to get information. | |
void * | eet_data_image_decode (const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, Eet_Image_Encoding *lossy) |
Decodes Image data into pixel data. | |
int | eet_data_image_decode_to_surface (const void *data, int size, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, Eet_Image_Encoding *lossy) |
Decodes Image data into pixel data and stores in the given buffer. | |
void * | eet_data_image_encode (const void *data, int *size_ret, unsigned int w, unsigned int h, int alpha, int compress, int quality, Eet_Image_Encoding lossy) |
Encodes image data for storage or transmission. | |
int | eet_data_image_colorspace_get (Eet_File *ef, const char *name, const char *cipher_key, const Eet_Colorspace **cspaces) |
Gets the colorspace Eet can decode into of a given eet image ressource. |
int eet_data_image_colorspace_get | ( | Eet_File * | ef, |
const char * | name, | ||
const char * | cipher_key, | ||
const Eet_Colorspace ** | cspaces | ||
) |
Gets the colorspace Eet can decode into of a given eet image ressource.
ef | A valid eet file handle opened for reading. |
name | Name of the entry. eg: "/base/file_i_want". |
cipher_key | The key to use as cipher. |
cspaces | Returned pointer by Eet to a list of possible decoding colorspace finished by EET_COLORSPACE_ARGB8888 . If NULL , only EET_COLORSPACE_ARGB8888 is supported. |
void* eet_data_image_decode | ( | const void * | data, |
int | size, | ||
unsigned int * | w, | ||
unsigned int * | h, | ||
int * | alpha, | ||
int * | compress, | ||
int * | quality, | ||
Eet_Image_Encoding * | lossy | ||
) |
Decodes Image data into pixel data.
data | The encoded pixel data. |
size | The size, in bytes, of the encoded pixel data. |
w | A pointer to the unsigned int to hold the width in pixels. |
h | A pointer to the unsigned int to hold the height in pixels. |
alpha | A pointer to the int to hold the alpha flag. |
compress | A pointer to the int to hold the compression amount. |
quality | A pointer to the int to hold the quality amount. |
lossy | A pointer to the int to hold the lossiness flag. |
This function takes encoded pixel data and decodes it into raw RGBA pixels on success.
It works exactly like eet_data_image_read(), but it takes the encoded data in the data
buffer of size size
, instead of reading from a file. All the others parameters are also the same.
On success the function returns a pointer to the image data decoded. The calling application is responsible for calling free() on the image data when it is done with it. On failure NULL is returned and the parameter values may not contain any sensible data.
int eet_data_image_decode_to_surface | ( | const void * | data, |
int | size, | ||
unsigned int | src_x, | ||
unsigned int | src_y, | ||
unsigned int * | d, | ||
unsigned int | w, | ||
unsigned int | h, | ||
unsigned int | row_stride, | ||
int * | alpha, | ||
int * | compress, | ||
int * | quality, | ||
Eet_Image_Encoding * | lossy | ||
) |
Decodes Image data into pixel data and stores in the given buffer.
data | The encoded pixel data. |
size | The size, in bytes, of the encoded pixel data. |
src_x | The starting x coordinate from where to dump the stream. |
src_y | The starting y coordinate from where to dump the stream. |
d | A pointer to the pixel surface. |
w | The expected width in pixels of the pixel surface to decode. |
h | The expected height in pixels of the pixel surface to decode. |
row_stride | The length of a pixels line in the destination surface. |
alpha | A pointer to the int to hold the alpha flag. |
compress | A pointer to the int to hold the compression amount. |
quality | A pointer to the int to hold the quality amount. |
lossy | A pointer to the int to hold the lossiness flag. |
1
on success, 0
otherwise.Like eet_data_image_read_to_surface(), but reading the given data
buffer instead of a file.
On success the function returns 1, and 0 on failure. On failure the parameter values may not contain any sensible data.
void* eet_data_image_encode | ( | const void * | data, |
int * | size_ret, | ||
unsigned int | w, | ||
unsigned int | h, | ||
int | alpha, | ||
int | compress, | ||
int | quality, | ||
Eet_Image_Encoding | lossy | ||
) |
Encodes image data for storage or transmission.
data | A pointer to the image pixel data. |
size_ret | A pointer to an int to hold the size of the returned data. |
w | The width of the image in pixels. |
h | The height of the image in pixels. |
alpha | The alpha channel flag. |
compress | The compression amount. |
quality | The quality encoding amount. |
lossy | The lossiness flag. |
This function stakes image pixel data and encodes it with compression and possible loss of quality (as a trade off for size) for storage or transmission to another system.
It works like eet_data_image_write(), but instead of writing the encoded image into an Eet file, it allocates a new buffer of the size required and returns the encoded data in it.
On success this function returns a pointer to the encoded data that you can free with free() when no longer needed.
int eet_data_image_header_decode | ( | const void * | data, |
int | size, | ||
unsigned int * | w, | ||
unsigned int * | h, | ||
int * | alpha, | ||
int * | compress, | ||
int * | quality, | ||
Eet_Image_Encoding * | lossy | ||
) |
Decodes Image data header only to get information.
data | The encoded pixel data. |
size | The size, in bytes, of the encoded pixel data. |
w | A pointer to the unsigned int to hold the width in pixels. |
h | A pointer to the unsigned int to hold the height in pixels. |
alpha | A pointer to the int to hold the alpha flag. |
compress | A pointer to the int to hold the compression amount. |
quality | A pointer to the int to hold the quality amount. |
lossy | A pointer to the int to hold the lossiness flag. |
1
on success, 0
on failure.This function works exactly like eet_data_image_header_read(), but instead of reading from an Eet file, it takes the buffer of size size
pointed by data
, which must be a valid Eet encoded image.
On success the function returns 1
indicating the header was read and decoded properly, or 0
on failure.
int eet_data_image_header_read | ( | Eet_File * | ef, |
const char * | name, | ||
unsigned int * | w, | ||
unsigned int * | h, | ||
int * | alpha, | ||
int * | compress, | ||
int * | quality, | ||
Eet_Image_Encoding * | lossy | ||
) |
Reads just the header data for an image and dont decode the pixels.
ef | A valid eet file handle opened for reading. |
name | Name of the entry. eg: "/base/file_i_want". |
w | A pointer to the unsigned int to hold the width in pixels. |
h | A pointer to the unsigned int to hold the height in pixels. |
alpha | A pointer to the int to hold the alpha flag. |
compress | A pointer to the int to hold the compression amount. |
quality | A pointer to the int to hold the quality amount. |
lossy | A pointer to the int to hold the lossiness flag. |
1
on successful decode, 0
otherwiseReads and decodes the image header data stored under the given key and Eet file.
The information decoded is placed in each of the parameters, which must be provided. The width and height, measured in pixels, will be stored under the variables pointed by w
and h
, respectively. If the read or decode of the header fails, this values will be 0. The alpha
parameter will be 1 or 0, denoting if the alpha channel of the image is used or not. If the image was losslessly compressed, the compress
parameter will hold the compression amount used, ranging from 0 to 9 and lossy
will be 0. In the case of lossy compression, lossy
will be 1, and the compression quality will be placed under quality
, with a value ranging from 0 to 100.
void* eet_data_image_read | ( | Eet_File * | ef, |
const char * | name, | ||
unsigned int * | w, | ||
unsigned int * | h, | ||
int * | alpha, | ||
int * | compress, | ||
int * | quality, | ||
Eet_Image_Encoding * | lossy | ||
) |
Reads image data from the named key in the eet file.
ef | A valid eet file handle opened for reading. |
name | Name of the entry. eg: "/base/file_i_want". |
w | A pointer to the unsigned int to hold the width in pixels. |
h | A pointer to the unsigned int to hold the height in pixels. |
alpha | A pointer to the int to hold the alpha flag. |
compress | A pointer to the int to hold the compression amount. |
quality | A pointer to the int to hold the quality amount. |
lossy | A pointer to the int to hold the lossiness flag. |
Reads and decodes the image stored in the given Eet file under the named key.
The returned pixel data is a linear array of pixels starting from the top-left of the image, scanning row by row from left to right. Each pile is a 32bit value, with the high byte being the alpha channel, the next being red, then green, and the low byte being blue.
The rest of the parameters are the same as in eet_data_image_header_read().
On success the function returns a pointer to the image data decoded. The calling application is responsible for calling free() on the image data when it is done with it. On failure NULL is returned and the parameter values may not contain any sensible data.
int eet_data_image_read_to_surface | ( | Eet_File * | ef, |
const char * | name, | ||
unsigned int | src_x, | ||
unsigned int | src_y, | ||
unsigned int * | d, | ||
unsigned int | w, | ||
unsigned int | h, | ||
unsigned int | row_stride, | ||
int * | alpha, | ||
int * | compress, | ||
int * | quality, | ||
Eet_Image_Encoding * | lossy | ||
) |
Reads image data from the named key in the eet file and store it in the given buffer.
ef | A valid eet file handle opened for reading. |
name | Name of the entry. eg: "/base/file_i_want". |
src_x | The starting x coordinate from where to dump the stream. |
src_y | The starting y coordinate from where to dump the stream. |
d | A pointer to the pixel surface. |
w | The expected width in pixels of the pixel surface to decode. |
h | The expected height in pixels of the pixel surface to decode. |
row_stride | The length of a pixels line in the destination surface. |
alpha | A pointer to the int to hold the alpha flag. |
compress | A pointer to the int to hold the compression amount. |
quality | A pointer to the int to hold the quality amount. |
lossy | A pointer to the int to hold the lossiness flag. |
1
on success, 0
otherwise.Reads and decodes the image stored in the given Eet file, placing the resulting pixel data in the buffer pointed by the user.
Like eet_data_image_read(), it takes the image data stored under the name
key in the ef
file, but instead of returning a new buffer with the pixel data, it places the result in the buffer pointed by d
, which must be provided by the user and of sufficient size to hold the requested portion of the image.
The src_x
and src_y
parameters indicate the top-left corner of the section of the image to decode. These have to be higher or equal than 0 and less than the respective total width and height of the image. The width and height of the section of the image to decode are given in w
and h
and also can't be higher than the total width and height of the image.
The row_stride
parameter indicates the length in bytes of each line in the destination buffer and it has to be at least w
* 4.
All the other parameters are the same as in eet_data_image_read().
On success the function returns 1, and 0 on failure. On failure the parameter values may not contain any sensible data.
int eet_data_image_write | ( | Eet_File * | ef, |
const char * | name, | ||
const void * | data, | ||
unsigned int | w, | ||
unsigned int | h, | ||
int | alpha, | ||
int | compress, | ||
int | quality, | ||
Eet_Image_Encoding | lossy | ||
) |
Writes image data to the named key in an eet file.
ef | A valid eet file handle opened for writing. |
name | Name of the entry. eg: "/base/file_i_want". |
data | A pointer to the image pixel data. |
w | The width of the image in pixels. |
h | The height of the image in pixels. |
alpha | The alpha channel flag. |
compress | The compression amount. |
quality | The quality encoding amount. |
lossy | The lossiness flag. |
This function takes image pixel data and encodes it in an eet file stored under the supplied name key, and returns how many bytes were actually written to encode the image data.
The data expected is the same format as returned by eet_data_image_read. If this is not the case weird things may happen. Width and height must be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning the alpha values are not useful and 1 meaning they are). Compress can be from 0 to 9 (0 meaning no compression, 9 meaning full compression). This is only used if the image is not lossily encoded. Quality is used on lossy compression and should be a value from 0 to 100. The lossy flag can be 0 or 1. 0 means encode losslessly and 1 means to encode with image quality loss (but then have a much smaller encoding).
On success this function returns the number of bytes that were required to encode the image data, or on failure it returns 0.