Rev 9812 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8796 | turbocat | 1 | /* Written by turbocat2001 (Logaev Maxim) */ |
2 | |||
3 | #ifndef KOLIBRI_LIBIMG_H |
||
4 | #define KOLIBRI_LIBIMG_H |
||
5 | |||
6 | #include |
||
9812 | Coldy | 7 | #include |
8796 | turbocat | 8 | #include |
9 | |||
9812 | Coldy | 10 | |
8796 | turbocat | 11 | //list of format id's |
12 | #define LIBIMG_FORMAT_BMP 1 |
||
13 | #define LIBIMG_FORMAT_ICO 2 |
||
14 | #define LIBIMG_FORMAT_CUR 3 |
||
15 | #define LIBIMG_FORMAT_GIF 4 |
||
16 | #define LIBIMG_FORMAT_PNG 5 |
||
17 | #define LIBIMG_FORMAT_JPEG 6 |
||
18 | #define LIBIMG_FORMAT_TGA 7 |
||
19 | #define LIBIMG_FORMAT_PCX 8 |
||
20 | #define LIBIMG_FORMAT_XCF 9 |
||
21 | #define LIBIMG_FORMAT_TIFF 10 |
||
22 | #define LIBIMG_FORMAT_PNM 11 |
||
23 | #define LIBIMG_FORMAT_WBMP 12 |
||
24 | #define LIBIMG_FORMAT_XBM 13 |
||
25 | #define LIBIMG_FORMAT_Z80 14 |
||
26 | |||
27 | #pragma pack(push, 1) |
||
28 | typedef struct{ |
||
29 | uint32_t Checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far |
||
30 | uint32_t Width; |
||
31 | uint32_t Height; |
||
32 | uint32_t Next; |
||
33 | uint32_t Previous; |
||
34 | uint32_t Type; // one of Image.bppN |
||
35 | uint32_t* Data; |
||
36 | uint32_t Palette; // used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i |
||
37 | uint32_t Extended; |
||
38 | uint32_t Flags; // bitfield |
||
39 | uint32_t Delay; // used iff Image.IsAnimated is set in Flags |
||
40 | } Image; |
||
41 | #pragma pack(pop) |
||
42 | |||
43 | #define IMAGE_BPP8i 1 // indexed |
||
44 | #define IMAGE_BPP24 2 |
||
45 | #define IMAGE_BPP32 3 |
||
46 | #define IMAGE_BPP15 4 |
||
47 | #define IMAGE_BPP16 5 |
||
48 | #define IMAGE_BPP1 6 |
||
49 | #define IMAGE_BPP8g 7 // grayscale |
||
50 | #define IMAGE_BPP2i 8 |
||
51 | #define IMAGE_BPP4i 9 |
||
52 | #define IMAGE_BPP8a 10 |
||
53 | |||
54 | // scale type |
||
55 | #define LIBIMG_SCALE_NONE 0 |
||
56 | #define LIBIMG_SCALE_INTEGER 1 |
||
57 | #define LIBIMG_SCALE_TILE 2 |
||
58 | #define LIBIMG_SCALE_STRETCH 3 |
||
59 | #define LIBIMG_SCALE_FIT_BOTH LIBIMG_SCALE_STRETCH |
||
60 | #define LIBIMG_SCALE_FIT_MIN 4 |
||
61 | #define LIBIMG_SCALE_FIT_RECT LIBIMG_SCALE_FIT_MIN |
||
62 | #define LIBIMG_SCALE_FIT_WIDTH 5 |
||
63 | #define LIBIMG_SCALE_FIT_HEIGHT 6 |
||
64 | #define LIBIMG_SCALE_FIT_MAX 7 |
||
65 | |||
66 | // interpolation algorithm |
||
67 | #define LIBIMG_INTER_NONE 0 // use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc |
||
68 | #define LIBIMG_INTER_BILINEAR 1 |
||
69 | #define LIBIMG_INTER_BICUBIC 2 |
||
70 | #define LIBIMG_INTER_LANCZOS 3 |
||
71 | #define LIBIMG_INTER_DEFAULT LIBIMG_INTER_BILINEAR |
||
72 | |||
73 | //error codes |
||
74 | #define LIBIMG_ERROR_OUT_OF_MEMORY 1 |
||
75 | #define LIBIMG_ERROR_FORMAT 2 |
||
76 | #define LIBIMG_ERROR_CONDITIONS 3 |
||
77 | #define LIBIMG_ERROR_BIT_DEPTH 4 |
||
78 | #define LIBIMG_ERROR_ENCODER 5 |
||
79 | #define LIBIMG_ERROR_SRC_TYPE 6 |
||
80 | #define LIBIMG_ERROR_SCALE 7 |
||
81 | #define LIBIMG_ERROR_INTER 8 |
||
82 | #define LIBIMG_ERROR_NOT_INPLEMENTED 9 |
||
83 | #define LIBIMG_ERROR_INVALID_INPUT 10 |
||
84 | |||
85 | //encode flags (byte 0x02 of _common option) |
||
86 | #define LIBIMG_ENCODE_STRICT_SPECIFIC 0x01 |
||
87 | #define LIBIMG_ENCODE_STRICT_BIT_DEPTH 0x02 |
||
88 | #define LIBIMG_ENCODE_DELETE_ALPHA 0x08 |
||
89 | #define LIBIMG_ENCODE_FLUSH_ALPHA 0x10 |
||
90 | |||
91 | #define FLIP_VERTICAL 0x01 |
||
92 | #define FLIP_HORIZONTAL 0x02 |
||
93 | |||
94 | #define ROTATE_90_CW 0x01 |
||
95 | #define ROTATE_180 0x02 |
||
96 | #define ROTATE_270_CW 0x03 |
||
97 | #define ROTATE_90_CCW ROTATE_270_CW |
||
98 | #define ROTATE_270_CCW ROTATE_90_CW |
||
99 | |||
9812 | Coldy | 100 | DLLAPI Image* __stdcall img_decode(void* file_data, uint32_t size, uint32_t b_color); |
101 | DLLAPI Image* __stdcall img_encode(Image* img, uint32_t length, uint32_t option); |
||
102 | DLLAPI Image* __stdcall img_create(uint32_t width, uint32_t height, uint32_t type); |
||
103 | DLLAPI void __stdcall img_to_rgb2(Image* img, void *rgb_data); |
||
104 | DLLAPI Image* __stdcall img_to_rgb(Image* img); |
||
105 | DLLAPI bool __stdcall img_flip(Image* img, uint32_t flip); |
||
106 | DLLAPI bool __stdcall img_flip_layer(Image *img, uint32_t flip); |
||
107 | DLLAPI bool __stdcall img_rotate(Image *img, uint32_t rotate); |
||
108 | DLLAPI bool __stdcall img_rotate_layer(Image* data, uint32_t rotate); |
||
109 | DLLAPI void __stdcall img_draw(Image *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t xoff, uint32_t yoff); |
||
110 | DLLAPI int32_t __stdcall img_count(Image *img); |
||
111 | DLLAPI bool __stdcall img_destroy(Image *img); |
||
112 | DLLAPI bool __stdcall img_destroy_layer(Image* img); |
||
113 | DLLAPI Image* __stdcall img_blend(Image* dst, Image* src, uint32_t out_x, uint32_t out_y, uint32_t in_x, uint32_t in_y, uint32_t width, uint32_t height); |
||
114 | DLLAPI Image* __stdcall img_convert(Image *src, Image *dst, uint32_t dst_type, uint32_t, uint32_t); |
||
115 | DLLAPI Image* __stdcall img_resize_data(Image *src, uint32_t width, uint32_t height); |
||
116 | DLLAPI Image* __stdcall img_scale(Image* src, uint32_t crop_x, uint32_t crop_y, uint32_t crop_width, uint32_t crop_height, Image* dst, uint32_t scale_type, uint32_t inter, uint32_t new_width, uint32_t new_height); |
||
8796 | turbocat | 117 | |
9973 | rgimad | 118 | static void img_fill_color(Image* img, uint32_t width, uint32_t height, uint32_t color){ |
8796 | turbocat | 119 | for (uint32_t i = 0; i < width*height; i++) { |
120 | img->Data[i] = color; |
||
121 | } |
||
122 | } |
||
123 | |||
124 | #endif /* KOLIBRI_LIBIMG_H */> |