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