Rev 6495 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6495 | Rev 8545 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | /* Written by turbocat2001 (Logaev Maxim) */ |
|
- | 2 | ||
1 | #ifndef KOLIBRI_LIBIMG_H |
3 | #ifndef KOLIBRI_LIBIMG_H |
2 | #define KOLIBRI_LIBIMG_H |
4 | #define KOLIBRI_LIBIMG_H |
Line -... | Line 5... | ||
- | 5 | ||
- | 6 | #include |
|
- | 7 | #include |
|
3 | 8 | ||
Line -... | Line 9... | ||
- | 9 | extern int kolibri_libimg_init(void); |
|
- | 10 | ||
4 | extern int kolibri_libimg_init(void); |
11 | #define _stdcall __attribute__((__stdcall__)) |
5 | 12 | ||
6 | //list of format id's |
13 | //list of format id's |
7 | #define LIBIMG_FORMAT_BMP 1 |
14 | #define LIBIMG_FORMAT_BMP 1 |
8 | #define LIBIMG_FORMAT_ICO 2 |
15 | #define LIBIMG_FORMAT_ICO 2 |
Line 17... | Line 24... | ||
17 | #define LIBIMG_FORMAT_PNM 11 |
24 | #define LIBIMG_FORMAT_PNM 11 |
18 | #define LIBIMG_FORMAT_WBMP 12 |
25 | #define LIBIMG_FORMAT_WBMP 12 |
19 | #define LIBIMG_FORMAT_XBM 13 |
26 | #define LIBIMG_FORMAT_XBM 13 |
20 | #define LIBIMG_FORMAT_Z80 14 |
27 | #define LIBIMG_FORMAT_Z80 14 |
Line -... | Line 28... | ||
- | 28 | ||
- | 29 | #pragma pack(push, 1) |
|
- | 30 | typedef struct{ |
|
- | 31 | uint32_t Checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far |
|
- | 32 | uint32_t Width; |
|
- | 33 | uint32_t Height; |
|
- | 34 | uint32_t Next; |
|
- | 35 | uint32_t Previous; |
|
- | 36 | uint32_t Type; // one of Image.bppN |
|
- | 37 | uint32_t* Data; |
|
- | 38 | uint32_t Palette; // used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i |
|
- | 39 | uint32_t Extended; |
|
- | 40 | uint32_t Flags; // bitfield |
|
- | 41 | uint32_t Delay; // used iff Image.IsAnimated is set in Flags |
|
- | 42 | } Image; |
|
- | 43 | #pragma pack(pop) |
|
- | 44 | ||
- | 45 | #define IMAGE_BPP8i 1 // indexed |
|
- | 46 | #define IMAGE_BPP24 2 |
|
- | 47 | #define IMAGE_BPP32 3 |
|
- | 48 | #define IMAGE_BPP15 4 |
|
- | 49 | #define IMAGE_BPP16 5 |
|
- | 50 | #define IMAGE_BPP1 6 |
|
- | 51 | #define IMAGE_BPP8g 7 // grayscale |
|
- | 52 | #define IMAGE_BPP2i 8 |
|
- | 53 | #define IMAGE_BPP4i 9 |
|
- | 54 | #define IMAGE_BPP8a 10 |
|
- | 55 | ||
- | 56 | // scale type |
|
- | 57 | #define LIBIMG_SCALE_NONE 0 |
|
- | 58 | #define LIBIMG_SCALE_INTEGER 1 |
|
- | 59 | #define LIBIMG_SCALE_TILE 2 |
|
- | 60 | #define LIBIMG_SCALE_STRETCH 3 |
|
- | 61 | #define LIBIMG_SCALE_FIT_BOTH LIBIMG_SCALE_STRETCH |
|
- | 62 | #define LIBIMG_SCALE_FIT_MIN 4 |
|
- | 63 | #define LIBIMG_SCALE_FIT_RECT LIBIMG_SCALE_FIT_MIN |
|
- | 64 | #define LIBIMG_SCALE_FIT_WIDTH 5 |
|
- | 65 | #define LIBIMG_SCALE_FIT_HEIGHT 6 |
|
- | 66 | #define LIBIMG_SCALE_FIT_MAX 7 |
|
- | 67 | ||
- | 68 | // interpolation algorithm |
|
- | 69 | #define LIBIMG_INTER_NONE 0 // use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc |
|
- | 70 | #define LIBIMG_INTER_BILINEAR 1 |
|
- | 71 | #define LIBIMG_INTER_BICUBIC 2 |
|
- | 72 | #define LIBIMG_INTER_LANCZOS 3 |
|
- | 73 | #define LIBIMG_INTER_DEFAULT LIBIMG_INTER_BILINEAR |
|
21 | 74 | ||
22 | //error codes |
75 | //error codes |
23 | #define LIBIMG_ERROR_OUT_OF_MEMORY 1 |
76 | #define LIBIMG_ERROR_OUT_OF_MEMORY 1 |
24 | #define LIBIMG_ERROR_FORMAT 2 |
77 | #define LIBIMG_ERROR_FORMAT 2 |
25 | #define LIBIMG_ERROR_CONDITIONS 3 |
78 | #define LIBIMG_ERROR_CONDITIONS 3 |
Line 35... | Line 88... | ||
35 | #define LIBIMG_ENCODE_STRICT_SPECIFIC 0x01 |
88 | #define LIBIMG_ENCODE_STRICT_SPECIFIC 0x01 |
36 | #define LIBIMG_ENCODE_STRICT_BIT_DEPTH 0x02 |
89 | #define LIBIMG_ENCODE_STRICT_BIT_DEPTH 0x02 |
37 | #define LIBIMG_ENCODE_DELETE_ALPHA 0x08 |
90 | #define LIBIMG_ENCODE_DELETE_ALPHA 0x08 |
38 | #define LIBIMG_ENCODE_FLUSH_ALPHA 0x10 |
91 | #define LIBIMG_ENCODE_FLUSH_ALPHA 0x10 |
Line 39... | Line -... | ||
39 | - | ||
40 | 92 | ||
41 | #define FLIP_VERTICAL 0x01 |
93 | #define FLIP_VERTICAL 0x01 |
Line 42... | Line 94... | ||
42 | #define FLIP_HORIZONTAL 0x02 |
94 | #define FLIP_HORIZONTAL 0x02 |
43 | 95 | ||
44 | #define ROTATE_90_CW 0x01 |
96 | #define ROTATE_90_CW 0x01 |
45 | #define ROTATE_180 0x02 |
97 | #define ROTATE_180 0x02 |
46 | #define ROTATE_270_CW 0x03 |
98 | #define ROTATE_270_CW 0x03 |
Line 47... | Line 99... | ||
47 | #define ROTATE_90_CCW ROTATE_270_CW |
99 | #define ROTATE_90_CCW ROTATE_270_CW |
48 | #define ROTATE_270_CCW ROTATE_90_CW |
100 | #define ROTATE_270_CCW ROTATE_90_CW |
49 | 101 | ||
50 | extern void* (*img_decode)(void *, uint32_t, uint32_t) __attribute__((__stdcall__)); |
102 | extern Image* (*img_decode)(void* file_data, uint32_t size, uint32_t b_color) _stdcall; |
51 | extern void* (*img_encode)(void *, uint32_t, uint32_t) __attribute__((__stdcall__)); |
103 | extern Image* (*img_encode)(Image* img, uint32_t length, uint32_t option) _stdcall; |
52 | extern void* (*img_create)(uint32_t, uint32_t, uint32_t) __attribute__((__stdcall__)); |
104 | extern Image* (*img_create)(uint32_t width, uint32_t height, uint32_t type) _stdcall; |
53 | extern void (*img_to_rgb2)(void *, void *) __attribute__((__stdcall__)); |
105 | extern void (*img_to_rgb2)(Image* img, void *rgb_data) _stdcall; |
54 | extern void* (*img_to_rgb)(void *) __attribute__((__stdcall__)); |
106 | extern Image* (*img_to_rgb)(Image* img) _stdcall; |
55 | extern uint32_t (*img_flip)(void *, uint32_t) __attribute__((__stdcall__)); |
107 | extern bool (*img_flip)(Image* img, uint32_t flip) _stdcall; |
56 | extern uint32_t (*img_flip_layer)(void *, uint32_t) __attribute__((__stdcall__)); |
108 | extern bool (*img_flip_layer)(Image *img, uint32_t flip) _stdcall; |
57 | extern uint32_t (*img_rotate)(void *, uint32_t) __attribute__((__stdcall__)); |
109 | extern bool (*img_rotate)(Image *img, uint32_t rotate) _stdcall; |
58 | extern uint32_t (*img_rotate_layer)(void *, uint32_t) __attribute__((__stdcall__)); |
110 | extern bool (*img_rotate_layer)(Image* data, uint32_t rotate) _stdcall; |
59 | extern void (*img_draw)(void *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t ) __attribute__((__stdcall__)); |
111 | extern void (*img_draw)(Image *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t xoff, uint32_t yoff) _stdcall; |
- | 112 | extern int32_t (*img_count)(Image *img) _stdcall; |
|
- | 113 | extern bool (*img_destroy)(Image *img) _stdcall; |
|
- | 114 | extern bool (*img_destroy_layer)(Image* img) _stdcall; |
|
- | 115 | extern Image* (*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) _stdcall; |
|
- | 116 | extern Image* (*img_convert)(Image *src, Image *dst, uint32_t dst_type, uint32_t, uint32_t) _stdcall; |
|
- | 117 | extern Image* (*img_resize_data)(Image *src, uint32_t width, uint32_t height) _stdcall; |
|
- | 118 | extern Image* (*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) _stdcall; |
|
- | 119 | ||
- | 120 | void img_fill_color(Image* img, uint32_t width, uint32_t height, uint32_t color){ |
|
- | 121 | for (uint32_t i = 0; i < width*height; i++) { |
|
Line 60... | Line 122... | ||
60 | extern uint32_t (*img_count)(void *) __attribute__((__stdcall__)); |
122 | img->Data[i] = color; |