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