Tizen Native API
5.0
|
The Thumbnail Util API provides functions for creating the thumbnail from a given media file.
#include <thumbnail_util.h>
The Thumbnail Util API allows you to create thumbnails of the size you want from media files.
Thumbnails can be created as files(thumbnail_util_extract_to_file()) or buffers(thumbnail_util_extract_to_buffer()).
Functions | |
int | thumbnail_util_create (thumbnail_h *thumb) TIZEN_DEPRECATED_API |
Creates thumbnail info handle. | |
int | thumbnail_util_extract (thumbnail_h thumb, thumbnail_extracted_cb callback, void *user_data, char **request_id) TIZEN_DEPRECATED_API |
Extracts the thumbnail for the given media, asynchronously. | |
int | thumbnail_util_set_path (thumbnail_h thumb, const char *path) TIZEN_DEPRECATED_API |
Sets the path of original media file. | |
int | thumbnail_util_set_size (thumbnail_h thumb, int width, int height) TIZEN_DEPRECATED_API |
Sets the size of thumbnail to be extracted. | |
int | thumbnail_util_cancel (thumbnail_h thumb, const char *request_id) TIZEN_DEPRECATED_API |
Cancels the thumbnail extraction request for the given media. | |
int | thumbnail_util_cancel_all (thumbnail_h thumb) TIZEN_DEPRECATED_API |
Cancels all thumbnail extraction requests associated with the given thumbnail info handle. | |
int | thumbnail_util_destroy (thumbnail_h thumb) TIZEN_DEPRECATED_API |
Destroys thumbnail info handle. | |
int | thumbnail_util_extract_to_file (const char *path, unsigned int width, unsigned int height, const char *thumbnail_path) |
Extracts the thumbnail for the given media into a file, synchronously. | |
int | thumbnail_util_extract_to_buffer (const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height) |
Extracts the thumbnail for the given media into a buffer, synchronously. | |
Typedefs | |
typedef struct thumbnail_s * | thumbnail_h |
The structure type for the thumbnail info handle. | |
typedef void(* | thumbnail_extracted_cb )(thumbnail_util_error_e error, const char *request_id, int thumb_width, int thumb_height, unsigned char *thumb_data, int thumb_size, void *user_data) |
Called when creating the thumbnail. | |
Defines | |
#define | THUMBNAIL_UTIL_ERROR_CLASS TIZEN_ERROR_THUMBNAIL_UTIL |
Definition for Thumbnail util Error Class. |
#define THUMBNAIL_UTIL_ERROR_CLASS TIZEN_ERROR_THUMBNAIL_UTIL |
Definition for Thumbnail util Error Class.
typedef void(* thumbnail_extracted_cb)(thumbnail_util_error_e error, const char *request_id, int thumb_width, int thumb_height, unsigned char *thumb_data, int thumb_size, void *user_data) |
Called when creating the thumbnail.
This callback is called for completion of generating the thumbnail. The following error codes can be received:
THUMBNAIL_UTIL_ERROR_NONE : Successful THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER : Invalid parameter THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED : Permission denied
[in] | error | The error code |
[in] | request_id | The generated request id by thumbnail extraction request |
[in] | thumb_width | The width of the thumbnail which is generated |
[in] | thumb_height | The height of the thumbnail which is generated |
[in] | thumb_data | The raw data of the thumbnail which is generated |
[in] | thumb_size | The size of the thumbnail which is generated |
[in] | user_data | The user data passed from the thumbnail_util_extract() function |
typedef struct thumbnail_s* thumbnail_h |
Enumeration for a thumbnail util error.
int thumbnail_util_cancel | ( | thumbnail_h | thumb, |
const char * | request_id | ||
) |
Cancels the thumbnail extraction request for the given media.
[in] | thumb | The media thumbnail info handle |
[in] | request_id | The generated request id by thumbnail extraction request |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
int thumbnail_util_cancel_all | ( | thumbnail_h | thumb | ) |
Cancels all thumbnail extraction requests associated with the given thumbnail info handle.
[in] | thumb | The media thumbnail info handle |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
int thumbnail_util_create | ( | thumbnail_h * | thumb | ) |
Creates thumbnail info handle.
[in] | thumb | The handle to thumbnail info |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY | Out of memory |
int thumbnail_util_destroy | ( | thumbnail_h | thumb | ) |
Destroys thumbnail info handle.
The function frees all resources related to the thumbnail info handle. This handle can no longer be used to perform any operations. New thumbnail info handle has to be created before the next usage.
[in] | thumb | The thumbnail info handle |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
int thumbnail_util_extract | ( | thumbnail_h | thumb, |
thumbnail_extracted_cb | callback, | ||
void * | user_data, | ||
char ** | request_id | ||
) |
Extracts the thumbnail for the given media, asynchronously.
This function extracts the thumbnail for given media item and calls registered callback function for completion of extracting the thumbnail.
You can distinguish generated thumbnails by request_id. Therefore, the request_id must be maintained until the request is completed.
And the request_id is also used to cancel the request.
[in] | thumb | The thumbnail info handle |
[in] | callback | The callback function to be invoked |
[in] | user_data | The user data to be passed to the callback function |
[out] | request_id | The request id for the thumbnail extraction request |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
int thumbnail_util_extract_to_buffer | ( | const char * | path, |
unsigned int | width, | ||
unsigned int | height, | ||
unsigned char ** | thumb_buffer, | ||
size_t * | thumb_size, | ||
unsigned int * | thumb_width, | ||
unsigned int * | thumb_height | ||
) |
Extracts the thumbnail for the given media into a buffer, synchronously.
This function creates thumbnails from a given media file.
The generated thumbnail is returned as a raw data stream.
[in] | path | The path of the original media file |
[in] | width | The width of the thumbnail |
[in] | height | The height of the thumbnail |
[out] | thumb_buffer | The raw data of the thumbnail which is generated |
[out] | thumb_size | The size of the thumbnail which is generated |
[out] | thumb_width | The width of the thumbnail which is generated |
[out] | thumb_height | The height of the thumbnail which is generated |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
THUMBNAIL_UTIL_ERROR_INVALID_OPERATION | Invalid operation |
THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY | Out of memory |
THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
int thumbnail_util_extract_to_file | ( | const char * | path, |
unsigned int | width, | ||
unsigned int | height, | ||
const char * | thumbnail_path | ||
) |
Extracts the thumbnail for the given media into a file, synchronously.
This function creates thumbnail from a given media file.
The generated thumbnail is saved in the given thumbnail path.
The format of the thumbnail file is determined by the extension of the thumbnail path (e.g. path is input.jpg and thumbnail_path is thumbnail.png then thumbnail.png is encoded in the PNG format).
If the extension is missing or the format is not supported, the thumbnail is encoded in the same format as the given media (e.g. path is input.jpg and thumbnail_path is thumbnail.out then thumbnail.out is encoded in the JPEG format).
Supported image formats are as follows:
[in] | path | The path of the original media file |
[in] | width | The width of the thumbnail |
[in] | height | The height of the thumbnail |
[in] | thumbnail_path | The path to save the generated thumbnail |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
THUMBNAIL_UTIL_ERROR_INVALID_OPERATION | Invalid operation |
THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY | Out of memory |
THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED | Permission denied |
int thumbnail_util_set_path | ( | thumbnail_h | thumb, |
const char * | path | ||
) |
Sets the path of original media file.
[in] | thumb | The thumbnail info handle |
[in] | path | The path of the original media file |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |
int thumbnail_util_set_size | ( | thumbnail_h | thumb, |
int | width, | ||
int | height | ||
) |
Sets the size of thumbnail to be extracted.
[in] | thumb | The thumbnail info handle |
[in] | width | The width of the thumbnail |
[in] | height | The height of the thumbnail |
0
on success, otherwise a negative error valueTHUMBNAIL_UTIL_ERROR_NONE | Successful |
THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER | Invalid parameter |