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