Commit | Line | Data |
---|---|---|
02d1d628 AMH |
1 | #ifndef _IMAGE_H_ |
2 | #define _IMAGE_H_ | |
3 | ||
4 | #include "io.h" | |
5 | #include "iolayer.h" | |
6 | #include "log.h" | |
7 | #include "stackmach.h" | |
8 | ||
9 | ||
10 | #ifndef _MSC_VER | |
11 | #include <unistd.h> | |
12 | #endif | |
13 | #include <string.h> | |
14 | #include <stdio.h> | |
15 | #include <math.h> | |
16 | #include <stdlib.h> | |
17 | ||
18 | #ifdef SUNOS | |
19 | #include <strings.h> | |
20 | #endif | |
21 | ||
22 | #ifndef PI | |
23 | #define PI 3.14159265358979323846 | |
24 | #endif | |
25 | ||
26 | #ifndef MAXINT | |
27 | #define MAXINT 2147483647 | |
28 | #endif | |
29 | ||
30 | #include "datatypes.h" | |
31 | ||
32 | undef_int i_has_format(char *frmt); | |
33 | ||
34 | /* constructors and destructors */ | |
35 | ||
36 | i_color *ICL_new_internal( unsigned char r,unsigned char g,unsigned char b,unsigned char a); | |
37 | i_color *ICL_set_internal(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a); | |
38 | void ICL_info (i_color *cl); | |
39 | void ICL_DESTROY (i_color *cl); | |
40 | void ICL_add (i_color *dst, i_color *src, int ch); | |
41 | ||
faa9b3e7 TC |
42 | extern i_fcolor *i_fcolor_new(double r, double g, double b, double a); |
43 | extern void i_fcolor_destroy(i_fcolor *cl); | |
44 | ||
6607600c TC |
45 | extern void i_rgb_to_hsvf(i_fcolor *color); |
46 | extern void i_hsv_to_rgbf(i_fcolor *color); | |
efdc2568 TC |
47 | extern void i_rgb_to_hsv(i_color *color); |
48 | extern void i_hsv_to_rgb(i_color *color); | |
6607600c | 49 | |
02d1d628 AMH |
50 | i_img *IIM_new(int x,int y,int ch); |
51 | void IIM_DESTROY(i_img *im); | |
52 | i_img *i_img_new( void ); | |
53 | i_img *i_img_empty(i_img *im,int x,int y); | |
54 | i_img *i_img_empty_ch(i_img *im,int x,int y,int ch); | |
55 | void i_img_exorcise(i_img *im); | |
56 | void i_img_destroy(i_img *im); | |
57 | ||
58 | void i_img_info(i_img *im,int *info); | |
59 | ||
faa9b3e7 | 60 | extern i_img *i_sametype(i_img *im, int xsize, int ysize); |
dff75dee | 61 | extern i_img *i_sametype_chans(i_img *im, int xsize, int ysize, int channels); |
faa9b3e7 TC |
62 | |
63 | i_img *i_img_pal_new(int x, int y, int ch, int maxpal); | |
64 | ||
02d1d628 AMH |
65 | /* Image feature settings */ |
66 | ||
67 | void i_img_setmask (i_img *im,int ch_mask); | |
68 | int i_img_getmask (i_img *im); | |
69 | int i_img_getchannels(i_img *im); | |
70 | ||
71 | /* Base functions */ | |
72 | ||
da1c841c | 73 | #if 0 |
02d1d628 AMH |
74 | int i_ppix(i_img *im,int x,int y,i_color *val); |
75 | int i_gpix(i_img *im,int x,int y,i_color *val); | |
faa9b3e7 TC |
76 | int i_ppixf(i_img *im,int x,int y,i_color *val); |
77 | int i_gpixf(i_img *im,int x,int y,i_color *val); | |
da1c841c | 78 | #endif |
02d1d628 | 79 | |
faa9b3e7 TC |
80 | #define i_ppix(im, x, y, val) (((im)->i_f_ppix)((im), (x), (y), (val))) |
81 | #define i_gpix(im, x, y, val) (((im)->i_f_gpix)((im), (x), (y), (val))) | |
82 | #define i_ppixf(im, x, y, val) (((im)->i_f_ppixf)((im), (x), (y), (val))) | |
83 | #define i_gpixf(im, x, y, val) (((im)->i_f_gpixf)((im), (x), (y), (val))) | |
84 | ||
85 | #if 0 | |
02d1d628 AMH |
86 | int i_ppix_d(i_img *im,int x,int y,i_color *val); |
87 | int i_gpix_d(i_img *im,int x,int y,i_color *val); | |
f261c328 TC |
88 | int i_plin_d(i_img *im,int l, int r, int y, i_color *val); |
89 | int i_glin_d(i_img *im,int l, int r, int y, i_color *val); | |
faa9b3e7 | 90 | #endif |
f261c328 TC |
91 | |
92 | #define i_plin(im, l, r, y, val) (((im)->i_f_plin)(im, l, r, y, val)) | |
93 | #define i_glin(im, l, r, y, val) (((im)->i_f_glin)(im, l, r, y, val)) | |
faa9b3e7 TC |
94 | #define i_plinf(im, l, r, y, val) (((im)->i_f_plinf)(im, l, r, y, val)) |
95 | #define i_glinf(im, l, r, y, val) (((im)->i_f_glinf)(im, l, r, y, val)) | |
96 | ||
97 | #define i_gsamp(im, l, r, y, samps, chans, count) \ | |
98 | (((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count))) | |
99 | #define i_gsampf(im, l, r, y, samps, chans, count) \ | |
100 | (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count))) | |
101 | ||
da1c841c AMH |
102 | #define i_psamp(im, l, r, y, samps, chans, count) \ |
103 | (((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count))) | |
104 | #define i_psampf(im, l, r, y, samps, chans, count) \ | |
105 | (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count))) | |
106 | ||
107 | ||
108 | ||
109 | ||
faa9b3e7 TC |
110 | #define i_findcolor(im, color, entry) \ |
111 | (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0) | |
112 | ||
113 | #define i_gpal(im, l, r, y, vals) \ | |
114 | (((im)->i_f_gpal) ? ((im)->i_f_gpal)((im), (l), (r), (y), (vals)) : 0) | |
115 | #define i_ppal(im, l, r, y, vals) \ | |
116 | (((im)->i_f_ppal) ? ((im)->i_f_ppal)((im), (l), (r), (y), (vals)) : 0) | |
117 | #define i_addcolors(im, colors, count) \ | |
261f91c5 | 118 | (((im)->i_f_addcolors) ? ((im)->i_f_addcolors)((im), (colors), (count)) : -1) |
faa9b3e7 TC |
119 | #define i_getcolors(im, index, color, count) \ |
120 | (((im)->i_f_getcolors) ? \ | |
121 | ((im)->i_f_getcolors)((im), (index), (color), (count)) : 0) | |
122 | #define i_setcolors(im, index, color, count) \ | |
123 | (((im)->i_f_setcolors) ? \ | |
124 | ((im)->i_f_setcolors)((im), (index), (color), (count)) : 0) | |
125 | #define i_colorcount(im) \ | |
126 | (((im)->i_f_colorcount) ? ((im)->i_f_colorcount)(im) : -1) | |
127 | #define i_maxcolors(im) \ | |
128 | (((im)->i_f_maxcolors) ? ((im)->i_f_maxcolors)(im) : -1) | |
129 | #define i_findcolor(im, color, entry) \ | |
130 | (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0) | |
131 | ||
132 | #define i_img_virtual(im) ((im)->virtual) | |
133 | #define i_img_type(im) ((im)->type) | |
134 | #define i_img_bits(im) ((im)->bits) | |
02d1d628 | 135 | |
f1ac5027 TC |
136 | /* Generic fills */ |
137 | struct i_fill_tag; | |
138 | ||
139 | typedef void (*i_fill_with_color_f) | |
140 | (struct i_fill_tag *fill, int x, int y, int width, int channels, | |
43c5dacb | 141 | i_color *data); |
f1ac5027 TC |
142 | typedef void (*i_fill_with_fcolor_f) |
143 | (struct i_fill_tag *fill, int x, int y, int width, int channels, | |
43c5dacb | 144 | i_fcolor *data); |
f1ac5027 | 145 | typedef void (*i_fill_destroy_f)(struct i_fill_tag *fill); |
efdc2568 TC |
146 | typedef void (*i_fill_combine_f)(i_color *out, i_color *in, int channels, |
147 | int count); | |
148 | typedef void (*i_fill_combinef_f)(i_fcolor *out, i_fcolor *in, int channels, | |
149 | int count); | |
150 | ||
f1ac5027 TC |
151 | |
152 | typedef struct i_fill_tag | |
153 | { | |
154 | /* called for 8-bit/sample image (and maybe lower) */ | |
155 | /* this may be NULL, if so call fill_with_fcolor */ | |
156 | i_fill_with_color_f fill_with_color; | |
157 | ||
158 | /* called for other sample sizes */ | |
159 | /* this must be non-NULL */ | |
160 | i_fill_with_fcolor_f fill_with_fcolor; | |
161 | ||
162 | /* called if non-NULL to release any extra resources */ | |
163 | i_fill_destroy_f destroy; | |
164 | ||
165 | /* if non-zero the caller will fill data with the original data | |
166 | from the image */ | |
efdc2568 TC |
167 | i_fill_combine_f combine; |
168 | i_fill_combinef_f combinef; | |
f1ac5027 TC |
169 | } i_fill_t; |
170 | ||
efdc2568 TC |
171 | typedef enum { |
172 | ic_none, | |
173 | ic_normal, | |
174 | ic_multiply, | |
175 | ic_dissolve, | |
176 | ic_add, | |
177 | ic_subtract, | |
178 | ic_diff, | |
179 | ic_lighten, | |
180 | ic_darken, | |
181 | ic_hue, | |
182 | ic_sat, | |
183 | ic_value, | |
184 | ic_color | |
185 | } i_combine_t; | |
186 | ||
f1ac5027 TC |
187 | extern i_fill_t *i_new_fill_solidf(i_fcolor *c, int combine); |
188 | extern i_fill_t *i_new_fill_solid(i_color *c, int combine); | |
189 | extern i_fill_t * | |
190 | i_new_fill_hatch(i_color *fg, i_color *bg, int combine, int hatch, | |
191 | unsigned char *cust_hatch, int dx, int dy); | |
192 | extern i_fill_t * | |
193 | i_new_fill_hatchf(i_fcolor *fg, i_fcolor *bg, int combine, int hatch, | |
194 | unsigned char *cust_hatch, int dx, int dy); | |
f576ce7e TC |
195 | extern i_fill_t * |
196 | i_new_fill_image(i_img *im, double *matrix, int xoff, int yoff, int combine); | |
f1ac5027 TC |
197 | extern void i_fill_destroy(i_fill_t *fill); |
198 | ||
02d1d628 AMH |
199 | float i_gpix_pch(i_img *im,int x,int y,int ch); |
200 | ||
201 | /* functions for drawing primitives */ | |
202 | ||
203 | void i_box (i_img *im,int x1,int y1,int x2,int y2,i_color *val); | |
204 | void i_box_filled (i_img *im,int x1,int y1,int x2,int y2,i_color *val); | |
f1ac5027 | 205 | void i_box_cfill(i_img *im, int x1, int y1, int x2, int y2, i_fill_t *fill); |
aa833c97 | 206 | void i_line (i_img *im,int x1,int y1,int x2,int y2,i_color *val, int endp); |
b437ce0a | 207 | void i_line_aa (i_img *im,int x1,int y1,int x2,int y2,i_color *val, int endp); |
02d1d628 | 208 | void i_arc (i_img *im,int x,int y,float rad,float d1,float d2,i_color *val); |
f1ac5027 | 209 | void i_arc_cfill(i_img *im,int x,int y,float rad,float d1,float d2,i_fill_t *fill); |
6af18d2b | 210 | void i_circle_aa (i_img *im,float x, float y,float rad,i_color *val); |
02d1d628 AMH |
211 | void i_copyto (i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty); |
212 | void i_copyto_trans(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty,i_color *trans); | |
213 | void i_copy (i_img *im,i_img *src); | |
71dc4a83 AMH |
214 | int i_rubthru (i_img *im, i_img *src, int tx, int ty, int src_minx, int src_miny, int src_maxx, int src_maxy); |
215 | ||
02d1d628 | 216 | |
142c26ff | 217 | undef_int i_flipxy (i_img *im, int direction); |
faa9b3e7 TC |
218 | extern i_img *i_rotate90(i_img *im, int degrees); |
219 | extern i_img *i_rotate_exact(i_img *im, double amount); | |
220 | extern i_img *i_matrix_transform(i_img *im, int xsize, int ysize, double *matrix); | |
142c26ff | 221 | |
02d1d628 AMH |
222 | void i_bezier_multi(i_img *im,int l,double *x,double *y,i_color *val); |
223 | void i_poly_aa (i_img *im,int l,double *x,double *y,i_color *val); | |
43c5dacb | 224 | void i_poly_aa_cfill(i_img *im,int l,double *x,double *y,i_fill_t *fill); |
02d1d628 | 225 | |
a321d497 AMH |
226 | undef_int i_flood_fill (i_img *im,int seedx,int seedy,i_color *dcol); |
227 | undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill); | |
228 | ||
02d1d628 AMH |
229 | |
230 | /* image processing functions */ | |
231 | ||
232 | void i_gaussian (i_img *im,float stdev); | |
233 | void i_conv (i_img *im,float *coeff,int len); | |
b6381851 | 234 | void i_unsharp_mask(i_img *im, double stddev, double scale); |
02d1d628 | 235 | |
f5991c03 TC |
236 | /* colour manipulation */ |
237 | extern int i_convert(i_img *im, i_img *src, float *coeff, int outchan, int inchan); | |
faa9b3e7 | 238 | extern void i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask); |
f5991c03 | 239 | |
02d1d628 AMH |
240 | float i_img_diff (i_img *im1,i_img *im2); |
241 | ||
242 | /* font routines */ | |
243 | ||
4cb58f1b | 244 | undef_int i_init_fonts( int t1log ); |
02d1d628 AMH |
245 | |
246 | #ifdef HAVE_LIBT1 | |
247 | #include <t1lib.h> | |
248 | ||
b33c08f8 | 249 | undef_int i_init_t1( int t1log ); |
02d1d628 AMH |
250 | int i_t1_new( char *pfb, char *afm ); |
251 | int i_t1_destroy( int font_id ); | |
1bd75e4c TC |
252 | undef_int i_t1_cp( i_img *im, int xb, int yb, int channel, int fontnum, float points, char* str, int len, int align, int utf8, char const *flags ); |
253 | undef_int i_t1_text( i_img *im, int xb, int yb, i_color *cl, int fontnum, float points, char* str, int len, int align, int utf8, char const *flags ); | |
3799c4d1 | 254 | int i_t1_bbox( int fontnum, float point, char *str, int len, int cords[6], int utf8, char const *flags ); |
02d1d628 AMH |
255 | void i_t1_set_aa( int st ); |
256 | void close_t1( void ); | |
3799c4d1 TC |
257 | int i_t1_has_chars(int font_num, char const *text, int len, int utf8, char *out); |
258 | extern int i_t1_face_name(int font_num, char *name_buf, size_t name_buf_size); | |
259 | extern int i_t1_glyph_name(int font_num, unsigned long ch, char *name_buf, | |
260 | size_t name_buf_size); | |
02d1d628 AMH |
261 | #endif |
262 | ||
263 | #ifdef HAVE_LIBTT | |
264 | ||
4f68b48f | 265 | struct TT_Fonthandle_; |
02d1d628 AMH |
266 | |
267 | typedef struct TT_Fonthandle_ TT_Fonthandle; | |
268 | ||
b33c08f8 | 269 | undef_int i_init_tt( void ); |
02d1d628 AMH |
270 | TT_Fonthandle* i_tt_new(char *fontname); |
271 | void i_tt_destroy( TT_Fonthandle *handle ); | |
4f68b48f TC |
272 | undef_int i_tt_cp( TT_Fonthandle *handle,i_img *im,int xb,int yb,int channel,float points,char const* txt,int len,int smooth, int utf8); |
273 | undef_int i_tt_text( TT_Fonthandle *handle, i_img *im, int xb, int yb, i_color *cl, float points, char const* txt, int len, int smooth, int utf8); | |
274 | undef_int i_tt_bbox( TT_Fonthandle *handle, float points,char *txt,int len,int cords[6], int utf8); | |
eeaa33fd | 275 | int i_tt_has_chars(TT_Fonthandle *handle, char const *text, int len, int utf8, char *out); |
3799c4d1 TC |
276 | void i_tt_dump_names(TT_Fonthandle *handle); |
277 | int i_tt_face_name(TT_Fonthandle *handle, char *name_buf, | |
278 | size_t name_buf_size); | |
279 | int i_tt_glyph_name(TT_Fonthandle *handle, unsigned long ch, char *name_buf, | |
280 | size_t name_buf_size); | |
02d1d628 AMH |
281 | |
282 | #endif /* End of freetype headers */ | |
283 | ||
faa9b3e7 TC |
284 | #ifdef HAVE_FT2 |
285 | ||
286 | typedef struct FT2_Fonthandle FT2_Fonthandle; | |
287 | extern int i_ft2_init(void); | |
288 | extern FT2_Fonthandle * i_ft2_new(char *name, int index); | |
289 | extern void i_ft2_destroy(FT2_Fonthandle *handle); | |
290 | extern int i_ft2_setdpi(FT2_Fonthandle *handle, int xdpi, int ydpi); | |
291 | extern int i_ft2_getdpi(FT2_Fonthandle *handle, int *xdpi, int *ydpi); | |
292 | extern int i_ft2_settransform(FT2_Fonthandle *handle, double *matrix); | |
293 | extern int i_ft2_sethinting(FT2_Fonthandle *handle, int hinting); | |
294 | extern int i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth, | |
4f68b48f | 295 | char const *text, int len, int *bbox, int utf8); |
faa9b3e7 TC |
296 | extern int i_ft2_text(FT2_Fonthandle *handle, i_img *im, int tx, int ty, |
297 | i_color *cl, double cheight, double cwidth, | |
4f68b48f TC |
298 | char const *text, int len, int align, int aa, |
299 | int vlayout, int utf8); | |
faa9b3e7 TC |
300 | extern int i_ft2_cp(FT2_Fonthandle *handle, i_img *im, int tx, int ty, |
301 | int channel, double cheight, double cwidth, | |
4f68b48f | 302 | char const *text, int len, int align, int aa, int vlayout, |
faa9b3e7 | 303 | int utf8); |
4f68b48f | 304 | extern int i_ft2_has_chars(FT2_Fonthandle *handle, char const *text, int len, |
3dec2c92 | 305 | int utf8, char *work); |
3799c4d1 TC |
306 | extern int i_ft2_face_name(FT2_Fonthandle *handle, char *name_buf, |
307 | size_t name_buf_size); | |
308 | extern int i_ft2_glyph_name(FT2_Fonthandle *handle, unsigned char ch, | |
309 | char *name_buf, size_t name_buf_size); | |
310 | extern int i_ft2_can_do_glyph_names(void); | |
311 | extern int i_ft2_face_has_glyph_names(FT2_Fonthandle *handle); | |
02d1d628 | 312 | |
faa9b3e7 | 313 | #endif |
02d1d628 | 314 | |
faa9b3e7 | 315 | #ifdef WIN32 |
02d1d628 | 316 | |
faa9b3e7 TC |
317 | extern int i_wf_bbox(char *face, int size, char *text, int length, int *bbox); |
318 | extern int i_wf_text(char *face, i_img *im, int tx, int ty, i_color *cl, | |
319 | int size, char *text, int len, int align, int aa); | |
320 | extern int i_wf_cp(char *face, i_img *im, int tx, int ty, int channel, | |
321 | int size, char *text, int len, int align, int aa); | |
02d1d628 | 322 | |
faa9b3e7 | 323 | #endif |
02d1d628 AMH |
324 | |
325 | /* functions for reading and writing formats */ | |
326 | ||
327 | /* general reader callback | |
328 | userdata - data the user passed into the reader | |
329 | buffer - the buffer to fill with data | |
330 | need - the amount of data needed | |
331 | want - the amount of space we have to store data | |
332 | fill buffer and return the number of bytes read, 0 for eof, -1 for error | |
333 | */ | |
334 | ||
335 | typedef int (*i_read_callback_t)(char *userdata, char *buffer, int need, | |
336 | int want); | |
337 | ||
338 | /* i_gen_reader() translates the low-level requests from whatever library | |
339 | into buffered requests. | |
340 | but the called function can always bypass buffering by only ever | |
341 | reading I<need> bytes. | |
342 | */ | |
343 | #define CBBUFSIZ 4096 | |
344 | ||
345 | typedef struct { | |
346 | i_read_callback_t cb; | |
347 | char *userdata; | |
348 | char buffer[CBBUFSIZ]; | |
349 | int length; | |
350 | int cpos; | |
351 | } i_gen_read_data; | |
352 | ||
353 | extern int i_gen_reader(i_gen_read_data *info, char *buffer, int need); | |
354 | extern i_gen_read_data *i_gen_read_data_new(i_read_callback_t cb, char *userdata); | |
b33c08f8 | 355 | extern void i_free_gen_read_data(i_gen_read_data *); |
02d1d628 AMH |
356 | |
357 | /* general writer callback | |
358 | userdata - the data the user passed into the writer | |
359 | data - the data to write | |
360 | data_size - the number of bytes to write | |
361 | write the data, return non-zero on success, zero on failure. | |
362 | */ | |
363 | typedef int (*i_write_callback_t)(char *userdata, char const *data, int size); | |
364 | ||
365 | typedef struct { | |
366 | i_write_callback_t cb; | |
367 | char *userdata; | |
368 | char buffer[CBBUFSIZ]; | |
369 | int maxlength; | |
370 | int filledto; | |
371 | } i_gen_write_data; | |
372 | ||
373 | extern int i_gen_writer(i_gen_write_data *info, char const *data, int size); | |
374 | extern i_gen_write_data *i_gen_write_data_new(i_write_callback_t cb, char *userdata, int maxlength); | |
b33c08f8 | 375 | extern int i_free_gen_write_data(i_gen_write_data *, int flush); |
02d1d628 AMH |
376 | |
377 | /* transparency handling for quantized output */ | |
378 | typedef enum i_transp_tag { | |
379 | tr_none, /* ignore any alpha channel */ | |
380 | tr_threshold, /* threshold the transparency - uses tr_threshold */ | |
381 | tr_errdiff, /* error diffusion */ | |
382 | tr_ordered /* an ordered dither */ | |
383 | } i_transp; | |
384 | ||
385 | /* controls how we build the colour map */ | |
386 | typedef enum i_make_colors_tag { | |
387 | mc_none, /* user supplied colour map only */ | |
388 | mc_web_map, /* Use the 216 colour web colour map */ | |
389 | mc_addi, /* Addi's algorithm */ | |
97c4effc | 390 | mc_median_cut, /* median cut - similar to giflib, hopefully */ |
02d1d628 AMH |
391 | mc_mask = 0xFF /* (mask for generator) */ |
392 | } i_make_colors; | |
393 | ||
394 | /* controls how we translate the colours */ | |
395 | typedef enum i_translate_tag { | |
396 | pt_giflib, /* get gif lib to do it (ignores make_colours) */ | |
397 | pt_closest, /* just use the closest match within the hashbox */ | |
398 | pt_perturb, /* randomly perturb the data - uses perturb_size*/ | |
399 | pt_errdiff /* error diffusion dither - uses errdiff */ | |
400 | } i_translate; | |
401 | ||
402 | /* Which error diffusion map to use */ | |
403 | typedef enum i_errdiff_tag { | |
404 | ed_floyd, /* floyd-steinberg */ | |
405 | ed_jarvis, /* Jarvis, Judice and Ninke */ | |
406 | ed_stucki, /* Stucki */ | |
407 | ed_custom, /* the map found in ed_map|width|height|orig */ | |
408 | ed_mask = 0xFF, /* mask to get the map */ | |
409 | ed_bidir = 0x100 /* change direction for each row */ | |
410 | } i_errdiff; | |
411 | ||
412 | /* which ordered dither map to use | |
413 | currently only available for transparency | |
414 | I don't know of a way to do ordered dither of an image against some | |
415 | general palette | |
416 | */ | |
417 | typedef enum i_ord_dith_tag | |
418 | { | |
419 | od_random, /* sort of random */ | |
420 | od_dot8, /* large dot */ | |
421 | od_dot4, | |
422 | od_hline, | |
423 | od_vline, | |
424 | od_slashline, /* / line dither */ | |
425 | od_backline, /* \ line dither */ | |
34ba4c5b | 426 | od_tiny, /* small checkerbox */ |
02d1d628 AMH |
427 | od_custom /* custom 8x8 map */ |
428 | } i_ord_dith; | |
429 | ||
430 | typedef struct i_gif_pos_tag { | |
431 | int x, y; | |
432 | } i_gif_pos; | |
433 | ||
434 | /* passed into i_writegif_gen() to control quantization */ | |
435 | typedef struct i_quantize_tag { | |
436 | /* how to handle transparency */ | |
437 | i_transp transp; | |
438 | /* the threshold at which to make pixels opaque */ | |
439 | int tr_threshold; | |
440 | i_errdiff tr_errdiff; | |
441 | i_ord_dith tr_orddith; | |
442 | unsigned char tr_custom[64]; | |
443 | ||
444 | /* how to make the colour map */ | |
445 | i_make_colors make_colors; | |
446 | ||
447 | /* any existing colours | |
448 | mc_existing is an existing colour table | |
449 | mc_count is the number of existing colours | |
450 | mc_size is the total size of the array that mc_existing points | |
451 | at - this must be at least 256 | |
452 | */ | |
453 | i_color *mc_colors; | |
454 | int mc_size; | |
455 | int mc_count; | |
456 | ||
457 | /* how we translate the colours */ | |
458 | i_translate translate; | |
459 | ||
460 | /* the error diffusion map to use if translate is mc_errdiff */ | |
461 | i_errdiff errdiff; | |
462 | /* the following define the error diffusion values to use if | |
463 | errdiff is ed_custom. ed_orig is the column on the top row that | |
464 | represents the current | |
465 | */ | |
466 | int *ed_map; | |
467 | int ed_width, ed_height, ed_orig; | |
468 | ||
469 | /* the amount of perturbation to use for translate is mc_perturb */ | |
470 | int perturb; | |
471 | } i_quantize; | |
472 | ||
473 | typedef struct i_gif_opts { | |
474 | /* each image has a local color map */ | |
475 | int each_palette; | |
476 | ||
477 | /* images are interlaced */ | |
478 | int interlace; | |
479 | ||
480 | /* time for which image is displayed | |
481 | (in 1/100 seconds) | |
482 | default: 0 | |
483 | */ | |
484 | int delay_count; | |
485 | int *delays; | |
486 | ||
487 | /* user input flags | |
488 | default: 0 | |
489 | */ | |
490 | int user_input_count; | |
491 | char *user_input_flags; | |
492 | ||
493 | /* disposal | |
494 | default: 0 */ | |
495 | int disposal_count; | |
496 | char *disposal; | |
497 | ||
498 | /* this is added to the color table when we make an image transparent */ | |
499 | i_color tran_color; | |
500 | ||
501 | /* image positions */ | |
502 | int position_count; | |
503 | i_gif_pos *positions; | |
504 | ||
505 | /* Netscape loop extension - number of loops */ | |
506 | int loop_count; | |
bf9dd17c TC |
507 | |
508 | /* should be eliminate unused colors? */ | |
509 | int eliminate_unused; | |
02d1d628 AMH |
510 | } i_gif_opts; |
511 | ||
512 | extern void quant_makemap(i_quantize *quant, i_img **imgs, int count); | |
513 | extern i_palidx *quant_translate(i_quantize *quant, i_img *img); | |
514 | extern void quant_transparent(i_quantize *quant, i_palidx *indices, i_img *img, i_palidx trans_index); | |
515 | ||
faa9b3e7 TC |
516 | extern i_img *i_img_pal_new(int x, int y, int channels, int maxpal); |
517 | extern i_img *i_img_pal_new_low(i_img *im, int x, int y, int channels, int maxpal); | |
518 | extern i_img *i_img_to_pal(i_img *src, i_quantize *quant); | |
519 | extern i_img *i_img_to_rgb(i_img *src); | |
520 | extern i_img *i_img_masked_new(i_img *targ, i_img *mask, int x, int y, | |
521 | int w, int h); | |
522 | extern i_img *i_img_16_new(int x, int y, int ch); | |
523 | extern i_img *i_img_16_new_low(i_img *im, int x, int y, int ch); | |
365ea842 TC |
524 | extern i_img *i_img_double_new(int x, int y, int ch); |
525 | extern i_img *i_img_double_new_low(i_img *im, int x, int y, int ch); | |
faa9b3e7 | 526 | |
e10bf46e AMH |
527 | |
528 | char * i_test_format_probe(io_glue *data, int length); | |
529 | ||
530 | ||
02d1d628 | 531 | #ifdef HAVE_LIBJPEG |
dd55acc8 AMH |
532 | i_img * |
533 | i_readjpeg_wiol(io_glue *ig, int length, char** iptc_itext, int *itlength); | |
534 | undef_int i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor); | |
02d1d628 AMH |
535 | #endif /* HAVE_LIBJPEG */ |
536 | ||
537 | #ifdef HAVE_LIBTIFF | |
04418ecc | 538 | i_img * i_readtiff_wiol(io_glue *ig, int length); |
10461f9a | 539 | i_img ** i_readtiff_multi_wiol(io_glue *ig, int length, int *count); |
02d1d628 | 540 | undef_int i_writetiff_wiol(i_img *im, io_glue *ig); |
10461f9a | 541 | undef_int i_writetiff_multi_wiol(io_glue *ig, i_img **imgs, int count); |
4c2d6970 | 542 | undef_int i_writetiff_wiol_faxable(i_img *im, io_glue *ig, int fine); |
10461f9a | 543 | undef_int i_writetiff_multi_wiol_faxable(io_glue *ig, i_img **imgs, int count, int fine); |
02d1d628 AMH |
544 | |
545 | #endif /* HAVE_LIBTIFF */ | |
546 | ||
547 | #ifdef HAVE_LIBPNG | |
04418ecc AMH |
548 | i_img *i_readpng_wiol(io_glue *ig, int length); |
549 | undef_int i_writepng_wiol(i_img *im, io_glue *ig); | |
02d1d628 AMH |
550 | #endif /* HAVE_LIBPNG */ |
551 | ||
552 | #ifdef HAVE_LIBGIF | |
faa9b3e7 | 553 | i_img *i_readgif(int fd, int **colour_table, int *colours); |
10461f9a | 554 | i_img *i_readgif_wiol(io_glue *ig, int **colour_table, int *colours); |
faa9b3e7 TC |
555 | i_img *i_readgif_scalar(char *data, int length, int **colour_table, int *colours); |
556 | i_img *i_readgif_callback(i_read_callback_t callback, char *userdata, int **colour_table, int *colours); | |
557 | extern i_img **i_readgif_multi(int fd, int *count); | |
558 | extern i_img **i_readgif_multi_scalar(char *data, int length, int *count); | |
559 | extern i_img **i_readgif_multi_callback(i_read_callback_t callback, char *userdata, int *count); | |
10461f9a | 560 | extern i_img **i_readgif_multi_wiol(io_glue *ig, int *count); |
02d1d628 AMH |
561 | undef_int i_writegif(i_img *im,int fd,int colors,int pixdev,int fixedlen,i_color fixed[]); |
562 | undef_int i_writegifmc(i_img *im,int fd,int colors); | |
563 | undef_int i_writegifex(i_img *im,int fd); | |
97c4effc TC |
564 | undef_int i_writegif_gen(i_quantize *quant, int fd, i_img **imgs, int count); |
565 | undef_int i_writegif_callback(i_quantize *quant, i_write_callback_t cb, char *userdata, int maxbuffer, i_img **imgs, int count); | |
566 | undef_int i_writegif_wiol(io_glue *ig, i_quantize *quant, | |
10461f9a | 567 | i_img **imgs, int count); |
02d1d628 AMH |
568 | void i_qdist(i_img *im); |
569 | ||
570 | #endif /* HAVE_LIBGIF */ | |
571 | ||
04418ecc | 572 | i_img * i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, int intrl); |
895dbd34 | 573 | undef_int i_writeraw_wiol(i_img* im, io_glue *ig); |
02d1d628 | 574 | |
04418ecc | 575 | i_img * i_readpnm_wiol(io_glue *ig, int length); |
067d6bdc | 576 | undef_int i_writeppm_wiol(i_img *im, io_glue *ig); |
02d1d628 | 577 | |
1ec86afa | 578 | extern int i_writebmp_wiol(i_img *im, io_glue *ig); |
d08b8f85 | 579 | extern i_img *i_readbmp_wiol(io_glue *ig); |
02d1d628 | 580 | |
84e51293 AMH |
581 | int tga_header_verify(unsigned char headbuf[18]); |
582 | ||
1ec86afa | 583 | i_img * i_readtga_wiol(io_glue *ig, int length); |
febba01f | 584 | undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen); |
1ec86afa | 585 | |
737a830c AMH |
586 | i_img * i_readrgb_wiol(io_glue *ig, int length); |
587 | undef_int i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen); | |
588 | ||
04418ecc AMH |
589 | i_img * i_scaleaxis(i_img *im, float Value, int Axis); |
590 | i_img * i_scale_nn(i_img *im, float scx, float scy); | |
591 | i_img * i_haar(i_img *im); | |
592 | int i_count_colors(i_img *im,int maxc); | |
02d1d628 | 593 | |
04418ecc | 594 | i_img * i_transform(i_img *im, int *opx,int opxl,int *opy,int opyl,double parm[],int parmlen); |
02d1d628 AMH |
595 | |
596 | struct rm_op; | |
04418ecc AMH |
597 | i_img * i_transform2(int width, int height, int channels, |
598 | struct rm_op *ops, int ops_count, | |
599 | double *n_regs, int n_regs_count, | |
600 | i_color *c_regs, int c_regs_count, | |
601 | i_img **in_imgs, int in_imgs_count); | |
febba01f | 602 | |
02d1d628 AMH |
603 | /* filters */ |
604 | ||
605 | void i_contrast(i_img *im, float intensity); | |
606 | void i_hardinvert(i_img *im); | |
607 | void i_noise(i_img *im, float amount, unsigned char type); | |
608 | void i_bumpmap(i_img *im,i_img *bump,int channel,int light_x,int light_y,int strength); | |
b2778574 AMH |
609 | void i_bumpmap_complex(i_img *im, i_img *bump, int channel, int tx, int ty, float Lx, float Ly, |
610 | float Lz, float cd, float cs, float n, i_color *Ia, i_color *Il, i_color *Is); | |
02d1d628 AMH |
611 | void i_postlevels(i_img *im,int levels); |
612 | void i_mosaic(i_img *im,int size); | |
613 | void i_watermark(i_img *im,i_img *wmark,int tx,int ty,int pixdiff); | |
614 | void i_autolevels(i_img *im,float lsat,float usat,float skew); | |
615 | void i_radnoise(i_img *im,int xo,int yo,float rscale,float ascale); | |
616 | void i_turbnoise(i_img *im,float xo,float yo,float scale); | |
617 | void i_gradgen(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure); | |
618 | void i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure); | |
dff75dee | 619 | i_img *i_diff_image(i_img *im, i_img *im2, int mindist); |
6607600c TC |
620 | typedef enum { |
621 | i_fst_linear, | |
622 | i_fst_curved, | |
623 | i_fst_sine, | |
624 | i_fst_sphere_up, | |
625 | i_fst_sphere_down, | |
626 | i_fst_end | |
627 | } i_fountain_seg_type; | |
628 | typedef enum { | |
629 | i_fc_direct, | |
630 | i_fc_hue_up, | |
631 | i_fc_hue_down, | |
632 | i_fc_end | |
633 | } i_fountain_color; | |
634 | typedef struct { | |
635 | double start, middle, end; | |
636 | i_fcolor c[2]; | |
637 | i_fountain_seg_type type; | |
638 | i_fountain_color color; | |
639 | } i_fountain_seg; | |
640 | typedef enum { | |
641 | i_fr_none, | |
642 | i_fr_sawtooth, | |
643 | i_fr_triangle, | |
644 | i_fr_saw_both, | |
645 | i_fr_tri_both | |
646 | } i_fountain_repeat; | |
647 | typedef enum { | |
648 | i_ft_linear, | |
649 | i_ft_bilinear, | |
650 | i_ft_radial, | |
651 | i_ft_radial_square, | |
652 | i_ft_revolution, | |
653 | i_ft_conical, | |
654 | i_ft_end | |
655 | } i_fountain_type; | |
656 | typedef enum { | |
657 | i_fts_none, | |
658 | i_fts_grid, | |
659 | i_fts_random, | |
660 | i_fts_circle | |
661 | } i_ft_supersample; | |
662 | void i_fountain(i_img *im, double xa, double ya, double xb, double yb, | |
663 | i_fountain_type type, i_fountain_repeat repeat, | |
664 | int combine, int super_sample, double ssample_param, | |
665 | int count, i_fountain_seg *segs); | |
f1ac5027 TC |
666 | extern i_fill_t * |
667 | i_new_fill_fount(double xa, double ya, double xb, double yb, | |
668 | i_fountain_type type, i_fountain_repeat repeat, | |
669 | int combine, int super_sample, double ssample_param, | |
670 | int count, i_fountain_seg *segs); | |
02d1d628 AMH |
671 | |
672 | /* Debug only functions */ | |
673 | ||
674 | void malloc_state( void ); | |
675 | ||
676 | /* this is sort of obsolete now */ | |
677 | ||
678 | typedef struct { | |
679 | undef_int (*i_has_format)(char *frmt); | |
680 | i_color*(*ICL_set)(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a); | |
681 | void (*ICL_info)(i_color *cl); | |
682 | ||
683 | i_img*(*i_img_new)( void ); | |
684 | i_img*(*i_img_empty)(i_img *im,int x,int y); | |
685 | i_img*(*i_img_empty_ch)(i_img *im,int x,int y,int ch); | |
686 | void(*i_img_exorcise)(i_img *im); | |
687 | ||
688 | void(*i_img_info)(i_img *im,int *info); | |
689 | ||
690 | void(*i_img_setmask)(i_img *im,int ch_mask); | |
691 | int (*i_img_getmask)(i_img *im); | |
692 | ||
da1c841c | 693 | /* |
02d1d628 AMH |
694 | int (*i_ppix)(i_img *im,int x,int y,i_color *val); |
695 | int (*i_gpix)(i_img *im,int x,int y,i_color *val); | |
da1c841c | 696 | */ |
02d1d628 | 697 | void(*i_box)(i_img *im,int x1,int y1,int x2,int y2,i_color *val); |
aa833c97 | 698 | void(*i_line)(i_img *im,int x1,int y1,int x2,int y2,i_color *val,int endp); |
02d1d628 AMH |
699 | void(*i_arc)(i_img *im,int x,int y,float rad,float d1,float d2,i_color *val); |
700 | void(*i_copyto)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty); | |
701 | void(*i_copyto_trans)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty,i_color *trans); | |
faa9b3e7 | 702 | int(*i_rubthru)(i_img *im,i_img *src,int tx,int ty); |
02d1d628 AMH |
703 | |
704 | } symbol_table_t; | |
705 | ||
848ba81a TC |
706 | /* error handling |
707 | see error.c for documentation | |
708 | the error information is currently global | |
709 | */ | |
710 | typedef struct { | |
711 | char *msg; | |
712 | int code; | |
713 | } i_errmsg; | |
a743c0a6 | 714 | |
848ba81a TC |
715 | typedef void (*i_error_cb)(int code, char const *msg); |
716 | typedef void (*i_failed_cb)(i_errmsg *msgs); | |
717 | extern i_error_cb i_set_error_cb(i_error_cb); | |
718 | extern i_failed_cb i_set_failed_cb(i_failed_cb); | |
719 | extern void i_set_argv0(char const *); | |
720 | extern int i_set_errors_fatal(int new_fatal); | |
faa9b3e7 | 721 | extern i_errmsg *i_errors(void); |
848ba81a TC |
722 | |
723 | extern void i_push_error(int code, char const *msg); | |
724 | extern void i_push_errorf(int code, char const *fmt, ...); | |
725 | extern void i_push_errorvf(int code, char const *fmt, va_list); | |
faa9b3e7 | 726 | extern void i_clear_error(void); |
848ba81a | 727 | extern int i_failed(int code, char const *msg); |
02d1d628 | 728 | |
faa9b3e7 TC |
729 | /* image tag processing */ |
730 | extern void i_tags_new(i_img_tags *tags); | |
97c4effc TC |
731 | extern int i_tags_addn(i_img_tags *tags, char const *name, int code, |
732 | int idata); | |
733 | extern int i_tags_add(i_img_tags *tags, char const *name, int code, | |
734 | char const *data, int size, int idata); | |
faa9b3e7 | 735 | extern void i_tags_destroy(i_img_tags *tags); |
97c4effc TC |
736 | extern int i_tags_find(i_img_tags *tags, char const *name, int start, |
737 | int *entry); | |
faa9b3e7 TC |
738 | extern int i_tags_findn(i_img_tags *tags, int code, int start, int *entry); |
739 | extern int i_tags_delete(i_img_tags *tags, int entry); | |
97c4effc | 740 | extern int i_tags_delbyname(i_img_tags *tags, char const *name); |
faa9b3e7 | 741 | extern int i_tags_delbycode(i_img_tags *tags, int code); |
97c4effc | 742 | extern int i_tags_get_float(i_img_tags *tags, char const *name, int code, |
fd9a31d2 | 743 | double *value); |
97c4effc | 744 | extern int i_tags_set_float(i_img_tags *tags, char const *name, int code, |
fd9a31d2 | 745 | double value); |
97c4effc TC |
746 | extern int i_tags_get_int(i_img_tags *tags, char const *name, int code, |
747 | int *value); | |
748 | extern int i_tags_get_string(i_img_tags *tags, char const *name, int code, | |
fd9a31d2 | 749 | char *value, size_t value_size); |
97c4effc TC |
750 | extern int i_tags_get_color(i_img_tags *tags, char const *name, int code, |
751 | i_color *value); | |
752 | extern int i_tags_set_color(i_img_tags *tags, char const *name, int code, | |
753 | i_color const *value); | |
fd9a31d2 | 754 | extern void i_tags_print(i_img_tags *tags); |
02d1d628 AMH |
755 | |
756 | #endif |