Add -Werror and modify test code
[platform/core/api/image-util.git] / include / image_util.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #ifndef __TIZEN_MEDIA_IMAGE_UTIL_H__
18 #define __TIZEN_MEDIA_IMAGE_UTIL_H__
19
20 #include <image_util_type.h>
21
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif
26
27 /**
28  * @file image_util.h
29  * @brief This file contains the image util API.
30  */
31
32 /**
33  * @addtogroup CAPI_MEDIA_IMAGE_UTIL_MODULE
34  * @{
35  */
36
37 /**
38 * @brief Creates a handle to image util transform.
39 * @since_tizen 2.3
40 *
41 * @details This function creates a handle to image util transform.
42 *
43 * @remarks You must release the @a image util handle using image_util_transform_destroy().
44 *
45 * @param[out] handle A handle to image util transform
46 *
47 * @return @c 0 on success,
48 *               otherwise a negative error value
49 *
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
54 *
55 * @see image_util_transform_destroy()
56 *
57 */
58 int image_util_transform_create(transformation_h *handle);
59
60 /**
61 * @brief Sets the image util's accurate mode.
62 * @since_tizen 2.3
63 *
64 * @details This function set if you use hardware accerlation or not.
65 *
66 * @remarks The value returned will be IMAGE_UTIL_ERROR_NOT_SUPPORTED, if H/W acceleration doesn't support on the device.
67 *
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
71 *
72 * @return @c 0 on success,
73 *               otherwise a negative error value
74 *
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
80 *
81 * @pre image_util_transform_create().
82 *
83 * @see image_util_transform_create()
84 * @see image_util_transform_destroy()
85 */
86 int image_util_transform_set_hardware_acceleration(transformation_h handle, bool mode);
87
88 /**
89 * @brief Sets the information of the converting
90 * @since_tizen 2.3
91 *
92 * @param[in] handle The handle to image util transform
93 * @param[in] colorspace The colorspace of the image buffer
94 *
95 * @return @c 0 on success,
96 *               otherwise a negative error value
97 *
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
103 *
104 * @pre image_util_transform_create().
105 *
106 * @see image_util_transform_create()
107 * @see image_util_transform_run()
108 * @see image_util_transform_destroy()
109 */
110 int image_util_transform_set_colorspace(transformation_h handle, image_util_colorspace_e colorspace);
111
112 /**
113 * @brief Sets the information of the resizing
114 * @since_tizen 2.3
115 *
116 * @remarks image_util_transform_set_resolution and image_util_transform_set_crop_area can't do that at the same time.
117 *
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
121 *
122 * @return @c 0 on success,
123 *               otherwise a negative error value
124 *
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
129 *
130 * @pre image_util_transform_create().
131 *
132 * @see image_util_transform_create()
133 * @see image_util_transform_run()
134 * @see image_util_transform_destroy()
135 */
136 int image_util_transform_set_resolution(transformation_h handle, unsigned int width, unsigned int height);
137
138 /**
139 * @brief Sets the information of the rotating
140 * @since_tizen 2.3
141 *
142 * @param[in] handle The handle to image util transform
143 * @param[in] rotation The rotation value of image buffer
144 *
145 * @return @c 0 on success,
146 *               otherwise a negative error value
147 *
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
152 *
153 * @pre image_util_transform_create().
154 *
155 * @see image_util_transform_create()
156 * @see image_util_transform_run()
157 * @see image_util_transform_destroy()
158 */
159 int image_util_transform_set_rotation(transformation_h handle, image_util_rotation_e rotation);
160
161 /**
162 * @brief Sets the information of the cropping
163 * @since_tizen 2.3
164 *
165 * @remarks image_util_transform_set_resolution and image_util_transform_set_crop_area can't do that at the same time.
166 *
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
172 *
173 * @return @c 0 on success,
174 *               otherwise a negative error value
175 *
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
180 *
181 * @pre image_util_transform_create().
182 *
183 * @see image_util_transform_create()
184 * @see image_util_transform_run()
185 * @see image_util_transform_destroy()
186 */
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);
188
189 /**
190 * @brief Gets the colorspace of the image buffer
191 * @since_tizen 2.3
192 *
193 * @param[in] handle The handle to image util transform
194 * @param[in, out] colorspace The colorspace of the image buffer
195 *
196 * @return @c 0 on success,
197 *               otherwise a negative error value
198 *
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
203 *
204 * @pre image_util_transform_create().\n
205             image_util_transform_set_crop_area().
206 *
207 * @see image_util_transform_create()
208 * @see image_util_transform_destroy()
209 */
210 int image_util_transform_get_colorspace(transformation_h handle, image_util_colorspace_e *colorspace);
211
212 /**
213 * @brief Gets the resolution of the image buffer
214 * @since_tizen 2.3
215 *
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
219 *
220 * @return @c 0 on success,
221 *               otherwise a negative error value
222 *
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
227 *
228 * @pre image_util_transform_create().\n
229             image_util_transform_set_resolution().
230 *
231 * @see image_util_transform_create()
232 * @see image_util_transform_destroy()
233 */
234 int image_util_transform_get_resolution(transformation_h handle, unsigned int *width, unsigned int *height);
235
236 /**
237 * @brief Gets the information of the rotating
238 * @since_tizen 2.3
239 *
240 * @param[in] handle The handle to image util transform
241 * @param[in, out] rotation The rotation value of image buffer
242 *
243 * @return @c 0 on success,
244 *               otherwise a negative error value
245 *
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
250 *
251 * @pre image_util_transform_create().\n
252             image_util_transform_set_rotation().
253 *
254 * @see image_util_transform_create()
255 * @see image_util_transform_destroy()
256 */
257 int image_util_transform_get_rotation(transformation_h handle, image_util_rotation_e *rotation);
258
259 /**
260 * @brief Gets the information of the cropping
261 * @since_tizen 2.3
262 *
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
268 *
269 * @return @c 0 on success,
270 *               otherwise a negative error value
271 *
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
276 *
277 * @pre image_util_transform_create().\n
278             image_util_transform_set_crop_area().
279 *
280 * @see image_util_transform_create()
281 * @see image_util_transform_destroy()
282 */
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);
284
285 /**
286 * @brief Transform the image for given image util handle.
287 * @since_tizen 2.3
288 *
289 * @remarks If H/W acceleration is not set, transformation is done via S/W acceleration.
290 *
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
293 *
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
298 *
299 * @return @c 0 on success,
300 *               otherwise a negative error value
301 *
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
306 *
307 * @see image_util_transform_create()
308 * @see image_util_transform_set_hardware_acceleration
309 * @see image_util_transform_destroy()
310 */
311 int image_util_transform_run(transformation_h handle, media_packet_h src, image_util_transform_completed_cb callback, void *user_data);
312
313 /**
314 * @brief Destroys a handle to image util.
315 * @since_tizen 2.3
316 *
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.
320 *
321 * @param[in] handle The handle to image util transform
322 *
323 * @return @c 0 on success,
324 *               otherwise a negative error value
325 *
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
329 *
330 * @see image_util_transform_create()
331 *
332 */
333 int image_util_transform_destroy(transformation_h handle);
334
335 /**
336 * @brief Called once for each supported JPEG encode/decode colorspace.
337 * @since_tizen 2.3
338 *
339 * @param[in] colorspace The colorspace
340 * @param[in] user_data The user data passed from the foreach function
341 *
342 * @return @c true to continue with the next iteration of the loop, \n
343 *         otherwise @c false to break out of the loop
344 *
345 * @pre image_util_foreach_supported_jpeg_colorspace() invokes this callback.
346 *
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()
352 */
353 typedef bool(*image_util_supported_jpeg_colorspace_cb)(image_util_colorspace_e colorspace, void *user_data);
354
355 /**
356 * @brief Retrieves all supported JPEG encoding/decoding colorspace by invoking a callback function once for each one.
357 * @since_tizen 2.3
358 *
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
363 *
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.
368 *
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()
374 */
375 int image_util_foreach_supported_jpeg_colorspace(image_util_supported_jpeg_colorspace_cb callback, void *user_data);
376
377 /**
378 * @brief Calculates the size of the image buffer for the specified resolution and colorspace.
379 * @since_tizen 2.3
380 *
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
385 *
386 * @return @c 0 on success,
387 *               otherwise a negative error value
388 *
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
392 *
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()
398 */
399 int image_util_calculate_buffer_size(int width, int height, image_util_colorspace_e colorspace , unsigned int *size);
400
401 /**
402 * @internal
403 * @brief Converts the image's colorspace.
404 * @since_tizen 2.3
405 *
406 * @remarks You must get the @a dest buffer size using image_util_transform_calculate_buffer_size().
407 *
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
415 *
416 * @return %c 0 on success
417 *            otherwise a negative error value
418 *
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
423 *
424 * @see image_util_transform_calculate_buffer_size()
425 * @see image_util_transform_create()
426 * @see image_util_transform_destroy()
427 */
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);
429
430 /**
431 * @internal
432 * @brief Resizes the image to the specified destination width and height.
433 * @since_tizen 2.3
434 *
435 * @remarks Because of YUV format padding, the destination image size can be adjusted.
436 *
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
445 *
446 *
447 * @return @c 0 on success,
448 *               otherwise a negative error value
449 *
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
454 *
455 * @see image_util_transform_calculate_buffer_size()
456 */
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);
458
459 /**
460 * @internal
461 * @brief Rotates the image to the specified angle given in degrees.
462 * @since_tizen 2.3
463 *
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.
475 *
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
485 *
486 * @return @c 0 on success,
487 *               otherwise a negative error value
488 *
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
493 *
494 * @see image_util_transform_calculate_buffer_size()
495 */
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);
497
498 /**
499 * @internal
500 * @brief Crops the image to the specified point and dimension.
501 * @since_tizen 2.3
502 *
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.
513 *
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
523 *
524 * @return @c 0 on success,
525 *               otherwise a negative error value
526 *
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
531 *
532 * @see image_util_transform_calculate_buffer_size()
533 */
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);
535
536
537
538
539 /**
540 * @brief Decodes the JPEG image to the buffer.
541 * @since_tizen 2.3
542 *
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.
548 *
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
555 *
556 * @return @c 0 on success,
557 *               otherwise a negative error value
558 *
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
565 *
566 * @see image_util_supported_jpeg_colorspace_cb()
567 * @see image_util_decode_jpeg_from_memory()
568 * @see image_util_foreach_supported_jpeg_colorspace()
569 */
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);
571
572 /**
573 * @brief Decodes the JPEG image(in memory) to the buffer.
574 * @since_tizen 2.3
575 *
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.
579 *
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
587 *
588 * @return 0 on success,
589 *           otherwise a negative error value
590 *
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
597 *
598 * @see image_util_supported_jpeg_colorspace_cb()
599 * @see image_util_decode_jpeg()
600 * @see image_util_foreach_supported_jpeg_colorspace()
601 */
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);
603
604 /**
605 * @brief Decodes the JPEG image to the buffer with downscale decoding option.
606 * @since_tizen 2.4
607 *
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.
613 *
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
621 *
622 * @return @c 0 on success,
623 *               otherwise a negative error value
624 *
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
631 *
632 * @see image_util_supported_jpeg_colorspace_cb()
633 * @see image_util_decode_jpeg_from_memory()
634 * @see image_util_foreach_supported_jpeg_colorspace()
635 */
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);
637
638 /**
639 * @brief Decodes the JPEG image(in memory) to the buffer with downscale decoding option.
640 * @since_tizen 2.4
641 *
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.
645 *
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
654 *
655 * @return @c 0 on success,
656 *           otherwise a negative error value
657 *
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
664 *
665 * @see image_util_supported_jpeg_colorspace_cb()
666 * @see image_util_decode_jpeg()
667 * @see image_util_foreach_supported_jpeg_colorspace()
668 */
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);
670
671 /**
672 * @brief Encodes the image to the JPEG image.
673 * @since_tizen 2.3
674 *
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.
677 *
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
684 *
685 * @return 0 on success,
686 *           otherwise a negative error value
687 *
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
694 *
695 * @see image_util_supported_jpeg_colorspace_cb()
696 * @see image_util_foreach_supported_jpeg_colorspace()
697 * @see image_util_encode_jpeg_to_memory()
698 */
699 int image_util_encode_jpeg(const unsigned char *buffer, int width, int height, image_util_colorspace_e colorspace,  int quality, const char *path);
700
701 /**
702 * @brief Encodes the image to the JPEG image
703 * @since_tizen 2.3
704 *
705 * @remarks You must release @a jpeg_buffer using free().
706 *
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
715 *
716 * @return 0 on success,
717 *           otherwise a negative error value
718 *
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
725 *
726 * @see image_util_supported_jpeg_colorspace_cb()
727 * @see image_util_foreach_supported_jpeg_colorspace()
728 * @see image_util_encode_jpeg()
729 */
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);
731
732
733
734 /**
735  * @}
736  */
737
738 #ifdef __cplusplus
739 }
740 #endif
741
742 #endif /* __TIZEN_MEDIA_IMAGE_UTIL_H__ */