-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_lib.h
300 lines (270 loc) · 9.38 KB
/
image_lib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#ifndef _IMAGE_LIB_H
#define _IMAGE_LIB_H
#include "portab.h"
#include "lcd_api.h"
/**
The enumeration defines all error code.
*/
typedef enum
{
IMAGELIB_SUCCESS,
IMAGELIB_UNKNOW_FORMAT,
IMAGELIB_OPENFILE_ERROR,
IMAGELIB_RAM_NOT_ENOUGH,
IMAGELIB_RAM_EXECPTION,
IMAGELIB_CURRENT_SESSION_BUSY,
IMAGELIB_EXTERNAL_STOP,
IMAGELIB_REGION_ERROR,
IMAGELIB_OTHER_ERROR,
}IMAGELIB_ERROR_CODE;
/**
The enumeration defines all states of IMAGELIB_SESSION.
*/
typedef enum
{
IMAGELIB_OPENED,
IMAGELIB_DECODING,
IMAGELIB_IDLE,
IMAGELIB_CLOSED
}IMAGELIB_STATE;
#define IMAGELIB_INSTANCE_P void*
/**
The structure represents a session used for invoker to control the procedure of image process.\n
To dispose an image, a session must be open first using function imagelib_start_decode_by_file or imagelib_start_decode_by_imagedata.
*/
typedef struct
{
WCHAR* pathname;
IMAGELIB_INSTANCE_P instance_p;
IMAGELIB_STATE state;
IMAGELIB_ERROR_CODE error_code;
SEMAPHORE * decode_sem;
} IMAGELIB_SESSION;
/**
The prototype defines a callback prototype invoked when a image frame is disposed over using asynchronous mode.
*/
typedef void (*DECODE_FRAME_ENDING_CB)(IMAGELIB_SESSION* session,void* return_data,IMAGELIB_ERROR_CODE error_code);
/**
The structure represents a rectangle.
*/
typedef struct
{
INT32 x;
INT32 y;
INT32 width;
INT32 height;
} IMAGELIB_RECT;
/**
The structure represents the information of an image.
*/
typedef enum
{
IMAGELIB_GIF_TYPE,
IMAGELIB_JPEG_TYPE,
IMAGELIB_BMP_TYPE,
IMAGELIB_PNG_TYPE,
IMAGELIB_WBMP_TYPE,
IMAGELIB_NATIVE_BMP_TYPE,
IMAGELIB_LCD_BMP_TYPE,
IMAGELIB_INVAILD_TYPE
}IMAGELIB_IMAGE_TYPE;
typedef struct
{
INT32 width;
INT32 height;
INT16 bits_per_pixel;
IMAGELIB_IMAGE_TYPE image_type;
}IMAGELIB_INFO;
/**
The enumeration defines all effect types.
*/
typedef enum
{
IMAGELIB_NONE_EFFECT,
IMAGELIB_EMBOSS_EFFECT,
IMAGELIB_BRIGHT_EFFECT,
IMAGELIB_BLACKWHITE_EFFECT,
IMAGELIB_NEGATIVE_EFFECT,
IMAGELIB_GRAY_EFFECT,
}IMAGELIB_EFFECT;
/**
The structure represents effect parameters.
*/
typedef struct
{
IMAGELIB_EFFECT effect_type;
INT32 effect_type_para;
}IMAGELIB_EFFECT_PARA;
/**
The enumeration defines all rotate types.
*/
typedef enum
{
IMAGELIB_ROTATE_0,
IMAGELIB_ROTATE_90,
IMAGELIB_ROTATE_180,
IMAGELIB_ROTATE_270,
}IMAGELIB_ROTATE_ANGLE;
/**
The structure represents draw parameters.
*/
typedef struct
{
IMAGELIB_RECT m_rect;
IMAGELIB_ROTATE_ANGLE m_angle;
INT32 m_src_x; //source x
INT32 m_src_y; //source x
}IMAGELIB_DRAW_PARA;
/**
The function open a os task/thread, the task/thread is blocked if there is no image process request.\n
The function is invoked on the beginning of the system start.
*/
extern void imagelib_start_thread();
/**
The function is used to get the information of an image file.
@param _pathname Source image path.
@param _info Return information value.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_getinfo_by_filename(const WCHAR* _pathname,IMAGELIB_INFO* _info);
/**
The function is used to get the information of an image data.
@param _dev Image device type, for example, for a gif data, the device type is "gif".
@param _buf Image data.
@param _buf_size Image data size.
@param _info Return information value.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_getinfo_by_imagedata(const CHAR* _dev,const CHAR* _buf,UINT32 _buf_size,IMAGELIB_INFO* _info);
/**
The function is used to start a session to process image file. It must be invoked on the beginning of image process.
@param _pathname Source image path.
@param _session Return session handle.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_start_decode_by_file(const WCHAR* _pathname,IMAGELIB_SESSION** _session);
/**
The function is used to start a session to process image data. It must be invoked on the beginning of image process.
@param _dev Image device type, for example, for a gif data, the device type is "gif".
@param _image_data Image data.
@param _size Image data size.
@param _session Return session handle.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_start_decode_by_imagedata(const char* _dev,const char* _image_data,UINT32 _size,IMAGELIB_SESSION** _session);
/**
The function is used to directly draw image frame to LCD.\n
The function is a asynchronous function.
@param _session Session handle.
@param _src_rect The rectangle of source image.
@param _dest_width Output width.
@param _dest_height Output height.
@param _effect_para Effect parameter.
@param _draw_para Draw parameter.
@param _cb Callback functon pointer invoked when the image frame is disposed over.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_draw_frame_asyn(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect,
INT32 _dest_width,INT32 _dest_height,IMAGELIB_EFFECT_PARA _effect_para ,
IMAGELIB_DRAW_PARA _draw_para,DECODE_FRAME_ENDING_CB _cb );
/**
The function is used to decode the image frame to DISP_BTIMAP foramt data.\n
The function is a asynchronous function.
@param _session Session handle.
@param _src_rect The rectangle of source image.
@param _dest_width Output width.
@param _dest_height Output height.
@param _effect_para Effect parameter.
@param _cb Callback functon pointer invoked when the image frame is disposed over.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_get_frame_data_asyn(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect,
INT32 _dest_width,INT32 _dest_height,
IMAGELIB_EFFECT_PARA _effect_para ,DECODE_FRAME_ENDING_CB _cb);
/**
The function is used to save the image frame to a image file(exclude gif foramt).\n
The function is a asynchronous function.
@param _session Session handle.
@param _src_rect The rectangle of source image.
@param _dest_pathname Destination pathname
@param _dest_width Output width.
@param _dest_height Output height.
@param _effect_para Effect parameter.
@param _cb Callback functon pointer invoked when the image frame is disposed over.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_save_frame_to_file_asyn(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect,
const WCHAR* _dest_pathname,INT32 _dest_width,INT32 _dest_height,
IMAGELIB_EFFECT_PARA _effect_para,DECODE_FRAME_ENDING_CB _cb );
/**
The function is used to directly draw image frame to LCD.\n
The function is a synchronous function.
@param _session Session handle.
@param _src_rect The rectangle of source image.
@param _dest_width Output width.
@param _dest_height Output height.
@param _effect_para Effect parameter.
@param _draw_para Draw parameter.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_draw_frame_sync(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect,
INT32 _dest_width,INT32 _dest_height,IMAGELIB_EFFECT_PARA _effect_para,
IMAGELIB_DRAW_PARA _draw_para);
/**
The function is used to decode the image frame to DISP_BTIMAP foramt data.\n
The function is a synchronous function.
@param _session Session handle.
@param _src_rect The rectangle of source image.
@param _dest_width Output width.
@param _dest_height Output height.
@param _effect_para Effect parameter.
@param _bitmap_rt Return value.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_get_frame_data_sync(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect,
INT32 _dest_width,INT32 _dest_height, IMAGELIB_EFFECT_PARA _effect_para,DISP_BITMAP** _bitmap_rt);
/**
The function is used to save the image frame to a image file(exclude gif foramt).\n
The function is a synchronous function.
@param _session Session handle.
@param _src_rect The rectangle of source image.
@param _dest_pathname Destination pathname
@param _dest_width Output width.
@param _dest_height Output height.
@param _effect_para Effect parameter.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_save_frame_to_file_sync(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect,
const WCHAR* _dest_pathname,INT32 _dest_width,INT32 _dest_height,
IMAGELIB_EFFECT_PARA _effect_para );
/**
The function is used to get next frame.
@param _session Session handle.
@return Delay value. If the delay equal zero, it means there is no next frame.
*/
extern INT32 imagelib_get_next_frame(IMAGELIB_SESSION*_session);
/**
The function is used to get width of image.
@param _session Session handle.
@return Width value.
*/
extern UINT32 imagelib_get_width(IMAGELIB_SESSION*_session);
/**
The function is used to get height of image.
@param _session Session handle.
@return Height value.
*/
extern UINT32 imagelib_get_height(IMAGELIB_SESSION*_session);
/**
The function is used to get image type.
@param _session Session handle.
@return image type.
*/
extern IMAGELIB_IMAGE_TYPE imagelib_get_image_type(IMAGELIB_SESSION*_session);
/**
The function is used to stop the session.
@param _session Session handle.
@return Error code.
*/
extern IMAGELIB_ERROR_CODE imagelib_end_decode(IMAGELIB_SESSION*_session);
#endif