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