Modify mm_util_resize_image() API to receive allocated buffer and buffer info
[platform/core/multimedia/libmm-utility.git] / imgp / include / mm_util_imgp.h
1 /*
2  * libmm-utility
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: YoungHun Kim <yh8004.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __MM_UTILITY_IMGP_H__
23 #define __MM_UTILITY_IMGP_H__
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <stdbool.h>
30 #include <stdlib.h>
31 #include "mm_util_type.h"
32
33 typedef void *mm_util_imgp_h;
34
35 typedef bool (*mm_util_completed_callback)(mm_util_color_image_h image, int error, void *user_param);
36 /**
37     @addtogroup UTILITY
38     @{
39
40     @par
41     This part describes the APIs with repect to image converting library.
42  */
43
44 /**
45  * Image rotation types
46  */
47 typedef enum {
48         MM_UTIL_ROTATE_0,               /**< Rotation 0 degree - no effect */
49         MM_UTIL_ROTATE_90,              /**< Rotation 90 degree */
50         MM_UTIL_ROTATE_180,             /**< Rotation 180 degree */
51         MM_UTIL_ROTATE_270,             /**< Rotation 270 degree */
52         MM_UTIL_ROTATE_FLIP_HORZ,       /**< Flip horizontal */
53         MM_UTIL_ROTATE_FLIP_VERT,       /**< Flip vertial */
54         MM_UTIL_ROTATE_NUM              /**< Number of rotation types */
55 } mm_util_img_rotate_type;
56
57 /**
58  * This function calculates the size of the image data in bytes.
59  *
60  * @param       format [in]     image format information
61  * @param       width  [in]     pixel size of width
62  * @param       height [in]     pixel size of height
63  * @param       size   [out]    data size of image in bytes
64  *
65  * @return      This function returns zero on success, or negative value with error code.
66  * @remark
67  * @see         mm_util_color_format_e
68  * @since       R1, 1.0
69  */
70 int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize);
71
72 /**
73  *
74  * @remark      Transform Handle Creation
75  *
76  * @param       imgp_handle             [in]                    image_util_imgp_h
77  * @return      This function returns transform processor result value
78  *              if the result is 0, then handle creation succeed
79  *              else if the result is -1, then handle creation failed
80  */
81 int mm_util_create(mm_util_imgp_h *imgp_handle);
82
83 /**
84  *
85  * @remark      Transform Handle Creation
86  *
87  * @param       imgp_handle             [in]                    image_util_imgp_h
88  * @param       colorspace      [in]                    colorspace The colorspace of the destination image buffer
89
90  * @return      This function returns transform processor result value
91  *              if the result is 0, then handle creation succeed
92  *              else if the result is -1, then handle creation failed
93  */
94 int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_color_format_e colorspace);
95
96 /**
97  *
98  * @remark      Transform Handle Creation
99  *
100  * @param       imgp_handle             [in]                    image_util_imgp_h
101  * @param       width           [in]                    width The width of destination image buffer
102  * @param       height          [in]                    height The height of destination image buffer
103
104  * @return      This function returns transform processor result value
105  *              if the result is 0, then handle creation succeed
106  *              else if the result is -1, then handle creation failed
107  */
108 int mm_util_set_resolution(mm_util_imgp_h imgp_handle, unsigned int width, unsigned int height);
109
110 /**
111  *
112  * @remark      Transform Handle Creation
113  *
114  * @param       imgp_handle             [in]                    image_util_imgp_h
115  * @param       rotation                [in]                    dest_rotation The rotation value of destination image buffer
116
117  * @return      This function returns transform processor result value
118  *              if the result is 0, then handle creation succeed
119  *              else if the result is -1, then handle creation failed
120  */
121 int mm_util_set_rotation(mm_util_imgp_h imgp_handle, mm_util_img_rotate_type rotation);
122
123 /**
124  *
125  * @remark      Transform Handle Creation
126  *
127  * @param       imgp_handle             [in]                    image_util_imgp_h
128  * @param       start_x                 [in]                    The start x position of cropped image buffer
129  * @param       start_y                 [in]                    The start y position of cropped image buffer
130  * @param       end_x                   [in]                    The start x position of cropped image buffer
131  * @param       end_y                   [in]                    The start y position of cropped image buffer
132
133  * @return      This function returns transform processor result value
134  *              if the result is 0, then handle creation succeed
135  *              else if the result is -1, then handle creation failed
136  */
137 int mm_util_set_crop_area(mm_util_imgp_h imgp_handle, unsigned int start_x, unsigned int start_y, unsigned int end_x, unsigned int end_y);
138
139 /**
140  *
141  * @remark      Transform Handle Creation
142  *
143  * @param       imgp_handle             [in]                    image_util_imgp_h
144  * @param       is_completed            [in/out]                Users can obtain the value of the conversion about whether to complete
145
146  * @return      This function returns transform processor result value
147  *              if the result is 0, then handle creation succeed
148  *              else if the result is -1, then handle creation failed
149  */
150 int mm_util_transform_is_completed(mm_util_imgp_h imgp_handle, bool *is_completed);
151
152 /**
153  *
154  * @remark      Image Transform Pipeline
155  *
156  * @param       imgp_handle             [in]                    image_util_imgp_h
157  * @param       completed_callback                                      [in]                    Completed_callback
158  * @param       user_param                                              [in]                    User parameter which is received from user when callback function was set
159
160  * @return      This function returns transform processor result value
161  *              if the result is 0, then you can use output_Filename pointer(char** value)
162  *              else if the result is -1, then do not execute when the colopsapce converter is not supported
163  */
164 int mm_util_transform(mm_util_imgp_h imgp_handle, mm_util_color_image_h image, mm_util_completed_callback completed_callback, void * user_data);
165
166 /**
167  *
168  * @remark      Transform Handle Destory
169  *
170  * @param       imgp_handle             [in]                    image_util_imgp_h
171  * @return      This function returns transform processor result value
172  *              if the result is 0, then handle destory succeed
173  *              else if the result is -1, then handle destory failed
174  */
175 int mm_util_destroy(mm_util_imgp_h imgp_handle);
176
177 /**
178  * This function convert the pixel format from source format to destination format.
179  *
180  * @param       src         [in]        pointer of source image data
181  * @param       src_width   [in]        pixel size of source image width
182  * @param       src_height  [in]        pixel size of source image height
183  * @param       src_format  [in]        pixel format of source image
184  * @param       dst         [in/out]    pointer of destination image data
185  * @param       dst_format  [in]        pixel format of destination image
186  *
187  * @return      This function returns zero on success, or negative value with error code.
188  * @remark
189  * @see         mm_util_color_format_e
190  * @since       R1, 1.0
191  */
192 int mm_util_convert_colorspace(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned char *dst, mm_util_color_format_e dst_format);
193
194 /**
195  * This function resizes the source image.
196  *
197  * @param       src         [in]        pointer of source image data
198  * @param       src_width   [in]        pixel size of source image width
199  * @param       src_height  [in]        pixel size of source image height
200  * @param       src_format  [in]        pixel format of source image
201  * @param       dst         [in/out]    pointer of destination image data
202  * @param       dst_width   [in/out]    pixel size of destination image width
203  * @param       dst_height  [in/out]    pixel size of destination image height
204  *
205  * @return      This function returns zero on success, or negative value with error code.
206  * @remark
207  * @see         mm_util_color_format_e
208  * @since       R1, 1.0
209  */
210 int mm_util_resize_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, unsigned int dst_width, unsigned int dst_height, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);
211
212
213 /**
214  * This function rotates the source image.
215  *
216  * @param       src         [in]        pointer of source image data
217  * @param       src_width   [in]        pixel size of source image width
218  * @param       src_height  [in]        pixel size of source image height
219  * @param       src_format  [in]        pixel format of source image
220  * @param       dst         [in/out]    pointer of destination image data
221  * @param       dst_width   [in/out]    pixel size of destination image width
222  * @param       dst_height  [in/out]    pixel size of destination image height
223  * @param       angle       [in]        rotation enum value
224  *
225  * @return      This function returns zero on success, or negative value with error code.
226  * @remark
227  * @see         mm_util_color_format_e, mm_util_img_rotate_type
228  * @since       R1, 1.0
229  */
230 int mm_util_rotate_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format, mm_util_img_rotate_type angle, unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);
231
232
233 /**
234  * This function crop the source image.
235  *
236  * @param       src         [in]                pointer of source image data
237  * @param       src_width   [in]             pixel size of source image width
238  * @param       src_height  [in]             pixel size of source image height
239  * @param       src_format  [in]            pixel format of source image
240  * @param       crop_start_x   [in]         pixel point of cropped image
241  * @param       crop_start_y  [in]          pixel point of cropped image
242  * @param       crop_dest_width   [in/out]   cropped image width (value is changed when yuv image width is odd)
243  * @param       crop_dest_height  [in/out]   cropped image height
244
245  * @param       dst         [in/out]    pointer of destination image data
246  *
247  * @return      This function returns zero on success, or negative value with error code.
248  * @remark
249  * @see         mm_util_color_format_e, mm_util_img_rotate_type
250  * @since       R1, 1.0
251  */
252 int mm_util_crop_image(const unsigned char *src, unsigned int src_width, unsigned int src_height, mm_util_color_format_e src_format,
253                         unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height,
254                         unsigned char **dst, unsigned int *result_buf_width, unsigned int *result_buf_height, size_t *result_buf_size);
255
256
257 #ifdef __cplusplus
258 }
259 #endif
260
261 #endif  /*__MM_UTILITY_IMGP_H__*/