1 #include "imexttypes.h"
5 static im_context_t get_context(void);
8 DON'T ADD CASTS TO THESE
10 im_ext_funcs imager_function_table =
103 /* IMAGER_API_LEVEL 2 functions */
104 im_set_image_file_limits,
105 im_get_image_file_limits,
106 im_int_check_image_file_limits,
109 i_flood_cfill_border,
111 /* IMAGER_API_LEVEL 3 functions */
120 /* IMAGER_API_LEVEL 4 functions */
124 /* IMAGER_API_LEVEL 5 functions */
128 i_get_file_background,
129 i_get_file_backgroundf,
167 /* in general these functions aren't called by Imager internally, but
168 only via the pointers above, since faster macros that call the
169 image vtable pointers are used.
171 () are used around the function names to prevent macro replacement
172 on the function names.
176 =item i_ppix(im, x, y, color)
180 Sets the pixel at (x,y) to I<color>.
182 Returns 0 if the pixel was drawn, or -1 if not.
184 Does no alpha blending, just copies the channels from the supplied
191 (i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) {
192 return i_ppix(im, x, y, val);
196 =item i_gpix(im, C<x>, C<y>, C<color>)
200 Retrieves the C<color> of the pixel (x,y).
202 Returns 0 if the pixel was retrieved, or -1 if not.
208 (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) {
209 return i_gpix(im, x, y, val);
213 =item i_ppixf(im, C<x>, C<y>, C<fcolor>)
217 Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
219 Returns 0 if the pixel was drawn, or -1 if not.
221 Does no alpha blending, just copies the channels from the supplied
227 (i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) {
228 return i_ppixf(im, x, y, val);
232 =item i_gpixf(im, C<x>, C<y>, C<fcolor>)
236 Retrieves the color of the pixel (x,y) as a floating point color into
239 Returns 0 if the pixel was retrieved, or -1 if not.
245 (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) {
246 return i_gpixf(im, x, y, val);
250 =item i_plin(im, l, r, y, colors)
254 Sets (r-l) pixels starting from (l,y) using (r-l) values from
257 Returns the number of pixels set.
263 (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) {
264 return i_plin(im, l, r, y, vals);
268 =item i_glin(im, l, r, y, colors)
272 Retrieves (r-l) pixels starting from (l,y) into I<colors>.
274 Returns the number of pixels retrieved.
280 (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) {
281 return i_glin(im, l, r, y, vals);
285 =item i_plinf(im, C<left>, C<right>, C<fcolors>)
289 Sets (right-left) pixels starting from (left,y) using (right-left)
290 floating point colors from C<fcolors>.
292 Returns the number of pixels set.
298 (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) {
299 return i_plinf(im, l, r, y, vals);
303 =item i_glinf(im, l, r, y, colors)
307 Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
310 Returns the number of pixels retrieved.
316 (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) {
317 return i_glinf(im, l, r, y, vals);
321 =item i_gsamp(im, left, right, y, samples, channels, channel_count)
325 Reads sample values from C<im> for the horizontal line (left, y) to
326 (right-1,y) for the channels specified by C<channels>, an array of int
327 with C<channel_count> elements.
329 If channels is NULL then the first channels_count channels are retrieved for
332 Returns the number of samples read (which should be (right-left) *
338 (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp,
339 const int *chans, int chan_count) {
340 return i_gsamp(im, l, r, y, samp, chans, chan_count);
344 =item i_gsampf(im, left, right, y, samples, channels, channel_count)
348 Reads floating point sample values from C<im> for the horizontal line
349 (left, y) to (right-1,y) for the channels specified by C<channels>, an
350 array of int with channel_count elements.
352 If C<channels> is NULL then the first C<channel_count> channels are
353 retrieved for each pixel.
355 Returns the number of samples read (which should be (C<right>-C<left>)
361 (i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
362 const int *chans, int chan_count) {
363 return i_gsampf(im, l, r, y, samp, chans, chan_count);
367 =item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits)
370 Reads integer samples scaled to C<bits> bits of precision into the
371 C<unsigned int> array C<samples>.
373 Expect this to be slow unless C<< bits == im->bits >>.
375 Returns the number of samples copied, or -1 on error.
377 Not all image types implement this method.
379 Pushes errors, but does not call C<i_clear_error()>.
385 =item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits)
388 Writes integer samples scaled to C<bits> bits of precision from the
389 C<unsigned int> array C<samples>.
391 Expect this to be slow unless C<< bits == im->bits >>.
393 Returns the number of samples copied, or -1 on error.
395 Not all image types implement this method.
397 Pushes errors, but does not call C<i_clear_error()>.
403 =item i_gpal(im, left, right, y, indexes)
407 Reads palette indexes for the horizontal line (left, y) to (right-1,
410 Returns the number of indexes read.
412 Always returns 0 for direct color images.
417 (i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) {
418 return i_gpal(im, x, r, y, vals);
422 =item i_ppal(im, left, right, y, indexes)
426 Writes palette indexes for the horizontal line (left, y) to (right-1,
429 Returns the number of indexes written.
431 Always returns 0 for direct color images.
436 (i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) {
437 return i_ppal(im, x, r, y, vals);
441 =item i_addcolors(im, colors, count)
443 =category Paletted images
445 Adds colors to the image's palette.
447 On success returns the index of the lowest color added.
449 On failure returns -1.
451 Always fails for direct color images.
457 (i_addcolors)(i_img *im, const i_color *colors, int count) {
458 return i_addcolors(im, colors, count);
462 =item i_getcolors(im, index, colors, count)
464 =category Paletted images
466 Retrieves I<count> colors starting from I<index> in the image's
469 On success stores the colors into I<colors> and returns true.
471 On failure returns false.
473 Always fails for direct color images.
475 Fails if there are less than I<index>+I<count> colors in the image's
482 (i_getcolors)(i_img *im, int i, i_color *colors, int count) {
483 return i_getcolors(im, i, colors, count);
487 =item i_colorcount(im)
489 =category Paletted images
491 Returns the number of colors in the image's palette.
493 Returns -1 for direct images.
499 (i_colorcount)(i_img *im) {
500 return i_colorcount(im);
504 =item i_maxcolors(im)
506 =category Paletted images
508 Returns the maximum number of colors the palette can hold for the
511 Returns -1 for direct color images.
517 (i_maxcolors)(i_img *im) {
518 return i_maxcolors(im);
522 =item i_findcolor(im, color, &entry)
524 =category Paletted images
526 Searches the images palette for the given color.
528 On success sets *I<entry> to the index of the color, and returns true.
530 On failure returns false.
532 Always fails on direct color images.
537 (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
538 return i_findcolor(im, color, entry);
542 =item i_setcolors(im, index, colors, count)
544 =category Paletted images
546 Sets I<count> colors starting from I<index> in the image's palette.
548 On success returns true.
550 On failure returns false.
552 The image must have at least I<index>+I<count> colors in it's palette
555 Always fails on direct color images.
560 (i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
561 return i_setcolors(im, index, colors, count);
565 =item im_get_context()
567 Retrieve the context object for the current thread.
569 Inside Imager itself this is just a function pointer, which the
570 Imager.xs BOOT handler initializes for use within perl. If you're
571 taking the Imager code and embedding it elsewhere you need to
572 initialize the C<im_get_context> pointer at some point.
579 return im_get_context();