]> git.imager.perl.org - imager.git/blobdiff - Imager.xs
[RT #65863] mostly eliminate i_has_format
[imager.git] / Imager.xs
index 2de3747f29f0dce2566d75bf9173bd37f9279c6f..e9a7952475c6c553ed64e76b6c58cad9c80d0c0d 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -1,3 +1,4 @@
+#define PERL_NO_GET_CONTEXT
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -18,6 +19,7 @@ extern "C" {
 #include "dynaload.h"
 #include "regmach.h"
 #include "imextdef.h"
+#include "imextpltypes.h"
 
 #if i_int_hlines_testing()
 #include "imageri.h"
@@ -27,6 +29,7 @@ extern "C" {
 
 /* These functions are all shared - then comes platform dependant code */
 static int getstr(void *hv_t,char *key,char **store) {
+  dTHX;
   SV** svpp;
   HV* hv=(HV*)hv_t;
 
@@ -41,6 +44,7 @@ static int getstr(void *hv_t,char *key,char **store) {
 }
 
 static int getint(void *hv_t,char *key,int *store) {
+  dTHX;
   SV** svpp;
   HV* hv=(HV*)hv_t;  
 
@@ -54,6 +58,7 @@ static int getint(void *hv_t,char *key,int *store) {
 }
 
 static int getdouble(void *hv_t,char* key,double *store) {
+  dTHX;
   SV** svpp;
   HV* hv=(HV*)hv_t;
 
@@ -66,6 +71,7 @@ static int getdouble(void *hv_t,char* key,double *store) {
 }
 
 static int getvoid(void *hv_t,char* key,void **store) {
+  dTHX;
   SV** svpp;
   HV* hv=(HV*)hv_t;
 
@@ -80,6 +86,7 @@ static int getvoid(void *hv_t,char* key,void **store) {
 }
 
 static int getobj(void *hv_t,char *key,char *type,void **store) {
+  dTHX;
   SV** svpp;
   HV* hv=(HV*)hv_t;
 
@@ -103,6 +110,7 @@ static int getobj(void *hv_t,char *key,char *type,void **store) {
 UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
 
 void my_SvREFCNT_dec(void *p) {
+  dTHX;
   SvREFCNT_dec((SV*)p);
 }
 
@@ -121,6 +129,7 @@ typedef struct i_reader_data_tag
 
 /* used by functions that want callbacks */
 static int read_callback(char *userdata, char *buffer, int need, int want) {
+  dTHX;
   i_reader_data *rd = (i_reader_data *)userdata;
   int count;
   int result;
@@ -172,6 +181,7 @@ typedef struct
 
 /* used by functions that want callbacks */
 static int write_callback(char *userdata, char const *data, int size) {
+  dTHX;
   i_writer_data *wd = (i_writer_data *)userdata;
   int count;
   int success;
@@ -243,6 +253,7 @@ Low-level function to call the perl writer callback.
 */
 
 static ssize_t call_writer(struct cbdata *cbd, void const *buf, size_t size) {
+  dTHX;
   int count;
   int success;
   SV *sv;
@@ -277,6 +288,7 @@ static ssize_t call_writer(struct cbdata *cbd, void const *buf, size_t size) {
 
 static ssize_t call_reader(struct cbdata *cbd, void *buf, size_t size, 
                            size_t maxread) {
+  dTHX;
   int count;
   int result;
   SV *data;
@@ -323,6 +335,7 @@ static ssize_t call_reader(struct cbdata *cbd, void *buf, size_t size,
 }
 
 static ssize_t write_flush(struct cbdata *cbd) {
+  dTHX;
   ssize_t result;
 
   if (cbd->used) {
@@ -336,6 +349,7 @@ static ssize_t write_flush(struct cbdata *cbd) {
 }
 
 static off_t io_seeker(void *p, off_t offset, int whence) {
+  dTHX;
   struct cbdata *cbd = p;
   int count;
   off_t result;
@@ -380,6 +394,7 @@ static off_t io_seeker(void *p, off_t offset, int whence) {
 }
 
 static ssize_t io_writer(void *p, void const *data, size_t size) {
+  dTHX;
   struct cbdata *cbd = p;
 
   /* printf("io_writer(%p, %p, %u)\n", p, data, size); */
@@ -413,6 +428,7 @@ static ssize_t io_writer(void *p, void const *data, size_t size) {
 
 static ssize_t 
 io_reader(void *p, void *data, size_t size) {
+  dTHX;
   struct cbdata *cbd = p;
   ssize_t total;
   char *out = data; /* so we can do pointer arithmetic */
@@ -471,6 +487,7 @@ io_reader(void *p, void *data, size_t size) {
 }
 
 static int io_closer(void *p) {
+  dTHX;
   struct cbdata *cbd = p;
 
   if (cbd->writing && cbd->used > 0) {
@@ -499,6 +516,7 @@ static int io_closer(void *p) {
 }
 
 static void io_destroyer(void *p) {
+  dTHX;
   struct cbdata *cbd = p;
 
   SvREFCNT_dec(cbd->writecb);
@@ -541,9 +559,7 @@ static struct value_name make_color_names[] =
 
 static struct value_name translate_names[] =
 {
-#ifdef HAVE_LIBGIF
   { "giflib", pt_giflib, },
-#endif
   { "closest", pt_closest, },
   { "perturb", pt_perturb, },
   { "errdiff", pt_errdiff, },
@@ -573,7 +589,8 @@ static struct value_name orddith_names[] =
 };
 
 /* look through the hash for quantization options */
-static void handle_quant_opts(i_quantize *quant, HV *hv)
+static void
+ip_handle_quant_opts(pTHX_ i_quantize *quant, HV *hv)
 {
   /*** POSSIBLY BROKEN: do I need to unref the SV from hv_fetch ***/
   SV **sv;
@@ -624,7 +641,7 @@ static void handle_quant_opts(i_quantize *quant, HV *hv)
       }
     }
   }
-  quant->make_colors = mc_addi;
+  quant->make_colors = mc_median_cut;
   sv = hv_fetch(hv, "make_colors", 11, 0);
   if (sv && *sv && (str = SvPV(*sv, len))) {
     quant->make_colors = 
@@ -704,14 +721,16 @@ static void handle_quant_opts(i_quantize *quant, HV *hv)
     quant->perturb = SvIV(*sv);
 }
 
-static void cleanup_quant_opts(i_quantize *quant) {
+static void
+ip_cleanup_quant_opts(pTHX_ i_quantize *quant) {
   myfree(quant->mc_colors);
   if (quant->ed_map)
     myfree(quant->ed_map);
 }
 
 /* copies the color map from the hv into the colors member of the HV */
-static void copy_colors_back(HV *hv, i_quantize *quant) {
+static void
+ip_copy_colors_back(pTHX_ HV *hv, i_quantize *quant) {
   SV **sv;
   AV *av;
   int i;
@@ -738,7 +757,7 @@ static void copy_colors_back(HV *hv, i_quantize *quant) {
 
 /* loads the segments of a fountain fill into an array */
 static i_fountain_seg *
-load_fount_segs(AV *asegs, int *count) {
+load_fount_segs(pTHX_ AV *asegs, int *count) {
   /* Each element of segs must contain:
      [ start, middle, end, c0, c1, segtype, colortrans ]
      start, middle, end are doubles from 0 to 1
@@ -873,6 +892,8 @@ i_int_hlines_DESTROY(i_int_hlines *hlines) {
   myfree(hlines);
 }
 
+#define i_int_hlines_CLONE_SKIP(cls) 1
+
 static int seg_compare(const void *vleft, const void *vright) {
   const i_int_hline_seg *left = vleft;
   const i_int_hline_seg *right = vright;
@@ -882,6 +903,7 @@ static int seg_compare(const void *vleft, const void *vright) {
 
 static SV *
 i_int_hlines_dump(i_int_hlines *hlines) {
+  dTHX;
   SV *dump = newSVpvf("start_y: %d limit_y: %d start_x: %d limit_x: %d\n",
        hlines->start_y, hlines->limit_y, hlines->start_x, hlines->limit_x);
   int y;
@@ -908,6 +930,18 @@ i_int_hlines_dump(i_int_hlines *hlines) {
 
 #endif
 
+static im_pl_ext_funcs im_perl_funcs =
+{
+  IMAGER_PL_API_VERSION,
+  IMAGER_PL_API_LEVEL,
+  ip_handle_quant_opts,
+  ip_cleanup_quant_opts,
+  ip_copy_colors_back
+};
+
+#define PERL_PL_SET_GLOBAL_CALLBACKS \
+  sv_setiv(get_sv(PERL_PL_FUNCTION_TABLE_NAME, 1), PTR2IV(&im_perl_funcs));
+
 #ifdef IMEXIF_ENABLE
 #define i_exif_enabled() 1
 #else
@@ -917,6 +951,9 @@ i_int_hlines_dump(i_int_hlines *hlines) {
 /* trying to use more C style names, map them here */
 #define i_io_DESTROY(ig) io_glue_destroy(ig)
 
+#define i_img_get_width(im) ((im)->xsize)
+#define i_img_get_height(im) ((im)->ysize)
+
 MODULE = Imager                PACKAGE = Imager::Color PREFIX = ICL_
 
 Imager::Color
@@ -1233,6 +1270,13 @@ void
 i_io_DESTROY(ig)
         Imager::IO     ig
 
+int
+i_io_CLONE_SKIP(...)
+    CODE:
+       RETVAL = 1;
+    OUTPUT:
+       RETVAL
+
 MODULE = Imager                PACKAGE = Imager
 
 PROTOTYPES: ENABLE
@@ -1249,10 +1293,6 @@ i_list_formats()
                      PUSHs(sv_2mortal(newSVpv(item,0)));
               }
 
-undef_int
-i_has_format(frmt)
-              char*    frmt
-
 Imager::ImgRaw
 i_img_new()
 
@@ -1343,6 +1383,15 @@ i_img_getdata(im)
                     sv_2mortal(newSVpv((char *)im->idata, im->bytes)) 
                     : &PL_sv_undef);
 
+IV
+i_img_get_width(im)
+    Imager::ImgRaw     im
+
+IV
+i_img_get_height(im)
+    Imager::ImgRaw     im
+
+
 void
 i_img_is_monochrome(im)
        Imager::ImgRaw im
@@ -1459,6 +1508,41 @@ i_circle_aa(im,x,y,rad,val)
              float     rad
           Imager::Color    val
 
+int
+i_circle_out(im,x,y,rad,val)
+    Imager::ImgRaw     im
+            i_img_dim     x
+            i_img_dim     y
+             i_img_dim     rad
+          Imager::Color    val
+
+int
+i_circle_out_aa(im,x,y,rad,val)
+    Imager::ImgRaw     im
+            i_img_dim     x
+            i_img_dim     y
+             i_img_dim     rad
+          Imager::Color    val
+
+int
+i_arc_out(im,x,y,rad,d1,d2,val)
+    Imager::ImgRaw     im
+            i_img_dim     x
+            i_img_dim     y
+             i_img_dim     rad
+            float d1
+            float d2
+          Imager::Color    val
+
+int
+i_arc_out_aa(im,x,y,rad,d1,d2,val)
+    Imager::ImgRaw     im
+            i_img_dim     x
+            i_img_dim     y
+             i_img_dim     rad
+            float d1
+            float d2
+          Imager::Color    val
 
 
 void
@@ -1496,7 +1580,7 @@ i_bezier_multi(im,xc,yc,val)
              myfree(y);
 
 
-void
+int
 i_poly_aa(im,xc,yc,val)
     Imager::ImgRaw     im
              Imager::Color  val
@@ -1508,7 +1592,7 @@ i_poly_aa(im,xc,yc,val)
             SV       *sv1;
             SV       *sv2;
             int i;
-            PPCODE:
+            CODE:
             ICL_info(val);
             if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
             if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa must be a reference to an array\n");
@@ -1526,11 +1610,13 @@ i_poly_aa(im,xc,yc,val)
               x[i]=(double)SvNV(sv1);
               y[i]=(double)SvNV(sv2);
             }
-             i_poly_aa(im,len,x,y,val);
+             RETVAL = i_poly_aa(im,len,x,y,val);
              myfree(x);
              myfree(y);
+            OUTPUT:
+              RETVAL
 
-void
+int
 i_poly_aa_cfill(im,xc,yc,fill)
     Imager::ImgRaw     im
      Imager::FillHandle     fill
@@ -1542,7 +1628,7 @@ i_poly_aa_cfill(im,xc,yc,fill)
             SV       *sv1;
             SV       *sv2;
             int i;
-            PPCODE:
+            CODE:
             if (!SvROK(ST(1))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
             if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
             if (!SvROK(ST(2))) croak("Imager: Parameter 1 to i_poly_aa_cfill must be a reference to an array\n");
@@ -1559,9 +1645,11 @@ i_poly_aa_cfill(im,xc,yc,fill)
               x[i]=(double)SvNV(sv1);
               y[i]=(double)SvNV(sv2);
             }
-             i_poly_aa_cfill(im,len,x,y,fill);
+             RETVAL = i_poly_aa_cfill(im,len,x,y,fill);
              myfree(x);
              myfree(y);
+            OUTPUT:
+              RETVAL
 
 
 
@@ -1665,6 +1753,47 @@ i_compose_mask(out, src, mask, out_left, out_top, src_left, src_top, mask_left,
        int combine
        double opacity
 
+Imager::ImgRaw
+i_combine(src_av, channels_av = NULL)
+       AV *src_av
+       AV *channels_av
+  PREINIT:
+       i_img **imgs = NULL;
+       STRLEN in_count;
+       int *channels = NULL;
+       int i;
+       SV **psv;
+       IV tmp;
+  CODE:
+       in_count = av_len(src_av) + 1;
+       if (in_count > 0) {
+         imgs = mymalloc(sizeof(i_img*) * in_count);
+         channels = mymalloc(sizeof(int) * in_count);
+         for (i = 0; i < in_count; ++i) {
+           psv = av_fetch(src_av, i, 0);
+           if (!psv || !*psv || !sv_derived_from(*psv, "Imager::ImgRaw")) {
+             myfree(imgs);
+             myfree(channels);
+             croak("imgs must contain only images");
+           }
+           tmp = SvIV((SV*)SvRV(*psv));
+           imgs[i] = INT2PTR(i_img*, tmp);
+           if (channels_av &&
+               (psv = av_fetch(channels_av, i, 0)) != NULL &&
+               *psv) {
+             channels[i] = SvIV(*psv);
+           }
+           else {
+             channels[i] = 0;
+           }
+         }
+       }
+       RETVAL = i_combine(imgs, channels, in_count);
+       myfree(imgs);
+       myfree(channels);
+  OUTPUT:
+       RETVAL
+
 undef_int
 i_flipxy(im, direction)
     Imager::ImgRaw     im
@@ -1756,34 +1885,33 @@ i_unsharp_mask(im,stdev,scale)
             float     stdev
              double    scale
 
-void
-i_conv(im,pcoef)
-    Imager::ImgRaw     im
-            PREINIT:
-            float*    coeff;
-            int     len;
-            AV* av;
-            SV* sv1;
-            int i;
-            PPCODE:
-            if (!SvROK(ST(1))) croak("Imager: Parameter 1 must be a reference to an array\n");
-            if (SvTYPE(SvRV(ST(1))) != SVt_PVAV) croak("Imager: Parameter 1 must be a reference to an array\n");
-            av=(AV*)SvRV(ST(1));
-            len=av_len(av)+1;
-            coeff=mymalloc( len*sizeof(float) );
-            for(i=0;i<len;i++) {
-              sv1=(*(av_fetch(av,i,0)));
-              coeff[i]=(float)SvNV(sv1);
-            }
-            i_conv(im,coeff,len);
-            myfree(coeff);
+int
+i_conv(im,coef)
+       Imager::ImgRaw     im
+       AV *coef
+     PREINIT:
+       double*    c_coef;
+       int     len;
+       SV* sv1;
+       int i;
+    CODE:
+       len = av_len(coef) + 1;
+       c_coef=mymalloc( len * sizeof(double) );
+       for(i = 0; i  < len; i++) {
+         sv1 = (*(av_fetch(coef, i, 0)));
+         c_coef[i] = (double)SvNV(sv1);
+       }
+       RETVAL = i_conv(im, c_coef, len);
+       myfree(c_coef);
+    OUTPUT:
+       RETVAL
 
 Imager::ImgRaw
 i_convert(src, avmain)
     Imager::ImgRaw     src
     AV *avmain
        PREINIT:
-         float *coeff;
+         double *coeff;
          int outchan;
          int inchan;
           SV **temp;
@@ -1803,7 +1931,7 @@ i_convert(src, avmain)
                inchan = len;
            }
           }
-          coeff = mymalloc(sizeof(float) * outchan * inchan);
+          coeff = mymalloc(sizeof(double) * outchan * inchan);
          for (j = 0; j < outchan; ++j) {
            avsub = (AV*)SvRV(*av_fetch(avmain, j, 0));
            len = av_len(avsub)+1;
@@ -1869,192 +1997,23 @@ i_img_diff(im1,im2)
     Imager::ImgRaw     im1
     Imager::ImgRaw     im2
 
+double
+i_img_diffd(im1,im2)
+    Imager::ImgRaw     im1
+    Imager::ImgRaw     im2
 
-
-undef_int        
-i_init_fonts(t1log=0)
-    int t1log
+bool
+_is_color_object(sv)
+       SV* sv
+    CODE:
+        SvGETMAGIC(sv);
+        RETVAL = SvOK(sv) && SvROK(sv) &&
+          (sv_derived_from(sv, "Imager::Color")
+          || sv_derived_from(sv, "Imager::Color::Float"));
+    OUTPUT:
+        RETVAL
 
 #ifdef HAVE_LIBT1
-
-void
-i_t1_set_aa(st)
-              int     st
-
-int
-i_t1_new(pfb,afm)
-                     char*    pfb
-                     char*    afm
-
-int
-i_t1_destroy(font_id)
-                      int     font_id
-
-
-undef_int
-i_t1_cp(im,xb,yb,channel,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
-    Imager::ImgRaw     im
-              int     xb
-              int     yb
-              int     channel
-              int     fontnum
-             float     points
-               SV*    str_sv
-              int     align
-               int     utf8
-              char*    flags
-             PREINIT:
-               char *str;
-               STRLEN len;
-             CODE:
-#ifdef SvUTF8
-               if (SvUTF8(str_sv))
-                 utf8 = 1;
-#endif
-               str = SvPV(str_sv, len);
-               RETVAL = i_t1_cp(im, xb,yb,channel,fontnum,points,str,len,align,
-                                  utf8,flags);
-           OUTPUT:
-             RETVAL
-
-
-void
-i_t1_bbox(fontnum,point,str_sv,len_ignored,utf8=0,flags="")
-               int     fontnum
-            float     point
-               SV*    str_sv
-               int     utf8
-              char*    flags
-            PREINIT:
-               char *str;
-               STRLEN len;
-              int     cords[BOUNDING_BOX_COUNT];
-               int i;
-               int rc;
-            PPCODE:
-#ifdef SvUTF8
-               if (SvUTF8(str_sv))
-                 utf8 = 1;
-#endif
-               str = SvPV(str_sv, len);
-               rc = i_t1_bbox(fontnum,point,str,len,cords,utf8,flags);
-               if (rc > 0) {
-                 EXTEND(SP, rc);
-                 for (i = 0; i < rc; ++i)
-                   PUSHs(sv_2mortal(newSViv(cords[i])));
-               }
-
-
-
-undef_int
-i_t1_text(im,xb,yb,cl,fontnum,points,str_sv,len_ignored,align,utf8=0,flags="")
-    Imager::ImgRaw     im
-              int     xb
-              int     yb
-     Imager::Color    cl
-              int     fontnum
-             float     points
-               SV*    str_sv
-              int     align
-               int     utf8
-              char*    flags
-             PREINIT:
-               char *str;
-               STRLEN len;
-             CODE:
-#ifdef SvUTF8
-               if (SvUTF8(str_sv))
-                 utf8 = 1;
-#endif
-               str = SvPV(str_sv, len);
-               RETVAL = i_t1_text(im, xb,yb,cl,fontnum,points,str,len,align,
-                                  utf8,flags);
-           OUTPUT:
-             RETVAL
-
-void
-i_t1_has_chars(handle, text_sv, utf8 = 0)
-        int handle
-        SV  *text_sv
-        int utf8
-      PREINIT:
-        char const *text;
-        STRLEN len;
-        char *work;
-        int count;
-        int i;
-      PPCODE:
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-        text = SvPV(text_sv, len);
-        work = mymalloc(len);
-        count = i_t1_has_chars(handle, text, len, utf8, work);
-        if (GIMME_V == G_ARRAY) {
-          EXTEND(SP, count);
-          for (i = 0; i < count; ++i) {
-            PUSHs(sv_2mortal(newSViv(work[i])));
-          }
-        }
-        else {
-          EXTEND(SP, 1);
-          PUSHs(sv_2mortal(newSVpv(work, count)));
-        }
-        myfree(work);
-
-void
-i_t1_face_name(handle)
-        int handle
-      PREINIT:
-        char name[255];
-        int len;
-      PPCODE:
-        len = i_t1_face_name(handle, name, sizeof(name));
-        if (len) {
-          EXTEND(SP, 1);
-          PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
-        }
-
-void
-i_t1_glyph_name(handle, text_sv, utf8 = 0)
-        int handle
-        SV *text_sv
-        int utf8
-      PREINIT:
-        char const *text;
-        STRLEN work_len;
-        int len;
-        char name[255];
-      PPCODE:
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-        text = SvPV(text_sv, work_len);
-        len = work_len;
-        while (len) {
-          unsigned long ch;
-          if (utf8) {
-            ch = i_utf8_advance(&text, &len);
-            if (ch == ~0UL) {
-              i_push_error(0, "invalid UTF8 character");
-              break;
-            }
-          }
-          else {
-            ch = *text++;
-            --len;
-          }
-          EXTEND(SP, 1);
-          if (i_t1_glyph_name(handle, ch, name, sizeof(name))) {
-            PUSHs(sv_2mortal(newSVpv(name, 0)));
-          }
-          else {
-            PUSHs(&PL_sv_undef);
-          } 
-        }
-
 #endif 
 
 #ifdef HAVE_LIBTT
@@ -2073,6 +2032,13 @@ void
 TT_DESTROY(handle)
      Imager::Font::TT   handle
 
+int
+TT_CLONE_SKIP(...)
+    CODE:
+        RETVAL = 1;
+    OUTPUT:
+        RETVAL
+
 
 MODULE = Imager         PACKAGE = Imager
 
@@ -2211,7 +2177,7 @@ i_tt_glyph_name(handle, text_sv, utf8 = 0)
       PREINIT:
         char const *text;
         STRLEN work_len;
-        int len;
+        size_t len;
         int outsize;
         char name[255];
       PPCODE:
@@ -2245,683 +2211,27 @@ i_tt_glyph_name(handle, text_sv, utf8 = 0)
 
 #endif 
 
-
-#ifdef HAVE_LIBJPEG
-undef_int
-i_writejpeg_wiol(im, ig, qfactor)
-    Imager::ImgRaw     im
-        Imager::IO     ig
-              int     qfactor
-
-
-void
-i_readjpeg_wiol(ig)
-        Imager::IO     ig
-            PREINIT:
-             char*    iptc_itext;
-              int     tlength;
-            i_img*    rimg;
-                SV*    r;
-            PPCODE:
-             iptc_itext = NULL;
-             rimg = i_readjpeg_wiol(ig,-1,&iptc_itext,&tlength);
-             if (iptc_itext == NULL) {
-                   r = sv_newmortal();
-                   EXTEND(SP,1);
-                   sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-                   PUSHs(r);
-             } else {
-                   r = sv_newmortal();
-                   EXTEND(SP,2);
-                   sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-                   PUSHs(r);
-                   PUSHs(sv_2mortal(newSVpv(iptc_itext,tlength)));
-                    myfree(iptc_itext);
-             }
-
-int
-i_exif_enabled()
-
-#endif
-
-
-const char *
-i_test_format_probe(ig, length)
-        Imager::IO     ig
-              int     length
-
-
-
-#ifdef HAVE_LIBTIFF
-
-Imager::ImgRaw
-i_readtiff_wiol(ig, allow_incomplete, page=0)
-        Imager::IO     ig
-              int     allow_incomplete
-               int     page
-
-void
-i_readtiff_multi_wiol(ig, length)
-        Imager::IO     ig
-              int     length
-      PREINIT:
-        i_img **imgs;
-        int count;
-        int i;
-      PPCODE:
-        imgs = i_readtiff_multi_wiol(ig, length, &count);
-        if (imgs) {
-          EXTEND(SP, count);
-          for (i = 0; i < count; ++i) {
-            SV *sv = sv_newmortal();
-            sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
-            PUSHs(sv);
-          }
-          myfree(imgs);
-        }
-
-
-undef_int
-i_writetiff_wiol(im, ig)
-    Imager::ImgRaw     im
-        Imager::IO     ig
-
-undef_int
-i_writetiff_multi_wiol(ig, ...)
-        Imager::IO     ig
-      PREINIT:
-        int i;
-        int img_count;
-        i_img **imgs;
-      CODE:
-        if (items < 2)
-          croak("Usage: i_writetiff_multi_wiol(ig, images...)");
-        img_count = items - 1;
-        RETVAL = 1;
-       if (img_count < 1) {
-         RETVAL = 0;
-         i_clear_error();
-         i_push_error(0, "You need to specify images to save");
-       }
-       else {
-          imgs = mymalloc(sizeof(i_img *) * img_count);
-          for (i = 0; i < img_count; ++i) {
-           SV *sv = ST(1+i);
-           imgs[i] = NULL;
-           if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
-             imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
-           }
-           else {
-             i_clear_error();
-             i_push_error(0, "Only images can be saved");
-              myfree(imgs);
-             RETVAL = 0;
-             break;
-            }
-         }
-          if (RETVAL) {
-           RETVAL = i_writetiff_multi_wiol(ig, imgs, img_count);
-          }
-         myfree(imgs);
-       }
-      OUTPUT:
-        RETVAL
-
-undef_int
-i_writetiff_wiol_faxable(im, ig, fine)
-    Imager::ImgRaw     im
-        Imager::IO     ig
-              int     fine
-
-undef_int
-i_writetiff_multi_wiol_faxable(ig, fine, ...)
-        Imager::IO     ig
-        int fine
-      PREINIT:
-        int i;
-        int img_count;
-        i_img **imgs;
-      CODE:
-        if (items < 3)
-          croak("Usage: i_writetiff_multi_wiol_faxable(ig, fine, images...)");
-        img_count = items - 2;
-        RETVAL = 1;
-       if (img_count < 1) {
-         RETVAL = 0;
-         i_clear_error();
-         i_push_error(0, "You need to specify images to save");
-       }
-       else {
-          imgs = mymalloc(sizeof(i_img *) * img_count);
-          for (i = 0; i < img_count; ++i) {
-           SV *sv = ST(2+i);
-           imgs[i] = NULL;
-           if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
-             imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
-           }
-           else {
-             i_clear_error();
-             i_push_error(0, "Only images can be saved");
-              myfree(imgs);
-             RETVAL = 0;
-             break;
-            }
-         }
-          if (RETVAL) {
-           RETVAL = i_writetiff_multi_wiol_faxable(ig, imgs, img_count, fine);
-          }
-         myfree(imgs);
-       }
-      OUTPUT:
-        RETVAL
-
 const char *
-i_tiff_libversion()
-
-bool
-i_tiff_has_compression(name)
-       const char *name
-
-#endif /* HAVE_LIBTIFF */
-
-
-#ifdef HAVE_LIBPNG
-
-Imager::ImgRaw
-i_readpng_wiol(ig, length)
-        Imager::IO     ig
-              int     length
-
-
-undef_int
-i_writepng_wiol(im, ig)
-    Imager::ImgRaw     im
-        Imager::IO     ig
-
-
-#endif
-
-
-#ifdef HAVE_LIBGIF
-
-void
-i_giflib_version()
-       PPCODE:
-         PUSHs(sv_2mortal(newSVnv(IM_GIFMAJOR+IM_GIFMINOR*0.1)));
-
-undef_int
-i_writegif(im,fd,colors,pixdev,fixed)
-    Imager::ImgRaw     im
-              int     fd
-              int     colors
-               int     pixdev
-            PREINIT:
-             int     fixedlen;
-            Imager__Color  fixed;
-            Imager__Color  tmp;
-            AV* av;
-            SV* sv1;
-             IV  Itmp;
-            int i;
-            CODE:
-            if (!SvROK(ST(4))) croak("Imager: Parameter 4 must be a reference to an array\n");
-            if (SvTYPE(SvRV(ST(4))) != SVt_PVAV) croak("Imager: Parameter 4 must be a reference to an array\n");
-            av=(AV*)SvRV(ST(4));
-            fixedlen=av_len(av)+1;
-            fixed=mymalloc( fixedlen*sizeof(i_color) );
-            for(i=0;i<fixedlen;i++) {
-              sv1=(*(av_fetch(av,i,0)));
-               if (sv_derived_from(sv1, "Imager::Color")) {
-                 Itmp = SvIV((SV*)SvRV(sv1));
-                 tmp = INT2PTR(i_color*, Itmp);
-               } else croak("Imager: one of the elements of array ref is not of Imager::Color type\n");
-               fixed[i]=*tmp;
-            }
-            RETVAL=i_writegif(im,fd,colors,pixdev,fixedlen,fixed);
-             myfree(fixed);
-             ST(0) = sv_newmortal();
-             if (RETVAL == 0) ST(0)=&PL_sv_undef;
-             else sv_setiv(ST(0), (IV)RETVAL);
-
-
-
-
-undef_int
-i_writegifmc(im,fd,colors)
-    Imager::ImgRaw    im
-              int     fd
-              int     colors
-
-
-undef_int
-i_writegif_gen(fd, ...)
-              int     fd
-      PROTOTYPE: $$@
-      PREINIT:
-       i_quantize quant;
-       i_img **imgs = NULL;
-       int img_count;
-       int i;
-       HV *hv;
-      CODE:
-       if (items < 3)
-           croak("Usage: i_writegif_gen(fd,hashref, images...)");
-       if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
-           croak("i_writegif_gen: Second argument must be a hash ref");
-       hv = (HV *)SvRV(ST(1));
-       memset(&quant, 0, sizeof(quant));
-       quant.mc_size = 256;
-       quant.transp = tr_threshold;
-       quant.tr_threshold = 127;
-       handle_quant_opts(&quant, hv);
-       img_count = items - 2;
-       RETVAL = 1;
-       if (img_count < 1) {
-         RETVAL = 0;
-         i_clear_error();
-         i_push_error(0, "You need to specify images to save");
-       }
-       else {
-          imgs = mymalloc(sizeof(i_img *) * img_count);
-          for (i = 0; i < img_count; ++i) {
-           SV *sv = ST(2+i);
-           imgs[i] = NULL;
-           if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
-             imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
-           }
-           else {
-             i_clear_error();
-             i_push_error(0, "Only images can be saved");
-             RETVAL = 0;
-             break;
-            }
-         }
-          if (RETVAL) {
-           RETVAL = i_writegif_gen(&quant, fd, imgs, img_count);
-          }
-         myfree(imgs);
-          if (RETVAL) {
-           copy_colors_back(hv, &quant);
-          }
-       }
-        ST(0) = sv_newmortal();
-        if (RETVAL == 0) ST(0)=&PL_sv_undef;
-        else sv_setiv(ST(0), (IV)RETVAL);
-       cleanup_quant_opts(&quant);
-
-
-undef_int
-i_writegif_callback(cb, maxbuffer,...)
-       int maxbuffer;
-      PREINIT:
-       i_quantize quant;
-       i_img **imgs = NULL;
-       int img_count;
-       int i;
-       HV *hv;
-        i_writer_data wd;
-      CODE:
-       if (items < 4)
-           croak("Usage: i_writegif_callback(\\&callback,maxbuffer,hashref, images...)");
-       if (!SvROK(ST(2)) || ! SvTYPE(SvRV(ST(2))))
-           croak("i_writegif_callback: Second argument must be a hash ref");
-       hv = (HV *)SvRV(ST(2));
-       memset(&quant, 0, sizeof(quant));
-       quant.mc_size = 256;
-       quant.transp = tr_threshold;
-       quant.tr_threshold = 127;
-       handle_quant_opts(&quant, hv);
-       img_count = items - 3;
-       RETVAL = 1;
-       if (img_count < 1) {
-         RETVAL = 0;
-       }
-       else {
-          imgs = mymalloc(sizeof(i_img *) * img_count);
-          for (i = 0; i < img_count; ++i) {
-           SV *sv = ST(3+i);
-           imgs[i] = NULL;
-           if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
-             imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
-           }
-           else {
-             RETVAL = 0;
-             break;
-            }
-         }
-          if (RETVAL) {
-           wd.sv = ST(0);
-           RETVAL = i_writegif_callback(&quant, write_callback, (char *)&wd, maxbuffer, imgs, img_count);
-          }
-         myfree(imgs);
-          if (RETVAL) {
-           copy_colors_back(hv, &quant);
-          }
-       }
-       ST(0) = sv_newmortal();
-       if (RETVAL == 0) ST(0)=&PL_sv_undef;
-       else sv_setiv(ST(0), (IV)RETVAL);
-       cleanup_quant_opts(&quant);
-
-undef_int
-i_writegif_wiol(ig, opts,...)
-       Imager::IO ig
-      PREINIT:
-       i_quantize quant;
-       i_img **imgs = NULL;
-       int img_count;
-       int i;
-       HV *hv;
-      CODE:
-       if (items < 3)
-           croak("Usage: i_writegif_wiol(IO,hashref, images...)");
-       if (!SvROK(ST(1)) || ! SvTYPE(SvRV(ST(1))))
-           croak("i_writegif_callback: Second argument must be a hash ref");
-       hv = (HV *)SvRV(ST(1));
-       memset(&quant, 0, sizeof(quant));
-       quant.mc_size = 256;
-       quant.transp = tr_threshold;
-       quant.tr_threshold = 127;
-       handle_quant_opts(&quant, hv);
-       img_count = items - 2;
-       RETVAL = 1;
-       if (img_count < 1) {
-         RETVAL = 0;
-       }
-       else {
-          imgs = mymalloc(sizeof(i_img *) * img_count);
-          for (i = 0; i < img_count; ++i) {
-           SV *sv = ST(2+i);
-           imgs[i] = NULL;
-           if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) {
-             imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv)));
-           }
-           else {
-             RETVAL = 0;
-             break;
-            }
-         }
-          if (RETVAL) {
-           RETVAL = i_writegif_wiol(ig, &quant, imgs, img_count);
-          }
-         myfree(imgs);
-          if (RETVAL) {
-           copy_colors_back(hv, &quant);
-          }
-       }
-       ST(0) = sv_newmortal();
-       if (RETVAL == 0) ST(0)=&PL_sv_undef;
-       else sv_setiv(ST(0), (IV)RETVAL);
-       cleanup_quant_opts(&quant);
-
-void
-i_readgif(fd)
-              int     fd
-             PREINIT:
-               int*    colour_table;
-               int     colours, q, w;
-             i_img*    rimg;
-                 SV*    temp[3];
-                 AV*    ct; 
-                 SV*    r;
-              PPCODE:
-              colour_table = NULL;
-               colours = 0;
-
-       if(GIMME_V == G_ARRAY) {
-            rimg = i_readgif(fd,&colour_table,&colours);
-        } else {
-            /* don't waste time with colours if they aren't wanted */
-            rimg = i_readgif(fd,NULL,NULL);
-        }
-       
-       if (colour_table == NULL) {
-            EXTEND(SP,1);
-            r=sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-       } else {
-            /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
-            /* I don't know if I have the reference counts right or not :( */
-            /* Neither do I :-) */
-            /* No Idea here either */
-
-            ct=newAV();
-            av_extend(ct, colours);
-            for(q=0; q<colours; q++) {
-                for(w=0; w<3; w++)
-                    temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
-                av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
-            }
-            myfree(colour_table);
-
-            EXTEND(SP,2);
-            r = sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-            PUSHs(newRV_noinc((SV*)ct));
-        }
-
-void
-i_readgif_wiol(ig)
-     Imager::IO         ig
-             PREINIT:
-               int*    colour_table;
-               int     colours, q, w;
-             i_img*    rimg;
-                 SV*    temp[3];
-                 AV*    ct; 
-                 SV*    r;
-              PPCODE:
-              colour_table = NULL;
-               colours = 0;
-
-       if(GIMME_V == G_ARRAY) {
-            rimg = i_readgif_wiol(ig,&colour_table,&colours);
-        } else {
-            /* don't waste time with colours if they aren't wanted */
-            rimg = i_readgif_wiol(ig,NULL,NULL);
-        }
-       
-       if (colour_table == NULL) {
-            EXTEND(SP,1);
-            r=sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-       } else {
-            /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
-            /* I don't know if I have the reference counts right or not :( */
-            /* Neither do I :-) */
-            /* No Idea here either */
-
-            ct=newAV();
-            av_extend(ct, colours);
-            for(q=0; q<colours; q++) {
-                for(w=0; w<3; w++)
-                    temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
-                av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
-            }
-            myfree(colour_table);
-
-            EXTEND(SP,2);
-            r = sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-            PUSHs(newRV_noinc((SV*)ct));
-        }
-
-Imager::ImgRaw
-i_readgif_single_wiol(ig, page=0)
-       Imager::IO      ig
-        int            page
-
-void
-i_readgif_scalar(...)
-          PROTOTYPE: $
-            PREINIT:
-               char*    data;
-             STRLEN     length;
-               int*    colour_table;
-               int     colours, q, w;
-             i_img*    rimg;
-                 SV*    temp[3];
-                 AV*    ct; 
-                 SV*    r;
-              PPCODE:
-        data = (char *)SvPV(ST(0), length);
-        colour_table=NULL;
-        colours=0;
-
-       if(GIMME_V == G_ARRAY) {  
-            rimg=i_readgif_scalar(data,length,&colour_table,&colours);
-        } else {
-            /* don't waste time with colours if they aren't wanted */
-            rimg=i_readgif_scalar(data,length,NULL,NULL);
-        }
-
-       if (colour_table == NULL) {
-            EXTEND(SP,1);
-            r=sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-       } else {
-            /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
-            /* I don't know if I have the reference counts right or not :( */
-            /* Neither do I :-) */
-            ct=newAV();
-            av_extend(ct, colours);
-            for(q=0; q<colours; q++) {
-                for(w=0; w<3; w++)
-                    temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
-                av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
-            }
-            myfree(colour_table);
-            
-            EXTEND(SP,2);
-            r=sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-            PUSHs(newRV_noinc((SV*)ct));
-        }
-
-void
-i_readgif_callback(...)
-          PROTOTYPE: &
-            PREINIT:
-               int*    colour_table;
-               int     colours, q, w;
-             i_img*    rimg;
-                 SV*    temp[3];
-                 AV*    ct; 
-                 SV*    r;
-       i_reader_data    rd;
-              PPCODE:
-       rd.sv = ST(0);
-        colour_table=NULL;
-        colours=0;
-
-       if(GIMME_V == G_ARRAY) {  
-            rimg=i_readgif_callback(read_callback, (char *)&rd,&colour_table,&colours);
-        } else {
-            /* don't waste time with colours if they aren't wanted */
-            rimg=i_readgif_callback(read_callback, (char *)&rd,NULL,NULL);
-        }
-
-       if (colour_table == NULL) {
-            EXTEND(SP,1);
-            r=sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-       } else {
-            /* the following creates an [[r,g,b], [r, g, b], [r, g, b]...] */
-            /* I don't know if I have the reference counts right or not :( */
-            /* Neither do I :-) */
-            /* Neither do I - maybe I'll move this somewhere */
-            ct=newAV();
-            av_extend(ct, colours);
-            for(q=0; q<colours; q++) {
-                for(w=0; w<3; w++)
-                    temp[w]=sv_2mortal(newSViv(colour_table[q*3 + w]));
-                av_store(ct, q, (SV*)newRV_noinc((SV*)av_make(3, temp)));
-            }
-            myfree(colour_table);
-            
-            EXTEND(SP,2);
-            r=sv_newmortal();
-            sv_setref_pv(r, "Imager::ImgRaw", (void*)rimg);
-            PUSHs(r);
-            PUSHs(newRV_noinc((SV*)ct));
-        }
-
-void
-i_readgif_multi(fd)
-        int     fd
-      PREINIT:
-        i_img **imgs;
-        int count;
-        int i;
-      PPCODE:
-        imgs = i_readgif_multi(fd, &count);
-        if (imgs) {
-          EXTEND(SP, count);
-          for (i = 0; i < count; ++i) {
-            SV *sv = sv_newmortal();
-            sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
-            PUSHs(sv);
-          }
-          myfree(imgs);
-        }
-
-void
-i_readgif_multi_scalar(data)
-      PREINIT:
-        i_img **imgs;
-        int count;
-        char *data;
-        STRLEN length;
-        int i;
-      PPCODE:
-        data = (char *)SvPV(ST(0), length);
-        imgs = i_readgif_multi_scalar(data, length, &count);
-        if (imgs) {
-          EXTEND(SP, count);
-          for (i = 0; i < count; ++i) {
-            SV *sv = sv_newmortal();
-            sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
-            PUSHs(sv);
-          }
-          myfree(imgs);
-        }
-
-void
-i_readgif_multi_callback(cb)
-      PREINIT:
-        i_reader_data rd;
-        i_img **imgs;
-        int count;
-        int i;
-      PPCODE:
-        rd.sv = ST(0);
-        imgs = i_readgif_multi_callback(read_callback, (char *)&rd, &count);
-        if (imgs) {
-          EXTEND(SP, count);
-          for (i = 0; i < count; ++i) {
-            SV *sv = sv_newmortal();
-            sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]);
-            PUSHs(sv);
-          }
-          myfree(imgs);
-        }
+i_test_format_probe(ig, length)
+        Imager::IO     ig
+              int     length
+
+Imager::ImgRaw
+i_readpnm_wiol(ig, allow_incomplete)
+        Imager::IO     ig
+              int     allow_incomplete
+
 
 void
-i_readgif_multi_wiol(ig)
+i_readpnm_multi_wiol(ig, allow_incomplete)
         Imager::IO ig
+              int     allow_incomplete
       PREINIT:
         i_img **imgs;
-        int count;
+        int count=0;
         int i;
       PPCODE:
-        imgs = i_readgif_multi_wiol(ig, &count);
+        imgs = i_readpnm_multi_wiol(ig, &count, allow_incomplete);
         if (imgs) {
           EXTEND(SP, count);
           for (i = 0; i < count; ++i) {
@@ -2932,23 +2242,15 @@ i_readgif_multi_wiol(ig)
           myfree(imgs);
         }
 
-
-#endif
-
-
-
-Imager::ImgRaw
-i_readpnm_wiol(ig, allow_incomplete)
-        Imager::IO     ig
-              int     allow_incomplete
-
-
 undef_int
 i_writeppm_wiol(im, ig)
     Imager::ImgRaw     im
         Imager::IO     ig
 
 
+
+
+
 Imager::ImgRaw
 i_readraw_wiol(ig,x,y,datachannels,storechannels,intrl)
         Imager::IO     ig
@@ -3192,6 +2494,10 @@ void
 i_hardinvert(im)
     Imager::ImgRaw     im
 
+void
+i_hardinvertall(im)
+    Imager::ImgRaw     im
+
 void
 i_noise(im,amount,type)
     Imager::ImgRaw     im
@@ -3346,7 +2652,7 @@ i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_para
            croak("i_fountain: argument 11 must be an array ref");
         
        asegs = (AV *)SvRV(ST(10));
-        segs = load_fount_segs(asegs, &count);
+        segs = load_fount_segs(aTHX_ asegs, &count);
         RETVAL = i_fountain(im, xa, ya, xb, yb, type, repeat, combine, 
                             super_sample, ssample_param, count, segs);
         myfree(segs);
@@ -3373,13 +2679,18 @@ i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_pa
            croak("i_fountain: argument 11 must be an array ref");
         
        asegs = (AV *)SvRV(ST(9));
-        segs = load_fount_segs(asegs, &count);
+        segs = load_fount_segs(aTHX_ asegs, &count);
         RETVAL = i_new_fill_fount(xa, ya, xb, yb, type, repeat, combine, 
                                   super_sample, ssample_param, count, segs);
         myfree(segs);        
       OUTPUT:
         RETVAL
 
+Imager::FillHandle
+i_new_fill_opacity(other_fill, alpha_mult)
+    Imager::FillHandle other_fill
+    double alpha_mult
+
 void
 i_errors()
       PREINIT:
@@ -3564,13 +2875,14 @@ i_img_to_pal(src, quant)
           croak("i_img_to_pal: second argument must be a hash ref");
         hv = (HV *)SvRV(ST(1));
         memset(&quant, 0, sizeof(quant));
+       quant.version = 1;
         quant.mc_size = 256;
-       handle_quant_opts(&quant, hv);
+       ip_handle_quant_opts(aTHX_ &quant, hv);
         RETVAL = i_img_to_pal(src, &quant);
         if (RETVAL) {
-          copy_colors_back(hv, &quant);
+          ip_copy_colors_back(aTHX_ hv, &quant);
         }
-       cleanup_quant_opts(&quant);
+       ip_cleanup_quant_opts(aTHX_ &quant);
       OUTPUT:
         RETVAL
 
@@ -4350,430 +3662,7 @@ i_tags_count(im)
       OUTPUT:
         RETVAL
 
-#ifdef HAVE_WIN32
-
-void
-i_wf_bbox(face, size, text_sv, utf8=0)
-       char *face
-       int size
-       SV *text_sv
-       int utf8
-      PREINIT:
-       int cords[BOUNDING_BOX_COUNT];
-        int rc, i;
-       char const *text;
-         STRLEN text_len;
-      PPCODE:
-        text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-        if (rc = i_wf_bbox(face, size, text, text_len, cords, utf8)) {
-          EXTEND(SP, rc);  
-          for (i = 0; i < rc; ++i) 
-            PUSHs(sv_2mortal(newSViv(cords[i])));
-        }
-
-undef_int
-i_wf_text(face, im, tx, ty, cl, size, text_sv, align, aa, utf8 = 0)
-       char *face
-       Imager::ImgRaw im
-       int tx
-       int ty
-       Imager::Color cl
-       int size
-       SV *text_sv
-       int align
-       int aa
-       int utf8
-      PREINIT:
-       char const *text;
-       STRLEN text_len;
-      CODE:
-        text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-       RETVAL = i_wf_text(face, im, tx, ty, cl, size, text, text_len, 
-                          align, aa, utf8);
-      OUTPUT:
-       RETVAL
-
-undef_int
-i_wf_cp(face, im, tx, ty, channel, size, text_sv, align, aa, utf8 = 0)
-       char *face
-       Imager::ImgRaw im
-       int tx
-       int ty
-       int channel
-       int size
-       SV *text_sv
-       int align
-       int aa
-       int utf8
-      PREINIT:
-       char const *text;
-       STRLEN text_len;
-      CODE:
-        text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-       RETVAL = i_wf_cp(face, im, tx, ty, channel, size, text, text_len, 
-                        align, aa, utf8);
-      OUTPUT:
-       RETVAL
-
-undef_int
-i_wf_addfont(font)
-        char *font
-
-undef_int
-i_wf_delfont(font)
-        char *font
-
-#endif
-
-#ifdef HAVE_FT2
-
-MODULE = Imager         PACKAGE = Imager::Font::FT2     PREFIX=FT2_
-
-#define FT2_DESTROY(font) i_ft2_destroy(font)
-
-void
-FT2_DESTROY(font)
-        Imager::Font::FT2 font
-
-MODULE = Imager         PACKAGE = Imager::Font::FreeType2 
-
-Imager::Font::FT2
-i_ft2_new(name, index)
-        char *name
-        int index
-
-undef_int
-i_ft2_setdpi(font, xdpi, ydpi)
-        Imager::Font::FT2 font
-        int xdpi
-        int ydpi
-
-void
-i_ft2_getdpi(font)
-        Imager::Font::FT2 font
-      PREINIT:
-        int xdpi, ydpi;
-      CODE:
-        if (i_ft2_getdpi(font, &xdpi, &ydpi)) {
-          EXTEND(SP, 2);
-          PUSHs(sv_2mortal(newSViv(xdpi)));
-          PUSHs(sv_2mortal(newSViv(ydpi)));
-        }
-
-undef_int
-i_ft2_sethinting(font, hinting)
-        Imager::Font::FT2 font
-        int hinting
-
-undef_int
-i_ft2_settransform(font, matrix)
-        Imager::Font::FT2 font
-      PREINIT:
-        double matrix[6];
-        int len;
-        AV *av;
-        SV *sv1;
-        int i;
-      CODE:
-        if (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVAV)
-          croak("i_ft2_settransform: parameter 2 must be an array ref\n");
-       av=(AV*)SvRV(ST(1));
-       len=av_len(av)+1;
-        if (len > 6)
-          len = 6;
-        for (i = 0; i < len; ++i) {
-         sv1=(*(av_fetch(av,i,0)));
-         matrix[i] = SvNV(sv1);
-        }
-        for (; i < 6; ++i)
-          matrix[i] = 0;
-        RETVAL = i_ft2_settransform(font, matrix);
-      OUTPUT:
-        RETVAL
-
-void
-i_ft2_bbox(font, cheight, cwidth, text_sv, utf8)
-        Imager::Font::FT2 font
-        double cheight
-        double cwidth
-        SV *text_sv
-       int utf8
-      PREINIT:
-        int bbox[BOUNDING_BOX_COUNT];
-        int i;
-        char *text;
-        STRLEN text_len;
-        int rc;
-      PPCODE:
-        text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-        rc = i_ft2_bbox(font, cheight, cwidth, text, text_len, bbox, utf8);
-        if (rc) {
-          EXTEND(SP, rc);
-          for (i = 0; i < rc; ++i)
-            PUSHs(sv_2mortal(newSViv(bbox[i])));
-        }
-
-void
-i_ft2_bbox_r(font, cheight, cwidth, text, vlayout, utf8)
-        Imager::Font::FT2 font
-        double cheight
-        double cwidth
-        char *text
-        int vlayout
-        int utf8
-      PREINIT:
-        int bbox[8];
-        int i;
-      PPCODE:
-#ifdef SvUTF8
-        if (SvUTF8(ST(3)))
-          utf8 = 1;
-#endif
-        if (i_ft2_bbox_r(font, cheight, cwidth, text, strlen(text), vlayout,
-                         utf8, bbox)) {
-          EXTEND(SP, 8);
-          for (i = 0; i < 8; ++i)
-            PUSHs(sv_2mortal(newSViv(bbox[i])));
-        }
-
-undef_int
-i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text, align, aa, vlayout, utf8)
-        Imager::Font::FT2 font
-        Imager::ImgRaw im
-        int tx
-        int ty
-        Imager::Color cl
-        double cheight
-        double cwidth
-        int align
-        int aa
-        int vlayout
-        int utf8
-      PREINIT:
-        char *text;
-        STRLEN len;
-      CODE:
-#ifdef SvUTF8
-        if (SvUTF8(ST(7))) {
-          utf8 = 1;
-        }
-#endif
-        text = SvPV(ST(7), len);
-        RETVAL = i_ft2_text(font, im, tx, ty, cl, cheight, cwidth, text,
-                            len, align, aa, vlayout, utf8);
-      OUTPUT:
-        RETVAL
-
-undef_int
-i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text_sv, align, aa, vlayout, utf8)
-        Imager::Font::FT2 font
-        Imager::ImgRaw im
-        int tx
-        int ty
-        int channel
-        double cheight
-        double cwidth
-        SV *text_sv
-        int align
-        int aa
-        int vlayout
-        int utf8
-      PREINIT:
-       char const *text;
-       STRLEN len;
-      CODE:
-#ifdef SvUTF8
-        if (SvUTF8(ST(7)))
-          utf8 = 1;
-#endif
-       text = SvPV(text_sv, len);
-        RETVAL = i_ft2_cp(font, im, tx, ty, channel, cheight, cwidth, text,
-                          len, align, aa, vlayout, 1);
-      OUTPUT:
-        RETVAL
-
-void
-ft2_transform_box(font, x0, x1, x2, x3)
-        Imager::Font::FT2 font
-        int x0
-        int x1
-        int x2
-        int x3
-      PREINIT:
-        int box[4];
-      PPCODE:
-        box[0] = x0; box[1] = x1; box[2] = x2; box[3] = x3;
-        ft2_transform_box(font, box);
-          EXTEND(SP, 4);
-          PUSHs(sv_2mortal(newSViv(box[0])));
-          PUSHs(sv_2mortal(newSViv(box[1])));
-          PUSHs(sv_2mortal(newSViv(box[2])));
-          PUSHs(sv_2mortal(newSViv(box[3])));
-
-void
-i_ft2_has_chars(handle, text_sv, utf8)
-        Imager::Font::FT2 handle
-        SV  *text_sv
-        int utf8
-      PREINIT:
-        char *text;
-        STRLEN len;
-        char *work;
-        int count;
-        int i;
-      PPCODE:
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-        text = SvPV(text_sv, len);
-        work = mymalloc(len);
-        count = i_ft2_has_chars(handle, text, len, utf8, work);
-        if (GIMME_V == G_ARRAY) {
-          EXTEND(SP, count);
-          for (i = 0; i < count; ++i) {
-            PUSHs(sv_2mortal(newSViv(work[i])));
-          }
-        }
-        else {
-          EXTEND(SP, 1);
-          PUSHs(sv_2mortal(newSVpv(work, count)));
-        }
-        myfree(work);
-
-void
-i_ft2_face_name(handle)
-        Imager::Font::FT2 handle
-      PREINIT:
-        char name[255];
-        int len;
-      PPCODE:
-        len = i_ft2_face_name(handle, name, sizeof(name));
-        if (len) {
-          EXTEND(SP, 1);
-          PUSHs(sv_2mortal(newSVpv(name, 0)));
-        }
-
-undef_int
-i_ft2_can_face_name()
-
-void
-i_ft2_glyph_name(handle, text_sv, utf8 = 0, reliable_only = 1)
-        Imager::Font::FT2 handle
-        SV *text_sv
-        int utf8
-        int reliable_only
-      PREINIT:
-        char const *text;
-        STRLEN work_len;
-        int len;
-        char name[255];
-      PPCODE:
-#ifdef SvUTF8
-        if (SvUTF8(text_sv))
-          utf8 = 1;
-#endif
-        text = SvPV(text_sv, work_len);
-        len = work_len;
-        while (len) {
-          unsigned long ch;
-          if (utf8) {
-            ch = i_utf8_advance(&text, &len);
-            if (ch == ~0UL) {
-              i_push_error(0, "invalid UTF8 character");
-              break;
-            }
-          }
-          else {
-            ch = *text++;
-            --len;
-          }
-          EXTEND(SP, 1);
-          if (i_ft2_glyph_name(handle, ch, name, sizeof(name), 
-                                         reliable_only)) {
-            PUSHs(sv_2mortal(newSVpv(name, 0)));
-          }
-          else {
-            PUSHs(&PL_sv_undef);
-          } 
-        }
-
-int
-i_ft2_can_do_glyph_names()
-
-int
-i_ft2_face_has_glyph_names(handle)
-        Imager::Font::FT2 handle
-
-int
-i_ft2_is_multiple_master(handle)
-        Imager::Font::FT2 handle
-
-void
-i_ft2_get_multiple_masters(handle)
-        Imager::Font::FT2 handle
-      PREINIT:
-        i_font_mm mm;
-        int i;
-      PPCODE:
-        if (i_ft2_get_multiple_masters(handle, &mm)) {
-          EXTEND(SP, 2+mm.num_axis);
-          PUSHs(sv_2mortal(newSViv(mm.num_axis)));
-          PUSHs(sv_2mortal(newSViv(mm.num_designs)));
-          for (i = 0; i < mm.num_axis; ++i) {
-            AV *av = newAV();
-            SV *sv;
-            av_extend(av, 3);
-            sv = newSVpv(mm.axis[i].name, strlen(mm.axis[i].name));
-            SvREFCNT_inc(sv);
-            av_store(av, 0, sv);
-            sv = newSViv(mm.axis[i].minimum);
-            SvREFCNT_inc(sv);
-            av_store(av, 1, sv);
-            sv = newSViv(mm.axis[i].maximum);
-            SvREFCNT_inc(sv);
-            av_store(av, 2, sv);
-            PUSHs(newRV_noinc((SV *)av));
-          }
-        }
-
-undef_int
-i_ft2_set_mm_coords(handle, ...)
-        Imager::Font::FT2 handle
-      PROTOTYPE: DISABLE
-      PREINIT:
-        long *coords;
-        int ix_coords, i;
-      CODE:
-        /* T_ARRAY handling by xsubpp seems to be busted in 5.6.1, so
-           transfer the array manually */
-        ix_coords = items-1;
-        coords = mymalloc(sizeof(long) * ix_coords);
-       for (i = 0; i < ix_coords; ++i) {
-          coords[i] = (long)SvIV(ST(1+i));
-        }
-        RETVAL = i_ft2_set_mm_coords(handle, ix_coords, coords);
-        myfree(coords);
-      OUTPUT:
-        RETVAL
 
-#endif
 
 MODULE = Imager         PACKAGE = Imager::FillHandle PREFIX=IFILL_
 
@@ -4781,6 +3670,13 @@ void
 IFILL_DESTROY(fill)
         Imager::FillHandle fill
 
+int
+IFILL_CLONE_SKIP(...)
+    CODE:
+        RETVAL = 1;
+    OUTPUT:
+        RETVAL
+
 MODULE = Imager         PACKAGE = Imager
 
 Imager::FillHandle
@@ -4906,7 +3802,12 @@ SV *
 i_int_hlines_dump(hlines)
        Imager::Internal::Hlines hlines
 
+int
+i_int_hlines_CLONE_SKIP(cls)
+       SV *cls
+
 #endif
 
 BOOT:
         PERL_SET_GLOBAL_CALLBACKS;
+       PERL_PL_SET_GLOBAL_CALLBACKS;
\ No newline at end of file