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