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