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