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