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