]> git.imager.perl.org - imager.git/blobdiff - imext.c
pick up im_ prefix functions too
[imager.git] / imext.c
diff --git a/imext.c b/imext.c
index 670e771cba0b0ba15c0ac4de9d874020e1e1ebf2..3f19123198b5f57cf1383dea2e31ff11f2b74794 100644 (file)
--- a/imext.c
+++ b/imext.c
@@ -1,11 +1,17 @@
 #include "imexttypes.h"
 #include "imager.h"
+#include "imio.h"
+
+static im_context_t get_context(void);
 
 /*
  DON'T ADD CASTS TO THESE
 */
 im_ext_funcs imager_function_table =
   {
+    IMAGER_API_VERSION,
+    IMAGER_API_LEVEL,
+
     mymalloc,
     myfree,
     myrealloc,
@@ -14,10 +20,10 @@ im_ext_funcs imager_function_table =
     myfree_file_line,
     myrealloc_file_line,
 
-    i_img_8_new,
-    i_img_16_new,
-    i_img_double_new,
-    i_img_pal_new,
+    im_img_8_new,
+    im_img_16_new,
+    im_img_double_new,
+    im_img_pal_new,
     i_img_destroy,
     i_sametype,
     i_sametype_chans,
@@ -54,10 +60,10 @@ im_ext_funcs imager_function_table =
     i_quant_translate,
     i_quant_transparent,
 
-    i_clear_error,
-    i_push_error,
+    im_clear_error,
+    im_push_error,
     i_push_errorf,
-    i_push_errorvf,
+    im_push_errorvf,
 
     i_tags_new,
     i_tags_set,
@@ -93,6 +99,69 @@ im_ext_funcs imager_function_table =
     i_copyto_trans,
     i_copy,
     i_rubthru,
+
+    /* IMAGER_API_LEVEL 2 functions */
+    im_set_image_file_limits,
+    im_get_image_file_limits,
+    im_int_check_image_file_limits,
+
+    i_flood_fill_border,
+    i_flood_cfill_border,
+
+    /* IMAGER_API_LEVEL 3 functions */
+    i_img_setmask,
+    i_img_getmask,
+    i_img_getchannels,
+    i_img_get_width,
+    i_img_get_height,
+    i_lhead,
+    i_loog,
+
+    /* IMAGER_API_LEVEL 4 functions */
+    im_img_alloc,
+    im_img_init,
+
+    /* IMAGER_API_LEVEL 5 functions */
+    i_img_is_monochrome,
+    i_gsamp_bg,
+    i_gsampf_bg,
+    i_get_file_background,
+    i_get_file_backgroundf,
+    i_utf8_advance,
+    i_render_new,
+    i_render_delete,
+    i_render_color,
+    i_render_fill,
+    i_render_line,
+    i_render_linef,
+
+    /* level 6 */
+    i_io_getc_imp,
+    i_io_peekc_imp,
+    i_io_peekn,
+    i_io_putc_imp,
+    i_io_read,
+    i_io_write,
+    i_io_seek,
+    i_io_flush,
+    i_io_close,
+    i_io_set_buffered,
+    i_io_gets,
+    im_io_new_fd,
+    im_io_new_bufchain,
+    im_io_new_buffer,
+    im_io_new_cb,
+    io_slurp,
+    io_glue_destroy,
+
+    /* level 8 */
+    get_context,
+    im_push_errorf,
+    im_lhead,
+    im_loog,
+    im_context_refinc,
+    im_context_refdec,
+    im_errors
   };
 
 /* in general these functions aren't called by Imager internally, but
@@ -119,16 +188,16 @@ color to the image.
 */
 
 int 
-(i_ppix)(i_img *im, int x, int y, const i_color *val) {
+(i_ppix)(i_img *im, i_img_dim x, i_img_dim y, const i_color *val) {
   return i_ppix(im, x, y, val);
 }
 
 /*
-=item i_gpix(im, x, y, color)
+=item i_gpix(im, C<x>, C<y>, C<color>)
 
 =category Drawing
 
-Retrieves the I<color> of the pixel (x,y).
+Retrieves the C<color> of the pixel (x,y).
 
 Returns 0 if the pixel was retrieved, or -1 if not.
 
@@ -136,16 +205,16 @@ Returns 0 if the pixel was retrieved, or -1 if not.
 */
 
 int
-(i_gpix)(i_img *im,int x,int y,i_color *val) {
+(i_gpix)(i_img *im,i_img_dim x,i_img_dim y,i_color *val) {
   return i_gpix(im, x, y, val);
 }
 
 /*
-=item i_ppixf(im, x, y, fcolor)
+=item i_ppixf(im, C<x>, C<y>, C<fcolor>)
 
 =category Drawing
 
-Sets the pixel at (x,y) to the floating point color I<fcolor>.
+Sets the pixel at (C<x>,C<y>) to the floating point color C<fcolor>.
 
 Returns 0 if the pixel was drawn, or -1 if not.
 
@@ -155,17 +224,17 @@ color to the image.
 =cut
 */
 int
-(i_ppixf)(i_img *im, int x, int y, const i_fcolor *val) {
+(i_ppixf)(i_img *im, i_img_dim x, i_img_dim y, const i_fcolor *val) {
   return i_ppixf(im, x, y, val);
 }
 
 /*
-=item i_gpixf(im, x, y, fcolor)
+=item i_gpixf(im, C<x>, C<y>, C<fcolor>)
 
 =category Drawing
 
 Retrieves the color of the pixel (x,y) as a floating point color into
-I<fcolor>.
+C<fcolor>.
 
 Returns 0 if the pixel was retrieved, or -1 if not.
 
@@ -173,7 +242,7 @@ Returns 0 if the pixel was retrieved, or -1 if not.
 */
 
 int
-(i_gpixf)(i_img *im,int x,int y,i_fcolor *val) {
+(i_gpixf)(i_img *im,i_img_dim x,i_img_dim y,i_fcolor *val) {
   return i_gpixf(im, x, y, val);
 }
 
@@ -190,8 +259,8 @@ Returns the number of pixels set.
 =cut
 */
 
-int
-(i_plin)(i_img *im, int l, int r, int y, const i_color *vals) {
+i_img_dim
+(i_plin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_color *vals) {
   return i_plin(im, l, r, y, vals);
 }
 
@@ -207,26 +276,26 @@ Returns the number of pixels retrieved.
 =cut
 */
 
-int
-(i_glin)(i_img *im, int l, int r, int y, i_color *vals) {
+i_img_dim
+(i_glin)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_color *vals) {
   return i_glin(im, l, r, y, vals);
 }
 
 /*
-=item i_plinf(im, l, r, fcolors)
+=item i_plinf(im, C<left>, C<right>, C<fcolors>)
 
 =category Drawing
 
-Sets (r-l) pixels starting from (l,y) using (r-l) floating point
-colors from I<colors>.
+Sets (right-left) pixels starting from (left,y) using (right-left)
+floating point colors from C<fcolors>.
 
 Returns the number of pixels set.
 
 =cut
 */
 
-int
-(i_plinf)(i_img *im, int l, int r, int y, const i_fcolor *vals) {
+i_img_dim
+(i_plinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, const i_fcolor *vals) {
   return i_plinf(im, l, r, y, vals);
 }
 
@@ -243,64 +312,100 @@ Returns the number of pixels retrieved.
 =cut
 */
 
-int
-(i_glinf)(i_img *im, int l, int r, int y, i_fcolor *vals) {
+i_img_dim
+(i_glinf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fcolor *vals) {
   return i_glinf(im, l, r, y, vals);
 }
 
 /*
-=item i_gsamp(im, l, r, y, samp, chans, chan_count)
+=item i_gsamp(im, left, right, y, samples, channels, channel_count)
 
 =category Drawing
 
-Reads sample values from im for the horizontal line (l, y) to (r-1,y)
-for the channels specified by chans, an array of int with chan_count
-elements.
+Reads sample values from C<im> for the horizontal line (left, y) to
+(right-1,y) for the channels specified by C<channels>, an array of int
+with C<channel_count> elements.
 
-If chans is NULL then the first chan_count channels are retrieved for
+If channels is NULL then the first channels_count channels are retrieved for
 each pixel.
 
-Returns the number of samples read (which should be (r-l) *
-chan_count)
+Returns the number of samples read (which should be (right-left) *
+channel_count)
 
 =cut
 */
-int
-(i_gsamp)(i_img *im, int l, int r, int y, i_sample_t *samp, 
+i_img_dim
+(i_gsamp)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_sample_t *samp, 
                    const int *chans, int chan_count) {
   return i_gsamp(im, l, r, y, samp, chans, chan_count);
 }
 
 /*
-=item i_gsampf(im, l, r, y, samp, chans, chan_count)
+=item i_gsampf(im, left, right, y, samples, channels, channel_count)
 
 =category Drawing
 
-Reads floating point sample values from im for the horizontal line (l,
-y) to (r-1,y) for the channels specified by chans, an array of int
-with chan_count elements.
+Reads floating point sample values from C<im> for the horizontal line
+(left, y) to (right-1,y) for the channels specified by C<channels>, an
+array of int with channel_count elements.
 
-If chans is NULL then the first chan_count channels are retrieved for
-each pixel.
+If C<channels> is NULL then the first C<channel_count> channels are
+retrieved for each pixel.
 
-Returns the number of samples read (which should be (r-l) *
-chan_count)
+Returns the number of samples read (which should be (C<right>-C<left>)
+* C<channel_count>)
 
 =cut
 */
-int
-(i_gsampf)(i_img *im, int l, int r, int y, i_fsample_t *samp, 
+i_img_dim
+(i_gsampf)(i_img *im, i_img_dim l, i_img_dim r, i_img_dim y, i_fsample_t *samp, 
            const int *chans, int chan_count) {
   return i_gsampf(im, l, r, y, samp, chans, chan_count);
 }
 
 /*
-=item i_gpal(im, x, r, y, indexes)
+=item i_gsamp_bits(im, left, right, y, samples, channels, channel_count, bits)
+=category Drawing
+
+Reads integer samples scaled to C<bits> bits of precision into the
+C<unsigned int> array C<samples>.
+
+Expect this to be slow unless C<< bits == im->bits >>.
+
+Returns the number of samples copied, or -1 on error.
+
+Not all image types implement this method.
+
+Pushes errors, but does not call C<i_clear_error()>.
+
+=cut
+*/
+
+/*
+=item i_psamp_bits(im, left, right, y, samples, channels, channel_count, bits)
+=category Drawing
+
+Writes integer samples scaled to C<bits> bits of precision from the
+C<unsigned int> array C<samples>.
+
+Expect this to be slow unless C<< bits == im->bits >>.
+
+Returns the number of samples copied, or -1 on error.
+
+Not all image types implement this method.
+
+Pushes errors, but does not call C<i_clear_error()>.
+
+=cut
+*/
+
+/*
+=item i_gpal(im, left, right, y, indexes)
 
 =category Drawing
 
-Reads palette indexes for the horizontal line (x, y) to (r-1, y) into
-indexes.
+Reads palette indexes for the horizontal line (left, y) to (right-1,
+y) into C<indexes>.
 
 Returns the number of indexes read.
 
@@ -308,18 +413,18 @@ Always returns 0 for direct color images.
 
 =cut
 */
-int
-(i_gpal)(i_img *im, int x, int r, int y, i_palidx *vals) {
+i_img_dim
+(i_gpal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, i_palidx *vals) {
   return i_gpal(im, x, r, y, vals);
 }
 
 /*
-=item i_ppal(im, x, r, y, indexes)
+=item i_ppal(im, left, right, y, indexes)
 
 =category Drawing
 
-Writes palette indexes for the horizontal line (x, y) to (r-1, y) from
-indexes.
+Writes palette indexes for the horizontal line (left, y) to (right-1,
+y) from C<indexes>.
 
 Returns the number of indexes written.
 
@@ -327,8 +432,8 @@ Always returns 0 for direct color images.
 
 =cut
 */
-int
-(i_ppal)(i_img *im, int x, int r, int y, const i_palidx *vals) {
+i_img_dim
+(i_ppal)(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, const i_palidx *vals) {
   return i_ppal(im, x, r, y, vals);
 }
 
@@ -440,7 +545,7 @@ int
 
 Sets I<count> colors starting from I<index> in the image's palette.
 
-On sucess returns true.
+On success returns true.
 
 On failure returns false.
 
@@ -456,3 +561,20 @@ int
   return i_setcolors(im, index, colors, count);
 }
 
+/*
+=item im_get_context()
+
+Retrieve the context object for the current thread.
+
+Inside Imager itself this is just a function pointer, which the
+Imager.xs BOOT handler initializes for use within perl.  If you're
+taking the Imager code and embedding it elsewhere you need to
+initialize the C<im_get_context> pointer at some point.
+
+=cut
+*/
+
+static im_context_t
+get_context(void) {
+  return im_get_context();
+}