Makefile was generating lib/Imager/APIRef.pod, not
[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,
92bda632
TC
104 };
105
106/* in general these functions aren't called by Imager internally, but
107 only via the pointers above, since faster macros that call the
108 image vtable pointers are used.
109
110 () are used around the function names to prevent macro replacement
111 on the function names.
112*/
113
114/*
115=item i_ppix(im, x, y, color)
116
117=category Drawing
118
119Sets the pixel at (x,y) to I<color>.
120
121Returns 0 if the pixel was drawn, or -1 if not.
122
123Does no alpha blending, just copies the channels from the supplied
124color to the image.
125
126=cut
127*/
128
129int
97ac0a96 130(i_ppix)(i_img *im, int x, int y, const i_color *val) {
92bda632
TC
131 return i_ppix(im, x, y, val);
132}
133
134/*
135=item i_gpix(im, x, y, color)
136
137=category Drawing
138
139Retrieves the I<color> of the pixel (x,y).
140
141Returns 0 if the pixel was retrieved, or -1 if not.
142
143=cut
144*/
145
146int
147(i_gpix)(i_img *im,int x,int y,i_color *val) {
148 return i_gpix(im, x, y, val);
149}
150
151/*
152=item i_ppixf(im, x, y, fcolor)
153
154=category Drawing
155
156Sets the pixel at (x,y) to the floating point color I<fcolor>.
157
158Returns 0 if the pixel was drawn, or -1 if not.
159
160Does no alpha blending, just copies the channels from the supplied
161color to the image.
162
163=cut
164*/
165int
97ac0a96 166(i_ppixf)(i_img *im, int x, int y, const i_fcolor *val) {
92bda632
TC
167 return i_ppixf(im, x, y, val);
168}
169
170/*
171=item i_gpixf(im, x, y, fcolor)
172
173=category Drawing
174
175Retrieves the color of the pixel (x,y) as a floating point color into
176I<fcolor>.
177
178Returns 0 if the pixel was retrieved, or -1 if not.
179
180=cut
181*/
182
183int
184(i_gpixf)(i_img *im,int x,int y,i_fcolor *val) {
185 return i_gpixf(im, x, y, val);
186}
187
188/*
189=item i_plin(im, l, r, y, colors)
190
191=category Drawing
192
193Sets (r-l) pixels starting from (l,y) using (r-l) values from
194I<colors>.
195
196Returns the number of pixels set.
197
198=cut
199*/
200
201int
97ac0a96 202(i_plin)(i_img *im, int l, int r, int y, const i_color *vals) {
92bda632
TC
203 return i_plin(im, l, r, y, vals);
204}
205
206/*
207=item i_glin(im, l, r, y, colors)
208
209=category Drawing
210
211Retrieves (r-l) pixels starting from (l,y) into I<colors>.
212
213Returns the number of pixels retrieved.
214
215=cut
216*/
217
218int
219(i_glin)(i_img *im, int l, int r, int y, i_color *vals) {
220 return i_glin(im, l, r, y, vals);
221}
222
223/*
224=item i_plinf(im, l, r, fcolors)
225
226=category Drawing
227
228Sets (r-l) pixels starting from (l,y) using (r-l) floating point
229colors from I<colors>.
230
231Returns the number of pixels set.
232
233=cut
234*/
235
236int
97ac0a96 237(i_plinf)(i_img *im, int l, int r, int y, const i_fcolor *vals) {
92bda632
TC
238 return i_plinf(im, l, r, y, vals);
239}
240
241/*
242=item i_glinf(im, l, r, y, colors)
243
244=category Drawing
245
246Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
247point colors.
248
249Returns the number of pixels retrieved.
250
251=cut
252*/
253
254int
255(i_glinf)(i_img *im, int l, int r, int y, i_fcolor *vals) {
256 return i_glinf(im, l, r, y, vals);
257}
258
259/*
260=item i_gsamp(im, l, r, y, samp, chans, chan_count)
261
262=category Drawing
263
264Reads sample values from im for the horizontal line (l, y) to (r-1,y)
265for the channels specified by chans, an array of int with chan_count
266elements.
267
268If chans is NULL then the first chan_count channels are retrieved for
269each pixel.
270
271Returns the number of samples read (which should be (r-l) *
272chan_count)
273
274=cut
275*/
276int
277(i_gsamp)(i_img *im, int l, int r, int y, i_sample_t *samp,
278 const int *chans, int chan_count) {
279 return i_gsamp(im, l, r, y, samp, chans, chan_count);
280}
281
282/*
283=item i_gsampf(im, l, r, y, samp, chans, chan_count)
284
285=category Drawing
286
287Reads floating point sample values from im for the horizontal line (l,
288y) to (r-1,y) for the channels specified by chans, an array of int
289with chan_count elements.
290
291If chans is NULL then the first chan_count channels are retrieved for
292each pixel.
293
294Returns the number of samples read (which should be (r-l) *
295chan_count)
296
297=cut
298*/
299int
300(i_gsampf)(i_img *im, int l, int r, int y, i_fsample_t *samp,
301 const int *chans, int chan_count) {
302 return i_gsampf(im, l, r, y, samp, chans, chan_count);
303}
304
305/*
306=item i_gpal(im, x, r, y, indexes)
307
308=category Drawing
309
310Reads palette indexes for the horizontal line (x, y) to (r-1, y) into
311indexes.
312
313Returns the number of indexes read.
314
315Always returns 0 for direct color images.
316
317=cut
318*/
319int
320(i_gpal)(i_img *im, int x, int r, int y, i_palidx *vals) {
321 return i_gpal(im, x, r, y, vals);
322}
323
324/*
325=item i_ppal(im, x, r, y, indexes)
326
327=category Drawing
328
329Writes palette indexes for the horizontal line (x, y) to (r-1, y) from
330indexes.
331
332Returns the number of indexes written.
333
334Always returns 0 for direct color images.
335
336=cut
337*/
338int
97ac0a96 339(i_ppal)(i_img *im, int x, int r, int y, const i_palidx *vals) {
92bda632
TC
340 return i_ppal(im, x, r, y, vals);
341}
342
343/*
344=item i_addcolors(im, colors, count)
345
346=category Paletted images
347
348Adds colors to the image's palette.
349
350On success returns the index of the lowest color added.
351
352On failure returns -1.
353
354Always fails for direct color images.
355
356=cut
357*/
358
359int
97ac0a96 360(i_addcolors)(i_img *im, const i_color *colors, int count) {
92bda632
TC
361 return i_addcolors(im, colors, count);
362}
363
364/*
365=item i_getcolors(im, index, colors, count)
366
367=category Paletted images
368
369Retrieves I<count> colors starting from I<index> in the image's
370palette.
371
372On success stores the colors into I<colors> and returns true.
373
374On failure returns false.
375
376Always fails for direct color images.
377
378Fails if there are less than I<index>+I<count> colors in the image's
379palette.
380
381=cut
382*/
383
384int
385(i_getcolors)(i_img *im, int i, i_color *colors, int count) {
386 return i_getcolors(im, i, colors, count);
387}
388
389/*
390=item i_colorcount(im)
391
392=category Paletted images
393
394Returns the number of colors in the image's palette.
395
396Returns -1 for direct images.
397
398=cut
399*/
400
401int
402(i_colorcount)(i_img *im) {
403 return i_colorcount(im);
404}
405
406/*
407=item i_maxcolors(im)
408
409=category Paletted images
410
411Returns the maximum number of colors the palette can hold for the
412image.
413
414Returns -1 for direct color images.
415
416=cut
417*/
418
419int
420(i_maxcolors)(i_img *im) {
421 return i_maxcolors(im);
422}
423
424/*
425=item i_findcolor(im, color, &entry)
426
427=category Paletted images
428
429Searches the images palette for the given color.
430
431On success sets *I<entry> to the index of the color, and returns true.
432
433On failure returns false.
434
435Always fails on direct color images.
436
437=cut
438*/
439int
97ac0a96 440(i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
92bda632
TC
441 return i_findcolor(im, color, entry);
442}
443
444/*
445=item i_setcolors(im, index, colors, count)
446
447=category Paletted images
448
449Sets I<count> colors starting from I<index> in the image's palette.
450
451On sucess returns true.
452
453On failure returns false.
454
455The image must have at least I<index>+I<count> colors in it's palette
456for this to succeed.
457
458Always fails on direct color images.
459
460=cut
461*/
462int
97ac0a96 463(i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
92bda632
TC
464 return i_setcolors(im, index, colors, count);
465}
466