Move freetype 2 support into its own module
[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);
52f2b10a 158extern i_fill_t *i_new_fill_opacity(i_fill_t *, double alpha_mult);
f1ac5027
TC
159extern void i_fill_destroy(i_fill_t *fill);
160
02d1d628
AMH
161float i_gpix_pch(i_img *im,int x,int y,int ch);
162
163/* functions for drawing primitives */
164
97ac0a96
TC
165void i_box (i_img *im,int x1,int y1,int x2,int y2,const i_color *val);
166void i_box_filled (i_img *im,int x1,int y1,int x2,int y2,const i_color *val);
f1ac5027 167void i_box_cfill(i_img *im, int x1, int y1, int x2, int y2, i_fill_t *fill);
97ac0a96
TC
168void i_line (i_img *im,int x1,int y1,int x2,int y2,const i_color *val, int endp);
169void i_line_aa (i_img *im,int x1,int y1,int x2,int y2,const i_color *val, int endp);
170void i_arc (i_img *im,int x,int y,float rad,float d1,float d2,const i_color *val);
40068b33
TC
171int 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);
172int 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);
97ac0a96 173void i_arc_aa (i_img *im, double x, double y, double rad, double d1, double d2, const i_color *val);
f1ac5027 174void i_arc_cfill(i_img *im,int x,int y,float rad,float d1,float d2,i_fill_t *fill);
a8652edf 175void i_arc_aa_cfill(i_img *im,double x,double y,double rad,double d1,double d2,i_fill_t *fill);
97ac0a96 176void i_circle_aa (i_img *im,float x, float y,float rad,const i_color *val);
40068b33
TC
177int i_circle_out (i_img *im,i_img_dim x, i_img_dim y, i_img_dim rad,const i_color *val);
178int i_circle_out_aa (i_img *im,i_img_dim x, i_img_dim y, i_img_dim rad,const i_color *val);
02d1d628 179void i_copyto (i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty);
97ac0a96 180void 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 181i_img* i_copy (i_img *src);
71dc4a83 182int 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
183extern int
184i_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);
188extern int
189i_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);
02d1d628 192
142c26ff 193undef_int i_flipxy (i_img *im, int direction);
faa9b3e7
TC
194extern i_img *i_rotate90(i_img *im, int degrees);
195extern i_img *i_rotate_exact(i_img *im, double amount);
97ac0a96
TC
196extern i_img *i_rotate_exact_bg(i_img *im, double amount, const i_color *backp, const i_fcolor *fbackp);
197extern i_img *i_matrix_transform(i_img *im, int xsize, int ysize, const double *matrix);
198extern 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 199
97ac0a96 200void i_bezier_multi(i_img *im,int l,const double *x,const double *y,const i_color *val);
1c5252ed
TC
201int i_poly_aa (i_img *im,int l,const double *x,const double *y,const i_color *val);
202int i_poly_aa_cfill(i_img *im,int l,const double *x,const double *y,i_fill_t *fill);
02d1d628 203
97ac0a96 204undef_int i_flood_fill (i_img *im,int seedx,int seedy, const i_color *dcol);
a321d497 205undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill);
3efb0915
TC
206undef_int i_flood_fill_border (i_img *im,int seedx,int seedy, const i_color *dcol, const i_color *border);
207undef_int i_flood_cfill_border(i_img *im, int seedx, int seedy, i_fill_t *fill, const i_color *border);
a321d497 208
02d1d628
AMH
209
210/* image processing functions */
211
167660cd 212int i_gaussian (i_img *im, double stdev);
6a3cbaef 213int i_conv (i_img *im,const double *coeff,int len);
b6381851 214void i_unsharp_mask(i_img *im, double stddev, double scale);
02d1d628 215
f5991c03 216/* colour manipulation */
d5477d3d 217extern i_img *i_convert(i_img *src, const float *coeff, int outchan, int inchan);
faa9b3e7 218extern void i_map(i_img *im, unsigned char (*maps)[256], unsigned int mask);
f5991c03 219
02d1d628 220float i_img_diff (i_img *im1,i_img *im2);
e41cfe8f 221double i_img_diffd(i_img *im1,i_img *im2);
02d1d628
AMH
222
223/* font routines */
224
4cb58f1b 225undef_int i_init_fonts( int t1log );
02d1d628
AMH
226
227#ifdef HAVE_LIBT1
02d1d628 228
b33c08f8 229undef_int i_init_t1( int t1log );
02d1d628
AMH
230int i_t1_new( char *pfb, char *afm );
231int i_t1_destroy( int font_id );
718b8c97
TC
232undef_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 );
233undef_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 );
234int i_t1_bbox( int fontnum, float point, const char *str, size_t len, int cords[6], int utf8, char const *flags );
02d1d628
AMH
235void i_t1_set_aa( int st );
236void close_t1( void );
718b8c97 237int i_t1_has_chars(int font_num, char const *text, size_t len, int utf8, char *out);
3799c4d1
TC
238extern int i_t1_face_name(int font_num, char *name_buf, size_t name_buf_size);
239extern int i_t1_glyph_name(int font_num, unsigned long ch, char *name_buf,
240 size_t name_buf_size);
02d1d628
AMH
241#endif
242
243#ifdef HAVE_LIBTT
244
b33c08f8 245undef_int i_init_tt( void );
97ac0a96 246TT_Fonthandle* i_tt_new(const char *fontname);
02d1d628 247void i_tt_destroy( TT_Fonthandle *handle );
718b8c97
TC
248undef_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);
249undef_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);
250undef_int i_tt_bbox( TT_Fonthandle *handle, float points,const char *txt,size_t len,int cords[6], int utf8);
251int i_tt_has_chars(TT_Fonthandle *handle, char const *text, size_t len, int utf8, char *out);
3799c4d1
TC
252void i_tt_dump_names(TT_Fonthandle *handle);
253int i_tt_face_name(TT_Fonthandle *handle, char *name_buf,
254 size_t name_buf_size);
255int i_tt_glyph_name(TT_Fonthandle *handle, unsigned long ch, char *name_buf,
256 size_t name_buf_size);
02d1d628
AMH
257
258#endif /* End of freetype headers */
259
02d1d628
AMH
260/* functions for reading and writing formats */
261
262/* general reader callback
263 userdata - data the user passed into the reader
264 buffer - the buffer to fill with data
265 need - the amount of data needed
266 want - the amount of space we have to store data
267 fill buffer and return the number of bytes read, 0 for eof, -1 for error
268*/
269
270typedef int (*i_read_callback_t)(char *userdata, char *buffer, int need,
271 int want);
272
273/* i_gen_reader() translates the low-level requests from whatever library
274 into buffered requests.
275 but the called function can always bypass buffering by only ever
276 reading I<need> bytes.
277*/
278#define CBBUFSIZ 4096
279
280typedef struct {
281 i_read_callback_t cb;
282 char *userdata;
283 char buffer[CBBUFSIZ];
284 int length;
285 int cpos;
286} i_gen_read_data;
287
288extern int i_gen_reader(i_gen_read_data *info, char *buffer, int need);
289extern i_gen_read_data *i_gen_read_data_new(i_read_callback_t cb, char *userdata);
b33c08f8 290extern void i_free_gen_read_data(i_gen_read_data *);
02d1d628
AMH
291
292/* general writer callback
293 userdata - the data the user passed into the writer
294 data - the data to write
295 data_size - the number of bytes to write
296 write the data, return non-zero on success, zero on failure.
297*/
298typedef int (*i_write_callback_t)(char *userdata, char const *data, int size);
299
300typedef struct {
301 i_write_callback_t cb;
302 char *userdata;
303 char buffer[CBBUFSIZ];
304 int maxlength;
305 int filledto;
306} i_gen_write_data;
307
308extern int i_gen_writer(i_gen_write_data *info, char const *data, int size);
309extern i_gen_write_data *i_gen_write_data_new(i_write_callback_t cb, char *userdata, int maxlength);
b33c08f8 310extern int i_free_gen_write_data(i_gen_write_data *, int flush);
02d1d628 311
92bda632
TC
312extern void i_quant_makemap(i_quantize *quant, i_img **imgs, int count);
313extern i_palidx *i_quant_translate(i_quantize *quant, i_img *img);
314extern void i_quant_transparent(i_quantize *quant, i_palidx *indices, i_img *img, i_palidx trans_index);
02d1d628 315
faa9b3e7 316extern i_img *i_img_pal_new(int x, int y, int channels, int maxpal);
faa9b3e7
TC
317extern i_img *i_img_to_pal(i_img *src, i_quantize *quant);
318extern i_img *i_img_to_rgb(i_img *src);
319extern i_img *i_img_masked_new(i_img *targ, i_img *mask, int x, int y,
320 int w, int h);
321extern i_img *i_img_16_new(int x, int y, int ch);
167660cd 322extern i_img *i_img_to_rgb16(i_img *im);
365ea842 323extern i_img *i_img_double_new(int x, int y, int ch);
faa9b3e7 324
9c106321 325extern int i_img_is_monochrome(i_img *im, int *zero_is_white);
6e4af7d4 326extern void i_get_file_background(i_img *im, i_color *bg);
fa90de94 327extern void i_get_file_backgroundf(i_img *im, i_fcolor *bg);
e10bf46e 328
ea1136fc 329const char * i_test_format_probe(io_glue *data, int length);
e10bf46e
AMH
330
331
02d1d628 332#ifdef HAVE_LIBJPEG
dd55acc8
AMH
333i_img *
334i_readjpeg_wiol(io_glue *ig, int length, char** iptc_itext, int *itlength);
335undef_int i_writejpeg_wiol(i_img *im, io_glue *ig, int qfactor);
02d1d628
AMH
336#endif /* HAVE_LIBJPEG */
337
04418ecc 338i_img * i_readraw_wiol(io_glue *ig, int x, int y, int datachannels, int storechannels, int intrl);
895dbd34 339undef_int i_writeraw_wiol(i_img* im, io_glue *ig);
02d1d628 340
d87dc9a4 341i_img * i_readpnm_wiol(io_glue *ig, int allow_incomplete);
2086be61 342i_img ** i_readpnm_multi_wiol(io_glue *ig, int *count, int allow_incomplete);
067d6bdc 343undef_int i_writeppm_wiol(i_img *im, io_glue *ig);
02d1d628 344
1ec86afa 345extern int i_writebmp_wiol(i_img *im, io_glue *ig);
d87dc9a4 346extern i_img *i_readbmp_wiol(io_glue *ig, int allow_incomplete);
02d1d628 347
84e51293
AMH
348int tga_header_verify(unsigned char headbuf[18]);
349
1ec86afa 350i_img * i_readtga_wiol(io_glue *ig, int length);
febba01f 351undef_int i_writetga_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
1ec86afa 352
737a830c
AMH
353i_img * i_readrgb_wiol(io_glue *ig, int length);
354undef_int i_writergb_wiol(i_img *img, io_glue *ig, int wierdpack, int compress, char *idstring, size_t idlen);
355
04418ecc
AMH
356i_img * i_scaleaxis(i_img *im, float Value, int Axis);
357i_img * i_scale_nn(i_img *im, float scx, float scy);
658f724e 358i_img * i_scale_mixing(i_img *src, int width, int height);
04418ecc
AMH
359i_img * i_haar(i_img *im);
360int i_count_colors(i_img *im,int maxc);
a60905e4 361int i_get_anonymous_color_histo(i_img *im, unsigned int **col_usage, int maxc);
02d1d628 362
04418ecc 363i_img * i_transform(i_img *im, int *opx,int opxl,int *opy,int opyl,double parm[],int parmlen);
02d1d628
AMH
364
365struct rm_op;
04418ecc
AMH
366i_img * i_transform2(int width, int height, int channels,
367 struct rm_op *ops, int ops_count,
368 double *n_regs, int n_regs_count,
369 i_color *c_regs, int c_regs_count,
370 i_img **in_imgs, int in_imgs_count);
febba01f 371
02d1d628
AMH
372/* filters */
373
374void i_contrast(i_img *im, float intensity);
375void i_hardinvert(i_img *im);
5558f899 376void i_hardinvertall(i_img *im);
02d1d628
AMH
377void i_noise(i_img *im, float amount, unsigned char type);
378void i_bumpmap(i_img *im,i_img *bump,int channel,int light_x,int light_y,int strength);
b2778574
AMH
379void i_bumpmap_complex(i_img *im, i_img *bump, int channel, int tx, int ty, float Lx, float Ly,
380 float Lz, float cd, float cs, float n, i_color *Ia, i_color *Il, i_color *Is);
02d1d628
AMH
381void i_postlevels(i_img *im,int levels);
382void i_mosaic(i_img *im,int size);
383void i_watermark(i_img *im,i_img *wmark,int tx,int ty,int pixdiff);
384void i_autolevels(i_img *im,float lsat,float usat,float skew);
385void i_radnoise(i_img *im,int xo,int yo,float rscale,float ascale);
386void i_turbnoise(i_img *im,float xo,float yo,float scale);
387void i_gradgen(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
e310e5f9 388int i_nearest_color(i_img *im, int num, int *xo, int *yo, i_color *ival, int dmeasure);
01b84320 389i_img *i_diff_image(i_img *im, i_img *im2, double mindist);
e310e5f9
TC
390int
391i_fountain(i_img *im, double xa, double ya, double xb, double yb,
392 i_fountain_type type, i_fountain_repeat repeat,
393 int combine, int super_sample, double ssample_param,
394 int count, i_fountain_seg *segs);
f1ac5027
TC
395extern i_fill_t *
396i_new_fill_fount(double xa, double ya, double xb, double yb,
397 i_fountain_type type, i_fountain_repeat repeat,
398 int combine, int super_sample, double ssample_param,
399 int count, i_fountain_seg *segs);
02d1d628
AMH
400
401/* Debug only functions */
402
403void malloc_state( void );
404
405/* this is sort of obsolete now */
406
407typedef struct {
408 undef_int (*i_has_format)(char *frmt);
409 i_color*(*ICL_set)(i_color *cl,unsigned char r,unsigned char g,unsigned char b,unsigned char a);
97ac0a96 410 void (*ICL_info)(const i_color *cl);
02d1d628
AMH
411
412 i_img*(*i_img_new)( void );
413 i_img*(*i_img_empty)(i_img *im,int x,int y);
414 i_img*(*i_img_empty_ch)(i_img *im,int x,int y,int ch);
415 void(*i_img_exorcise)(i_img *im);
416
417 void(*i_img_info)(i_img *im,int *info);
418
419 void(*i_img_setmask)(i_img *im,int ch_mask);
420 int (*i_img_getmask)(i_img *im);
421
da1c841c 422 /*
02d1d628
AMH
423 int (*i_ppix)(i_img *im,int x,int y,i_color *val);
424 int (*i_gpix)(i_img *im,int x,int y,i_color *val);
da1c841c 425 */
97ac0a96
TC
426 void(*i_box)(i_img *im,int x1,int y1,int x2,int y2,const i_color *val);
427 void(*i_line)(i_img *im,int x1,int y1,int x2,int y2,const i_color *val,int endp);
428 void(*i_arc)(i_img *im,int x,int y,float rad,float d1,float d2,const i_color *val);
02d1d628 429 void(*i_copyto)(i_img *im,i_img *src,int x1,int y1,int x2,int y2,int tx,int ty);
97ac0a96
TC
430 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);
431 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
432
433} symbol_table_t;
434
af070d99 435#include "imerror.h"
02d1d628 436
faa9b3e7
TC
437/* image tag processing */
438extern void i_tags_new(i_img_tags *tags);
97c4effc
TC
439extern int i_tags_addn(i_img_tags *tags, char const *name, int code,
440 int idata);
441extern int i_tags_add(i_img_tags *tags, char const *name, int code,
442 char const *data, int size, int idata);
92bda632
TC
443extern int i_tags_set(i_img_tags *tags, char const *name,
444 char const *data, int size);
445extern int i_tags_setn(i_img_tags *tags, char const *name, int idata);
446
faa9b3e7 447extern void i_tags_destroy(i_img_tags *tags);
97c4effc
TC
448extern int i_tags_find(i_img_tags *tags, char const *name, int start,
449 int *entry);
faa9b3e7
TC
450extern int i_tags_findn(i_img_tags *tags, int code, int start, int *entry);
451extern int i_tags_delete(i_img_tags *tags, int entry);
97c4effc 452extern int i_tags_delbyname(i_img_tags *tags, char const *name);
faa9b3e7 453extern int i_tags_delbycode(i_img_tags *tags, int code);
97c4effc 454extern int i_tags_get_float(i_img_tags *tags, char const *name, int code,
fd9a31d2 455 double *value);
97c4effc 456extern int i_tags_set_float(i_img_tags *tags, char const *name, int code,
fd9a31d2 457 double value);
2e41e30b
TC
458extern int i_tags_set_float2(i_img_tags *tags, char const *name, int code,
459 double value, int places);
97c4effc
TC
460extern int i_tags_get_int(i_img_tags *tags, char const *name, int code,
461 int *value);
462extern int i_tags_get_string(i_img_tags *tags, char const *name, int code,
fd9a31d2 463 char *value, size_t value_size);
97c4effc
TC
464extern int i_tags_get_color(i_img_tags *tags, char const *name, int code,
465 i_color *value);
466extern int i_tags_set_color(i_img_tags *tags, char const *name, int code,
467 i_color const *value);
fd9a31d2 468extern void i_tags_print(i_img_tags *tags);
02d1d628 469
77157728
TC
470/* image file limits */
471extern int
472i_set_image_file_limits(int width, int height, int bytes);
473extern int
474i_get_image_file_limits(int *width, int *height, int *bytes);
2b405c9e
TC
475extern int
476i_int_check_image_file_limits(int width, int height, int channels, int sample_size);
77157728 477
e310e5f9
TC
478/* memory allocation */
479void* mymalloc(int size);
480void myfree(void *p);
481void* myrealloc(void *p, size_t newsize);
482void* mymalloc_file_line (size_t size, char* file, int line);
483void myfree_file_line (void *p, char*file, int line);
484void* myrealloc_file_line(void *p, size_t newsize, char* file,int line);
485
486#ifdef IMAGER_DEBUG_MALLOC
487
488#define mymalloc(x) (mymalloc_file_line((x), __FILE__, __LINE__))
489#define myrealloc(x,y) (myrealloc_file_line((x),(y), __FILE__, __LINE__))
490#define myfree(x) (myfree_file_line((x), __FILE__, __LINE__))
491
492void malloc_state (void);
493void* mymalloc_comm (int size, char *comm);
494void bndcheck_all (void);
495
496#else
497
498#define malloc_comm(a,b) (mymalloc(a))
499void malloc_state(void);
500
501#endif /* IMAGER_MALLOC_DEBUG */
502
9c106321 503#include "imrender.h"
bea65b1f 504#include "immacros.h"
9c106321 505
9b1ec2b8
TC
506extern void
507i_adapt_colors(int dest_channels, int src_channels, i_color *colors,
508 size_t count);
509extern void
510i_adapt_fcolors(int dest_channels, int src_channels, i_fcolor *colors,
511 size_t count);
512
fa90de94
TC
513extern void
514i_adapt_colors_bg(int dest_channels, int src_channels, i_color *colors,
515 size_t count, i_color const *bg);
516extern void
517i_adapt_fcolors_bg(int dest_channels, int src_channels, i_fcolor *colors,
518 size_t count, i_fcolor const *bg);
519
2a31a4b4
TC
520extern int
521i_gsamp_bg(i_img *im, int l, int r, int y, i_sample_t *samples,
522 int out_channels, i_color const *bg);
523
524extern int
525i_gsampf_bg(i_img *im, int l, int r, int y, i_fsample_t *samples,
526 int out_channels, i_fcolor const *bg);
527
02d1d628 528#endif