- the XS code for i_tt_glyph_name() used unsigned char to store a
[imager.git] / image.h
CommitLineData
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
32undef_int i_has_format(char *frmt);
33
34/* constructors and destructors */
35
36i_color *ICL_new_internal( unsigned char r,unsigned char g,unsigned char b,unsigned char a);
37i_color *ICL_set_internal(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
38void ICL_info (i_color *cl);
39void ICL_DESTROY (i_color *cl);
40void ICL_add (i_color *dst, i_color *src, int ch);
41
faa9b3e7
TC
42extern i_fcolor *i_fcolor_new(double r, double g, double b, double a);
43extern void i_fcolor_destroy(i_fcolor *cl);
44
6607600c
TC
45extern void i_rgb_to_hsvf(i_fcolor *color);
46extern void i_hsv_to_rgbf(i_fcolor *color);
efdc2568
TC
47extern void i_rgb_to_hsv(i_color *color);
48extern void i_hsv_to_rgb(i_color *color);
6607600c 49
02d1d628
AMH
50i_img *IIM_new(int x,int y,int ch);
51void IIM_DESTROY(i_img *im);
52i_img *i_img_new( void );
53i_img *i_img_empty(i_img *im,int x,int y);
54i_img *i_img_empty_ch(i_img *im,int x,int y,int ch);
55void i_img_exorcise(i_img *im);
56void i_img_destroy(i_img *im);
57
58void i_img_info(i_img *im,int *info);
59
faa9b3e7 60extern i_img *i_sametype(i_img *im, int xsize, int ysize);
dff75dee 61extern i_img *i_sametype_chans(i_img *im, int xsize, int ysize, int channels);
faa9b3e7
TC
62
63i_img *i_img_pal_new(int x, int y, int ch, int maxpal);
64
02d1d628
AMH
65/* Image feature settings */
66
67void i_img_setmask (i_img *im,int ch_mask);
68int i_img_getmask (i_img *im);
69int i_img_getchannels(i_img *im);
70
71/* Base functions */
72
da1c841c 73#if 0
02d1d628
AMH
74int i_ppix(i_img *im,int x,int y,i_color *val);
75int i_gpix(i_img *im,int x,int y,i_color *val);
faa9b3e7
TC
76int i_ppixf(i_img *im,int x,int y,i_color *val);
77int 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
86int i_ppix_d(i_img *im,int x,int y,i_color *val);
87int i_gpix_d(i_img *im,int x,int y,i_color *val);
f261c328
TC
88int i_plin_d(i_img *im,int l, int r, int y, i_color *val);
89int 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 */
137struct i_fill_tag;
138
139typedef 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
142typedef 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 145typedef void (*i_fill_destroy_f)(struct i_fill_tag *fill);
efdc2568
TC
146typedef void (*i_fill_combine_f)(i_color *out, i_color *in, int channels,
147 int count);
148typedef void (*i_fill_combinef_f)(i_fcolor *out, i_fcolor *in, int channels,
149 int count);
150
f1ac5027
TC
151
152typedef 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
171typedef 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
187extern i_fill_t *i_new_fill_solidf(i_fcolor *c, int combine);
188extern i_fill_t *i_new_fill_solid(i_color *c, int combine);
189extern i_fill_t *
190i_new_fill_hatch(i_color *fg, i_color *bg, int combine, int hatch,
191 unsigned char *cust_hatch, int dx, int dy);
192extern i_fill_t *
193i_new_fill_hatchf(i_fcolor *fg, i_fcolor *bg, int combine, int hatch,
194 unsigned char *cust_hatch, int dx, int dy);
f576ce7e
TC
195extern i_fill_t *
196i_new_fill_image(i_img *im, double *matrix, int xoff, int yoff, int combine);
f1ac5027
TC
197extern void i_fill_destroy(i_fill_t *fill);
198
02d1d628
AMH
199float i_gpix_pch(i_img *im,int x,int y,int ch);
200
201/* functions for drawing primitives */
202
203void i_box (i_img *im,int x1,int y1,int x2,int y2,i_color *val);
204void i_box_filled (i_img *im,int x1,int y1,int x2,int y2,i_color *val);
f1ac5027 205void i_box_cfill(i_img *im, int x1, int y1, int x2, int y2, i_fill_t *fill);
aa833c97 206void i_line (i_img *im,int x1,int y1,int x2,int y2,i_color *val, int endp);
b437ce0a 207void i_line_aa (i_img *im,int x1,int y1,int x2,int y2,i_color *val, int endp);
02d1d628 208void i_arc (i_img *im,int x,int y,float rad,float d1,float d2,i_color *val);
f1ac5027 209void i_arc_cfill(i_img *im,int x,int y,float rad,float d1,float d2,i_fill_t *fill);
6af18d2b 210void i_circle_aa (i_img *im,float x, float y,float rad,i_color *val);
02d1d628
AMH
211void i_copyto (i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty);
212void i_copyto_trans(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty,i_color *trans);
213void i_copy (i_img *im,i_img *src);
71dc4a83
AMH
214int 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 217undef_int i_flipxy (i_img *im, int direction);
faa9b3e7
TC
218extern i_img *i_rotate90(i_img *im, int degrees);
219extern i_img *i_rotate_exact(i_img *im, double amount);
0d3b936e 220extern i_img *i_rotate_exact_bg(i_img *im, double amount, i_color *backp, i_fcolor *fbackp);
faa9b3e7 221extern i_img *i_matrix_transform(i_img *im, int xsize, int ysize, double *matrix);
0d3b936e 222extern i_img *i_matrix_transform_bg(i_img *im, int xsize, int ysize, double *matrix, i_color *backp, i_fcolor *fbackp);
142c26ff 223
02d1d628
AMH
224void i_bezier_multi(i_img *im,int l,double *x,double *y,i_color *val);
225void i_poly_aa (i_img *im,int l,double *x,double *y,i_color *val);
43c5dacb 226void i_poly_aa_cfill(i_img *im,int l,double *x,double *y,i_fill_t *fill);
02d1d628 227
a321d497
AMH
228undef_int i_flood_fill (i_img *im,int seedx,int seedy,i_color *dcol);
229undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill);
230
02d1d628
AMH
231
232/* image processing functions */
233
234void i_gaussian (i_img *im,float stdev);
235void i_conv (i_img *im,float *coeff,int len);
b6381851 236void i_unsharp_mask(i_img *im, double stddev, double scale);
02d1d628 237
f5991c03
TC
238/* colour manipulation */
239extern int i_convert(i_img *im, i_img *src, float *coeff, int outchan, int inchan);
faa9b3e7 240extern void i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask);
f5991c03 241
02d1d628
AMH
242float i_img_diff (i_img *im1,i_img *im2);
243
244/* font routines */
245
4cb58f1b 246undef_int i_init_fonts( int t1log );
02d1d628
AMH
247
248#ifdef HAVE_LIBT1
249#include <t1lib.h>
250
b33c08f8 251undef_int i_init_t1( int t1log );
02d1d628
AMH
252int i_t1_new( char *pfb, char *afm );
253int i_t1_destroy( int font_id );
1bd75e4c
TC
254undef_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 );
255undef_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 256int i_t1_bbox( int fontnum, float point, char *str, int len, int cords[6], int utf8, char const *flags );
02d1d628
AMH
257void i_t1_set_aa( int st );
258void close_t1( void );
3799c4d1
TC
259int i_t1_has_chars(int font_num, char const *text, int len, int utf8, char *out);
260extern int i_t1_face_name(int font_num, char *name_buf, size_t name_buf_size);
261extern int i_t1_glyph_name(int font_num, unsigned long ch, char *name_buf,
262 size_t name_buf_size);
02d1d628
AMH
263#endif
264
265#ifdef HAVE_LIBTT
266
4f68b48f 267struct TT_Fonthandle_;
02d1d628
AMH
268
269typedef struct TT_Fonthandle_ TT_Fonthandle;
270
b33c08f8 271undef_int i_init_tt( void );
02d1d628
AMH
272TT_Fonthandle* i_tt_new(char *fontname);
273void i_tt_destroy( TT_Fonthandle *handle );
4f68b48f
TC
274undef_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);
275undef_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);
276undef_int i_tt_bbox( TT_Fonthandle *handle, float points,char *txt,int len,int cords[6], int utf8);
eeaa33fd 277int i_tt_has_chars(TT_Fonthandle *handle, char const *text, int len, int utf8, char *out);
3799c4d1
TC
278void i_tt_dump_names(TT_Fonthandle *handle);
279int i_tt_face_name(TT_Fonthandle *handle, char *name_buf,
280 size_t name_buf_size);
281int i_tt_glyph_name(TT_Fonthandle *handle, unsigned long ch, char *name_buf,
282 size_t name_buf_size);
02d1d628
AMH
283
284#endif /* End of freetype headers */
285
faa9b3e7
TC
286#ifdef HAVE_FT2
287
288typedef struct FT2_Fonthandle FT2_Fonthandle;
289extern int i_ft2_init(void);
290extern FT2_Fonthandle * i_ft2_new(char *name, int index);
291extern void i_ft2_destroy(FT2_Fonthandle *handle);
292extern int i_ft2_setdpi(FT2_Fonthandle *handle, int xdpi, int ydpi);
293extern int i_ft2_getdpi(FT2_Fonthandle *handle, int *xdpi, int *ydpi);
294extern int i_ft2_settransform(FT2_Fonthandle *handle, double *matrix);
295extern int i_ft2_sethinting(FT2_Fonthandle *handle, int hinting);
296extern int i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth,
4f68b48f 297 char const *text, int len, int *bbox, int utf8);
faa9b3e7
TC
298extern int i_ft2_text(FT2_Fonthandle *handle, i_img *im, int tx, int ty,
299 i_color *cl, double cheight, double cwidth,
4f68b48f
TC
300 char const *text, int len, int align, int aa,
301 int vlayout, int utf8);
faa9b3e7
TC
302extern int i_ft2_cp(FT2_Fonthandle *handle, i_img *im, int tx, int ty,
303 int channel, double cheight, double cwidth,
4f68b48f 304 char const *text, int len, int align, int aa, int vlayout,
faa9b3e7 305 int utf8);
4f68b48f 306extern int i_ft2_has_chars(FT2_Fonthandle *handle, char const *text, int len,
3dec2c92 307 int utf8, char *work);
3799c4d1
TC
308extern int i_ft2_face_name(FT2_Fonthandle *handle, char *name_buf,
309 size_t name_buf_size);
042cdaea 310extern int i_ft2_can_face_name(void);
a4168bea
TC
311extern int i_ft2_glyph_name(FT2_Fonthandle *handle, unsigned long ch,
312 char *name_buf, size_t name_buf_size,
313 int reliable_only);
3799c4d1
TC
314extern int i_ft2_can_do_glyph_names(void);
315extern int i_ft2_face_has_glyph_names(FT2_Fonthandle *handle);
02d1d628 316
faa9b3e7 317#endif
02d1d628 318
faa9b3e7 319#ifdef WIN32
02d1d628 320
faa9b3e7
TC
321extern int i_wf_bbox(char *face, int size, char *text, int length, int *bbox);
322extern 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);
324extern 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
339typedef 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
349typedef 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
357extern int i_gen_reader(i_gen_read_data *info, char *buffer, int need);
358extern i_gen_read_data *i_gen_read_data_new(i_read_callback_t cb, char *userdata);
b33c08f8 359extern void i_free_gen_read_data(i_gen_read_data *);
02d1d628
AMH
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*/
367typedef int (*i_write_callback_t)(char *userdata, char const *data, int size);
368
369typedef 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
377extern int i_gen_writer(i_gen_write_data *info, char const *data, int size);
378extern i_gen_write_data *i_gen_write_data_new(i_write_callback_t cb, char *userdata, int maxlength);
b33c08f8 379extern int i_free_gen_write_data(i_gen_write_data *, int flush);
02d1d628
AMH
380
381/* transparency handling for quantized output */
382typedef 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 */
390typedef 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 */
97c4effc 394 mc_median_cut, /* median cut - similar to giflib, hopefully */
02d1d628
AMH
395 mc_mask = 0xFF /* (mask for generator) */
396} i_make_colors;
397
398/* controls how we translate the colours */
399typedef enum i_translate_tag {
400 pt_giflib, /* get gif lib to do it (ignores make_colours) */
401 pt_closest, /* just use the closest match within the hashbox */
402 pt_perturb, /* randomly perturb the data - uses perturb_size*/
403 pt_errdiff /* error diffusion dither - uses errdiff */
404} i_translate;
405
406/* Which error diffusion map to use */
407typedef enum i_errdiff_tag {
408 ed_floyd, /* floyd-steinberg */
409 ed_jarvis, /* Jarvis, Judice and Ninke */
410 ed_stucki, /* Stucki */
411 ed_custom, /* the map found in ed_map|width|height|orig */
412 ed_mask = 0xFF, /* mask to get the map */
413 ed_bidir = 0x100 /* change direction for each row */
414} i_errdiff;
415
416/* which ordered dither map to use
417 currently only available for transparency
418 I don't know of a way to do ordered dither of an image against some
419 general palette
420 */
421typedef enum i_ord_dith_tag
422{
423 od_random, /* sort of random */
424 od_dot8, /* large dot */
425 od_dot4,
426 od_hline,
427 od_vline,
428 od_slashline, /* / line dither */
429 od_backline, /* \ line dither */
34ba4c5b 430 od_tiny, /* small checkerbox */
02d1d628
AMH
431 od_custom /* custom 8x8 map */
432} i_ord_dith;
433
434typedef struct i_gif_pos_tag {
435 int x, y;
436} i_gif_pos;
437
438/* passed into i_writegif_gen() to control quantization */
439typedef struct i_quantize_tag {
440 /* how to handle transparency */
441 i_transp transp;
442 /* the threshold at which to make pixels opaque */
443 int tr_threshold;
444 i_errdiff tr_errdiff;
445 i_ord_dith tr_orddith;
446 unsigned char tr_custom[64];
447
448 /* how to make the colour map */
449 i_make_colors make_colors;
450
451 /* any existing colours
452 mc_existing is an existing colour table
453 mc_count is the number of existing colours
454 mc_size is the total size of the array that mc_existing points
455 at - this must be at least 256
456 */
457 i_color *mc_colors;
458 int mc_size;
459 int mc_count;
460
461 /* how we translate the colours */
462 i_translate translate;
463
464 /* the error diffusion map to use if translate is mc_errdiff */
465 i_errdiff errdiff;
466 /* the following define the error diffusion values to use if
467 errdiff is ed_custom. ed_orig is the column on the top row that
468 represents the current
469 */
470 int *ed_map;
471 int ed_width, ed_height, ed_orig;
472
473 /* the amount of perturbation to use for translate is mc_perturb */
474 int perturb;
475} i_quantize;
476
477typedef struct i_gif_opts {
478 /* each image has a local color map */
479 int each_palette;
480
481 /* images are interlaced */
482 int interlace;
483
484 /* time for which image is displayed
485 (in 1/100 seconds)
486 default: 0
487 */
488 int delay_count;
489 int *delays;
490
491 /* user input flags
492 default: 0
493 */
494 int user_input_count;
495 char *user_input_flags;
496
497 /* disposal
498 default: 0 */
499 int disposal_count;
500 char *disposal;
501
502 /* this is added to the color table when we make an image transparent */
503 i_color tran_color;
504
505 /* image positions */
506 int position_count;
507 i_gif_pos *positions;
508
509 /* Netscape loop extension - number of loops */
510 int loop_count;
bf9dd17c
TC
511
512 /* should be eliminate unused colors? */
513 int eliminate_unused;
02d1d628
AMH
514} i_gif_opts;
515
516extern void quant_makemap(i_quantize *quant, i_img **imgs, int count);
517extern i_palidx *quant_translate(i_quantize *quant, i_img *img);
518extern void quant_transparent(i_quantize *quant, i_palidx *indices, i_img *img, i_palidx trans_index);
519
faa9b3e7
TC
520extern i_img *i_img_pal_new(int x, int y, int channels, int maxpal);
521extern i_img *i_img_pal_new_low(i_img *im, int x, int y, int channels, int maxpal);
522extern i_img *i_img_to_pal(i_img *src, i_quantize *quant);
523extern i_img *i_img_to_rgb(i_img *src);
524extern i_img *i_img_masked_new(i_img *targ, i_img *mask, int x, int y,
525 int w, int h);
526extern i_img *i_img_16_new(int x, int y, int ch);
527extern i_img *i_img_16_new_low(i_img *im, int x, int y, int ch);
365ea842
TC
528extern i_img *i_img_double_new(int x, int y, int ch);
529extern i_img *i_img_double_new_low(i_img *im, int x, int y, int ch);
faa9b3e7 530
e10bf46e
AMH
531
532char * i_test_format_probe(io_glue *data, int length);
533
534
02d1d628 535#ifdef HAVE_LIBJPEG
dd55acc8
AMH
536i_img *
537i_readjpeg_wiol(io_glue *ig, int length, char** iptc_itext, int *itlength);
538undef_int i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor);
02d1d628
AMH
539#endif /* HAVE_LIBJPEG */
540
541#ifdef HAVE_LIBTIFF
04418ecc 542i_img * i_readtiff_wiol(io_glue *ig, int length);
10461f9a 543i_img ** i_readtiff_multi_wiol(io_glue *ig, int length, int *count);
02d1d628 544undef_int i_writetiff_wiol(i_img *im, io_glue *ig);
10461f9a 545undef_int i_writetiff_multi_wiol(io_glue *ig, i_img **imgs, int count);
4c2d6970 546undef_int i_writetiff_wiol_faxable(i_img *im, io_glue *ig, int fine);
10461f9a 547undef_int i_writetiff_multi_wiol_faxable(io_glue *ig, i_img **imgs, int count, int fine);
02d1d628
AMH
548
549#endif /* HAVE_LIBTIFF */
550
551#ifdef HAVE_LIBPNG
04418ecc
AMH
552i_img *i_readpng_wiol(io_glue *ig, int length);
553undef_int i_writepng_wiol(i_img *im, io_glue *ig);
02d1d628
AMH
554#endif /* HAVE_LIBPNG */
555
556#ifdef HAVE_LIBGIF
faa9b3e7 557i_img *i_readgif(int fd, int **colour_table, int *colours);
10461f9a 558i_img *i_readgif_wiol(io_glue *ig, int **colour_table, int *colours);
faa9b3e7
TC
559i_img *i_readgif_scalar(char *data, int length, int **colour_table, int *colours);
560i_img *i_readgif_callback(i_read_callback_t callback, char *userdata, int **colour_table, int *colours);
561extern i_img **i_readgif_multi(int fd, int *count);
562extern i_img **i_readgif_multi_scalar(char *data, int length, int *count);
563extern i_img **i_readgif_multi_callback(i_read_callback_t callback, char *userdata, int *count);
10461f9a 564extern i_img **i_readgif_multi_wiol(io_glue *ig, int *count);
02d1d628
AMH
565undef_int i_writegif(i_img *im,int fd,int colors,int pixdev,int fixedlen,i_color fixed[]);
566undef_int i_writegifmc(i_img *im,int fd,int colors);
567undef_int i_writegifex(i_img *im,int fd);
97c4effc
TC
568undef_int i_writegif_gen(i_quantize *quant, int fd, i_img **imgs, int count);
569undef_int i_writegif_callback(i_quantize *quant, i_write_callback_t cb, char *userdata, int maxbuffer, i_img **imgs, int count);
570undef_int i_writegif_wiol(io_glue *ig, i_quantize *quant,
10461f9a 571 i_img **imgs, int count);
02d1d628
AMH
572void i_qdist(i_img *im);
573
574#endif /* HAVE_LIBGIF */
575
04418ecc 576i_img * i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, int intrl);
895dbd34 577undef_int i_writeraw_wiol(i_img* im, io_glue *ig);
02d1d628 578
04418ecc 579i_img * i_readpnm_wiol(io_glue *ig, int length);
067d6bdc 580undef_int i_writeppm_wiol(i_img *im, io_glue *ig);
02d1d628 581
1ec86afa 582extern int i_writebmp_wiol(i_img *im, io_glue *ig);
d08b8f85 583extern i_img *i_readbmp_wiol(io_glue *ig);
02d1d628 584
84e51293
AMH
585int tga_header_verify(unsigned char headbuf[18]);
586
1ec86afa 587i_img * i_readtga_wiol(io_glue *ig, int length);
febba01f 588undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
1ec86afa 589
737a830c
AMH
590i_img * i_readrgb_wiol(io_glue *ig, int length);
591undef_int i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
592
04418ecc
AMH
593i_img * i_scaleaxis(i_img *im, float Value, int Axis);
594i_img * i_scale_nn(i_img *im, float scx, float scy);
595i_img * i_haar(i_img *im);
596int i_count_colors(i_img *im,int maxc);
02d1d628 597
04418ecc 598i_img * i_transform(i_img *im, int *opx,int opxl,int *opy,int opyl,double parm[],int parmlen);
02d1d628
AMH
599
600struct rm_op;
04418ecc
AMH
601i_img * i_transform2(int width, int height, int channels,
602 struct rm_op *ops, int ops_count,
603 double *n_regs, int n_regs_count,
604 i_color *c_regs, int c_regs_count,
605 i_img **in_imgs, int in_imgs_count);
febba01f 606
02d1d628
AMH
607/* filters */
608
609void i_contrast(i_img *im, float intensity);
610void i_hardinvert(i_img *im);
611void i_noise(i_img *im, float amount, unsigned char type);
612void i_bumpmap(i_img *im,i_img *bump,int channel,int light_x,int light_y,int strength);
b2778574
AMH
613void i_bumpmap_complex(i_img *im, i_img *bump, int channel, int tx, int ty, float Lx, float Ly,
614 float Lz, float cd, float cs, float n, i_color *Ia, i_color *Il, i_color *Is);
02d1d628
AMH
615void i_postlevels(i_img *im,int levels);
616void i_mosaic(i_img *im,int size);
617void i_watermark(i_img *im,i_img *wmark,int tx,int ty,int pixdiff);
618void i_autolevels(i_img *im,float lsat,float usat,float skew);
619void i_radnoise(i_img *im,int xo,int yo,float rscale,float ascale);
620void i_turbnoise(i_img *im,float xo,float yo,float scale);
621void i_gradgen(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
622void i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
dff75dee 623i_img *i_diff_image(i_img *im, i_img *im2, int mindist);
6607600c
TC
624typedef enum {
625 i_fst_linear,
626 i_fst_curved,
627 i_fst_sine,
628 i_fst_sphere_up,
629 i_fst_sphere_down,
630 i_fst_end
631} i_fountain_seg_type;
632typedef enum {
633 i_fc_direct,
634 i_fc_hue_up,
635 i_fc_hue_down,
636 i_fc_end
637} i_fountain_color;
638typedef struct {
639 double start, middle, end;
640 i_fcolor c[2];
641 i_fountain_seg_type type;
642 i_fountain_color color;
643} i_fountain_seg;
644typedef enum {
645 i_fr_none,
646 i_fr_sawtooth,
647 i_fr_triangle,
648 i_fr_saw_both,
649 i_fr_tri_both
650} i_fountain_repeat;
651typedef enum {
652 i_ft_linear,
653 i_ft_bilinear,
654 i_ft_radial,
655 i_ft_radial_square,
656 i_ft_revolution,
657 i_ft_conical,
658 i_ft_end
659} i_fountain_type;
660typedef enum {
661 i_fts_none,
662 i_fts_grid,
663 i_fts_random,
664 i_fts_circle
665} i_ft_supersample;
666void i_fountain(i_img *im, double xa, double ya, double xb, double yb,
667 i_fountain_type type, i_fountain_repeat repeat,
668 int combine, int super_sample, double ssample_param,
669 int count, i_fountain_seg *segs);
f1ac5027
TC
670extern i_fill_t *
671i_new_fill_fount(double xa, double ya, double xb, double yb,
672 i_fountain_type type, i_fountain_repeat repeat,
673 int combine, int super_sample, double ssample_param,
674 int count, i_fountain_seg *segs);
02d1d628
AMH
675
676/* Debug only functions */
677
678void malloc_state( void );
679
680/* this is sort of obsolete now */
681
682typedef struct {
683 undef_int (*i_has_format)(char *frmt);
684 i_color*(*ICL_set)(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
685 void (*ICL_info)(i_color *cl);
686
687 i_img*(*i_img_new)( void );
688 i_img*(*i_img_empty)(i_img *im,int x,int y);
689 i_img*(*i_img_empty_ch)(i_img *im,int x,int y,int ch);
690 void(*i_img_exorcise)(i_img *im);
691
692 void(*i_img_info)(i_img *im,int *info);
693
694 void(*i_img_setmask)(i_img *im,int ch_mask);
695 int (*i_img_getmask)(i_img *im);
696
da1c841c 697 /*
02d1d628
AMH
698 int (*i_ppix)(i_img *im,int x,int y,i_color *val);
699 int (*i_gpix)(i_img *im,int x,int y,i_color *val);
da1c841c 700 */
02d1d628 701 void(*i_box)(i_img *im,int x1,int y1,int x2,int y2,i_color *val);
aa833c97 702 void(*i_line)(i_img *im,int x1,int y1,int x2,int y2,i_color *val,int endp);
02d1d628
AMH
703 void(*i_arc)(i_img *im,int x,int y,float rad,float d1,float d2,i_color *val);
704 void(*i_copyto)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty);
705 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 706 int(*i_rubthru)(i_img *im,i_img *src,int tx,int ty);
02d1d628
AMH
707
708} symbol_table_t;
709
848ba81a
TC
710/* error handling
711 see error.c for documentation
712 the error information is currently global
713*/
714typedef struct {
715 char *msg;
716 int code;
717} i_errmsg;
a743c0a6 718
848ba81a
TC
719typedef void (*i_error_cb)(int code, char const *msg);
720typedef void (*i_failed_cb)(i_errmsg *msgs);
721extern i_error_cb i_set_error_cb(i_error_cb);
722extern i_failed_cb i_set_failed_cb(i_failed_cb);
723extern void i_set_argv0(char const *);
724extern int i_set_errors_fatal(int new_fatal);
faa9b3e7 725extern i_errmsg *i_errors(void);
848ba81a
TC
726
727extern void i_push_error(int code, char const *msg);
728extern void i_push_errorf(int code, char const *fmt, ...);
729extern void i_push_errorvf(int code, char const *fmt, va_list);
faa9b3e7 730extern void i_clear_error(void);
848ba81a 731extern int i_failed(int code, char const *msg);
02d1d628 732
faa9b3e7
TC
733/* image tag processing */
734extern void i_tags_new(i_img_tags *tags);
97c4effc
TC
735extern int i_tags_addn(i_img_tags *tags, char const *name, int code,
736 int idata);
737extern int i_tags_add(i_img_tags *tags, char const *name, int code,
738 char const *data, int size, int idata);
faa9b3e7 739extern void i_tags_destroy(i_img_tags *tags);
97c4effc
TC
740extern int i_tags_find(i_img_tags *tags, char const *name, int start,
741 int *entry);
faa9b3e7
TC
742extern int i_tags_findn(i_img_tags *tags, int code, int start, int *entry);
743extern int i_tags_delete(i_img_tags *tags, int entry);
97c4effc 744extern int i_tags_delbyname(i_img_tags *tags, char const *name);
faa9b3e7 745extern int i_tags_delbycode(i_img_tags *tags, int code);
97c4effc 746extern int i_tags_get_float(i_img_tags *tags, char const *name, int code,
fd9a31d2 747 double *value);
97c4effc 748extern int i_tags_set_float(i_img_tags *tags, char const *name, int code,
fd9a31d2 749 double value);
97c4effc
TC
750extern int i_tags_get_int(i_img_tags *tags, char const *name, int code,
751 int *value);
752extern int i_tags_get_string(i_img_tags *tags, char const *name, int code,
fd9a31d2 753 char *value, size_t value_size);
97c4effc
TC
754extern int i_tags_get_color(i_img_tags *tags, char const *name, int code,
755 i_color *value);
756extern int i_tags_set_color(i_img_tags *tags, char const *name, int code,
757 i_color const *value);
fd9a31d2 758extern void i_tags_print(i_img_tags *tags);
02d1d628
AMH
759
760#endif