4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: YoungHun Kim <yh8004.kim@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #ifndef __MM_UTILITY_IMGP_H__
23 #define __MM_UTILITY_IMGP_H__
31 #include "mm_util_type.h"
33 typedef void *mm_util_imgp_h;
35 typedef bool (*mm_util_completed_callback)(mm_util_color_image_h image, int error, void *user_param);
41 This part describes the APIs with repect to image converting library.
45 * Image rotation types
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;
58 * This function calculates the size of the image data in bytes.
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
65 * @return This function returns zero on success, or negative value with error code.
67 * @see mm_util_color_format_e
70 int mm_util_get_image_size(mm_util_color_format_e format, unsigned int width, unsigned int height, size_t *imgsize);
74 * @remark Transform Handle Creation
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
81 int mm_util_create(mm_util_imgp_h *imgp_handle);
85 * @remark Transform Handle Creation
87 * @param imgp_handle [in] image_util_imgp_h
88 * @param colorspace [in] colorspace The colorspace of the destination image buffer
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
94 int mm_util_set_colorspace_convert(mm_util_imgp_h imgp_handle, mm_util_color_format_e colorspace);
98 * @remark Transform Handle Creation
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
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
108 int mm_util_set_resolution(mm_util_imgp_h imgp_handle, unsigned int width, unsigned int height);
112 * @remark Transform Handle Creation
114 * @param imgp_handle [in] image_util_imgp_h
115 * @param rotation [in] dest_rotation The rotation value of destination image buffer
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
121 int mm_util_set_rotation(mm_util_imgp_h imgp_handle, mm_util_img_rotate_type rotation);
125 * @remark Transform Handle Creation
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
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
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);
141 * @remark Transform Handle Creation
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
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
150 int mm_util_transform_is_completed(mm_util_imgp_h imgp_handle, bool *is_completed);
154 * @remark Image Transform Pipeline
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
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
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);
168 * @remark Transform Handle Destory
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
175 int mm_util_destroy(mm_util_imgp_h imgp_handle);
178 * This function convert the pixel format from source format to destination format.
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
187 * @return This function returns zero on success, or negative value with error code.
189 * @see mm_util_color_format_e
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);
195 * This function resizes the source image.
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
205 * @return This function returns zero on success, or negative value with error code.
207 * @see mm_util_color_format_e
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);
214 * This function rotates the source image.
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
225 * @return This function returns zero on success, or negative value with error code.
227 * @see mm_util_color_format_e, mm_util_img_rotate_type
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);
234 * This function crop the source image.
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
245 * @param dst [in/out] pointer of destination image data
247 * @return This function returns zero on success, or negative value with error code.
249 * @see mm_util_color_format_e, mm_util_img_rotate_type
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);
261 #endif /*__MM_UTILITY_IMGP_H__*/