Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 147 lines (114 sloc) 4.731 kB
faa9b3e Egads
Tony Cook authored
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
92bda63 - start of external Imager API access:
Tony Cook authored
8 #include "imager.h"
31a1347 @tonycoz implement reference counting for context objects
authored
9 #include <stddef.h>
faa9b3e Egads
Tony Cook authored
10
11 /* wrapper functions that implement the floating point sample version of a
12 function in terms of the 8-bit sample version
13 */
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
14 extern int i_ppixf_fp(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *pix);
15 extern int i_gpixf_fp(i_img *im, i_img_dim x, i_img_dim y, i_fcolor *pix);
16 extern i_img_dim i_plinf_fp(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *pix);
17 extern i_img_dim i_glinf_fp(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *pix);
18 extern i_img_dim i_gsampf_fp(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
18accb2 Ticket #369 - writing grayscale images to GIF
Tony Cook authored
19 int const *chans, int chan_count);
faa9b3e Egads
Tony Cook authored
20
21 /* wrapper functions that forward palette calls to the underlying image,
22 assuming the underlying image is the first pointer in whatever
23 ext_data points at
24 */
97ac0a9 - constify the Imager API
Tony Cook authored
25 extern int i_addcolors_forward(i_img *im, const i_color *, int count);
faa9b3e Egads
Tony Cook authored
26 extern int i_getcolors_forward(i_img *im, int i, i_color *, int count);
27 extern int i_colorcount_forward(i_img *im);
28 extern int i_maxcolors_forward(i_img *im);
97ac0a9 - constify the Imager API
Tony Cook authored
29 extern int i_findcolor_forward(i_img *im, const i_color *color,
30 i_palidx *entry);
31 extern int i_setcolors_forward(i_img *im, int index, const i_color *colors,
faa9b3e Egads
Tony Cook authored
32 int count);
33
bd8052a merge in tiff re-work branch
Tony Cook authored
34 /* fallback handler for gsamp_bits */
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
35 extern i_img_dim i_gsamp_bits_fb(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, unsigned *samp,
bd8052a merge in tiff re-work branch
Tony Cook authored
36 const int *chans, int chan_count, int bits);
37
29b3867 @tonycoz re-work sample down-conversion to rounding
authored
38 #define SampleFTo16(num) ((int)((num) * 65535.0 + 0.5))
faa9b3e Egads
Tony Cook authored
39 /* we add that little bit to avoid rounding issues */
40 #define Sample16ToF(num) ((num) / 65535.0)
41
29b3867 @tonycoz re-work sample down-conversion to rounding
authored
42 #define SampleFTo8(num) ((int)((num) * 255.0 + 0.5))
faa9b3e Egads
Tony Cook authored
43 #define Sample8ToF(num) ((num) / 255.0)
44
29b3867 @tonycoz re-work sample down-conversion to rounding
authored
45 #define Sample16To8(num) (((num)+128) / 257)
faa9b3e Egads
Tony Cook authored
46 #define Sample8To16(num) ((num) * 257)
47
efdc256 minor error handling in bmp.c
Tony Cook authored
48 extern void i_get_combine(int combine, i_fill_combine_f *, i_fill_combinef_f *);
49
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
50 #define im_min(a, b) ((a) < (b) ? (a) : (b))
51 #define im_max(a, b) ((a) > (b) ? (a) : (b))
52
b33c08f hide or rename any symbols that are likely to conflict with other
Tony Cook authored
53 #include "ext.h"
54
55 extern UTIL_table_t i_UTIL_table;
56
35f4052 - setmask() now returns true on success and reports a missing mask
Tony Cook authored
57 /* test if all channels are writable */
58 #define I_ALL_CHANNELS_WRITABLE(im) (((im)->ch_mask & 0xF) == 0xf)
59
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
60 typedef struct i_int_hline_seg_tag {
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
61 i_img_dim minx, x_limit;
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
62 } i_int_hline_seg;
63
64 typedef struct i_int_hline_entry_tag {
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
65 i_img_dim count;
66 size_t alloc;
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
67 i_int_hline_seg segs[1];
68 } i_int_hline_entry;
69
70 /* represents a set of horizontal line segments to be filled in later */
71 typedef struct i_int_hlines_tag {
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
72 i_img_dim start_y, limit_y;
73 i_img_dim start_x, limit_x;
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
74 i_int_hline_entry **entries;
75 } i_int_hlines;
76
77 extern void
78 i_int_init_hlines(
79 i_int_hlines *hlines,
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
80 i_img_dim start_y,
81 i_img_dim count_y,
82 i_img_dim start_x,
83 i_img_dim width_x
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
84 );
85 extern void i_int_init_hlines_img(i_int_hlines *hlines, i_img *img);
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
86 extern void i_int_hlines_add(i_int_hlines *hlines, i_img_dim y, i_img_dim minx, i_img_dim width);
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
87 extern void i_int_hlines_destroy(i_int_hlines *hlines);
88
97ac0a9 - constify the Imager API
Tony Cook authored
89 extern void i_int_hlines_fill_color(i_img *im, i_int_hlines *hlines, const i_color *val);
a8652ed - arc(..., fill=> ...) wasn't handling concave areas correctly
Tony Cook authored
90 extern void i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill);
91
13c9a30 - correctly blend a rotated (or matrix_transformed()) image when
Tony Cook authored
92 #define I_LIMIT_8(x) ((x) < 0 ? 0 : (x) > 255 ? 255 : (x))
93 #define I_LIMIT_DOUBLE(x) ((x) < 0.0 ? 0.0 : (x) > 1.0 ? 1.0 : (x))
94
42a0797 rename I_STRING to IM_STRING, since I_STRING conflicts with a perl
Tony Cook authored
95 #define IM_STRING(x) #x
b3afeed - an integer division meant that preview scaling to below 1 pixel
Tony Cook authored
96
97 /* I considered using assert.h here, but perl does it's own thing with
98 assert() and the NDEBUG test is opposite to the direction I prefer */
99 #ifdef IM_ASSERT
100 extern void im_assert_fail(char const *, int, char const *);
42a0797 rename I_STRING to IM_STRING, since I_STRING conflicts with a perl
Tony Cook authored
101 #define im_assert(x) ((x) ? (void)(0) : im_assert_fail(__FILE__, __LINE__, IM_STRING(x)))
b3afeed - an integer division meant that preview scaling to below 1 pixel
Tony Cook authored
102 #else
103 #define im_assert(x) (void)(0)
104 #endif
105
50c7538 Move freetype 2 support into its own module
Tony Cook authored
106 i_img_dim i_minx(i_img_dim a, i_img_dim b);
107 i_img_dim i_maxx(i_img_dim x, i_img_dim y);
8d14daa @tonycoz switch to using size_t and i_img_dim strictly
authored
108 i_img_dim i_abs(i_img_dim x);
50c7538 Move freetype 2 support into its own module
Tony Cook authored
109
110 #define i_min(a, b) i_minx((a), (b))
111 #define i_max(a, b) i_maxx((a), (b))
112
6d068d3 @tonycoz [RT #68508] do error diffusion on gray scale if the supplied palette …
authored
113 #define color_to_grey(col) ((col)->rgb.r * 0.222 + (col)->rgb.g * 0.707 + (col)->rgb.b * 0.071)
114
74315ca @tonycoz WIP context objects
authored
115 #define IM_ERROR_COUNT 20
116 typedef struct im_context_tag {
117 int error_sp;
118 size_t error_alloc[IM_ERROR_COUNT];
119 i_errmsg error_stack[IM_ERROR_COUNT];
120 #ifdef IMAGER_LOG
6ee0c41 @tonycoz hopefully fix the seg fault on darwin
authored
121 /* the log file and level for this context */
74315ca @tonycoz WIP context objects
authored
122 FILE *lg_file;
6ee0c41 @tonycoz hopefully fix the seg fault on darwin
authored
123 int log_level;
124
125 /* whether we own the lg_file, false for stderr and for cloned contexts */
126 int own_log;
127
128 /* values supplied by lhead */
696cb85 @tonycoz WIP, more context changes
authored
129 const char *filename;
130 int line;
74315ca @tonycoz WIP context objects
authored
131 #endif
44d8648 @tonycoz WIP, it compiles
authored
132
133 /* file size limits */
134 i_img_dim max_width, max_height;
135 size_t max_bytes;
31a1347 @tonycoz implement reference counting for context objects
authored
136
fc02e37 @tonycoz add the context slot APIs
authored
137 /* per context storage */
138 size_t slot_alloc;
139 void **slots;
140
31a1347 @tonycoz implement reference counting for context objects
authored
141 ptrdiff_t refcount;
74315ca @tonycoz WIP context objects
authored
142 } im_context_struct;
143
44d8648 @tonycoz WIP, it compiles
authored
144 #define DEF_BYTES_LIMIT 0x40000000
145
faa9b3e Egads
Tony Cook authored
146 #endif
Something went wrong with that request. Please try again.