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.
63 * @details This function set if you use hardware accerlation or not.
65 * @remarks The value returned will be IMAGE_UTIL_ERROR_NOT_SUPPORTED, if H/W acceleration doesn't support on the device.
67 * @param[in] handle The handle to image util
68 * @param [in] mode Set @c true, user can use the hardware acceleration\n
69 * otherwise set @c false if user can only software image processing
71 * @return @c 0 on success,
72 * otherwise a negative error value
74 * @retval #IMAGE_UTIL_ERROR_NONE Successful
75 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
76 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
77 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
78 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED The application does not have the hardware acceleration
80 * @pre image_util_transform_create().
82 * @see image_util_transform_create()
83 * @see image_util_transform_destroy()
85 int image_util_transform_set_hardware_acceleration(transformation_h handle, bool mode);
88 * @brief Sets the information of the converting
91 * @param[in] handle The handle to image util transform
92 * @param[in] colorspace The colorspace of the image buffer
94 * @return @c 0 on success,
95 * otherwise a negative error value
97 * @retval #IMAGE_UTIL_ERROR_NONE Successful
98 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
99 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
100 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
101 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
103 * @pre image_util_transform_create().
105 * @see image_util_transform_create()
106 * @see image_util_transform_run()
107 * @see image_util_transform_destroy()
109 int image_util_transform_set_colorspace(transformation_h handle, image_util_colorspace_e colorspace);
112 * @brief Sets the information of the resizing
115 * @remarks image_util_transform_set_resolution and image_util_transform_set_crop_area can't do that at the same time.
117 * @param[in] handle The handle to image util transform
118 * @param[in] width The width of image buffer
119 * @param[in] height The height of image buffer
121 * @return @c 0 on success,
122 * otherwise a negative error value
124 * @retval #IMAGE_UTIL_ERROR_NONE Successful
125 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
126 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
127 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
129 * @pre image_util_transform_create().
131 * @see image_util_transform_create()
132 * @see image_util_transform_run()
133 * @see image_util_transform_destroy()
135 int image_util_transform_set_resolution(transformation_h handle, unsigned int width, unsigned int height);
138 * @brief Sets the information of the rotating
141 * @param[in] handle The handle to image util transform
142 * @param[in] rotation The rotation value of image buffer
144 * @return @c 0 on success,
145 * otherwise a negative error value
147 * @retval #IMAGE_UTIL_ERROR_NONE Successful
148 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
149 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
150 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
152 * @pre image_util_transform_create().
154 * @see image_util_transform_create()
155 * @see image_util_transform_run()
156 * @see image_util_transform_destroy()
158 int image_util_transform_set_rotation(transformation_h handle, image_util_rotation_e rotation);
161 * @brief Sets the information of the cropping
164 * @remarks image_util_transform_set_resolution and image_util_transform_set_crop_area can't do that at the same time.
166 * @param[in] handle The handle to image util transform
167 * @param[in] start_x The start x position of cropped image buffer
168 * @param[in] start_y The start y position of cropped image buffer
169 * @param[in] end_x The end x position of cropped image buffer
170 * @param[in] end_y The end y position of cropped image buffer
172 * @return @c 0 on success,
173 * otherwise a negative error value
175 * @retval #IMAGE_UTIL_ERROR_NONE Successful
176 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
177 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
178 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
180 * @pre image_util_transform_create().
182 * @see image_util_transform_create()
183 * @see image_util_transform_run()
184 * @see image_util_transform_destroy()
186 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);
189 * @brief Gets the colorspace of the image buffer
192 * @param[in] handle The handle to image util transform
193 * @param[in, out] colorspace The colorspace of the image buffer
195 * @return @c 0 on success,
196 * otherwise a negative error value
198 * @retval #IMAGE_UTIL_ERROR_NONE Successful
199 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
200 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
201 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Not supported format
203 * @pre image_util_transform_create().\n
204 image_util_transform_set_crop_area().
206 * @see image_util_transform_create()
207 * @see image_util_transform_destroy()
209 int image_util_transform_get_colorspace(transformation_h handle, image_util_colorspace_e *colorspace);
212 * @brief Gets the resolution of the image buffer
215 * @param[in] handle The handle to image util transform
216 * @param[in, out] width The width of source image buffer
217 * @param[in, out] height The height of source image buffer
219 * @return @c 0 on success,
220 * otherwise a negative error value
222 * @retval #IMAGE_UTIL_ERROR_NONE Successful
223 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
224 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
225 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
227 * @pre image_util_transform_create().\n
228 image_util_transform_set_resolution().
230 * @see image_util_transform_create()
231 * @see image_util_transform_destroy()
233 int image_util_transform_get_resolution(transformation_h handle, unsigned int *width, unsigned int *height);
236 * @brief Gets the information of the rotating
239 * @param[in] handle The handle to image util transform
240 * @param[in, out] rotation The rotation value of image buffer
242 * @return @c 0 on success,
243 * otherwise a negative error value
245 * @retval #IMAGE_UTIL_ERROR_NONE Successful
246 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
247 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
248 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
250 * @pre image_util_transform_create().\n
251 image_util_transform_set_rotation().
253 * @see image_util_transform_create()
254 * @see image_util_transform_destroy()
256 int image_util_transform_get_rotation(transformation_h handle, image_util_rotation_e *rotation);
259 * @brief Gets the information of the cropping
262 * @param[in] handle The handle to image util transform
263 * @param[in, out] start_x The start x position of cropped source image buffer
264 * @param[in, out] start_y The start y position of cropped source image buffer
265 * @param[in, out] end_x The end x position of cropped source image buffer
266 * @param[in, out] end_y The end y position of cropped source image buffer
268 * @return @c 0 on success,
269 * otherwise a negative error value
271 * @retval #IMAGE_UTIL_ERROR_NONE Successful
272 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
273 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
274 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
276 * @pre image_util_transform_create().\n
277 image_util_transform_set_crop_area().
279 * @see image_util_transform_create()
280 * @see image_util_transform_destroy()
282 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);
285 * @brief Transform the image for given image util handle.
288 * @remarks If H/W acceleration is not set, transformation is done via S/W acceleration.
290 * @details The function execute asynchronously, which contains complete callback \n
291 * If you set more than two transforming, the order of running is crop or resolution, colorspace converting, rotaion. \n
293 * @param[in] handle The handle of transform
294 * @param[in] src The handle to image util transform
295 * @param[in] callback The callback function to be invoked
296 * @param[in] user_data The user data to be passed to the callback function
298 * @return @c 0 on success,
299 * otherwise a negative error value
301 * @retval #IMAGE_UTIL_ERROR_NONE Successful
302 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
303 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
304 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
306 * @see image_util_transform_create()
307 * @see image_util_transform_set_hardware_acceleration
308 * @see image_util_transform_destroy()
310 int image_util_transform_run(transformation_h handle, media_packet_h src, image_util_transform_completed_cb callback, void *user_data);
313 * @brief Destroys a handle to image util.
316 * @details The function frees all resources related to the image util handle. The image util
317 * handle no longer can be used to perform any operation. A new image util handle
318 * has to be created before the next usage.
320 * @param[in] handle The handle to image util transform
322 * @return @c 0 on success,
323 * otherwise a negative error value
325 * @retval #IMAGE_UTIL_ERROR_NONE Successful
326 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
327 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
329 * @see image_util_transform_create()
332 int image_util_transform_destroy(transformation_h handle);
335 * @brief Called once for each supported JPEG encode/decode colorspace.
338 * @param[in] colorspace The colorspace
339 * @param[in] user_data The user data passed from the foreach function
341 * @return @c true to continue with the next iteration of the loop, \n
342 * otherwise @c false to break out of the loop
344 * @pre image_util_foreach_supported_jpeg_colorspace() invokes this callback.
346 * @see image_util_foreach_supported_jpeg_colorspace()
347 * @see image_util_encode_jpeg()
348 * @see image_util_encode_jpeg_to_memory()
349 * @see image_util_decode_jpeg()
350 * @see image_util_decode_jpeg_from_memory()
352 typedef bool(*image_util_supported_jpeg_colorspace_cb)(image_util_colorspace_e colorspace, void *user_data);
355 * @brief Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one.
358 * @param[in] callback The callback function to invoke
359 * @param[in] user_data The user data to be passed to the callback function
360 * @return 0 on success,
361 * otherwise a negative error value
363 * @retval #IMAGE_UTIL_ERROR_NONE Successful
364 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
365 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
366 * @post This function invokes image_util_supported_jpeg_colorspace_cb() repeatedly to retrieve each supported JPEG encoding/decoding colorspace.
368 * @see image_util_supported_jpeg_colorspace_cb()
369 * @see image_util_encode_jpeg()
370 * @see image_util_encode_jpeg_to_memory()
371 * @see image_util_decode_jpeg()
372 * @see image_util_decode_jpeg_from_memory()
374 int image_util_foreach_supported_jpeg_colorspace(image_util_supported_jpeg_colorspace_cb callback, void *user_data);
377 * @brief Calculates the size of the image buffer for the specified resolution and colorspace.
380 * @param[in] width The image width
381 * @param[in] height The image height
382 * @param[in] colorspace The image colorspace
383 * @param[out] size The Calculated buffer size
385 * @return @c 0 on success,
386 * otherwise a negative error value
388 * @retval #IMAGE_UTIL_ERROR_NONE Successful
389 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
390 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
392 * @see image_util_transform_run()
393 * @see image_util_decode_jpeg()
394 * @see image_util_decode_jpeg_from_memory()
395 * @see image_util_encode_jpeg()
396 * @see image_util_encode_jpeg_to_memory()
398 int image_util_calculate_buffer_size(int width, int height, image_util_colorspace_e colorspace , unsigned int *size);
402 * @brief Converts the image's colorspace.
405 * @remarks You must get the @a dest buffer size using image_util_transform_calculate_buffer_size().
407 * @param[in, out] dest The image buffer for result \n
408 * Must be allocated by the user
409 * @param[in] dest_colorspace The colorspace to be converted
410 * @param[in] src The source image buffer
411 * @param[in] width The width of the source image
412 * @param[in] height The height of the source image
413 * @param[in] src_colorspace The colorspace of the source image buffer
415 * @return %c 0 on success
416 * otherwise a negative error value
418 * @retval #IMAGE_UTIL_ERROR_NONE Successful
419 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
420 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
421 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
423 * @see image_util_transform_calculate_buffer_size()
424 * @see image_util_transform_create()
425 * @see image_util_transform_destroy()
427 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);
431 * @brief Resizes the image to the specified destination width and height.
434 * @remarks Because of YUV format padding, the destination image size can be adjusted.
436 * @param[in, out] dest The image buffer for result \n
437 * Must be allocated by the user.
438 * @param[in, out] dest_width The image width to resize, and resized width
439 * @param[in, out] dest_height The image height to resize, and resized height
440 * @param[in] src The image buffer for the original image
441 * @param[in] src_width The original image width
442 * @param[in] src_height The original image height
443 * @param[in] colorspace The image colorspace
446 * @return @c 0 on success,
447 * otherwise a negative error value
449 * @retval #IMAGE_UTIL_ERROR_NONE Successful
450 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
451 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
452 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
454 * @see image_util_transform_calculate_buffer_size()
456 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);
460 * @brief Rotates the image to the specified angle given in degrees.
463 * @remarks Because of YUV format padding, the destination image size can be adjusted.
464 * Rotations are supported only in these color spaces\n
465 * #IMAGE_UTIL_COLORSPACE_YV12\n
466 * #IMAGE_UTIL_COLORSPACE_I420\n
467 * #IMAGE_UTIL_COLORSPACE_NV12\n
468 * #IMAGE_UTIL_COLORSPACE_RGB888\n
469 * #IMAGE_UTIL_COLORSPACE_RGB565\n
470 * #IMAGE_UTIL_COLORSPACE_ARGB8888\n
471 * #IMAGE_UTIL_COLORSPACE_BGRA8888\n
472 * #IMAGE_UTIL_COLORSPACE_RGBA8888\n
473 * #IMAGE_UTIL_COLORSPACE_BGRX8888\n.
475 * @param[in, out] dest The image buffer for result \n
476 * Must be allocated by the user.
477 * @param[out] dest_width The rotated image width
478 * @param[out] dest_height The rotated image height
479 * @param[in] dest_rotation The angle to rotate
480 * @param[in] src The image buffer for the original image
481 * @param[in] src_width The original image width
482 * @param[in] src_height The original image height
483 * @param[in] colorspace The image colorspace
485 * @return @c 0 on success,
486 * otherwise a negative error value
488 * @retval #IMAGE_UTIL_ERROR_NONE Successful
489 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
490 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
491 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
493 * @see image_util_transform_calculate_buffer_size()
495 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);
499 * @brief Crops the image to the specified point and dimension.
502 * @remarks Because of YUV format padding, the destination image size can be adjusted.
503 * Crop is supported only in these colorspaces\n
504 * #IMAGE_UTIL_COLORSPACE_YV12 \n
505 * #IMAGE_UTIL_COLORSPACE_I420 \n
506 * #IMAGE_UTIL_COLORSPACE_RGB888 \n
507 * #IMAGE_UTIL_COLORSPACE_RGB565 \n
508 * #IMAGE_UTIL_COLORSPACE_ARGB8888\n
509 * #IMAGE_UTIL_COLORSPACE_BGRA8888\n
510 * #IMAGE_UTIL_COLORSPACE_RGBA8888\n
511 * #IMAGE_UTIL_COLORSPACE_BGRX8888\n.
513 * @param[in, out] dest The image buffer for result. Must be allocated by you
514 * @param[in] x The starting x-axis of crop
515 * @param[in] y The starting y-axis of crop
516 * @param[in/out] width The image width to crop, and cropped width
517 * @param[in/out] height The image height to crop, and cropped height
518 * @param[in] src The image buffer for original image
519 * @param[in] src_width The original image width
520 * @param[in] src_height The original image height
521 * @param[in] colorspace The image colorspace
523 * @return @c 0 on success,
524 * otherwise a negative error value
526 * @retval #IMAGE_UTIL_ERROR_NONE Successful
527 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
528 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
529 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
531 * @see image_util_transform_calculate_buffer_size()
533 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);
539 * @brief Decodes the JPEG image to the buffer.
542 * @remarks You must release @a image_buffer using free().\n
543 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
544 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
545 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
546 * the width or height of decoded data will be rounded down to even numbered width or height.
548 * @param[in] path The image file path
549 * @param[in] colorspace The decoded image colorspace
550 * @param[out] image_buffer The image buffer for the decoded image
551 * @param[out] width The image width
552 * @param[out] height The image height
553 * @param[out] size The image buffer size
555 * @return @c 0 on success,
556 * otherwise a negative error value
558 * @retval #IMAGE_UTIL_ERROR_NONE Successful
559 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
560 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
561 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
562 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
563 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
565 * @see image_util_supported_jpeg_colorspace_cb()
566 * @see image_util_decode_jpeg_from_memory()
567 * @see image_util_foreach_supported_jpeg_colorspace()
569 int image_util_decode_jpeg(const char *path, image_util_colorspace_e colorspace, unsigned char **image_buffer, int *width, int *height, unsigned int *size);
572 * @brief Decodes the JPEG image(in memory) to the buffer.
575 * @remarks You must release @a image_buffer using free().\n
576 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
577 * the width or height of decoded data will be rounded down to even numbered width or height.
579 * @param[in] jpeg_buffer The JPEG image buffer
580 * @param[in] jpeg_size The JPEG image buffer size
581 * @param[in] colorspace The decoded image colorspace
582 * @param[out] image_buffer The image buffer for the decoded image
583 * @param[out] width The image width
584 * @param[out] height The image height
585 * @param[out] size The image buffer size
587 * @return 0 on success,
588 * otherwise a negative error value
590 * @retval #IMAGE_UTIL_ERROR_NONE Successful
591 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
592 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
593 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
594 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
595 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
597 * @see image_util_supported_jpeg_colorspace_cb()
598 * @see image_util_decode_jpeg()
599 * @see image_util_foreach_supported_jpeg_colorspace()
601 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);
604 * @brief Decodes the JPEG image to the buffer with downscale decoding option.
607 * @remarks You must release @a image_buffer using free().\n
608 * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
609 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.\n
610 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
611 * the width or height of decoded data will be rounded down to even numbered width or height.
613 * @param[in] path The image file path
614 * @param[in] colorspace The decoded image colorspace
615 * @param[in] downscale The downscale value
616 * @param[out] image_buffer The image buffer for the decoded image
617 * @param[out] width The image width
618 * @param[out] height The image height
619 * @param[out] size The image buffer size
621 * @return @c 0 on success,
622 * otherwise a negative error value
624 * @retval #IMAGE_UTIL_ERROR_NONE Successful
625 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
626 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
627 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
628 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
629 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
631 * @see image_util_supported_jpeg_colorspace_cb()
632 * @see image_util_decode_jpeg_from_memory()
633 * @see image_util_foreach_supported_jpeg_colorspace()
635 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);
638 * @brief Decodes the JPEG image(in memory) to the buffer with downscale decoding option.
641 * @remarks You must release @a image_buffer using free().\n
642 * If you decode the JPEG image which has odd numbered width or height to YUV colorspace, \n
643 * the width or height of decoded data will be rounded down to even numbered width or height.
645 * @param[in] jpeg_buffer The JPEG image buffer
646 * @param[in] jpeg_size The JPEG image buffer size
647 * @param[in] colorspace The decoded image colorspace
648 * @param[in] downscale The downscale value
649 * @param[out] image_buffer The image buffer for the decoded image
650 * @param[out] width The image width
651 * @param[out] height The image height
652 * @param[out] size The image buffer size
654 * @return @c 0 on success,
655 * otherwise a negative error value
657 * @retval #IMAGE_UTIL_ERROR_NONE Successful
658 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
659 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
660 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
661 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
662 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
664 * @see image_util_supported_jpeg_colorspace_cb()
665 * @see image_util_decode_jpeg()
666 * @see image_util_foreach_supported_jpeg_colorspace()
668 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);
671 * @brief Encodes the image to the JPEG image.
674 * @remarks http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.\n
675 * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
677 * @param[in] buffer The original image buffer
678 * @param[in] width The original image width
679 * @param[in] height The original image height
680 * @param[in] colorspace The original image colorspace
681 * @param[in] quality The quality for JPEG image encoding(1 ~ 100)
682 * @param[in] path The file path to be created
684 * @return 0 on success,
685 * otherwise a negative error value
687 * @retval #IMAGE_UTIL_ERROR_NONE Successful
688 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
689 * @retval #IMAGE_UTIL_ERROR_NO_SUCH_FILE No such file
690 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
691 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
692 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
694 * @see image_util_supported_jpeg_colorspace_cb()
695 * @see image_util_foreach_supported_jpeg_colorspace()
696 * @see image_util_encode_jpeg_to_memory()
698 int image_util_encode_jpeg(const unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace, int quality, const char *path);
701 * @brief Encodes the image to the JPEG image
704 * @remarks You must release @a jpeg_buffer using free().
706 * @param[in] image_buffer The original image buffer
707 * @param[in] width The image width
708 * @param[in] height The image height
709 * @param[in] colorspace The original image colorspace
710 * @param[in] quality The quality for JPEG image encoding(1 ~ 100)
711 * @param[out] jpeg_buffer The created JPEG image buffer \n
712 * The buffer is created by frameworks
713 * @param[out] jpeg_size The created jpeg image buffer size
715 * @return 0 on success,
716 * otherwise a negative error value
718 * @retval #IMAGE_UTIL_ERROR_NONE Successful
719 * @retval #IMAGE_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
720 * @retval #IMAGE_UTIL_ERROR_OUT_OF_MEMORY out of memory
721 * @retval #IMAGE_UTIL_ERROR_NOT_SUPPORTED_FORMAT Format not supported
722 * @retval #IMAGE_UTIL_ERROR_INVALID_OPERATION Invalid operation
723 * @retval #IMAGE_UTIL_ERROR_PERMISSION_DENIED The application does not have the privilege to call this funtion
725 * @see image_util_supported_jpeg_colorspace_cb()
726 * @see image_util_foreach_supported_jpeg_colorspace()
727 * @see image_util_encode_jpeg()
729 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);
741 #endif /* __TIZEN_MEDIA_IMAGE_UTIL_H__ */