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