log of discussion on IRC
[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);
02d1d628
AMH
206void i_draw (i_img *im,int x1,int y1,int x2,int y2,i_color *val);
207void i_line_aa (i_img *im,int x1,int y1,int x2,int y2,i_color *val);
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);
faa9b3e7 214int i_rubthru (i_img *im,i_img *src,int tx,int ty);
02d1d628 215
142c26ff 216undef_int i_flipxy (i_img *im, int direction);
faa9b3e7
TC
217extern i_img *i_rotate90(i_img *im, int degrees);
218extern i_img *i_rotate_exact(i_img *im, double amount);
219extern i_img *i_matrix_transform(i_img *im, int xsize, int ysize, double *matrix);
142c26ff 220
02d1d628
AMH
221void i_bezier_multi(i_img *im,int l,double *x,double *y,i_color *val);
222void i_poly_aa (i_img *im,int l,double *x,double *y,i_color *val);
43c5dacb 223void i_poly_aa_cfill(i_img *im,int l,double *x,double *y,i_fill_t *fill);
02d1d628
AMH
224
225void i_flood_fill (i_img *im,int seedx,int seedy,i_color *dcol);
226
227/* image processing functions */
228
229void i_gaussian (i_img *im,float stdev);
230void i_conv (i_img *im,float *coeff,int len);
b6381851 231void i_unsharp_mask(i_img *im, double stddev, double scale);
02d1d628 232
f5991c03
TC
233/* colour manipulation */
234extern int i_convert(i_img *im, i_img *src, float *coeff, int outchan, int inchan);
faa9b3e7 235extern void i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask);
f5991c03 236
02d1d628
AMH
237float i_img_diff (i_img *im1,i_img *im2);
238
239/* font routines */
240
4cb58f1b 241undef_int i_init_fonts( int t1log );
02d1d628
AMH
242
243#ifdef HAVE_LIBT1
244#include <t1lib.h>
245
b33c08f8 246undef_int i_init_t1( int t1log );
02d1d628
AMH
247int i_t1_new( char *pfb, char *afm );
248int i_t1_destroy( int font_id );
249undef_int i_t1_cp( i_img *im, int xb, int yb, int channel, int fontnum, float points, char* str, int len, int align );
250undef_int i_t1_text( i_img *im, int xb, int yb, i_color *cl, int fontnum, float points, char* str, int len, int align );
251void i_t1_bbox( int fontnum, float point, char *str, int len, int cords[6] );
252void i_t1_set_aa( int st );
253void close_t1( void );
254
255#endif
256
257#ifdef HAVE_LIBTT
258
4f68b48f 259struct TT_Fonthandle_;
02d1d628
AMH
260
261typedef struct TT_Fonthandle_ TT_Fonthandle;
262
b33c08f8 263undef_int i_init_tt( void );
02d1d628
AMH
264TT_Fonthandle* i_tt_new(char *fontname);
265void i_tt_destroy( TT_Fonthandle *handle );
4f68b48f
TC
266undef_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);
267undef_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);
268undef_int i_tt_bbox( TT_Fonthandle *handle, float points,char *txt,int len,int cords[6], int utf8);
02d1d628
AMH
269
270#endif /* End of freetype headers */
271
faa9b3e7
TC
272#ifdef HAVE_FT2
273
274typedef struct FT2_Fonthandle FT2_Fonthandle;
275extern int i_ft2_init(void);
276extern FT2_Fonthandle * i_ft2_new(char *name, int index);
277extern void i_ft2_destroy(FT2_Fonthandle *handle);
278extern int i_ft2_setdpi(FT2_Fonthandle *handle, int xdpi, int ydpi);
279extern int i_ft2_getdpi(FT2_Fonthandle *handle, int *xdpi, int *ydpi);
280extern int i_ft2_settransform(FT2_Fonthandle *handle, double *matrix);
281extern int i_ft2_sethinting(FT2_Fonthandle *handle, int hinting);
282extern int i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth,
4f68b48f 283 char const *text, int len, int *bbox, int utf8);
faa9b3e7
TC
284extern int i_ft2_text(FT2_Fonthandle *handle, i_img *im, int tx, int ty,
285 i_color *cl, double cheight, double cwidth,
4f68b48f
TC
286 char const *text, int len, int align, int aa,
287 int vlayout, int utf8);
faa9b3e7
TC
288extern int i_ft2_cp(FT2_Fonthandle *handle, i_img *im, int tx, int ty,
289 int channel, double cheight, double cwidth,
4f68b48f 290 char const *text, int len, int align, int aa, int vlayout,
faa9b3e7 291 int utf8);
4f68b48f 292extern int i_ft2_has_chars(FT2_Fonthandle *handle, char const *text, int len,
3dec2c92 293 int utf8, char *work);
02d1d628 294
faa9b3e7 295#endif
02d1d628 296
faa9b3e7 297#ifdef WIN32
02d1d628 298
faa9b3e7
TC
299extern int i_wf_bbox(char *face, int size, char *text, int length, int *bbox);
300extern int i_wf_text(char *face, i_img *im, int tx, int ty, i_color *cl,
301 int size, char *text, int len, int align, int aa);
302extern int i_wf_cp(char *face, i_img *im, int tx, int ty, int channel,
303 int size, char *text, int len, int align, int aa);
02d1d628 304
faa9b3e7 305#endif
02d1d628
AMH
306
307/* functions for reading and writing formats */
308
309/* general reader callback
310 userdata - data the user passed into the reader
311 buffer - the buffer to fill with data
312 need - the amount of data needed
313 want - the amount of space we have to store data
314 fill buffer and return the number of bytes read, 0 for eof, -1 for error
315*/
316
317typedef int (*i_read_callback_t)(char *userdata, char *buffer, int need,
318 int want);
319
320/* i_gen_reader() translates the low-level requests from whatever library
321 into buffered requests.
322 but the called function can always bypass buffering by only ever
323 reading I<need> bytes.
324*/
325#define CBBUFSIZ 4096
326
327typedef struct {
328 i_read_callback_t cb;
329 char *userdata;
330 char buffer[CBBUFSIZ];
331 int length;
332 int cpos;
333} i_gen_read_data;
334
335extern int i_gen_reader(i_gen_read_data *info, char *buffer, int need);
336extern i_gen_read_data *i_gen_read_data_new(i_read_callback_t cb, char *userdata);
b33c08f8 337extern void i_free_gen_read_data(i_gen_read_data *);
02d1d628
AMH
338
339/* general writer callback
340 userdata - the data the user passed into the writer
341 data - the data to write
342 data_size - the number of bytes to write
343 write the data, return non-zero on success, zero on failure.
344*/
345typedef int (*i_write_callback_t)(char *userdata, char const *data, int size);
346
347typedef struct {
348 i_write_callback_t cb;
349 char *userdata;
350 char buffer[CBBUFSIZ];
351 int maxlength;
352 int filledto;
353} i_gen_write_data;
354
355extern int i_gen_writer(i_gen_write_data *info, char const *data, int size);
356extern i_gen_write_data *i_gen_write_data_new(i_write_callback_t cb, char *userdata, int maxlength);
b33c08f8 357extern int i_free_gen_write_data(i_gen_write_data *, int flush);
02d1d628
AMH
358
359/* transparency handling for quantized output */
360typedef enum i_transp_tag {
361 tr_none, /* ignore any alpha channel */
362 tr_threshold, /* threshold the transparency - uses tr_threshold */
363 tr_errdiff, /* error diffusion */
364 tr_ordered /* an ordered dither */
365} i_transp;
366
367/* controls how we build the colour map */
368typedef enum i_make_colors_tag {
369 mc_none, /* user supplied colour map only */
370 mc_web_map, /* Use the 216 colour web colour map */
371 mc_addi, /* Addi's algorithm */
97c4effc 372 mc_median_cut, /* median cut - similar to giflib, hopefully */
02d1d628
AMH
373 mc_mask = 0xFF /* (mask for generator) */
374} i_make_colors;
375
376/* controls how we translate the colours */
377typedef enum i_translate_tag {
378 pt_giflib, /* get gif lib to do it (ignores make_colours) */
379 pt_closest, /* just use the closest match within the hashbox */
380 pt_perturb, /* randomly perturb the data - uses perturb_size*/
381 pt_errdiff /* error diffusion dither - uses errdiff */
382} i_translate;
383
384/* Which error diffusion map to use */
385typedef enum i_errdiff_tag {
386 ed_floyd, /* floyd-steinberg */
387 ed_jarvis, /* Jarvis, Judice and Ninke */
388 ed_stucki, /* Stucki */
389 ed_custom, /* the map found in ed_map|width|height|orig */
390 ed_mask = 0xFF, /* mask to get the map */
391 ed_bidir = 0x100 /* change direction for each row */
392} i_errdiff;
393
394/* which ordered dither map to use
395 currently only available for transparency
396 I don't know of a way to do ordered dither of an image against some
397 general palette
398 */
399typedef enum i_ord_dith_tag
400{
401 od_random, /* sort of random */
402 od_dot8, /* large dot */
403 od_dot4,
404 od_hline,
405 od_vline,
406 od_slashline, /* / line dither */
407 od_backline, /* \ line dither */
34ba4c5b 408 od_tiny, /* small checkerbox */
02d1d628
AMH
409 od_custom /* custom 8x8 map */
410} i_ord_dith;
411
412typedef struct i_gif_pos_tag {
413 int x, y;
414} i_gif_pos;
415
416/* passed into i_writegif_gen() to control quantization */
417typedef struct i_quantize_tag {
418 /* how to handle transparency */
419 i_transp transp;
420 /* the threshold at which to make pixels opaque */
421 int tr_threshold;
422 i_errdiff tr_errdiff;
423 i_ord_dith tr_orddith;
424 unsigned char tr_custom[64];
425
426 /* how to make the colour map */
427 i_make_colors make_colors;
428
429 /* any existing colours
430 mc_existing is an existing colour table
431 mc_count is the number of existing colours
432 mc_size is the total size of the array that mc_existing points
433 at - this must be at least 256
434 */
435 i_color *mc_colors;
436 int mc_size;
437 int mc_count;
438
439 /* how we translate the colours */
440 i_translate translate;
441
442 /* the error diffusion map to use if translate is mc_errdiff */
443 i_errdiff errdiff;
444 /* the following define the error diffusion values to use if
445 errdiff is ed_custom. ed_orig is the column on the top row that
446 represents the current
447 */
448 int *ed_map;
449 int ed_width, ed_height, ed_orig;
450
451 /* the amount of perturbation to use for translate is mc_perturb */
452 int perturb;
453} i_quantize;
454
455typedef struct i_gif_opts {
456 /* each image has a local color map */
457 int each_palette;
458
459 /* images are interlaced */
460 int interlace;
461
462 /* time for which image is displayed
463 (in 1/100 seconds)
464 default: 0
465 */
466 int delay_count;
467 int *delays;
468
469 /* user input flags
470 default: 0
471 */
472 int user_input_count;
473 char *user_input_flags;
474
475 /* disposal
476 default: 0 */
477 int disposal_count;
478 char *disposal;
479
480 /* this is added to the color table when we make an image transparent */
481 i_color tran_color;
482
483 /* image positions */
484 int position_count;
485 i_gif_pos *positions;
486
487 /* Netscape loop extension - number of loops */
488 int loop_count;
bf9dd17c
TC
489
490 /* should be eliminate unused colors? */
491 int eliminate_unused;
02d1d628
AMH
492} i_gif_opts;
493
494extern void quant_makemap(i_quantize *quant, i_img **imgs, int count);
495extern i_palidx *quant_translate(i_quantize *quant, i_img *img);
496extern void quant_transparent(i_quantize *quant, i_palidx *indices, i_img *img, i_palidx trans_index);
497
faa9b3e7
TC
498extern i_img *i_img_pal_new(int x, int y, int channels, int maxpal);
499extern i_img *i_img_pal_new_low(i_img *im, int x, int y, int channels, int maxpal);
500extern i_img *i_img_to_pal(i_img *src, i_quantize *quant);
501extern i_img *i_img_to_rgb(i_img *src);
502extern i_img *i_img_masked_new(i_img *targ, i_img *mask, int x, int y,
503 int w, int h);
504extern i_img *i_img_16_new(int x, int y, int ch);
505extern i_img *i_img_16_new_low(i_img *im, int x, int y, int ch);
365ea842
TC
506extern i_img *i_img_double_new(int x, int y, int ch);
507extern i_img *i_img_double_new_low(i_img *im, int x, int y, int ch);
faa9b3e7 508
02d1d628 509#ifdef HAVE_LIBJPEG
dd55acc8
AMH
510i_img *
511i_readjpeg_wiol(io_glue *ig, int length, char** iptc_itext, int *itlength);
512undef_int i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor);
02d1d628
AMH
513#endif /* HAVE_LIBJPEG */
514
515#ifdef HAVE_LIBTIFF
04418ecc 516i_img * i_readtiff_wiol(io_glue *ig, int length);
10461f9a 517i_img ** i_readtiff_multi_wiol(io_glue *ig, int length, int *count);
02d1d628 518undef_int i_writetiff_wiol(i_img *im, io_glue *ig);
10461f9a 519undef_int i_writetiff_multi_wiol(io_glue *ig, i_img **imgs, int count);
4c2d6970 520undef_int i_writetiff_wiol_faxable(i_img *im, io_glue *ig, int fine);
10461f9a 521undef_int i_writetiff_multi_wiol_faxable(io_glue *ig, i_img **imgs, int count, int fine);
02d1d628
AMH
522
523#endif /* HAVE_LIBTIFF */
524
525#ifdef HAVE_LIBPNG
04418ecc
AMH
526i_img *i_readpng_wiol(io_glue *ig, int length);
527undef_int i_writepng_wiol(i_img *im, io_glue *ig);
02d1d628
AMH
528#endif /* HAVE_LIBPNG */
529
530#ifdef HAVE_LIBGIF
faa9b3e7 531i_img *i_readgif(int fd, int **colour_table, int *colours);
10461f9a 532i_img *i_readgif_wiol(io_glue *ig, int **colour_table, int *colours);
faa9b3e7
TC
533i_img *i_readgif_scalar(char *data, int length, int **colour_table, int *colours);
534i_img *i_readgif_callback(i_read_callback_t callback, char *userdata, int **colour_table, int *colours);
535extern i_img **i_readgif_multi(int fd, int *count);
536extern i_img **i_readgif_multi_scalar(char *data, int length, int *count);
537extern i_img **i_readgif_multi_callback(i_read_callback_t callback, char *userdata, int *count);
10461f9a 538extern i_img **i_readgif_multi_wiol(io_glue *ig, int *count);
02d1d628
AMH
539undef_int i_writegif(i_img *im,int fd,int colors,int pixdev,int fixedlen,i_color fixed[]);
540undef_int i_writegifmc(i_img *im,int fd,int colors);
541undef_int i_writegifex(i_img *im,int fd);
97c4effc
TC
542undef_int i_writegif_gen(i_quantize *quant, int fd, i_img **imgs, int count);
543undef_int i_writegif_callback(i_quantize *quant, i_write_callback_t cb, char *userdata, int maxbuffer, i_img **imgs, int count);
544undef_int i_writegif_wiol(io_glue *ig, i_quantize *quant,
10461f9a 545 i_img **imgs, int count);
02d1d628
AMH
546void i_qdist(i_img *im);
547
548#endif /* HAVE_LIBGIF */
549
04418ecc 550i_img * i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, int intrl);
895dbd34 551undef_int i_writeraw_wiol(i_img* im, io_glue *ig);
02d1d628 552
04418ecc 553i_img * i_readpnm_wiol(io_glue *ig, int length);
067d6bdc 554undef_int i_writeppm_wiol(i_img *im, io_glue *ig);
02d1d628 555
1ec86afa 556extern int i_writebmp_wiol(i_img *im, io_glue *ig);
d08b8f85 557extern i_img *i_readbmp_wiol(io_glue *ig);
02d1d628 558
1ec86afa 559i_img * i_readtga_wiol(io_glue *ig, int length);
febba01f 560undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
1ec86afa 561
737a830c
AMH
562i_img * i_readrgb_wiol(io_glue *ig, int length);
563undef_int i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
564
04418ecc
AMH
565i_img * i_scaleaxis(i_img *im, float Value, int Axis);
566i_img * i_scale_nn(i_img *im, float scx, float scy);
567i_img * i_haar(i_img *im);
568int i_count_colors(i_img *im,int maxc);
02d1d628 569
04418ecc 570i_img * i_transform(i_img *im, int *opx,int opxl,int *opy,int opyl,double parm[],int parmlen);
02d1d628
AMH
571
572struct rm_op;
04418ecc
AMH
573i_img * i_transform2(int width, int height, int channels,
574 struct rm_op *ops, int ops_count,
575 double *n_regs, int n_regs_count,
576 i_color *c_regs, int c_regs_count,
577 i_img **in_imgs, int in_imgs_count);
febba01f 578
02d1d628
AMH
579/* filters */
580
581void i_contrast(i_img *im, float intensity);
582void i_hardinvert(i_img *im);
583void i_noise(i_img *im, float amount, unsigned char type);
584void i_bumpmap(i_img *im,i_img *bump,int channel,int light_x,int light_y,int strength);
b2778574
AMH
585void i_bumpmap_complex(i_img *im, i_img *bump, int channel, int tx, int ty, float Lx, float Ly,
586 float Lz, float cd, float cs, float n, i_color *Ia, i_color *Il, i_color *Is);
02d1d628
AMH
587void i_postlevels(i_img *im,int levels);
588void i_mosaic(i_img *im,int size);
589void i_watermark(i_img *im,i_img *wmark,int tx,int ty,int pixdiff);
590void i_autolevels(i_img *im,float lsat,float usat,float skew);
591void i_radnoise(i_img *im,int xo,int yo,float rscale,float ascale);
592void i_turbnoise(i_img *im,float xo,float yo,float scale);
593void i_gradgen(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
594void i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
dff75dee 595i_img *i_diff_image(i_img *im, i_img *im2, int mindist);
6607600c
TC
596typedef enum {
597 i_fst_linear,
598 i_fst_curved,
599 i_fst_sine,
600 i_fst_sphere_up,
601 i_fst_sphere_down,
602 i_fst_end
603} i_fountain_seg_type;
604typedef enum {
605 i_fc_direct,
606 i_fc_hue_up,
607 i_fc_hue_down,
608 i_fc_end
609} i_fountain_color;
610typedef struct {
611 double start, middle, end;
612 i_fcolor c[2];
613 i_fountain_seg_type type;
614 i_fountain_color color;
615} i_fountain_seg;
616typedef enum {
617 i_fr_none,
618 i_fr_sawtooth,
619 i_fr_triangle,
620 i_fr_saw_both,
621 i_fr_tri_both
622} i_fountain_repeat;
623typedef enum {
624 i_ft_linear,
625 i_ft_bilinear,
626 i_ft_radial,
627 i_ft_radial_square,
628 i_ft_revolution,
629 i_ft_conical,
630 i_ft_end
631} i_fountain_type;
632typedef enum {
633 i_fts_none,
634 i_fts_grid,
635 i_fts_random,
636 i_fts_circle
637} i_ft_supersample;
638void i_fountain(i_img *im, double xa, double ya, double xb, double yb,
639 i_fountain_type type, i_fountain_repeat repeat,
640 int combine, int super_sample, double ssample_param,
641 int count, i_fountain_seg *segs);
f1ac5027
TC
642extern i_fill_t *
643i_new_fill_fount(double xa, double ya, double xb, double yb,
644 i_fountain_type type, i_fountain_repeat repeat,
645 int combine, int super_sample, double ssample_param,
646 int count, i_fountain_seg *segs);
02d1d628
AMH
647
648/* Debug only functions */
649
650void malloc_state( void );
651
652/* this is sort of obsolete now */
653
654typedef struct {
655 undef_int (*i_has_format)(char *frmt);
656 i_color*(*ICL_set)(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
657 void (*ICL_info)(i_color *cl);
658
659 i_img*(*i_img_new)( void );
660 i_img*(*i_img_empty)(i_img *im,int x,int y);
661 i_img*(*i_img_empty_ch)(i_img *im,int x,int y,int ch);
662 void(*i_img_exorcise)(i_img *im);
663
664 void(*i_img_info)(i_img *im,int *info);
665
666 void(*i_img_setmask)(i_img *im,int ch_mask);
667 int (*i_img_getmask)(i_img *im);
668
da1c841c 669 /*
02d1d628
AMH
670 int (*i_ppix)(i_img *im,int x,int y,i_color *val);
671 int (*i_gpix)(i_img *im,int x,int y,i_color *val);
da1c841c 672 */
02d1d628
AMH
673 void(*i_box)(i_img *im,int x1,int y1,int x2,int y2,i_color *val);
674 void(*i_draw)(i_img *im,int x1,int y1,int x2,int y2,i_color *val);
675 void(*i_arc)(i_img *im,int x,int y,float rad,float d1,float d2,i_color *val);
676 void(*i_copyto)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty);
677 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 678 int(*i_rubthru)(i_img *im,i_img *src,int tx,int ty);
02d1d628
AMH
679
680} symbol_table_t;
681
848ba81a
TC
682/* error handling
683 see error.c for documentation
684 the error information is currently global
685*/
686typedef struct {
687 char *msg;
688 int code;
689} i_errmsg;
a743c0a6 690
848ba81a
TC
691typedef void (*i_error_cb)(int code, char const *msg);
692typedef void (*i_failed_cb)(i_errmsg *msgs);
693extern i_error_cb i_set_error_cb(i_error_cb);
694extern i_failed_cb i_set_failed_cb(i_failed_cb);
695extern void i_set_argv0(char const *);
696extern int i_set_errors_fatal(int new_fatal);
faa9b3e7 697extern i_errmsg *i_errors(void);
848ba81a
TC
698
699extern void i_push_error(int code, char const *msg);
700extern void i_push_errorf(int code, char const *fmt, ...);
701extern void i_push_errorvf(int code, char const *fmt, va_list);
faa9b3e7 702extern void i_clear_error(void);
848ba81a 703extern int i_failed(int code, char const *msg);
02d1d628 704
faa9b3e7
TC
705/* image tag processing */
706extern void i_tags_new(i_img_tags *tags);
97c4effc
TC
707extern int i_tags_addn(i_img_tags *tags, char const *name, int code,
708 int idata);
709extern int i_tags_add(i_img_tags *tags, char const *name, int code,
710 char const *data, int size, int idata);
faa9b3e7 711extern void i_tags_destroy(i_img_tags *tags);
97c4effc
TC
712extern int i_tags_find(i_img_tags *tags, char const *name, int start,
713 int *entry);
faa9b3e7
TC
714extern int i_tags_findn(i_img_tags *tags, int code, int start, int *entry);
715extern int i_tags_delete(i_img_tags *tags, int entry);
97c4effc 716extern int i_tags_delbyname(i_img_tags *tags, char const *name);
faa9b3e7 717extern int i_tags_delbycode(i_img_tags *tags, int code);
97c4effc 718extern int i_tags_get_float(i_img_tags *tags, char const *name, int code,
fd9a31d2 719 double *value);
97c4effc 720extern int i_tags_set_float(i_img_tags *tags, char const *name, int code,
fd9a31d2 721 double value);
97c4effc
TC
722extern int i_tags_get_int(i_img_tags *tags, char const *name, int code,
723 int *value);
724extern int i_tags_get_string(i_img_tags *tags, char const *name, int code,
fd9a31d2 725 char *value, size_t value_size);
97c4effc
TC
726extern int i_tags_get_color(i_img_tags *tags, char const *name, int code,
727 i_color *value);
728extern int i_tags_set_color(i_img_tags *tags, char const *name, int code,
729 i_color const *value);
fd9a31d2 730extern void i_tags_print(i_img_tags *tags);
02d1d628
AMH
731
732#endif