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,
171 /* in general these functions aren't called by Imager internally, but
172 only via the pointers above, since faster macros that call the
173 image vtable pointers are used.
175 () are used around the function names to prevent macro replacement
176 on the function names.
180 =item i_ppix(im, x, y, color)
184 Sets the pixel at (x,y) to I<color>.
186 Returns 0 if the pixel was drawn, or -1 if not.
188 Does no alpha blending, just copies the channels from the supplied
195 (i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) {
196 return i_ppix(im, x, y, val);
200 =item i_gpix(im, C<x>, C<y>, C<color>)
204 Retrieves the C<color> of the pixel (x,y).
206 Returns 0 if the pixel was retrieved, or -1 if not.
212 (i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) {
213 return i_gpix(im, x, y, val);
217 =item i_ppixf(im, C<x>, C<y>, C<fcolor>)
221 Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
223 Returns 0 if the pixel was drawn, or -1 if not.
225 Does no alpha blending, just copies the channels from the supplied
231 (i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) {
232 return i_ppixf(im, x, y, val);
236 =item i_gpixf(im, C<x>, C<y>, C<fcolor>)
240 Retrieves the color of the pixel (x,y) as a floating point color into
243 Returns 0 if the pixel was retrieved, or -1 if not.
249 (i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) {
250 return i_gpixf(im, x, y, val);
254 =item i_plin(im, l, r, y, colors)
258 Sets (r-l) pixels starting from (l,y) using (r-l) values from
261 Returns the number of pixels set.
267 (i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) {
268 return i_plin(im, l, r, y, vals);
272 =item i_glin(im, l, r, y, colors)
276 Retrieves (r-l) pixels starting from (l,y) into I<colors>.
278 Returns the number of pixels retrieved.
284 (i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) {
285 return i_glin(im, l, r, y, vals);
289 =item i_plinf(im, C<left>, C<right>, C<fcolors>)
293 Sets (right-left) pixels starting from (left,y) using (right-left)
294 floating point colors from C<fcolors>.
296 Returns the number of pixels set.
302 (i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) {
303 return i_plinf(im, l, r, y, vals);
307 =item i_glinf(im, l, r, y, colors)
311 Retrieves (r-l) pixels starting from (l,y) into I<colors> as floating
314 Returns the number of pixels retrieved.
320 (i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) {
321 return i_glinf(im, l, r, y, vals);
325 =item i_gsamp(im, left, right, y, samples, channels, channel_count)
329 Reads sample values from C<im> for the horizontal line (left, y) to
330 (right-1,y) for the channels specified by C<channels>, an array of int
331 with C<channel_count> elements.
333 If channels is NULL then the first channels_count channels are retrieved for
336 Returns the number of samples read (which should be (right-left) *
342 (i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp,
343 const int *chans, int chan_count) {
344 return i_gsamp(im, l, r, y, samp, chans, chan_count);
348 =item i_gsampf(im, left, right, y, samples, channels, channel_count)
352 Reads floating point sample values from C<im> for the horizontal line
353 (left, y) to (right-1,y) for the channels specified by C<channels>, an
354 array of int with channel_count elements.
356 If C<channels> is NULL then the first C<channel_count> channels are
357 retrieved for each pixel.
359 Returns the number of samples read (which should be (C<right>-C<left>)
365 (i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp,
366 const int *chans, int chan_count) {
367 return i_gsampf(im, l, r, y, samp, chans, chan_count);
371 =item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits)
374 Reads integer samples scaled to C<bits> bits of precision into the
375 C<unsigned int> array C<samples>.
377 Expect this to be slow unless C<< bits == im->bits >>.
379 Returns the number of samples copied, or -1 on error.
381 Not all image types implement this method.
383 Pushes errors, but does not call C<i_clear_error()>.
389 =item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits)
392 Writes integer samples scaled to C<bits> bits of precision from the
393 C<unsigned int> array C<samples>.
395 Expect this to be slow unless C<< bits == im->bits >>.
397 Returns the number of samples copied, or -1 on error.
399 Not all image types implement this method.
401 Pushes errors, but does not call C<i_clear_error()>.
407 =item i_gpal(im, left, right, y, indexes)
411 Reads palette indexes for the horizontal line (left, y) to (right-1,
414 Returns the number of indexes read.
416 Always returns 0 for direct color images.
421 (i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) {
422 return i_gpal(im, x, r, y, vals);
426 =item i_ppal(im, left, right, y, indexes)
430 Writes palette indexes for the horizontal line (left, y) to (right-1,
433 Returns the number of indexes written.
435 Always returns 0 for direct color images.
440 (i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) {
441 return i_ppal(im, x, r, y, vals);
445 =item i_addcolors(im, colors, count)
447 =category Paletted images
449 Adds colors to the image's palette.
451 On success returns the index of the lowest color added.
453 On failure returns -1.
455 Always fails for direct color images.
461 (i_addcolors)(i_img *im, const i_color *colors, int count) {
462 return i_addcolors(im, colors, count);
466 =item i_getcolors(im, index, colors, count)
468 =category Paletted images
470 Retrieves I<count> colors starting from I<index> in the image's
473 On success stores the colors into I<colors> and returns true.
475 On failure returns false.
477 Always fails for direct color images.
479 Fails if there are less than I<index>+I<count> colors in the image's
486 (i_getcolors)(i_img *im, int i, i_color *colors, int count) {
487 return i_getcolors(im, i, colors, count);
491 =item i_colorcount(im)
493 =category Paletted images
495 Returns the number of colors in the image's palette.
497 Returns -1 for direct images.
503 (i_colorcount)(i_img *im) {
504 return i_colorcount(im);
508 =item i_maxcolors(im)
510 =category Paletted images
512 Returns the maximum number of colors the palette can hold for the
515 Returns -1 for direct color images.
521 (i_maxcolors)(i_img *im) {
522 return i_maxcolors(im);
526 =item i_findcolor(im, color, &entry)
528 =category Paletted images
530 Searches the images palette for the given color.
532 On success sets *I<entry> to the index of the color, and returns true.
534 On failure returns false.
536 Always fails on direct color images.
541 (i_findcolor)(i_img *im, const i_color *color, i_palidx *entry) {
542 return i_findcolor(im, color, entry);
546 =item i_setcolors(im, index, colors, count)
548 =category Paletted images
550 Sets I<count> colors starting from I<index> in the image's palette.
552 On success returns true.
554 On failure returns false.
556 The image must have at least I<index>+I<count> colors in it's palette
559 Always fails on direct color images.
564 (i_setcolors)(i_img *im, int index, const i_color *colors, int count) {
565 return i_setcolors(im, index, colors, count);
569 =item im_get_context()
571 Retrieve the context object for the current thread.
573 Inside Imager itself this is just a function pointer, which the
574 F<Imager.xs> BOOT handler initializes for use within perl. If you're
575 taking the Imager code and embedding it elsewhere you need to
576 initialize the C<im_get_context> pointer at some point.
583 return im_get_context();