2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TIZEN_MEDIA_IMAGE_UTIL_H__
18 #define __TIZEN_MEDIA_IMAGE_UTIL_H__
20 #include <image_util_type.h>
29 * @brief This file contains the image util API.
33 * @addtogroup CAPI_MEDIA_IMAGE_UTIL_MODULE
38 * @brief Creates a handle to image util transform.
41 * @details This function creates a handle to image util transform.
43 * @remarks You must release the @a image util handle using image_util_transform_destroy().
45 * @param[out] handle A handle to image util transform
47 * @return @c 0 on success,
48 * otherwise a negative error value
50 * @retval #IMAGE_UTIL_ERROR_NONE Successful
51 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
52 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY Out of memory
53 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
55 * @see image_util_transform_destroy()
58 int image_util_transform_create(transformation_h *handle);
61 * @brief Sets the image util's accurate mode.
64 * @details This function set if you use hardware accerlation or not.
66 * @remarks The value returned will be IMAGE_UTIL_ERROR_NOT_SUPPORTED, if H/W acceleration doesn't support on the device.
68 * @param[in] handle The handle to image util
69 * @param [in] mode Set @c true, user can use the hardware acceleration\n
70 * otherwise set @c false if user can only software image processing
72 * @return @c 0 on success,
73 * otherwise a negative error value
75 * @retval #IMAGE_UTIL_ERROR_NONE Successful
76 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
77 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
78 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
79 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED The application does not have the hardware acceleration
81 * @pre image_util_transform_create().
83 * @see image_util_transform_create()
84 * @see image_util_transform_destroy()
86 int image_util_transform_set_hardware_acceleration(transformation_h handle, bool mode);
89 * @brief Sets the information of the converting
92 * @param[in] handle The handle to image util transform
93 * @param[in] colorspace The colorspace of the image buffer
95 * @return @c 0 on success,
96 * otherwise a negative error value
98 * @retval #IMAGE_UTIL_ERROR_NONE Successful
99 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
100 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
101 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
102 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
104 * @pre image_util_transform_create().
106 * @see image_util_transform_create()
107 * @see image_util_transform_run()
108 * @see image_util_transform_destroy()
110 int image_util_transform_set_colorspace(transformation_h handle, image_util_colorspace_e colorspace);
113 * @brief Sets the information of the resizing
116 * @remarks image_util_transform_set_resolution and image_util_transform_set_crop_area can't do that at the same time.
118 * @param[in] handle The handle to image util transform
119 * @param[in] width The width of image buffer
120 * @param[in] height The height of image buffer
122 * @return @c 0 on success,
123 * otherwise a negative error value
125 * @retval #IMAGE_UTIL_ERROR_NONE Successful
126 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
127 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
128 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
130 * @pre image_util_transform_create().
132 * @see image_util_transform_create()
133 * @see image_util_transform_run()
134 * @see image_util_transform_destroy()
136 int image_util_transform_set_resolution(transformation_h handle, unsigned int width, unsigned int height);
139 * @brief Sets the information of the rotating
142 * @param[in] handle The handle to image util transform
143 * @param[in] rotation The rotation value of image buffer
145 * @return @c 0 on success,
146 * otherwise a negative error value
148 * @retval #IMAGE_UTIL_ERROR_NONE Successful
149 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
150 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
151 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
153 * @pre image_util_transform_create().
155 * @see image_util_transform_create()
156 * @see image_util_transform_run()
157 * @see image_util_transform_destroy()
159 int image_util_transform_set_rotation(transformation_h handle, image_util_rotation_e rotation);
162 * @brief Sets the information of the cropping
165 * @remarks image_util_transform_set_resolution and image_util_transform_set_crop_area can't do that at the same time.
167 * @param[in] handle The handle to image util transform
168 * @param[in] start_x The start x position of cropped image buffer
169 * @param[in] start_y The start y position of cropped image buffer
170 * @param[in] end_x The end x position of cropped image buffer
171 * @param[in] end_y The end y position of cropped image buffer
173 * @return @c 0 on success,
174 * otherwise a negative error value
176 * @retval #IMAGE_UTIL_ERROR_NONE Successful
177 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
178 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
179 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
181 * @pre image_util_transform_create().
183 * @see image_util_transform_create()
184 * @see image_util_transform_run()
185 * @see image_util_transform_destroy()
187 int image_util_transform_set_crop_area(transformation_h handle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y);
190 * @brief Gets the colorspace of the image buffer
193 * @param[in] handle The handle to image util transform
194 * @param[in, out] colorspace The colorspace of the image buffer
196 * @return @c 0 on success,
197 * otherwise a negative error value
199 * @retval #IMAGE_UTIL_ERROR_NONE Successful
200 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
201 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
202 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
204 * @pre image_util_transform_create().\n
205 image_util_transform_set_crop_area().
207 * @see image_util_transform_create()
208 * @see image_util_transform_destroy()
210 int image_util_transform_get_colorspace(transformation_h handle, image_util_colorspace_e *colorspace);
213 * @brief Gets the resolution of the image buffer
216 * @param[in] handle The handle to image util transform
217 * @param[in, out] width The width of source image buffer
218 * @param[in, out] height The height of source image buffer
220 * @return @c 0 on success,
221 * otherwise a negative error value
223 * @retval #IMAGE_UTIL_ERROR_NONE Successful
224 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
225 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
226 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
228 * @pre image_util_transform_create().\n
229 image_util_transform_set_resolution().
231 * @see image_util_transform_create()
232 * @see image_util_transform_destroy()
234 int image_util_transform_get_resolution(transformation_h handle, unsigned int *width, unsigned int *height);
237 * @brief Gets the information of the rotating
240 * @param[in] handle The handle to image util transform
241 * @param[in, out] rotation The rotation value of image buffer
243 * @return @c 0 on success,
244 * otherwise a negative error value
246 * @retval #IMAGE_UTIL_ERROR_NONE Successful
247 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
248 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
249 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
251 * @pre image_util_transform_create().\n
252 image_util_transform_set_rotation().
254 * @see image_util_transform_create()
255 * @see image_util_transform_destroy()
257 int image_util_transform_get_rotation(transformation_h handle, image_util_rotation_e *rotation);
260 * @brief Gets the information of the cropping
263 * @param[in] handle The handle to image util transform
264 * @param[in, out] start_x The start x position of cropped source image buffer
265 * @param[in, out] start_y The start y position of cropped source image buffer
266 * @param[in, out] end_x The end x position of cropped source image buffer
267 * @param[in, out] end_y The end y position of cropped source image buffer
269 * @return @c 0 on success,
270 * otherwise a negative error value
272 * @retval #IMAGE_UTIL_ERROR_NONE Successful
273 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
274 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
275 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
277 * @pre image_util_transform_create().\n
278 image_util_transform_set_crop_area().
280 * @see image_util_transform_create()
281 * @see image_util_transform_destroy()
283 int image_util_transform_get_crop_area(transformation_h handle, unsigned int *start_x, unsigned int *start_y, unsigned int *end_x, unsigned int *end_y);
286 * @brief Transform the image for given image util handle.
289 * @remarks If H/W acceleration is not set, transformation is done via S/W acceleration.
291 * @details The function execute asynchronously, which contains complete callback \n
292 * If you set more than two transforming, the order of running is crop or resolution, colorspace converting, rotaion. \n
294 * @param[in] handle The handle of transform
295 * @param[in] src The handle to image util transform
296 * @param[in] callback The callback function to be invoked
297 * @param[in] user_data The user data to be passed to the callback function
299 * @return @c 0 on success,
300 * otherwise a negative error value
302 * @retval #IMAGE_UTIL_ERROR_NONE Successful
303 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
304 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
305 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
307 * @see image_util_transform_create()
308 * @see image_util_transform_set_hardware_acceleration
309 * @see image_util_transform_destroy()
311 int image_util_transform_run(transformation_h handle, media_packet_h src, image_util_transform_completed_cb callback, void *user_data);
314 * @brief Destroys a handle to image util.
317 * @details The function frees all resources related to the image util handle. The image util
318 * handle no longer can be used to perform any operation. A new image util handle
319 * has to be created before the next usage.
321 * @param[in] handle The handle to image util transform
323 * @return @c 0 on success,
324 * otherwise a negative error value
326 * @retval #IMAGE_UTIL_ERROR_NONE Successful
327 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
328 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
330 * @see image_util_transform_create()
333 int image_util_transform_destroy(transformation_h handle);
336 * @brief Called once for each supported JPEG encode/decode colorspace.
339 * @param[in] colorspace The colorspace
340 * @param[in] user_data The user data passed from the foreach function
342 * @return @c true to continue with the next iteration of the loop, \n
343 * otherwise @c false to break out of the loop
345 * @pre image_util_foreach_supported_jpeg_colorspace() invokes this callback.
347 * @see image_util_foreach_supported_jpeg_colorspace()
348 * @see image_util_encode_jpeg()
349 * @see image_util_encode_jpeg_to_memory()
350 * @see image_util_decode_jpeg()
351 * @see image_util_decode_jpeg_from_memory()
353 typedef bool(*image_util_supported_jpeg_colorspace_cb)(image_util_colorspace_e colorspace, void *user_data);
356 * @brief Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one.
359 * @param[in] callback The callback function to invoke
360 * @param[in] user_data The user data to be passed to the callback function
361 * @return 0 on success,
362 * otherwise a negative error value
364 * @retval #IMAGE_UTIL_ERROR_NONE Successful
365 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
366 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
367 * @post This function invokes image_util_supported_jpeg_colorspace_cb() repeatedly to retrieve each supported JPEG encoding/decoding colorspace.
369 * @see image_util_supported_jpeg_colorspace_cb()
370 * @see image_util_encode_jpeg()
371 * @see image_util_encode_jpeg_to_memory()
372 * @see image_util_decode_jpeg()
373 * @see image_util_decode_jpeg_from_memory()
375 int image_util_foreach_supported_jpeg_colorspace(image_util_supported_jpeg_colorspace_cb callback, void *user_data);
378 * @brief Calculates the size of the image buffer for the specified resolution and colorspace.
381 * @param[in] width The image width
382 * @param[in] height The image height
383 * @param[in] colorspace The image colorspace
384 * @param[out] size The Calculated buffer size
386 * @return @c 0 on success,
387 * otherwise a negative error value
389 * @retval #IMAGE_UTIL_ERROR_NONE Successful
390 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
391 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
393 * @see image_util_transform_run()
394 * @see image_util_decode_jpeg()
395 * @see image_util_decode_jpeg_from_memory()
396 * @see image_util_encode_jpeg()
397 * @see image_util_encode_jpeg_to_memory()
399 int image_util_calculate_buffer_size(int width, int height, image_util_colorspace_e colorspace , unsigned int *size);
403 * @brief Converts the image's colorspace.
406 * @remarks You must get the @a dest buffer size using image_util_transform_calculate_buffer_size().
408 * @param[in, out] dest The image buffer for result \n
409 * Must be allocated by the user
410 * @param[in] dest_colorspace The colorspace to be converted
411 * @param[in] src The source image buffer
412 * @param[in] width The width of the source image
413 * @param[in] height The height of the source image
414 * @param[in] src_colorspace The colorspace of the source image buffer
416 * @return %c 0 on success
417 * otherwise a negative error value
419 * @retval #IMAGE_UTIL_ERROR_NONE Successful
420 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
421 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
422 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
424 * @see image_util_transform_calculate_buffer_size()
425 * @see image_util_transform_create()
426 * @see image_util_transform_destroy()
428 int image_util_convert_colorspace(unsigned char *dest, image_util_colorspace_e dest_colorspace, const unsigned char *src, int width, int height, image_util_colorspace_e src_colorspace);
432 * @brief Resizes the image to the specified destination width and height.
435 * @remarks Because of YUV format padding, the destination image size can be adjusted.
437 * @param[in, out] dest The image buffer for result \n
438 * Must be allocated by the user.
439 * @param[in, out] dest_width The image width to resize, and resized width
440 * @param[in, out] dest_height The image height to resize, and resized height
441 * @param[in] src The image buffer for the original image
442 * @param[in] src_width The original image width
443 * @param[in] src_height The original image height
444 * @param[in] colorspace The image colorspace
447 * @return @c 0 on success,
448 * otherwise a negative error value
450 * @retval #IMAGE_UTIL_ERROR_NONE Successful
451 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
452 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
453 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
455 * @see image_util_transform_calculate_buffer_size()
457 int image_util_resize(unsigned char *dest, int *dest_width, int *dest_height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace);
461 * @brief Rotates the image to the specified angle given in degrees.
464 * @remarks Because of YUV format padding, the destination image size can be adjusted.
465 * Rotations are supported only in these color spaces\n
466 * #IMAGE_UTIL_COLORSPACE_YV12\n
467 * #IMAGE_UTIL_COLORSPACE_I420\n
468 * #IMAGE_UTIL_COLORSPACE_NV12\n
469 * #IMAGE_UTIL_COLORSPACE_RGB888\n
470 * #IMAGE_UTIL_COLORSPACE_RGB565\n
471 * #IMAGE_UTIL_COLORSPACE_ARGB8888\n
472 * #IMAGE_UTIL_COLORSPACE_BGRA8888\n
473 * #IMAGE_UTIL_COLORSPACE_RGBA8888\n
474 * #IMAGE_UTIL_COLORSPACE_BGRX8888\n.
476 * @param[in, out] dest The image buffer for result \n
477 * Must be allocated by the user.
478 * @param[out] dest_width The rotated image width
479 * @param[out] dest_height The rotated image height
480 * @param[in] dest_rotation The angle to rotate
481 * @param[in] src The image buffer for the original image
482 * @param[in] src_width The original image width
483 * @param[in] src_height The original image height
484 * @param[in] colorspace The image colorspace
486 * @return @c 0 on success,
487 * otherwise a negative error value
489 * @retval #IMAGE_UTIL_ERROR_NONE Successful
490 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
491 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
492 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
494 * @see image_util_transform_calculate_buffer_size()
496 int image_util_rotate(unsigned char *dest, int *dest_width, int *dest_height, image_util_rotation_e dest_rotation, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace);
500 * @brief Crops the image to the specified point and dimension.
503 * @remarks Because of YUV format padding, the destination image size can be adjusted.
504 * Crop is supported only in these colorspaces\n
505 * #IMAGE_UTIL_COLORSPACE_YV12 \n
506 * #IMAGE_UTIL_COLORSPACE_I420 \n
507 * #IMAGE_UTIL_COLORSPACE_RGB888 \n
508 * #IMAGE_UTIL_COLORSPACE_RGB565 \n
509 * #IMAGE_UTIL_COLORSPACE_ARGB8888\n
510 * #IMAGE_UTIL_COLORSPACE_BGRA8888\n
511 * #IMAGE_UTIL_COLORSPACE_RGBA8888\n
512 * #IMAGE_UTIL_COLORSPACE_BGRX8888\n.
514 * @param[in, out] dest The image buffer for result. Must be allocated by you
515 * @param[in] x The starting x-axis of crop
516 * @param[in] y The starting y-axis of crop
517 * @param[in/out] width The image width to crop, and cropped width
518 * @param[in/out] height The image height to crop, and cropped height
519 * @param[in] src The image buffer for original image
520 * @param[in] src_width The original image width
521 * @param[in] src_height The original image height
522 * @param[in] colorspace The image colorspace
524 * @return @c 0 on success,
525 * otherwise a negative error value
527 * @retval #IMAGE_UTIL_ERROR_NONE Successful
528 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
529 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
530 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
532 * @see image_util_transform_calculate_buffer_size()
534 int image_util_crop(unsigned char *dest, int x, int y, int *width, int *height, const unsigned char *src, int src_width, int src_height, image_util_colorspace_e colorspace);
540 * @brief Decodes the JPEG image to the buffer.
543 * @remarks You must release @a image_buffer using free().\n
544 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
545 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
546 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
547 * the width or height of decoded data will be rounded down to even numbered width or height.
549 * @param[in] path The image file path
550 * @param[in] colorspace The decoded image colorspace
551 * @param[out] image_buffer The image buffer for the decoded image
552 * @param[out] width The image width
553 * @param[out] height The image height
554 * @param[out] size The image buffer size
556 * @return @c 0 on success,
557 * otherwise a negative error value
559 * @retval #IMAGE_UTIL_ERROR_NONE Successful
560 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
561 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
562 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
563 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
564 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
566 * @see image_util_supported_jpeg_colorspace_cb()
567 * @see image_util_decode_jpeg_from_memory()
568 * @see image_util_foreach_supported_jpeg_colorspace()
570 int image_util_decode_jpeg(const char *path, image_util_colorspace_e colorspace, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
573 * @brief Decodes the JPEG image(in memory) to the buffer.
576 * @remarks You must release @a image_buffer using free().\n
577 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
578 * the width or height of decoded data will be rounded down to even numbered width or height.
580 * @param[in] jpeg_buffer The JPEG image buffer
581 * @param[in] jpeg_size The JPEG image buffer size
582 * @param[in] colorspace The decoded image colorspace
583 * @param[out] image_buffer The image buffer for the decoded image
584 * @param[out] width The image width
585 * @param[out] height The image height
586 * @param[out] size The image buffer size
588 * @return 0 on success,
589 * otherwise a negative error value
591 * @retval #IMAGE_UTIL_ERROR_NONE Successful
592 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
593 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
594 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
595 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
596 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
598 * @see image_util_supported_jpeg_colorspace_cb()
599 * @see image_util_decode_jpeg()
600 * @see image_util_foreach_supported_jpeg_colorspace()
602 int image_util_decode_jpeg_from_memory(const unsigned char *jpeg_buffer, int jpeg_size, image_util_colorspace_e colorspace, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
605 * @brief Decodes the JPEG image to the buffer with downscale decoding option.
608 * @remarks You must release @a image_buffer using free().\n
609 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
610 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
611 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
612 * the width or height of decoded data will be rounded down to even numbered width or height.
614 * @param[in] path The image file path
615 * @param[in] colorspace The decoded image colorspace
616 * @param[in] downscale The downscale value
617 * @param[out] image_buffer The image buffer for the decoded image
618 * @param[out] width The image width
619 * @param[out] height The image height
620 * @param[out] size The image buffer size
622 * @return @c 0 on success,
623 * otherwise a negative error value
625 * @retval #IMAGE_UTIL_ERROR_NONE Successful
626 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
627 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
628 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
629 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
630 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
632 * @see image_util_supported_jpeg_colorspace_cb()
633 * @see image_util_decode_jpeg_from_memory()
634 * @see image_util_foreach_supported_jpeg_colorspace()
636 int image_util_decode_jpeg_with_downscale(const char *path, image_util_colorspace_e colorspace, image_util_scale_e downscale, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
639 * @brief Decodes the JPEG image(in memory) to the buffer with downscale decoding option.
642 * @remarks You must release @a image_buffer using free().\n
643 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
644 * the width or height of decoded data will be rounded down to even numbered width or height.
646 * @param[in] jpeg_buffer The JPEG image buffer
647 * @param[in] jpeg_size The JPEG image buffer size
648 * @param[in] colorspace The decoded image colorspace
649 * @param[in] downscale The downscale value
650 * @param[out] image_buffer The image buffer for the decoded image
651 * @param[out] width The image width
652 * @param[out] height The image height
653 * @param[out] size The image buffer size
655 * @return @c 0 on success,
656 * otherwise a negative error value
658 * @retval #IMAGE_UTIL_ERROR_NONE Successful
659 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
660 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
661 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
662 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
663 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
665 * @see image_util_supported_jpeg_colorspace_cb()
666 * @see image_util_decode_jpeg()
667 * @see image_util_foreach_supported_jpeg_colorspace()
669 int image_util_decode_jpeg_from_memory_with_downscale(const unsigned char *jpeg_buffer, int jpeg_size, image_util_colorspace_e colorspace, image_util_scale_e downscale, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
672 * @brief Encodes the image to the JPEG image.
675 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
676 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
678 * @param[in] buffer The original image buffer
679 * @param[in] width The original image width
680 * @param[in] height The original image height
681 * @param[in] colorspace The original image colorspace
682 * @param[in] quality The quality for JPEG image encoding(1 ~ 100)
683 * @param[in] path The file path to be created
685 * @return 0 on success,
686 * otherwise a negative error value
688 * @retval #IMAGE_UTIL_ERROR_NONE Successful
689 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
690 * @retval #IMAGE_UTIL_ERROR_NO_SUCH_FILE No such file
691 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
692 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
693 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
695 * @see image_util_supported_jpeg_colorspace_cb()
696 * @see image_util_foreach_supported_jpeg_colorspace()
697 * @see image_util_encode_jpeg_to_memory()
699 int image_util_encode_jpeg(const unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path);
702 * @brief Encodes the image to the JPEG image
705 * @remarks You must release @a jpeg_buffer using free().
707 * @param[in] image_buffer The original image buffer
708 * @param[in] width The image width
709 * @param[in] height The image height
710 * @param[in] colorspace The original image colorspace
711 * @param[in] quality The quality for JPEG image encoding(1 ~ 100)
712 * @param[out] jpeg_buffer The created JPEG image buffer \n
713 * The buffer is created by frameworks
714 * @param[out] jpeg_size The created jpeg image buffer size
716 * @return 0 on success,
717 * otherwise a negative error value
719 * @retval #IMAGE_UTIL_ERROR_NONE Successful
720 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
721 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
722 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
723 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
724 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
726 * @see image_util_supported_jpeg_colorspace_cb()
727 * @see image_util_foreach_supported_jpeg_colorspace()
728 * @see image_util_encode_jpeg()
730 int image_util_encode_jpeg_to_memory(const unsigned char *image_buffer, int width, int height, image_util_colorspace_e colorspace, int quality, unsigned char **jpeg_buffer, unsigned int *jpeg_size);
742 #endif /* __TIZEN_MEDIA_IMAGE_UTIL_H__ */