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