Commit | Line | Data |
---|---|---|
faa9b3e7 TC |
1 | /* Declares utility functions useful across various files which |
2 | aren't meant to be available externally | |
3 | */ | |
4 | ||
5 | #ifndef IMAGEI_H_ | |
6 | #define IMAGEI_H_ | |
7 | ||
92bda632 | 8 | #include "imager.h" |
faa9b3e7 TC |
9 | |
10 | /* wrapper functions that implement the floating point sample version of a | |
11 | function in terms of the 8-bit sample version | |
12 | */ | |
97ac0a96 | 13 | extern int i_ppixf_fp(i_img *im, int x, int y, const i_fcolor *pix); |
faa9b3e7 | 14 | extern int i_gpixf_fp(i_img *im, int x, int y, i_fcolor *pix); |
97ac0a96 | 15 | extern int i_plinf_fp(i_img *im, int l, int r, int y, const i_fcolor *pix); |
faa9b3e7 TC |
16 | extern int i_glinf_fp(i_img *im, int l, int r, int y, i_fcolor *pix); |
17 | extern int i_gsampf_fp(i_img *im, int l, int r, int y, i_fsample_t *samp, | |
18accb2a | 18 | int const *chans, int chan_count); |
faa9b3e7 TC |
19 | |
20 | /* wrapper functions that forward palette calls to the underlying image, | |
21 | assuming the underlying image is the first pointer in whatever | |
22 | ext_data points at | |
23 | */ | |
97ac0a96 | 24 | extern int i_addcolors_forward(i_img *im, const i_color *, int count); |
faa9b3e7 TC |
25 | extern int i_getcolors_forward(i_img *im, int i, i_color *, int count); |
26 | extern int i_colorcount_forward(i_img *im); | |
27 | extern int i_maxcolors_forward(i_img *im); | |
97ac0a96 TC |
28 | extern int i_findcolor_forward(i_img *im, const i_color *color, |
29 | i_palidx *entry); | |
30 | extern int i_setcolors_forward(i_img *im, int index, const i_color *colors, | |
faa9b3e7 TC |
31 | int count); |
32 | ||
33 | #define SampleFTo16(num) ((int)((num) * 65535.0 + 0.01)) | |
34 | /* we add that little bit to avoid rounding issues */ | |
35 | #define Sample16ToF(num) ((num) / 65535.0) | |
36 | ||
37 | #define SampleFTo8(num) ((int)((num) * 255.0 + 0.01)) | |
38 | #define Sample8ToF(num) ((num) / 255.0) | |
39 | ||
40 | #define Sample16To8(num) ((num) / 257) | |
41 | #define Sample8To16(num) ((num) * 257) | |
42 | ||
efdc2568 TC |
43 | extern void i_get_combine(int combine, i_fill_combine_f *, i_fill_combinef_f *); |
44 | ||
a8652edf TC |
45 | #define im_min(a, b) ((a) < (b) ? (a) : (b)) |
46 | #define im_max(a, b) ((a) > (b) ? (a) : (b)) | |
47 | ||
b33c08f8 TC |
48 | #include "ext.h" |
49 | ||
50 | extern UTIL_table_t i_UTIL_table; | |
51 | ||
ffeb4a67 TC |
52 | /* Ideally this will move into imconfig.h if we ever probe */ |
53 | #if defined(_GNU_SOURCE) || __STDC_VERSION__ >= 199901L | |
54 | /* snprintf() is part of C99 and provided by Glibc */ | |
55 | #define HAVE_SNPRINTF | |
56 | #endif | |
57 | ||
35f40526 TC |
58 | /* test if all channels are writable */ |
59 | #define I_ALL_CHANNELS_WRITABLE(im) (((im)->ch_mask & 0xF) == 0xf) | |
60 | ||
a8652edf TC |
61 | typedef struct i_int_hline_seg_tag { |
62 | int minx, x_limit; | |
63 | } i_int_hline_seg; | |
64 | ||
65 | typedef struct i_int_hline_entry_tag { | |
66 | int count; | |
67 | int alloc; | |
68 | i_int_hline_seg segs[1]; | |
69 | } i_int_hline_entry; | |
70 | ||
71 | /* represents a set of horizontal line segments to be filled in later */ | |
72 | typedef struct i_int_hlines_tag { | |
73 | int start_y, limit_y; | |
74 | int start_x, limit_x; | |
75 | i_int_hline_entry **entries; | |
76 | } i_int_hlines; | |
77 | ||
78 | extern void | |
79 | i_int_init_hlines( | |
80 | i_int_hlines *hlines, | |
81 | int start_y, | |
82 | int count_y, | |
83 | int start_x, | |
84 | int width_x | |
85 | ); | |
86 | extern void i_int_init_hlines_img(i_int_hlines *hlines, i_img *img); | |
87 | extern void i_int_hlines_add(i_int_hlines *hlines, int y, int minx, int width); | |
88 | extern void i_int_hlines_destroy(i_int_hlines *hlines); | |
89 | ||
97ac0a96 | 90 | extern void i_int_hlines_fill_color(i_img *im, i_int_hlines *hlines, const i_color *val); |
a8652edf TC |
91 | extern void i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill); |
92 | ||
faa9b3e7 | 93 | #endif |