move TIFF into its own module
[imager.git] / imext.c
CommitLineData
92bda632
TC
1#include "imexttypes.h"
2#include "imager.h"
3
4/*
5 DON'T ADD CASTS TO THESE
6*/
7im_ext_funcs imager_function_table =
8 {
d1f5892c
TC
9 IMAGER_API_VERSION,
10 IMAGER_API_LEVEL,
11
92bda632
TC
12 mymalloc,
13 myfree,
14 myrealloc,
15
e310e5f9
TC
16 mymalloc_file_line,
17 myfree_file_line,
18 myrealloc_file_line,
19
92bda632
TC
20 i_img_8_new,
21 i_img_16_new,
22 i_img_double_new,
23 i_img_pal_new,
24 i_img_destroy,
25 i_sametype,
26 i_sametype_chans,
27 i_img_info,
28
29 i_ppix,
30 i_gpix,
31 i_ppixf,
32 i_gpixf,
33 i_plin,
34 i_glin,
35 i_plinf,
36 i_glinf,
37 i_gsamp,
38 i_gsampf,
39 i_gpal,
40 i_ppal,
41 i_addcolors,
42 i_getcolors,
43 i_colorcount,
44 i_maxcolors,
45 i_findcolor,
46 i_setcolors,
47
48 i_new_fill_solid,
49 i_new_fill_solidf,
50 i_new_fill_hatch,
51 i_new_fill_hatchf,
52 i_new_fill_image,
53 i_new_fill_fount,
54 i_fill_destroy,
55
56 i_quant_makemap,
57 i_quant_translate,
58 i_quant_transparent,
59
60 i_clear_error,
61 i_push_error,
62 i_push_errorf,
63 i_push_errorvf,
64
65 i_tags_new,
66 i_tags_set,
67 i_tags_setn,
68 i_tags_destroy,
69 i_tags_find,
70 i_tags_findn,
71 i_tags_delete,
72 i_tags_delbyname,
73 i_tags_delbycode,
74 i_tags_get_float,
75 i_tags_set_float,
76 i_tags_set_float2,
77 i_tags_get_int,
78 i_tags_get_string,
79 i_tags_get_color,
80 i_tags_set_color,
81
82 i_box,
83 i_box_filled,
84 i_box_cfill,
85 i_line,
86 i_line_aa,
87 i_arc,
88 i_arc_aa,
89 i_arc_cfill,
90 i_arc_aa_cfill,
91 i_circle_aa,
92 i_flood_fill,
93 i_flood_cfill,
94
95 i_copyto,
96 i_copyto_trans,
97 i_copy,
98 i_rubthru,
2b405c9e
TC
99
100 /* IMAGER_API_LEVEL 2 functions */
101 i_set_image_file_limits,
102 i_get_image_file_limits,
103 i_int_check_image_file_limits,
3efb0915
TC
104
105 i_flood_fill_border,
106 i_flood_cfill_border,
d5477d3d
TC
107
108 /* IMAGER_API_LEVEL 3 functions */
109 i_img_setmask,
110 i_img_getmask,
111 i_img_getchannels,
112 i_img_get_width,
113 i_img_get_height,
114 i_lhead,
bd8052a6
TC
115 i_loog,
116
117 /* IMAGER_API_LEVEL 4 functions */
118 i_img_alloc,
119 i_img_init,
e5ee047b
TC
120
121 /* IMAGER_API_LEVEL 5 functions */
122 i_img_is_monochrome
92bda632
TC
123 };
124
125/* in general these functions aren't called by Imager internally, but
126 only via the pointers above, since faster macros that call the
127 image vtable pointers are used.
128
129 () are used around the function names to prevent macro replacement
130 on the function names.
131*/
132
133/*
134=item i_ppix(im, x, y, color)
135
136=category Drawing
137
138Sets the pixel at (x,y) to I<color>.
139
140Returns 0 if the pixel was drawn, or -1 if not.
141
142Does no alpha blending, just copies the channels from the supplied
143color to the image.
144
145=cut
146*/
147
148int
97ac0a96 149(i_ppix)(i_img *im, int x, int y, const i_color *val) {
92bda632
TC
150 return i_ppix(im, x, y, val);
151}
152
153/*
5715f7c3 154=item i_gpix(im, C<x>, C<y>, C<color>)
92bda632
TC
155
156=category Drawing
157
5715f7c3 158Retrieves the C<color> of the pixel (x,y).
92bda632
TC
159
160Returns 0 if the pixel was retrieved, or -1 if not.
161
162=cut
163*/
164
165int
166(i_gpix)(i_img *im,int x,int y,i_color *val) {
167 return i_gpix(im, x, y, val);
168}
169
170/*
5715f7c3 171=item i_ppixf(im, C<x>, C<y>, C<fcolor>)
92bda632
TC
172
173=category Drawing
174
5715f7c3 175Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
92bda632
TC
176
177Returns 0 if the pixel was drawn, or -1 if not.
178
179Does no alpha blending, just copies the channels from the supplied
180color to the image.
181
182=cut
183*/
184int
97ac0a96 185(i_ppixf)(i_img *im, int x, int y, const i_fcolor *val) {
92bda632
TC
186 return i_ppixf(im, x, y, val);
187}
188
189/*
5715f7c3 190=item i_gpixf(im, C<x>, C<y>, C<fcolor>)
92bda632
TC
191
192=category Drawing
193
194Retrieves the color of the pixel (x,y) as a floating point color into
5715f7c3 195C<fcolor>.
92bda632
TC
196
197Returns 0 if the pixel was retrieved, or -1 if not.
198
199=cut
200*/
201
202int
203(i_gpixf)(i_img *im,int x,int y,i_fcolor *val) {
204 return i_gpixf(im, x, y, val);
205}
206
207/*
208=item i_plin(im, l, r, y, colors)
209
210=category Drawing
211
212Sets (r-l) pixels starting from (l,y) using (r-l) values from
213I<colors>.
214
215Returns the number of pixels set.
216
217=cut
218*/
219
220int
97ac0a96 221(i_plin)(i_img *im, int l, int r, int y, const i_color *vals) {
92bda632
TC
222 return i_plin(im, l, r, y, vals);
223}
224
225/*
226=item i_glin(im, l, r, y, colors)
227
228=category Drawing
229
230Retrieves (r-l) pixels starting from (l,y) into I<colors>.
231
232Returns the number of pixels retrieved.
233
234=cut
235*/
236
237int
238(i_glin)(i_img *im, int l, int r, int y, i_color *vals) {
239 return i_glin(im, l, r, y, vals);
240}
241
242/*
5715f7c3 243=item i_plinf(im, C<left>, C<right>, C<fcolors>)
92bda632
TC
244
245=category Drawing
246
5715f7c3
TC
247Sets (right-left) pixels starting from (left,y) using (right-left)
248floating point colors from C<fcolors>.
92bda632
TC
249
250Returns the number of pixels set.
251
252=cut
253*/
254
255int
97ac0a96 256(i_plinf)(i_img *im, int l, int r, int y, const i_fcolor *vals) {
92bda632
TC
257 return i_plinf(im, l, r, y, vals);
258}
259
260/*
261=item i_glinf(im, l, r, y, colors)
262
263=category Drawing
264
265Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
266point colors.
267
268Returns the number of pixels retrieved.
269
270=cut
271*/
272
273int
274(i_glinf)(i_img *im, int l, int r, int y, i_fcolor *vals) {
275 return i_glinf(im, l, r, y, vals);
276}
277
278/*
5715f7c3 279=item i_gsamp(im, left, right, y, samples, channels, channel_count)
92bda632
TC
280
281=category Drawing
282
5715f7c3
TC
283Reads sample values from C<im> for the horizontal line (left, y) to
284(right-1,y) for the channels specified by C<channels>, an array of int
285with C<channel_count> elements.
92bda632 286
5715f7c3 287If channels is NULL then the first channels_count channels are retrieved for
92bda632
TC
288each pixel.
289
5715f7c3
TC
290Returns the number of samples read (which should be (right-left) *
291channel_count)
92bda632
TC
292
293=cut
294*/
295int
296(i_gsamp)(i_img *im, int l, int r, int y, i_sample_t *samp,
297 const int *chans, int chan_count) {
298 return i_gsamp(im, l, r, y, samp, chans, chan_count);
299}
300
301/*
5715f7c3 302=item i_gsampf(im, left, right, y, samples, channels, channel_count)
92bda632
TC
303
304=category Drawing
305
5715f7c3
TC
306Reads floating point sample values from C<im> for the horizontal line
307(left, y) to (right-1,y) for the channels specified by C<channels>, an
308array of int with channel_count elements.
92bda632 309
5715f7c3
TC
310If C<channels> is NULL then the first C<channel_count> channels are
311retrieved for each pixel.
92bda632 312
5715f7c3
TC
313Returns the number of samples read (which should be (C<right>-C<left>)
314* C<channel_count>)
92bda632
TC
315
316=cut
317*/
318int
319(i_gsampf)(i_img *im, int l, int r, int y, i_fsample_t *samp,
320 const int *chans, int chan_count) {
321 return i_gsampf(im, l, r, y, samp, chans, chan_count);
322}
323
324/*
5715f7c3 325=item i_gpal(im, left, right, y, indexes)
92bda632
TC
326
327=category Drawing
328
5715f7c3
TC
329Reads palette indexes for the horizontal line (left, y) to (right-1,
330y) into C<indexes>.
92bda632
TC
331
332Returns the number of indexes read.
333
334Always returns 0 for direct color images.
335
336=cut
337*/
338int
339(i_gpal)(i_img *im, int x, int r, int y, i_palidx *vals) {
340 return i_gpal(im, x, r, y, vals);
341}
342
343/*
5715f7c3 344=item i_ppal(im, left, right, y, indexes)
92bda632
TC
345
346=category Drawing
347
5715f7c3
TC
348Writes palette indexes for the horizontal line (left, y) to (right-1,
349y) from C<indexes>.
92bda632
TC
350
351Returns the number of indexes written.
352
353Always returns 0 for direct color images.
354
355=cut
356*/
357int
97ac0a96 358(i_ppal)(i_img *im, int x, int r, int y, const i_palidx *vals) {
92bda632
TC
359 return i_ppal(im, x, r, y, vals);
360}
361
362/*
363=item i_addcolors(im, colors, count)
364
365=category Paletted images
366
367Adds colors to the image's palette.
368
369On success returns the index of the lowest color added.
370
371On failure returns -1.
372
373Always fails for direct color images.
374
375=cut
376*/
377
378int
97ac0a96 379(i_addcolors)(i_img *im, const i_color *colors, int count) {
92bda632
TC
380 return i_addcolors(im, colors, count);
381}
382
383/*
384=item i_getcolors(im, index, colors, count)
385
386=category Paletted images
387
388Retrieves I<count> colors starting from I<index> in the image's
389palette.
390
391On success stores the colors into I<colors> and returns true.
392
393On failure returns false.
394
395Always fails for direct color images.
396
397Fails if there are less than I<index>+I<count> colors in the image's
398palette.
399
400=cut
401*/
402
403int
404(i_getcolors)(i_img *im, int i, i_color *colors, int count) {
405 return i_getcolors(im, i, colors, count);
406}
407
408/*
409=item i_colorcount(im)
410
411=category Paletted images
412
413Returns the number of colors in the image's palette.
414
415Returns -1 for direct images.
416
417=cut
418*/
419
420int
421(i_colorcount)(i_img *im) {
422 return i_colorcount(im);
423}
424
425/*
426=item i_maxcolors(im)
427
428=category Paletted images
429
430Returns the maximum number of colors the palette can hold for the
431image.
432
433Returns -1 for direct color images.
434
435=cut
436*/
437
438int
439(i_maxcolors)(i_img *im) {
440 return i_maxcolors(im);
441}
442
443/*
444=item i_findcolor(im, color, &entry)
445
446=category Paletted images
447
448Searches the images palette for the given color.
449
450On success sets *I<entry> to the index of the color, and returns true.
451
452On failure returns false.
453
454Always fails on direct color images.
455
456=cut
457*/
458int
97ac0a96 459(i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
92bda632
TC
460 return i_findcolor(im, color, entry);
461}
462
463/*
464=item i_setcolors(im, index, colors, count)
465
466=category Paletted images
467
468Sets I<count> colors starting from I<index> in the image's palette.
469
5715f7c3 470On success returns true.
92bda632
TC
471
472On failure returns false.
473
474The image must have at least I<index>+I<count> colors in it's palette
475for this to succeed.
476
477Always fails on direct color images.
478
479=cut
480*/
481int
97ac0a96 482(i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
92bda632
TC
483 return i_setcolors(im, index, colors, count);
484}
485