]> git.imager.perl.org - imager.git/blob - imager.h
0.61 release
[imager.git] / imager.h
1 #ifndef _IMAGE_H_
2 #define _IMAGE_H_
3
4 #include "imconfig.h"
5 #include "imio.h"
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 "imdatatypes.h"
32
33 undef_int i_has_format(char *frmt);
34
35 /* constructors and destructors */
36
37 i_color *ICL_new_internal(            unsigned char r,unsigned char g,unsigned char b,unsigned char a);
38 i_color *ICL_set_internal(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
39 void     ICL_info        (const i_color *cl);
40 void     ICL_DESTROY     (i_color *cl);
41 void     ICL_add         (i_color *dst, i_color *src, int ch);
42
43 extern i_fcolor *i_fcolor_new(double r, double g, double b, double a);
44 extern void i_fcolor_destroy(i_fcolor *cl);
45
46 extern void i_rgb_to_hsvf(i_fcolor *color);
47 extern void i_hsv_to_rgbf(i_fcolor *color);
48 extern void i_rgb_to_hsv(i_color *color);
49 extern void i_hsv_to_rgb(i_color *color);
50
51 i_img *IIM_new(int x,int y,int ch);
52 #define i_img_8_new IIM_new
53 void   IIM_DESTROY(i_img *im);
54 i_img *i_img_new( void );
55 i_img *i_img_empty(i_img *im,int x,int y);
56 i_img *i_img_empty_ch(i_img *im,int x,int y,int ch);
57 void   i_img_exorcise(i_img *im);
58 void   i_img_destroy(i_img *im);
59
60 void   i_img_info(i_img *im,int *info);
61
62 extern i_img *i_sametype(i_img *im, int xsize, int ysize);
63 extern i_img *i_sametype_chans(i_img *im, int xsize, int ysize, int channels);
64
65 i_img *i_img_pal_new(int x, int y, int ch, int maxpal);
66
67 /* Image feature settings */
68
69 void   i_img_setmask    (i_img *im,int ch_mask);
70 int    i_img_getmask    (i_img *im);
71 int    i_img_getchannels(i_img *im);
72 i_img_dim i_img_get_width(i_img *im);
73 i_img_dim i_img_get_height(i_img *im);
74
75 /* Base functions */
76
77 extern int i_ppix(i_img *im,int x,int y, const i_color *val);
78 extern int i_gpix(i_img *im,int x,int y,i_color *val);
79 extern int i_ppixf(i_img *im,int x,int y, const i_fcolor *val);
80 extern int i_gpixf(i_img *im,int x,int y,i_fcolor *val);
81
82 #define i_ppix(im, x, y, val) (((im)->i_f_ppix)((im), (x), (y), (val)))
83 #define i_gpix(im, x, y, val) (((im)->i_f_gpix)((im), (x), (y), (val)))
84 #define i_ppixf(im, x, y, val) (((im)->i_f_ppixf)((im), (x), (y), (val)))
85 #define i_gpixf(im, x, y, val) (((im)->i_f_gpixf)((im), (x), (y), (val)))
86
87 extern int i_plin(i_img *im, int l, int r, int y, const i_color *vals);
88 extern int i_glin(i_img *im, int l, int r, int y, i_color *vals);
89 extern int i_plinf(i_img *im, int l, int r, int y, const i_fcolor *vals);
90 extern int i_glinf(i_img *im, int l, int r, int y, i_fcolor *vals);
91 extern int i_gsamp(i_img *im, int l, int r, int y, i_sample_t *samp, 
92                    const int *chans, int chan_count);
93 extern int i_gsampf(i_img *im, int l, int r, int y, i_fsample_t *samp, 
94                    const int *chans, int chan_count);
95 extern int i_gpal(i_img *im, int x, int r, int y, i_palidx *vals);
96 extern int i_ppal(i_img *im, int x, int r, int y, const i_palidx *vals);
97 extern int i_addcolors(i_img *im, const i_color *colors, int count);
98 extern int i_getcolors(i_img *im, int i, i_color *, int count);
99 extern int i_colorcount(i_img *im);
100 extern int i_maxcolors(i_img *im);
101 extern int i_findcolor(i_img *im, const i_color *color, i_palidx *entry);
102 extern int i_setcolors(i_img *im, int index, const i_color *colors, 
103                        int count);
104
105 #define i_plin(im, l, r, y, val) (((im)->i_f_plin)(im, l, r, y, val))
106 #define i_glin(im, l, r, y, val) (((im)->i_f_glin)(im, l, r, y, val))
107 #define i_plinf(im, l, r, y, val) (((im)->i_f_plinf)(im, l, r, y, val))
108 #define i_glinf(im, l, r, y, val) (((im)->i_f_glinf)(im, l, r, y, val))
109
110 #define i_gsamp(im, l, r, y, samps, chans, count) \
111   (((im)->i_f_gsamp)((im), (l), (r), (y), (samps), (chans), (count)))
112 #define i_gsampf(im, l, r, y, samps, chans, count) \
113   (((im)->i_f_gsampf)((im), (l), (r), (y), (samps), (chans), (count)))
114
115 #define i_findcolor(im, color, entry) \
116   (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
117
118 #define i_gpal(im, l, r, y, vals) \
119   (((im)->i_f_gpal) ? ((im)->i_f_gpal)((im), (l), (r), (y), (vals)) : 0)
120 #define i_ppal(im, l, r, y, vals) \
121   (((im)->i_f_ppal) ? ((im)->i_f_ppal)((im), (l), (r), (y), (vals)) : 0)
122 #define i_addcolors(im, colors, count) \
123   (((im)->i_f_addcolors) ? ((im)->i_f_addcolors)((im), (colors), (count)) : -1)
124 #define i_getcolors(im, index, color, count) \
125   (((im)->i_f_getcolors) ? \
126    ((im)->i_f_getcolors)((im), (index), (color), (count)) : 0)
127 #define i_setcolors(im, index, color, count) \
128   (((im)->i_f_setcolors) ? \
129    ((im)->i_f_setcolors)((im), (index), (color), (count)) : 0)
130 #define i_colorcount(im) \
131   (((im)->i_f_colorcount) ? ((im)->i_f_colorcount)(im) : -1)
132 #define i_maxcolors(im) \
133   (((im)->i_f_maxcolors) ? ((im)->i_f_maxcolors)(im) : -1)
134 #define i_findcolor(im, color, entry) \
135   (((im)->i_f_findcolor) ? ((im)->i_f_findcolor)((im), (color), (entry)) : 0)
136
137 #define i_img_virtual(im) ((im)->virtual)
138 #define i_img_type(im) ((im)->type)
139 #define i_img_bits(im) ((im)->bits)
140
141 extern i_fill_t *i_new_fill_solidf(const i_fcolor *c, int combine);
142 extern i_fill_t *i_new_fill_solid(const i_color *c, int combine);
143 extern i_fill_t *
144 i_new_fill_hatch(const i_color *fg, const i_color *bg, int combine, int hatch, 
145                  const unsigned char *cust_hatch, int dx, int dy);
146 extern i_fill_t *
147 i_new_fill_hatchf(const i_fcolor *fg, const i_fcolor *bg, int combine, int hatch, 
148                   const unsigned char *cust_hatch, int dx, int dy);
149 extern i_fill_t *
150 i_new_fill_image(i_img *im, const double *matrix, int xoff, int yoff, int combine);
151 extern void i_fill_destroy(i_fill_t *fill);
152
153 float i_gpix_pch(i_img *im,int x,int y,int ch);
154
155 /* functions for drawing primitives */
156
157 void i_box         (i_img *im,int x1,int y1,int x2,int y2,const i_color *val);
158 void i_box_filled  (i_img *im,int x1,int y1,int x2,int y2,const i_color *val);
159 void i_box_cfill(i_img *im, int x1, int y1, int x2, int y2, i_fill_t *fill);
160 void i_line        (i_img *im,int x1,int y1,int x2,int y2,const i_color *val, int endp);
161 void i_line_aa     (i_img *im,int x1,int y1,int x2,int y2,const i_color *val, int endp);
162 void i_arc         (i_img *im,int x,int y,float rad,float d1,float d2,const i_color *val);
163 void i_arc_aa         (i_img *im, double x, double y, double rad, double d1, double d2, const i_color *val);
164 void i_arc_cfill(i_img *im,int x,int y,float rad,float d1,float d2,i_fill_t *fill);
165 void i_arc_aa_cfill(i_img *im,double x,double y,double rad,double d1,double d2,i_fill_t *fill);
166 void i_circle_aa   (i_img *im,float x, float y,float rad,const i_color *val);
167 void i_copyto      (i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty);
168 void i_copyto_trans(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty,const i_color *trans);
169 i_img* i_copy        (i_img *src);
170 int  i_rubthru     (i_img *im, i_img *src, int tx, int ty, int src_minx, int src_miny, int src_maxx, int src_maxy);
171
172
173 undef_int i_flipxy (i_img *im, int direction);
174 extern i_img *i_rotate90(i_img *im, int degrees);
175 extern i_img *i_rotate_exact(i_img *im, double amount);
176 extern i_img *i_rotate_exact_bg(i_img *im, double amount, const i_color *backp, const i_fcolor *fbackp);
177 extern i_img *i_matrix_transform(i_img *im, int xsize, int ysize, const double *matrix);
178 extern i_img *i_matrix_transform_bg(i_img *im, int xsize, int ysize, const double *matrix,  const i_color *backp, const i_fcolor *fbackp);
179
180 void i_bezier_multi(i_img *im,int l,const double *x,const double *y,const i_color *val);
181 void i_poly_aa     (i_img *im,int l,const double *x,const double *y,const i_color *val);
182 void i_poly_aa_cfill(i_img *im,int l,const double *x,const double *y,i_fill_t *fill);
183
184 undef_int i_flood_fill  (i_img *im,int seedx,int seedy, const i_color *dcol);
185 undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill);
186 undef_int i_flood_fill_border  (i_img *im,int seedx,int seedy, const i_color *dcol, const i_color *border);
187 undef_int i_flood_cfill_border(i_img *im, int seedx, int seedy, i_fill_t *fill, const i_color *border);
188
189
190 /* image processing functions */
191
192 int i_gaussian    (i_img *im, double stdev);
193 void i_conv        (i_img *im,const float *coeff,int len);
194 void i_unsharp_mask(i_img *im, double stddev, double scale);
195
196 /* colour manipulation */
197 extern i_img *i_convert(i_img *src, const float *coeff, int outchan, int inchan);
198 extern void i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask);
199
200 float i_img_diff   (i_img *im1,i_img *im2);
201
202 /* font routines */
203
204 undef_int i_init_fonts( int t1log );
205
206 #ifdef HAVE_LIBT1
207
208 undef_int i_init_t1( int t1log );
209 int       i_t1_new( char *pfb, char *afm );
210 int       i_t1_destroy( int font_id );
211 undef_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 );
212 undef_int i_t1_text( i_img *im, int xb, int yb, const i_color *cl, int fontnum, float points, const char* str, int len, int align, int utf8, char const *flags );
213 int      i_t1_bbox( int fontnum, float point, const char *str, int len, int cords[6], int utf8, char const *flags );
214 void      i_t1_set_aa( int st );
215 void      close_t1( void );
216 int       i_t1_has_chars(int font_num, char const *text, int len, int utf8, char *out);
217 extern int i_t1_face_name(int font_num, char *name_buf, size_t name_buf_size);
218 extern int i_t1_glyph_name(int font_num, unsigned long ch, char *name_buf, 
219                            size_t name_buf_size);
220 #endif
221
222 #ifdef HAVE_LIBTT
223
224 undef_int i_init_tt( void );
225 TT_Fonthandle* i_tt_new(const char *fontname);
226 void i_tt_destroy( TT_Fonthandle *handle );
227 undef_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);
228 undef_int i_tt_text( TT_Fonthandle *handle, i_img *im, int xb, int yb, const i_color *cl, float points, char const* txt, int len, int smooth, int utf8, int align);
229 undef_int i_tt_bbox( TT_Fonthandle *handle, float points,const char *txt,int len,int cords[6], int utf8);
230 int i_tt_has_chars(TT_Fonthandle *handle, char const *text, int len, int utf8, char *out);
231 void i_tt_dump_names(TT_Fonthandle *handle);
232 int i_tt_face_name(TT_Fonthandle *handle, char *name_buf, 
233                    size_t name_buf_size);
234 int i_tt_glyph_name(TT_Fonthandle *handle, unsigned long ch, char *name_buf,
235                     size_t name_buf_size);
236
237 #endif  /* End of freetype headers */
238
239 #ifdef HAVE_FT2
240
241 extern int i_ft2_init(void);
242 extern FT2_Fonthandle * i_ft2_new(const char *name, int index);
243 extern void i_ft2_destroy(FT2_Fonthandle *handle);
244 extern int i_ft2_setdpi(FT2_Fonthandle *handle, int xdpi, int ydpi);
245 extern int i_ft2_getdpi(FT2_Fonthandle *handle, int *xdpi, int *ydpi);
246 extern int i_ft2_settransform(FT2_Fonthandle *handle, const double *matrix);
247 extern int i_ft2_sethinting(FT2_Fonthandle *handle, int hinting);
248 extern int i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth, 
249                       char const *text, int len, int *bbox, int utf8);
250 extern int i_ft2_bbox_r(FT2_Fonthandle *handle, double cheight, double cwidth, 
251                       char const *text, int len, int vlayout, int utf8, int *bbox);
252 extern int i_ft2_text(FT2_Fonthandle *handle, i_img *im, int tx, int ty, 
253                       const i_color *cl, double cheight, double cwidth, 
254                       char const *text, int len, int align, int aa, 
255                       int vlayout, int utf8);
256 extern int i_ft2_cp(FT2_Fonthandle *handle, i_img *im, int tx, int ty, 
257                     int channel, double cheight, double cwidth, 
258                     char const *text, int len, int align, int aa, int vlayout, 
259                     int utf8);
260 extern int i_ft2_has_chars(FT2_Fonthandle *handle, char const *text, int len,
261                            int utf8, char *work);
262 extern int i_ft2_face_name(FT2_Fonthandle *handle, char *name_buf, 
263                            size_t name_buf_size);
264 extern int i_ft2_can_face_name(void);
265 extern int i_ft2_glyph_name(FT2_Fonthandle *handle, unsigned long ch, 
266                             char *name_buf, size_t name_buf_size,
267                             int reliable_only);
268 extern int i_ft2_can_do_glyph_names(void);
269 extern int i_ft2_face_has_glyph_names(FT2_Fonthandle *handle);
270
271 extern int i_ft2_get_multiple_masters(FT2_Fonthandle *handle,
272                                       i_font_mm *mm);
273 extern int
274 i_ft2_is_multiple_master(FT2_Fonthandle *handle);
275 extern int
276 i_ft2_set_mm_coords(FT2_Fonthandle *handle, int coord_count, const long *coords);
277 #endif
278
279 #ifdef WIN32
280
281 extern int i_wf_bbox(const char *face, int size, const char *text, int length, int *bbox, int utf8);
282 extern int i_wf_text(const char *face, i_img *im, int tx, int ty, const i_color *cl, 
283                      int size, const char *text, int len, int align, int aa, int utf8);
284 extern int i_wf_cp(const char *face, i_img *im, int tx, int ty, int channel, 
285                    int size, const char *text, int len, int align, int aa, int utf8);
286 extern int i_wf_addfont(char const *file);
287 extern int i_wf_delfont(char const *file);
288
289 #endif
290
291 /* functions for reading and writing formats */
292
293 /* general reader callback 
294  userdata - data the user passed into the reader
295  buffer - the buffer to fill with data
296  need - the amount of data needed
297  want - the amount of space we have to store data
298  fill buffer and return the number of bytes read, 0 for eof, -1 for error
299 */
300
301 typedef int (*i_read_callback_t)(char *userdata, char *buffer, int need, 
302                                  int want);
303
304 /* i_gen_reader() translates the low-level requests from whatever library
305    into buffered requests.
306    but the called function can always bypass buffering by only ever 
307    reading I<need> bytes.
308 */
309 #define CBBUFSIZ 4096
310
311 typedef struct {
312   i_read_callback_t cb;
313   char *userdata;
314   char buffer[CBBUFSIZ];
315   int length;
316   int cpos;
317 } i_gen_read_data;
318
319 extern int  i_gen_reader(i_gen_read_data *info, char *buffer, int need);
320 extern      i_gen_read_data *i_gen_read_data_new(i_read_callback_t cb, char *userdata);
321 extern void i_free_gen_read_data(i_gen_read_data *);
322
323 /* general writer callback
324    userdata - the data the user passed into the writer
325    data - the data to write
326    data_size - the number of bytes to write
327    write the data, return non-zero on success, zero on failure.
328 */
329 typedef int (*i_write_callback_t)(char *userdata, char const *data, int size);
330
331 typedef struct {
332   i_write_callback_t cb;
333   char *userdata;
334   char buffer[CBBUFSIZ];
335   int maxlength;
336   int filledto;
337 } i_gen_write_data;
338
339 extern int i_gen_writer(i_gen_write_data *info, char const *data, int size);
340 extern i_gen_write_data *i_gen_write_data_new(i_write_callback_t cb, char *userdata, int maxlength);
341 extern int i_free_gen_write_data(i_gen_write_data *, int flush);
342
343 extern void i_quant_makemap(i_quantize *quant, i_img **imgs, int count);
344 extern i_palidx *i_quant_translate(i_quantize *quant, i_img *img);
345 extern void i_quant_transparent(i_quantize *quant, i_palidx *indices, i_img *img, i_palidx trans_index);
346
347 extern i_img *i_img_pal_new(int x, int y, int channels, int maxpal);
348 extern i_img *i_img_pal_new_low(i_img *im, int x, int y, int channels, int maxpal);
349 extern i_img *i_img_to_pal(i_img *src, i_quantize *quant);
350 extern i_img *i_img_to_rgb(i_img *src);
351 extern i_img *i_img_masked_new(i_img *targ, i_img *mask, int x, int y, 
352                                int w, int h);
353 extern i_img *i_img_16_new(int x, int y, int ch);
354 extern i_img *i_img_16_new_low(i_img *im, int x, int y, int ch);
355 extern i_img *i_img_to_rgb16(i_img *im);
356 extern i_img *i_img_double_new(int x, int y, int ch);
357 extern i_img *i_img_double_new_low(i_img *im, int x, int y, int ch);
358
359 extern int i_img_is_monochrome(i_img *im, int *zero_is_white);
360
361 const char * i_test_format_probe(io_glue *data, int length);
362
363
364 #ifdef HAVE_LIBJPEG
365 i_img *   
366 i_readjpeg_wiol(io_glue *ig, int length, char** iptc_itext, int *itlength);
367 undef_int i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor);
368 #endif /* HAVE_LIBJPEG */
369
370 #ifdef HAVE_LIBTIFF
371 i_img   * i_readtiff_wiol(io_glue *ig, int allow_incomplete, int page);
372 i_img  ** i_readtiff_multi_wiol(io_glue *ig, int length, int *count);
373 undef_int i_writetiff_wiol(i_img *im, io_glue *ig);
374 undef_int i_writetiff_multi_wiol(io_glue *ig, i_img **imgs, int count);
375 undef_int i_writetiff_wiol_faxable(i_img *im, io_glue *ig, int fine);
376 undef_int i_writetiff_multi_wiol_faxable(io_glue *ig, i_img **imgs, int count, int fine);
377
378 #endif /* HAVE_LIBTIFF */
379
380 #ifdef HAVE_LIBPNG
381 i_img    *i_readpng_wiol(io_glue *ig, int length);
382 undef_int i_writepng_wiol(i_img *im, io_glue *ig);
383 #endif /* HAVE_LIBPNG */
384
385 #ifdef HAVE_LIBGIF
386 i_img *i_readgif(int fd, int **colour_table, int *colours);
387 i_img *i_readgif_wiol(io_glue *ig, int **colour_table, int *colours);
388 i_img *i_readgif_scalar(char *data, int length, int **colour_table, int *colours);
389 i_img *i_readgif_callback(i_read_callback_t callback, char *userdata, int **colour_table, int *colours);
390 i_img *i_readgif_single_wiol(io_glue *ig, int page);
391 extern i_img **i_readgif_multi(int fd, int *count);
392 extern i_img **i_readgif_multi_scalar(char *data, int length, int *count);
393 extern i_img **i_readgif_multi_callback(i_read_callback_t callback, char *userdata, int *count);
394 extern i_img **i_readgif_multi_wiol(io_glue *ig, int *count);
395 undef_int i_writegif(i_img *im,int fd,int colors,int pixdev,int fixedlen,i_color fixed[]);
396 undef_int i_writegifmc(i_img *im,int fd,int colors);
397 undef_int i_writegifex(i_img *im,int fd);
398 undef_int i_writegif_gen(i_quantize *quant, int fd, i_img **imgs, int count);
399 undef_int i_writegif_callback(i_quantize *quant, i_write_callback_t cb, char *userdata, int maxbuffer, i_img **imgs, int count);
400 undef_int i_writegif_wiol(io_glue *ig, i_quantize *quant, 
401                           i_img **imgs, int count);
402 void i_qdist(i_img *im);
403
404 #endif /* HAVE_LIBGIF */
405
406 i_img   * i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, int intrl);
407 undef_int i_writeraw_wiol(i_img* im, io_glue *ig);
408
409 i_img   * i_readpnm_wiol(io_glue *ig, int allow_incomplete);
410 undef_int i_writeppm_wiol(i_img *im, io_glue *ig);
411
412 extern int    i_writebmp_wiol(i_img *im, io_glue *ig);
413 extern i_img *i_readbmp_wiol(io_glue *ig, int allow_incomplete);
414
415 int tga_header_verify(unsigned char headbuf[18]);
416
417 i_img   * i_readtga_wiol(io_glue *ig, int length);
418 undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
419
420 i_img   * i_readrgb_wiol(io_glue *ig, int length);
421 undef_int i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
422
423 i_img * i_scaleaxis(i_img *im, float Value, int Axis);
424 i_img * i_scale_nn(i_img *im, float scx, float scy);
425 i_img * i_scale_mixing(i_img *src, int width, int height);
426 i_img * i_haar(i_img *im);
427 int     i_count_colors(i_img *im,int maxc);
428 int i_get_anonymous_color_histo(i_img *im, unsigned int **col_usage, int maxc);
429
430 i_img * i_transform(i_img *im, int *opx,int opxl,int *opy,int opyl,double parm[],int parmlen);
431
432 struct rm_op;
433 i_img * i_transform2(int width, int height, int channels,
434                      struct rm_op *ops, int ops_count, 
435                      double *n_regs, int n_regs_count, 
436                      i_color *c_regs, int c_regs_count, 
437                      i_img **in_imgs, int in_imgs_count);
438
439 /* filters */
440
441 void i_contrast(i_img *im, float intensity);
442 void i_hardinvert(i_img *im);
443 void i_noise(i_img *im, float amount, unsigned char type);
444 void i_bumpmap(i_img *im,i_img *bump,int channel,int light_x,int light_y,int strength);
445 void i_bumpmap_complex(i_img *im, i_img *bump, int channel, int tx, int ty, float Lx, float Ly, 
446                        float Lz, float cd, float cs, float n, i_color *Ia, i_color *Il, i_color *Is);
447 void i_postlevels(i_img *im,int levels);
448 void i_mosaic(i_img *im,int size);
449 void i_watermark(i_img *im,i_img *wmark,int tx,int ty,int pixdiff);
450 void i_autolevels(i_img *im,float lsat,float usat,float skew);
451 void i_radnoise(i_img *im,int xo,int yo,float rscale,float ascale);
452 void i_turbnoise(i_img *im,float xo,float yo,float scale);
453 void i_gradgen(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
454 int i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
455 i_img *i_diff_image(i_img *im, i_img *im2, double mindist);
456 int
457 i_fountain(i_img *im, double xa, double ya, double xb, double yb, 
458            i_fountain_type type, i_fountain_repeat repeat, 
459            int combine, int super_sample, double ssample_param,
460            int count, i_fountain_seg *segs);
461 extern i_fill_t *
462 i_new_fill_fount(double xa, double ya, double xb, double yb, 
463                  i_fountain_type type, i_fountain_repeat repeat, 
464                  int combine, int super_sample, double ssample_param, 
465                  int count, i_fountain_seg *segs);
466
467 /* Debug only functions */
468
469 void malloc_state( void );
470
471 /* this is sort of obsolete now */
472
473 typedef struct {
474   undef_int (*i_has_format)(char *frmt);
475   i_color*(*ICL_set)(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
476   void (*ICL_info)(const i_color *cl);
477
478   i_img*(*i_img_new)( void );
479   i_img*(*i_img_empty)(i_img *im,int x,int y);
480   i_img*(*i_img_empty_ch)(i_img *im,int x,int y,int ch);
481   void(*i_img_exorcise)(i_img *im);
482
483   void(*i_img_info)(i_img *im,int *info);
484   
485   void(*i_img_setmask)(i_img *im,int ch_mask);
486   int (*i_img_getmask)(i_img *im);
487   
488   /*
489   int (*i_ppix)(i_img *im,int x,int y,i_color *val);
490   int (*i_gpix)(i_img *im,int x,int y,i_color *val);
491   */
492   void(*i_box)(i_img *im,int x1,int y1,int x2,int y2,const i_color *val);
493   void(*i_line)(i_img *im,int x1,int y1,int x2,int y2,const i_color *val,int endp);
494   void(*i_arc)(i_img *im,int x,int y,float rad,float d1,float d2,const i_color *val);
495   void(*i_copyto)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty);
496   void(*i_copyto_trans)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty,const i_color *trans);
497   int(*i_rubthru)(i_img *im,i_img *src,int tx,int ty, int src_minx, int src_miny, int src_maxx, int src_maxy);
498
499 } symbol_table_t;
500
501 #include "imerror.h"
502
503 /* image tag processing */
504 extern void i_tags_new(i_img_tags *tags);
505 extern int i_tags_addn(i_img_tags *tags, char const *name, int code, 
506                        int idata);
507 extern int i_tags_add(i_img_tags *tags, char const *name, int code, 
508                       char const *data, int size, int idata);
509 extern int i_tags_set(i_img_tags *tags, char const *name,
510                       char const *data, int size);
511 extern int i_tags_setn(i_img_tags *tags, char const *name, int idata);
512                        
513 extern void i_tags_destroy(i_img_tags *tags);
514 extern int i_tags_find(i_img_tags *tags, char const *name, int start, 
515                        int *entry);
516 extern int i_tags_findn(i_img_tags *tags, int code, int start, int *entry);
517 extern int i_tags_delete(i_img_tags *tags, int entry);
518 extern int i_tags_delbyname(i_img_tags *tags, char const *name);
519 extern int i_tags_delbycode(i_img_tags *tags, int code);
520 extern int i_tags_get_float(i_img_tags *tags, char const *name, int code, 
521                             double *value);
522 extern int i_tags_set_float(i_img_tags *tags, char const *name, int code, 
523                             double value);
524 extern int i_tags_set_float2(i_img_tags *tags, char const *name, int code, 
525                             double value, int places);
526 extern int i_tags_get_int(i_img_tags *tags, char const *name, int code, 
527                           int *value);
528 extern int i_tags_get_string(i_img_tags *tags, char const *name, int code, 
529                              char *value, size_t value_size);
530 extern int i_tags_get_color(i_img_tags *tags, char const *name, int code, 
531                             i_color *value);
532 extern int i_tags_set_color(i_img_tags *tags, char const *name, int code, 
533                             i_color const *value);
534 extern void i_tags_print(i_img_tags *tags);
535
536 /* image file limits */
537 extern int
538 i_set_image_file_limits(int width, int height, int bytes);
539 extern int
540 i_get_image_file_limits(int *width, int *height, int *bytes);
541 extern int
542 i_int_check_image_file_limits(int width, int height, int channels, int sample_size);
543
544 /* memory allocation */
545 void* mymalloc(int size);
546 void  myfree(void *p);
547 void* myrealloc(void *p, size_t newsize);
548 void* mymalloc_file_line (size_t size, char* file, int line);
549 void  myfree_file_line   (void *p, char*file, int line);
550 void* myrealloc_file_line(void *p, size_t newsize, char* file,int line);
551
552 #ifdef IMAGER_DEBUG_MALLOC
553
554 #define mymalloc(x) (mymalloc_file_line((x), __FILE__, __LINE__))
555 #define myrealloc(x,y) (myrealloc_file_line((x),(y), __FILE__, __LINE__))
556 #define myfree(x) (myfree_file_line((x), __FILE__, __LINE__))
557
558 void  malloc_state       (void);
559 void* mymalloc_comm      (int size, char *comm);
560 void  bndcheck_all       (void);
561
562 #else
563
564 #define malloc_comm(a,b) (mymalloc(a))
565 void  malloc_state(void);
566
567 #endif /* IMAGER_MALLOC_DEBUG */
568
569 #include "imrender.h"
570
571 #endif