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