/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
 * contents of GD.xs. Do not edit this file, edit GD.xs instead.
 *
 *    ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "GD.xs"
#ifdef PERL_CAPI
#define WIN32IO_IS_STDIO
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <gd.h>
#include <gdfontg.h>
#include <gdfontl.h>
#include <gdfontmb.h>
#include <gdfonts.h>
#include <gdfontt.h>
#include <errno.h>

/* no xbm writer, no gdImageXbmPtr() */

/* 2.0.x: < 2.1.0-alpha */
#ifndef GD_VERSION_STRING
# if defined(GD2_VERS) && (GD2_VERS==2)
#   ifdef VERSION_33
#    define GD_VERSION 20033
#    define GD_VERSION_STRING "2.0.33"
#   else
#    define GD_VERSION 20032
#    define GD_VERSION_STRING "2.0.x"
#   endif
# else
#   define GD_VERSION 10000
#   define GD_VERSION_STRING "?"
# endif
#else
#  define GD_VERSION ((GD_MAJOR_VERSION * 10000) +\
                      (GD_MINOR_VERSION * 100) +\
                      GD_RELEASE_VERSION)
#endif

#ifdef FCGI
 #include <fcgi_stdio.h>
#else
 #ifdef USE_SFIO
  #include <config.h>
 #else
  #include <stdio.h>
 #endif
 #include <perlio.h>
#endif
/* Copyright 1995 - 1998, Lincoln D. Stein.  See accompanying README file for
	usage restrictions */

#ifndef PERL_REVISION
#   ifndef __PATCHLEVEL_H_INCLUDED__
#       include "patchlevel.h"
#   endif
#   ifndef PERL_REVISION
#       define PERL_REVISION    (5)
        /* Replace: 1 */
#       define PERL_VERSION     PATCHLEVEL
#       define PERL_SUBVERSION  SUBVERSION
        /* Replace PERL_PATCHLEVEL with PERL_VERSION */
        /* Replace: 0 */
#   endif
#endif

#if (PERL_VERSION == 5) && (PERL_SUBVERSION==3)
#ifndef PL_na
# define PL_na na
#endif
#ifndef SvPV_nolen
# define SvPV_nolen(sv) SvPV(sv, PL_na)
#endif
#endif /* 5.00503 */

#ifndef dMY_CXT
# define dMY_CXT (void)0
#endif
#ifndef PERL_UNUSED_ARG
# define PERL_UNUSED_ARG(x) ((void)sizeof(x))
#endif

#ifndef mPUSHp
#define mPUSHp(p,l)	PUSHs(sv_2mortal(newSVpvn((p), (l))))
#endif
#ifndef mPUSHi
#define mPUSHi(i)	PUSHs(sv_2mortal(newSViv((i))))
#endif
#ifndef mPUSHn
#define mPUSHn(n)	PUSHs(sv_2mortal(newSVnv((n))))
#endif
#ifndef mXPUSHp
# define mXPUSHp(p,l)	STMT_START { EXTEND(sp,1); mPUSHp((p), (l)); } STMT_END
#endif
#ifndef mXPUSHi
# define mXPUSHi(i)	STMT_START { EXTEND(sp,1); mPUSHi((i)); } STMT_END
#endif
#ifndef mXPUSHn
# define mXPUSHn(i)	STMT_START { EXTEND(sp,1); mPUSHn((i)); } STMT_END
#endif
#ifndef hv_fetchs
# define hv_fetchs(H, K, L) hv_fetch((H), (K), sizeof(K)-1, (L))
#endif

#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
#endif

#ifndef START_MY_CXT
static int truecolor_default = 0;
#endif

#include "const-c.inc"

typedef gdImagePtr	GD__Image;
typedef gdFontPtr	GD__Font;
typedef PerlIO          * InputStream;

#ifdef PERL_OBJECT
#  ifdef WIN32
#define GDIMAGECREATEFROMPNG(x)  gdImageCreateFromPng((FILE*)x)
#define GDIMAGECREATEFROMXBM(x)  gdImageCreateFromXbm((FILE*)x)
#define GDIMAGECREATEFROMJPEG(x) gdImageCreateFromJpeg((FILE*)x)
#define GDIMAGECREATEFROMGIF(x)  gdImageCreateFromGif((FILE*)x)
#define GDIMAGECREATEFROMWBMP(x) gdImageCreateFromWBMP((FILE*)x)
#define GDIMAGECREATEFROMBMP(x)  gdImageCreateFromBmp((FILE*)x)
#define GDIMAGECREATEFROMTIFF(x) gdImageCreateFromTiff((FILE*)x)
#define GDIMAGECREATEFROMGD(x)   gdImageCreateFromGd((FILE*)x)
#define GDIMAGECREATEFROMGD2(x)  gdImageCreateFromGd2((FILE*)x)
#define GDIMAGECREATEFROMGD2PART(x,a,b,c,d) gdImageCreateFromGd2Part((FILE*)x,a,b,c,d)
#define GDIMAGECREATEFROMWEBP(x)  gdImageCreateFromWebp((FILE*)x)
#define GDIMAGECREATEFROMHEIF(x)  gdImageCreateFromHeif((FILE*)x)
#define GDIMAGECREATEFROMAVIF(x)  gdImageCreateFromAvif((FILE*)x)
#  endif
#else
#  ifdef USE_PERLIO
#define GDIMAGECREATEFROMPNG(x) gdImageCreateFromPng(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMXBM(x) gdImageCreateFromXbm(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMJPEG(x) gdImageCreateFromJpeg(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMGIF(x)  gdImageCreateFromGif(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMWBMP(x) gdImageCreateFromWBMP(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMBMP(x)  gdImageCreateFromBmp(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMTIFF(x) gdImageCreateFromTiff(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMGD(x) gdImageCreateFromGd(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMGD2(x) gdImageCreateFromGd2(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMGD2PART(x,a,b,c,d) gdImageCreateFromGd2Part(PerlIO_findFILE(x),a,b,c,d)
#define GDIMAGECREATEFROMWEBP(x) gdImageCreateFromWebp(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMHEIF(x) gdImageCreateFromHeif(PerlIO_findFILE(x))
#define GDIMAGECREATEFROMAVIF(x) gdImageCreateFromAvif(PerlIO_findFILE(x))
#  else
#define GDIMAGECREATEFROMPNG(x) gdImageCreateFromPng(x)
#define GDIMAGECREATEFROMXBM(x) gdImageCreateFromXbm(x)
#define GDIMAGECREATEFROMJPEG(x) gdImageCreateFromJpeg(x)
#define GDIMAGECREATEFROMGIF(x) gdImageCreateFromGif(x)
#define GDIMAGECREATEFROMWBMP(x) gdImageCreateFromWBMP(x)
#define GDIMAGECREATEFROMBMP(x)  gdImageCreateFromBmp(x)
#define GDIMAGECREATEFROMTIFF(x) gdImageCreateFromTiff(x)
#define GDIMAGECREATEFROMGD(x) gdImageCreateFromGd(x)
#define GDIMAGECREATEFROMGD2(x) gdImageCreateFromGd2(x)
#define GDIMAGECREATEFROMGD2PART(x,a,b,c,d) gdImageCreateFromGd2Part(x,a,b,c,d)
#define GDIMAGECREATEFROMWEBP(x) gdImageCreateFromWebp(x)
#define GDIMAGECREATEFROMHEIF(x) gdImageCreateFromHeif(x)
#define GDIMAGECREATEFROMAVIF(x) gdImageCreateFromAvif(x)
#  endif
#endif

#define littleendian(a) \
    (a[3]<<24)+(a[2]<<16)+(a[1]<<8)+a[0]

/* definitions required to create images from in-memory buffers */
		     
typedef struct bufIOCtx {
  gdIOCtx    ctx;
  char*      data;
  int        length;
  int        pos;
} bufIOCtx;

typedef struct bufIOCtx *bufIOCtxPtr;

static int bufGetC (gdIOCtxPtr ctx) {
  bufIOCtxPtr bctx = (bufIOCtxPtr) ctx;

  if (bctx->pos >= bctx->length) return EOF;
  return bctx->data[bctx->pos];
}

static int bufGetBuf (gdIOCtxPtr ctx, void* buf, int len) {
  bufIOCtxPtr bctx = (bufIOCtxPtr) ctx;
  int remain,rlen;

  remain = bctx->length - bctx->pos;
  if (remain >= len) {
    rlen = len;
  } else {
    if (remain <= 0) return EOF;
    rlen = remain;
  }
  memcpy(buf,(void*)(bctx->data + bctx->pos),rlen);
  bctx->pos += rlen;
  return rlen;
}

static int bufSeek (gdIOCtxPtr ctx, const int pos) {
  bufIOCtxPtr bctx = (bufIOCtxPtr) ctx;
  bctx->pos = pos;
  if (bctx->pos > bctx->length)
    bctx->pos = bctx->length;
  return TRUE;
}

static long bufTell (gdIOCtxPtr ctx) {
  bufIOCtxPtr bctx = (bufIOCtxPtr) ctx;
  return bctx->pos;
}

static void bufFree(gdIOCtxPtr ctx) {
  Safefree(ctx);
}

static gdIOCtx* newDynamicCtx (char* data, int length) {
  bufIOCtxPtr   ctx;
  
#ifdef Newz
  Newz(0,ctx,1,bufIOCtx);
#else
  Newxz(ctx,1,bufIOCtx);
#endif
  if (ctx == NULL) return NULL;
  ctx->data   = data;
  ctx->pos    = 0;
  ctx->length = length;

  ctx->ctx.getC   = bufGetC;
  ctx->ctx.getBuf = bufGetBuf;
  ctx->ctx.seek   = bufSeek;
  ctx->ctx.tell   = bufTell;
  ctx->ctx.gd_free = bufFree;
  ctx->ctx.putC   = NULL;
  ctx->ctx.putBuf = NULL;
  return (gdIOCtx*)ctx;
}

/* helper routines for image transformation */
static GD__Image
gd_cloneDim(GD__Image src, int x, int y) {
  GD__Image dst;
  if (gdImageTrueColor(src)) {
     dst = (GD__Image) gdImageCreateTrueColor(x,y);
     if (!dst)
       croak("gdImageCreateTrueColor error");
  } else {
     int i;
     dst = (GD__Image) gdImageCreatePalette(x,y);
     if (!dst)
       croak("gdImageCreatePalette error");
     /* copy across the palette information */
     for (i = 0; i < gdMaxColors; i++) {
	dst->red[i]   = src->red[i];
	dst->green[i] = src->green[i];
	dst->blue[i]  = src->blue[i];
	dst->alpha[i] = src->alpha[i];
	dst->open[i]  = src->open[i];
     }
     dst->colorsTotal = src->colorsTotal;
     dst->transparent = src->transparent;
     dst->interlace   = src->interlace;
     dst->thick       = src->thick;
  }
  return(dst);
}

void
get_xformbounds(GD__Image src, int *x, int *y,
			int *x1, int *y1, int *x2, int *y2)
{
   *x  = gdImageSX(src);
   *y  = gdImageSY(src);
   *x1 = *x - 1;
   *y1 = *y - 1;
   *x2 = *x / 2;
   *y2 = *y / 2;
}

/* helper macros for image transformations */
#define GDGetImagePixel(im,x,y) \
	gdImageTrueColor(im) ? \
	gdImageTrueColorPixel(im,x,y) : \
	gdImagePalettePixel(im,x,y)

#define GDSetImagePixel(im,x,y,p) \
	gdImageTrueColor(im) ? \
	(gdImageTrueColorPixel(im,x,y) = p) : \
	(gdImagePalettePixel(im,x,y) = p)

#define GDCopyImagePixel(dst,dx,dy,src,sx,sy) \
	gdImageTrueColor(src) ? \
	(gdImageTrueColorPixel(dst,dx,dy)=gdImageTrueColorPixel(src,sx,sy)) : \
	(gdImagePalettePixel(dst,dx,dy)=gdImagePalettePixel(src,sx,sy))

/* Check the image format being returned */
void
gd_chkimagefmt(GD__Image image, int truecolor) {
  if ((image != NULL)
      && !truecolor) {			/* return a palette image */
     if (gdImageTrueColor(image)) {
	gdImageTrueColorToPalette(image,1,gdMaxColors);
     }
  }
}

/* GLOBAL THREAD-SAFE DATA */

#ifdef START_MY_CXT

#define MY_CXT_KEY "GD::_guts" XS_VERSION
typedef struct {
  /* Current image true color default
   *  0 - create palette based images by default
   *  1 - create true color images by default
   */
  int truecolor_default;
} my_cxt_t;
#define truecolor_default MY_CXT.truecolor_default

START_MY_CXT
#endif

#line 336 "GD.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#ifndef dVAR
#  define dVAR		dNOOP
#endif


/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
#  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
#  define PERL_DECIMAL_VERSION \
	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
#  define PERL_VERSION_GE(r,v,s) \
	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
#  define PERL_VERSION_LE(r,v,s) \
	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif

/* XS_INTERNAL is the explicit static-linkage variant of the default
 * XS macro.
 *
 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
 * "static", ie. it exports XSUB symbols. You probably don't want that
 * for anything but the BOOT XSUB.
 *
 * See XSUB.h in core!
 */


/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
#  undef XS_EXTERNAL
#  undef XS_INTERNAL
#  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
#    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
#    define XS_INTERNAL(name) static XSPROTO(name)
#  endif
#  if defined(__SYMBIAN32__)
#    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
#    define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
#  endif
#  ifndef XS_EXTERNAL
#    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
#      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
#      define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
#    else
#      ifdef __cplusplus
#        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      else
#        define XS_EXTERNAL(name) XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      endif
#    endif
#  endif
#endif

/* perl >= 5.10.0 && perl <= 5.15.1 */


/* The XS_EXTERNAL macro is used for functions that must not be static
 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
 * macro defined, the best we can do is assume XS is the same.
 * Dito for XS_INTERNAL.
 */
#ifndef XS_EXTERNAL
#  define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
#  define XS_INTERNAL(name) XS(name)
#endif

/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
 * internal macro that we're free to redefine for varying linkage due
 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
 */

#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
#  define XS_EUPXS(name) XS_EXTERNAL(name)
#else
   /* default to internal */
#  define XS_EUPXS(name) XS_INTERNAL(name)
#endif

#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)

/* prototype to pass -Wmissing-prototypes */
static void
S_croak_xs_usage(const CV *const cv, const char *const params);

static void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
    const GV *const gv = CvGV(cv);

    PERL_ARGS_ASSERT_CROAK_XS_USAGE;

    if (gv) {
        const char *const gvname = GvNAME(gv);
        const HV *const stash = GvSTASH(gv);
        const char *const hvname = stash ? HvNAME(stash) : NULL;

        if (hvname)
	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
        else
	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#define croak_xs_usage        S_croak_xs_usage

#endif

/* NOTE: the prototype of newXSproto() is different in versions of perls,
 * so we define a portable version of newXSproto()
 */
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */

#if PERL_VERSION_LE(5, 21, 5)
#  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
#  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif

/* simple backcompat versions of the TARGx() macros with no optimisation */
#ifndef TARGi
#  define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
#  define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
#  define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
#endif

#line 487 "GD.c"

/* INCLUDE:  Including 'const-xs.inc' from 'GD.xs' */


XS_EUPXS(XS_GD_constant); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD_constant)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "sv");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 4 "./const-xs.inc"
#ifdef dXSTARG
	dXSTARG; /* Faster if we have it.  */
#else
	dTARGET;
#endif
	STRLEN		len;
        int		type;
	IV		iv = 0;
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
#line 512 "GD.c"
	SV *	sv = ST(0)
;
	const char *	s = SvPV(sv, len);
#line 18 "./const-xs.inc"
        /* Change this to constant(aTHX_ s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(aTHX_ s, len, &iv);
      /* Return 1 or 2 items. First is error message, or undef if no error.
           Second, if present, is found value */
        switch (type) {
        case PERL_constant_NOTFOUND:
          sv =
	    sv_2mortal(newSVpvf("%s is not a valid GD macro", s));
          PUSHs(sv);
          break;
        case PERL_constant_NOTDEF:
          sv = sv_2mortal(newSVpvf(
	    "Your vendor has not defined GD macro %s, used",
				   s));
          PUSHs(sv);
          break;
        case PERL_constant_ISIV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHi(iv);
          break;
	/* Uncomment this if you need to return NOs
        case PERL_constant_ISNO:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHs(&PL_sv_no);
          break; */
	/* Uncomment this if you need to return NVs
        case PERL_constant_ISNV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHn(nv);
          break; */
	/* Uncomment this if you need to return PVs
        case PERL_constant_ISPV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHp(pv, strlen(pv));
          break; */
	/* Uncomment this if you need to return PVNs
        case PERL_constant_ISPVN:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHp(pv, iv);
          break; */
	/* Uncomment this if you need to return SVs
        case PERL_constant_ISSV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHs(sv);
          break; */
	/* Uncomment this if you need to return UNDEFs
        case PERL_constant_ISUNDEF:
          break; */
	/* Uncomment this if you need to return UVs
        case PERL_constant_ISUV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHu((UV)iv);
          break; */
	/* Uncomment this if you need to return YESs
        case PERL_constant_ISYES:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHs(&PL_sv_yes);
          break; */
        default:
          sv = sv_2mortal(newSVpvf(
	    "Unexpected return type %d while processing GD macro %s, used",
               type, s));
          PUSHs(sv);
        }
#line 590 "GD.c"
	PUTBACK;
	return;
    }
}


/* INCLUDE: Returning to 'GD.xs' from 'const-xs.inc' */


XS_EUPXS(XS_GD_VERSION_STRING); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD_VERSION_STRING)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 333 "GD.xs"
    mXPUSHp(GD_VERSION_STRING,sizeof(GD_VERSION_STRING)-1);
#line 611 "GD.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_GD_LIBGD_VERSION); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD_LIBGD_VERSION)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 338 "GD.xs"
    mXPUSHn(GD_VERSION/10000.0);
#line 629 "GD.c"
	PUTBACK;
	return;
    }
}

#if GD_VERSION >= 20101
#define XSubPPtmpAAAA 1


XS_EUPXS(XS_GD_supportsFileType); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD_supportsFileType)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "filename, writing=0");
    {
	bool	RETVAL;
	char *	filename = (char *)SvPV_nolen(ST(0))
;
	int	writing;

	if (items < 2)
	    writing = 0;
	else {
	    writing = (int)SvIV(ST(1))
;
	}
#line 346 "GD.xs"
    RETVAL = gdSupportsFileType(filename, writing);
#line 659 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image_trueColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_trueColor)
{
    dVAR; dXSARGS;
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
    {
	char *	packname;
#line 370 "GD.xs"
        dMY_CXT;
        int previous_value = truecolor_default;
#line 678 "GD.c"
	int	RETVAL;
	dXSTARG;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 373 "GD.xs"
        PERL_UNUSED_ARG(packname);
        if (items > 1)
          truecolor_default = (int)SvIV(ST(1));
        RETVAL = previous_value;
#line 693 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image__new); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__new)
{
    dVAR; dXSARGS;
    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
    {
	char *	packname;
	int	x;
	int	y;
#line 387 "GD.xs"
        gdImagePtr theImage;
        dMY_CXT;
        int truecolor = truecolor_default;
#line 715 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}

	if (items < 2)
	    x = 64;
	else {
	    x = (int)SvIV(ST(1))
;
	}

	if (items < 3)
	    y = 64;
	else {
	    y = (int)SvIV(ST(2))
;
	}
#line 391 "GD.xs"
    PERL_UNUSED_ARG(packname);
    if (items > 3)
      truecolor = (int)SvIV(ST(3));
    if (truecolor) {
      theImage = (GD__Image) gdImageCreateTrueColor(x,y);
      if (!theImage)
        croak("gdImageCreateTrueColor error");
    } else {
      theImage = (GD__Image) gdImageCreate(x,y);
      if (!theImage)
        croak("gdImageCreate error");
    }
    RETVAL = theImage;
#line 752 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#if GD_VERSION >= 20101
#define XSubPPtmpAAAB 1


XS_EUPXS(XS_GD__Image__file); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__file)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, filename");
    {
	GD__Image	image;
	char *	filename = (char *)SvPV_nolen(ST(1))
;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::_file",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 415 "GD.xs"
    RETVAL = gdImageFile(image, filename);
#line 794 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_PNG
#define XSubPPtmpAAAC 1


XS_EUPXS(XS_GD__Image__newFromPng); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromPng)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle, ...");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
#line 429 "GD.xs"
        dMY_CXT;
        int truecolor = truecolor_default;
#line 818 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 432 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = (GD__Image) GDIMAGECREATEFROMPNG(filehandle);
        if (!RETVAL)
          croak("gdImageCreateFromPng error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 834 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_newFromPngData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromPngData)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData, ...");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 447 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
	dMY_CXT;
        int truecolor = truecolor_default;
#line 862 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 453 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromPngCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
          croak("gdImageCreateFromPngCtx error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 881 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_GD2
#define XSubPPtmpAAAD 1


XS_EUPXS(XS_GD__Image_newFromGdData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromGdData)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 474 "GD.xs"
        char*    data;
        STRLEN   len;
#line 910 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 477 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
	RETVAL = (GD__Image) gdImageCreateFromGdPtr(len,(void*) data);
        if (!RETVAL)
          croak("gdImageCreateFromGdPtr error");
#line 925 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_newFromGd2Data); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromGd2Data)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 491 "GD.xs"
          char*    data;
          STRLEN   len;
#line 950 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 494 "GD.xs"
        PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
	RETVAL = (GD__Image) gdImageCreateFromGd2Ptr(len,(void*) data);
        if (!RETVAL)
          croak("gdImageCreateFromGd2Ptr error");
#line 965 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_JPEG
#define XSubPPtmpAAAE 1


XS_EUPXS(XS_GD__Image_newFromJpegData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromJpegData)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData, ...");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 511 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
	dMY_CXT;
	int     truecolor = truecolor_default;
#line 997 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 517 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
        RETVAL = (GD__Image) gdImageCreateFromJpegCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
          croak("gdImageCreateFromJpegCtx error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 1016 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_BMP
#define XSubPPtmpAAAF 1


XS_EUPXS(XS_GD__Image_newFromBmpData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromBmpData)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData, ...");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 538 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
	dMY_CXT;
	int      truecolor = truecolor_default;
#line 1048 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 544 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromBmpCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
          croak("gdImageCreateFromBmpCtx error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 1067 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image_newFromWBMPData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromWBMPData)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData, ...");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 564 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
	dMY_CXT;
	int      truecolor = truecolor_default;
#line 1096 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 570 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromWBMPCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
          croak("gdImageCreateFromWBMPCtx error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 1115 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image__newFromXbm); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromXbm)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 588 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMXBM(filehandle);
        if (!RETVAL)
          croak("gdImageCreateFromXbm error");
#line 1150 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#ifdef HAVE_GD2
#define XSubPPtmpAAAG 1


XS_EUPXS(XS_GD__Image__newFromGd); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromGd)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 602 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMGD(filehandle);
        if (!RETVAL)
          croak("gdImageCreateFromGd error");
#line 1188 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image__newFromGd2); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromGd2)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 615 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMGD2(filehandle);
        if (!RETVAL)
          croak("gdImageCreateFromGd2 error");
#line 1223 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image__newFromGd2Part); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromGd2Part)
{
    dVAR; dXSARGS;
    if (items < 5 || items > 6)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle, srcX, srcY, width, height");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	int	srcX = (int)SvIV(ST(2))
;
	int	srcY = (int)SvIV(ST(3))
;
	int	width = (int)SvIV(ST(4))
;
	int	height = (int)SvIV(ST(5))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 632 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMGD2PART(filehandle,srcX,srcY,width,height);
        if (!RETVAL)
            croak("gdImageCreateFromGd2Part error");
#line 1266 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_JPEG
#define XSubPPtmpAAAH 1


XS_EUPXS(XS_GD__Image__newFromJpeg); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromJpeg)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle, ...");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
#line 648 "GD.xs"
	dMY_CXT;
        int     truecolor = truecolor_default;
#line 1295 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 651 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMJPEG(filehandle);
        if (!RETVAL)
          croak("gdImageCreateFromJpeg error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 1311 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_TIFF
#define XSubPPtmpAAAI 1


XS_EUPXS(XS_GD__Image__newFromTiff); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromTiff)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle, ...");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
#line 669 "GD.xs"
	dMY_CXT;
        int     truecolor = truecolor_default;
#line 1340 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 672 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMTIFF(filehandle);
        if (!RETVAL)
          croak("gdImageCreateFromTiff error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 1356 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_newFromTiffData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromTiffData)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData, ...");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 687 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
	dMY_CXT;
        int truecolor = truecolor_default;
#line 1384 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 693 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromTiffCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
          croak("gdImageCreateFromTiffCtx error");
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 1403 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_BMP
#define XSubPPtmpAAAJ 1


XS_EUPXS(XS_GD__Image__newFromBmp); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromBmp)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
#line 714 "GD.xs"
	gdImagePtr img;
	SV* errormsg;
#line 1432 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 717 "GD.xs"
	PERL_UNUSED_ARG(packname);
	img = GDIMAGECREATEFROMBMP(filehandle);
        if (img == NULL) {
          errormsg = perl_get_sv("@",0);
	  if (errormsg != NULL)
	    sv_setpv(errormsg,"libgd was not built with BMP support\n");
          else
            croak("gdImageCreateFromBmp error");
	  XSRETURN_EMPTY;
        }
        RETVAL = img;
#line 1453 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image__newFromWBMP); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromWBMP)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
#line 739 "GD.xs"
	gdImagePtr img;
	SV* errormsg;
#line 1479 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 742 "GD.xs"
	PERL_UNUSED_ARG(packname);
	img = GDIMAGECREATEFROMWBMP(filehandle);
        if (img == NULL) {
          errormsg = perl_get_sv("@",0);
	  if (errormsg != NULL)
	    sv_setpv(errormsg,"libgd was not built with WBMP support\n");
          else
            croak("gdImageCreateFromWBMP error");
	  XSRETURN_EMPTY;
        }
        RETVAL = img;
#line 1500 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#ifdef HAVE_XPM
#define XSubPPtmpAAAK 1


XS_EUPXS(XS_GD__Image_newFromXpm); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromXpm)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filename");
    {
	char *	packname;
	char *	filename = (char *)SvPV_nolen(ST(1))
;
#line 763 "GD.xs"
  	gdImagePtr img;
	SV* errormsg;
#line 1528 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 766 "GD.xs"
	PERL_UNUSED_ARG(packname);
        img = (GD__Image) gdImageCreateFromXpm(filename);
        if (img == NULL) {
            errormsg = perl_get_sv("@",0);
            if (errormsg != NULL)
              sv_setpv(errormsg,"libgd was not built with xpm support\n");
          else
            croak("gdImageCreateFromXpm error");
          XSRETURN_EMPTY;
        }
        RETVAL = img;
#line 1549 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_GIF
#define XSubPPtmpAAAL 1


XS_EUPXS(XS_GD__Image__newFromGif); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromGif)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 789 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMGIF(filehandle);
	if (!RETVAL)
            croak("gdImageCreateFromGif error");
#line 1588 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_newFromGifData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromGifData)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 802 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
#line 1614 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 806 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromGifCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
           croak("gdImageCreateFromGifCtx error");
#line 1631 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_WEBP
#define XSubPPtmpAAAM 1


XS_EUPXS(XS_GD__Image__newFromWebp); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromWebp)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 825 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMWEBP(filehandle);
	if (!RETVAL)
            croak("gdImageCreateFromWebp error");
#line 1670 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_newFromWebpData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromWebpData)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 838 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
#line 1696 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 842 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromWebpCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
           croak("gdImageCreateFromWebpCtx error");
#line 1713 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_HEIF
#define XSubPPtmpAAAN 1


XS_EUPXS(XS_GD__Image__newFromHeif); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromHeif)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 861 "GD.xs"
	PERL_UNUSED_ARG(packname);
        RETVAL = GDIMAGECREATEFROMHEIF(filehandle);
	if (!RETVAL)
            croak("gdImageCreateFromHeif error");
#line 1752 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_newFromHeifData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromHeifData)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 874 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
#line 1778 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 878 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromHeifCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
           croak("gdImageCreateFromHeifCtx error");
#line 1795 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_AVIF
#define XSubPPtmpAAAO 1


XS_EUPXS(XS_GD__Image__newFromAvif); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image__newFromAvif)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", filehandle");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)))
;
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 897 "GD.xs"
	PERL_UNUSED_ARG(packname);
	RETVAL = GDIMAGECREATEFROMAVIF(filehandle);
	if (!RETVAL)
            croak("gdImageCreateFromAvif error");
#line 1834 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_newFromAvifData); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_newFromAvifData)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Image\", imageData");
    {
	char *	packname;
	SV *	imageData = ST(1)
;
#line 910 "GD.xs"
	gdIOCtx* ctx;
        char*    data;
        STRLEN   len;
#line 1860 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 914 "GD.xs"
	PERL_UNUSED_ARG(packname);
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromAvifCtx(ctx);
        (ctx->gd_free)(ctx);
        if (!RETVAL)
           croak("gdImageCreateFromAvifCtx error");
#line 1877 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_DESTROY)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"GD::Image::DESTROY",
			"image")
;
#line 931 "GD.xs"
	gdImageDestroy(image);
#line 1910 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_STORABLE_freeze); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_STORABLE_freeze)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, cloning");
    {
	GD__Image	image;
	int	cloning = (int)SvIV(ST(1))
;
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::STORABLE_freeze",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 938 "GD.xs"
     {
       void*     data;
       int       size;

       if (cloning) XSRETURN_UNDEF;
       data = gdImageGd2Ptr(image,0,GD2_FMT_COMPRESSED,&size);
       if (!data)
         croak("gdImageGd2Ptr error");
       RETVAL = newSVpvn((char*)data,size);
       gdFree(data);
     }
#line 1953 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_STORABLE_thaw); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_STORABLE_thaw)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "object, cloning, serialized");
    {
	SV*	object = ST(0)
;
	int	cloning = (int)SvIV(ST(1))
;
	SV*	serialized = ST(2)
;
#line 957 "GD.xs"
     STRLEN    length;
     void*     data;
     GD__Image image;
#line 1978 "GD.c"
#line 961 "GD.xs"
     {
       if (cloning) XSRETURN_UNDEF;
       data = (void*) SvPV(serialized,length);
       image = gdImageCreateFromGd2Ptr(length,data);
       if (!image)
         croak("gdImageCreateFromGd2Ptr error");
       sv_setiv(SvRV(object),(IV)image);
     }
#line 1988 "GD.c"
    }
    XSRETURN_EMPTY;
}

#ifdef HAVE_PNG
#define XSubPPtmpAAAP 1


XS_EUPXS(XS_GD__Image_png); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_png)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    {
	GD__Image	image;
#line 976 "GD.xs"
#line 2006 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::png",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 977 "GD.xs"
  {
	void*         data;
	int           size;
	int           level;
        if (items > 1) {
	  level = (int)SvIV(ST(1));
	  data  = (void *) gdImagePngPtrEx(image,&size,level);
          if (!data)
            croak("gdImagePngPtrEx error");
	} else {
	  data = (void *) gdImagePngPtr(image,&size);
          if (!data)
            croak("gdImagePngPtr error");
	}
	RETVAL = newSVpvn((char*) data,size);
	gdFree(data);
  }
#line 2040 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_JPEG
#define XSubPPtmpAAAQ 1


XS_EUPXS(XS_GD__Image_jpeg); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_jpeg)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "image, quality=-1");
    {
	GD__Image	image;
	int	quality;
#line 1006 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
#line 2065 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::jpeg",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    quality = -1;
	else {
	    quality = (int)SvIV(ST(1))
;
	}
#line 1010 "GD.xs"
    data = (void *) gdImageJpegPtr(image,&size,quality);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with jpeg support\n");
      else
        croak("gdImageJpegPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2100 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image_gifanimbegin); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_gifanimbegin)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 3)
       croak_xs_usage(cv,  "image, globalcm=-1, loops=-1");
    {
	GD__Image	image;
	int	globalcm;
	int	loops;
#line 1033 "GD.xs"
	void*         data;
	int           size;
#line 2122 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::gifanimbegin",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    globalcm = -1;
	else {
	    globalcm = (int)SvIV(ST(1))
;
	}

	if (items < 3)
	    loops = -1;
	else {
	    loops = (int)SvIV(ST(2))
;
	}
#line 1036 "GD.xs"
#ifdef HAVE_GIFANIM
    data = (void *) gdImageGifAnimBeginPtr(image,&size,globalcm,loops);
    if (!data)
      croak("gdImageGifAnimBeginPtr error");
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#else
    PERL_UNUSED_ARG(data);
    PERL_UNUSED_ARG(size);
    PERL_UNUSED_ARG(image);
    PERL_UNUSED_ARG(globalcm);
    PERL_UNUSED_ARG(loops);
    die("libgd 2.0.33 or higher required for animated GIF support");
#endif
#line 2167 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_gifanimadd); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_gifanimadd)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 7)
       croak_xs_usage(cv,  "image, localcm=-1, leftofs=-1, topofs=-1, delay=-1, disposal=-1, previm=0");
    {
	GD__Image	image;
	int	localcm;
	int	leftofs;
	int	topofs;
	int	delay;
	int	disposal;
	GD__Image	previm;
#line 1064 "GD.xs"
	void*         data;
	int           size;
#line 2192 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::gifanimadd",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    localcm = -1;
	else {
	    localcm = (int)SvIV(ST(1))
;
	}

	if (items < 3)
	    leftofs = -1;
	else {
	    leftofs = (int)SvIV(ST(2))
;
	}

	if (items < 4)
	    topofs = -1;
	else {
	    topofs = (int)SvIV(ST(3))
;
	}

	if (items < 5)
	    delay = -1;
	else {
	    delay = (int)SvIV(ST(4))
;
	}

	if (items < 6)
	    disposal = -1;
	else {
	    disposal = (int)SvIV(ST(5))
;
	}

	if (items < 7)
	    previm = 0;
	else {
	    if (SvROK(ST(6)) && sv_derived_from(ST(6), "GD::Image")) {
		IV tmp = SvIV((SV*)SvRV(ST(6)));
		previm = INT2PTR(GD__Image,tmp);
	    }
	    else {
		    const char* refstr = SvROK(ST(6)) ? "" : SvOK(ST(6)) ? "scalar " : "undef";
		Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			    "GD::Image::gifanimadd",
			    "previm", "GD::Image",
			    refstr, ST(6)
		    );
	    }
;
	}
#line 1067 "GD.xs"
#ifdef HAVE_GIFANIM
    data = (void *) gdImageGifAnimAddPtr(image,&size,localcm,leftofs,topofs,
                                             delay,disposal,previm);
    if (!data)
      croak("gdImageGifAnimAddPtr error");
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#else
    PERL_UNUSED_ARG(data);
    PERL_UNUSED_ARG(size);
    PERL_UNUSED_ARG(image);
    PERL_UNUSED_ARG(localcm);
    PERL_UNUSED_ARG(leftofs);
    PERL_UNUSED_ARG(topofs);
    PERL_UNUSED_ARG(delay);
    PERL_UNUSED_ARG(disposal);
    PERL_UNUSED_ARG(previm);
    die("libgd 2.0.33 or higher required for animated GIF support");
#endif
#line 2281 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_gifanimend); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_gifanimend)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
#line 1094 "GD.xs"
	void*         data;
	int           size;
#line 2300 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::gifanimend",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1097 "GD.xs"
    PERL_UNUSED_ARG(image);
#ifdef HAVE_GIFANIM
    data = (void *) gdImageGifAnimEndPtr(&size);
    if (!data)
      croak("gdImageGifAnimEndPtr error");
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#else
    PERL_UNUSED_ARG(data);
    PERL_UNUSED_ARG(size);
    die("libgd 2.0.33 or higher required for animated GIF support");
#endif
#line 2329 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#ifdef HAVE_BMP
#define XSubPPtmpAAAR 1


XS_EUPXS(XS_GD__Image_bmp); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_bmp)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "image, compression=0");
    {
	GD__Image	image;
	int	compression;
#line 1119 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
#line 2353 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::bmp",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    compression = 0;
	else {
	    compression = (int)SvIV(ST(1))
;
	}
#line 1123 "GD.xs"
    data = (void *) gdImageBmpPtr(image,&size,compression);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with WBMP support\n");
      else
        croak("gdImageBmpPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2388 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image_wbmp); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_wbmp)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, fg");
    {
	GD__Image	image;
	int	fg = (int)SvIV(ST(1))
;
#line 1145 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
#line 2411 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::wbmp",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1149 "GD.xs"
    data = (void *) gdImageWBMPPtr(image,&size,fg);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with WBMP support\n");
      else
        croak("gdImageWBMPPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2439 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#ifdef HAVE_GIF
#define XSubPPtmpAAAS 1


XS_EUPXS(XS_GD__Image_gif); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_gif)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
#line 1169 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
#line 2462 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::gif",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1173 "GD.xs"
    data = (void *) gdImageGifPtr(image,&size);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with gif support\n");
      else
        croak("gdImageGifPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2490 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_GD2
#define XSubPPtmpAAAT 1


XS_EUPXS(XS_GD__Image_gd); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_gd)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::gd",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1195 "GD.xs"
  {
	void*         data;
	int           size;
	data = gdImageGdPtr(image,&size);
        if (!data)
          croak("gdImageGdPtr error");
	RETVAL = newSVpvn((char*) data,size);
	gdFree(data);
  }
#line 2535 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_gd2); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_gd2)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::gd2",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1212 "GD.xs"
  {
	void*         data;
	int           size;
	data = gdImageGd2Ptr(image,0,GD2_FMT_COMPRESSED,&size);
        if (!data)
          croak("gdImageGd2Ptr error");
	RETVAL = newSVpvn((char*) data,size);
	gdFree(data);
  }
#line 2576 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_TIFF
#define XSubPPtmpAAAU 1


XS_EUPXS(XS_GD__Image_tiff); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_tiff)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
#line 1232 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
#line 2600 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::tiff",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1236 "GD.xs"
    data = (void *) gdImageTiffPtr(image,&size);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with TIFF support\n");
      else
        croak("gdImageTiffPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2628 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_WEBP
#define XSubPPtmpAAAV 1


XS_EUPXS(XS_GD__Image_webp); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_webp)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    {
	GD__Image	image;
#line 1258 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
        int           quality;
#line 2653 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::webp",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1263 "GD.xs"
    if (items > 1) {
      quality=(int)SvIV(ST(1));
      data = (void *) gdImageWebpPtrEx(image,&size,quality);
    }
    else
      data = (void *) gdImageWebpPtr(image,&size);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with webp support\n");
      else
        croak("gdImageWebpPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2686 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_HEIF
#define XSubPPtmpAAAW 1


XS_EUPXS(XS_GD__Image_heif); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_heif)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    {
	GD__Image	image;
#line 1290 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
        int           quality;
        //enum or char* codec: HEVC or AV1
#line 2712 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::heif",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1296 "GD.xs"
    if (items > 1) {
      quality=(int)SvIV(ST(1));
      data = (void *) gdImageHeifPtrEx(image,&size,quality,GD_HEIF_CODEC_HEVC,GD_HEIF_CHROMA_444);
    }
    else
      data = (void *) gdImageHeifPtr(image,&size);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with heif support\n");
      else
        croak("gdImageHeifPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2745 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif
#ifdef HAVE_AVIF
#define XSubPPtmpAAAX 1


XS_EUPXS(XS_GD__Image_avif); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_avif)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    {
	GD__Image	image;
#line 1323 "GD.xs"
	SV* errormsg;
	void*         data;
	int           size;
        int           quality; // -1 for default
        int           speed;   // 6 is default
#line 2771 "GD.c"
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::avif",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1329 "GD.xs"
    if (items > 1) {
      quality=(int)SvIV(ST(1));
      speed=items > 2 ? (int)SvIV(ST(2)) : 6; // AVIF_SPEED_DEFAULT
      data = (void *) gdImageAvifPtrEx(image,&size,quality,speed);
    }
    else
      data = (void *) gdImageAvifPtr(image,&size);
    if (data == NULL) {
      errormsg = perl_get_sv("@",0);
      if (errormsg != NULL)
        sv_setpv(errormsg,"libgd was not built with avif support\n");
      else
        croak("gdImageAvifPtr error");
      XSRETURN_EMPTY;
    }
    RETVAL = newSVpvn((char*) data,size);
    gdFree(data);
#line 2805 "GD.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image_transparent); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_transparent)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    {
	GD__Image	image;
#line 1356 "GD.xs"
	int color;
#line 2824 "GD.c"
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::transparent",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1358 "GD.xs"
	if (items > 1) {
          color=(int)SvIV(ST(1));
          gdImageColorTransparent(image,color);
        }
        RETVAL = gdImageGetTransparent(image);
#line 2847 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_getBounds); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_getBounds)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	GD__Image	image;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::getBounds",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1371 "GD.xs"
    mXPUSHi(gdImageSX(image));
    mXPUSHi(gdImageSY(image));
#line 2882 "GD.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_GD__Image_isTrueColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_isTrueColor)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::isTrueColor",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1379 "GD.xs"
    RETVAL = gdImageTrueColor(image);
#line 2915 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_trueColorToPalette); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_trueColorToPalette)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 3)
       croak_xs_usage(cv,  "image, dither=0, colors=gdMaxColors");
    {
	GD__Image	image;
	int	dither;
	int	colors;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::trueColorToPalette",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    dither = 0;
	else {
	    dither = (int)SvIV(ST(1))
;
	}

	if (items < 3)
	    colors = gdMaxColors;
	else {
	    colors = (int)SvIV(ST(2))
;
	}
#line 1390 "GD.xs"
    gdImageTrueColorToPalette(image,dither,colors);
#line 2963 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_createPaletteFromTrueColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_createPaletteFromTrueColor)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 3)
       croak_xs_usage(cv,  "image, dither=0, colors=gdMaxColors");
    {
	GD__Image	image;
	int	dither;
	int	colors;
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::createPaletteFromTrueColor",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    dither = 0;
	else {
	    dither = (int)SvIV(ST(1))
;
	}

	if (items < 3)
	    colors = gdMaxColors;
	else {
	    colors = (int)SvIV(ST(2))
;
	}
#line 1399 "GD.xs"
    RETVAL = gdImageCreatePaletteFromTrueColor(image,dither,colors);
    if (!RETVAL)
      croak("gdImageCreatePaletteFromTrueColor error");
#line 3012 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#if GD_VERSION >= 20100
#define XSubPPtmpAAAY 1


XS_EUPXS(XS_GD__Image_neuQuant); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_neuQuant)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 3)
       croak_xs_usage(cv,  "image, colors=gdMaxColors, samplefactor=5");
    {
	GD__Image	image;
	int	colors;
	int	samplefactor;
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::neuQuant",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    colors = gdMaxColors;
	else {
	    colors = (int)SvIV(ST(1))
;
	}

	if (items < 3)
	    samplefactor = 5;
	else {
	    samplefactor = (int)SvIV(ST(2))
;
	}
#line 1414 "GD.xs"
    RETVAL = gdImageNeuQuant(image,colors,samplefactor);
    if (!RETVAL)
      XSRETURN_UNDEF;
#line 3070 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorMatch); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorMatch)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, im2");
    {
	GD__Image	image;
	GD__Image	im2;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorMatch",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    im2 = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorMatch",
			"im2", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 1428 "GD.xs"
#if GD_VERSION <= 20205
  if (gdImageTrueColor(image) ^ gdImageTrueColor(im2))
    XSRETURN_UNDEF;
  else
#endif
    RETVAL = gdImageColorMatch(image,im2);
#line 3128 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}

#endif

XS_EUPXS(XS_GD__Image_rgb); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_rgb)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, color");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::rgb",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1445 "GD.xs"
    mXPUSHi(gdImageRed(image,color));
    mXPUSHi(gdImageGreen(image,color));
    mXPUSHi(gdImageBlue(image,color));
#line 3167 "GD.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_GD__Image_alpha); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_alpha)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, color");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::alpha",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1455 "GD.xs"
    mXPUSHi(gdImageAlpha(image,color));
#line 3202 "GD.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_GD__Image_boundsSafe); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_boundsSafe)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, x, y");
    {
	GD__Image	image;
	int	x = (int)SvIV(ST(1))
;
	int	y = (int)SvIV(ST(2))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::boundsSafe",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1464 "GD.xs"
    RETVAL = gdImageBoundsSafe(image,x,y);
    if (RETVAL == 0)
      XSRETURN_UNDEF;
#line 3241 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_getPixel); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_getPixel)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, x, y");
    {
	GD__Image	image;
	int	x = (int)SvIV(ST(1))
;
	int	y = (int)SvIV(ST(2))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::getPixel",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1477 "GD.xs"
    RETVAL = gdImageGetPixel(image,x,y);
#line 3279 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_setPixel); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_setPixel)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, x, y, color");
    {
	GD__Image	image;
	int	x = (int)SvIV(ST(1))
;
	int	y = (int)SvIV(ST(2))
;
	int	color = (int)SvIV(ST(3))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setPixel",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1489 "GD.xs"
    gdImageSetPixel(image,x,y,color);
#line 3317 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_copyRotate90); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyRotate90)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1496 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3333 "GD.c"
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyRotate90",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1498 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
	RETVAL = gd_cloneDim(src, y, x);

	for (j=0; j<y; j++) {
	   for (i=0; i<x; i++) {
	      GDCopyImagePixel(RETVAL, y1-j, i, src, i, j);
	   }
	}
#line 3358 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_copyRotate180); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyRotate180)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1514 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3380 "GD.c"
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyRotate180",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1516 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
	RETVAL = gd_cloneDim(src, x, y);

	for (j=0; j<y; j++) {
          for (i=0; i<x; i++) {
            GDCopyImagePixel(RETVAL, x1-i, y1-j, src, i, j);
          }
        }
#line 3405 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_copyRotate270); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyRotate270)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1532 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3427 "GD.c"
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyRotate270",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1534 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
	RETVAL = gd_cloneDim(src, y, x);

	for (i=0; i<x; i++) {
	   for (j=0; j<y; j++) {
	      GDCopyImagePixel(RETVAL, j, x1-i, src, i, j);
	   }
	}
#line 3452 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_copyFlipHorizontal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyFlipHorizontal)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1550 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3474 "GD.c"
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyFlipHorizontal",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1552 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
	RETVAL = gd_cloneDim(src, x, y);

	for (j=0; j<y; j++) {
	   for (i=0; i<x; i++) {
	      GDCopyImagePixel(RETVAL, x1-i, j, src, i, j);
	   }
	}
#line 3499 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_copyFlipVertical); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyFlipVertical)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1568 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3521 "GD.c"
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyFlipVertical",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1570 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
	RETVAL = gd_cloneDim(src, x, y);

	for (j=0; j<y; j++) {
          for (i=0; i<x; i++) {
            GDCopyImagePixel(RETVAL, i, y1-j, src, i, j);
          }
        }
#line 3546 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_copyTranspose); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyTranspose)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1586 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3568 "GD.c"
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyTranspose",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1588 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
	RETVAL = gd_cloneDim(src, y, x);

	for (j=0; j<y; j++) {
          for (i=0; i<x; i++) {
            GDCopyImagePixel(RETVAL,j,i,src,i,j);
          }
        }
#line 3593 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_copyReverseTranspose); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyReverseTranspose)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1604 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3615 "GD.c"
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyReverseTranspose",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1606 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
	RETVAL = gd_cloneDim(src, y, x);

	for (j=0; j<y; j++) {
          for (i=0; i<x; i++) {
            GDCopyImagePixel(RETVAL, y1-j, x1-i, src, i, j);
          }
        }
#line 3640 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_rotate180); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_rotate180)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1622 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3662 "GD.c"

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::rotate180",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1624 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);

	for (j=0; j<y2; j++) {
          for (i=0; i<x; i++) {
            int tmp = GDGetImagePixel(src, x1-i, y1-j);
            GDCopyImagePixel(src, x1-i, y1-j, src, i, j);
            GDSetImagePixel(src, i, j, tmp);
          }
        }
        if (y % 2 == 1) {
          for (i=0; i<x2; i++) {
            int tmp = GDGetImagePixel(src,x1-i,j);
            GDCopyImagePixel(src,x1-i,j,src,i,j);
            GDSetImagePixel(src,i,j,tmp);
          }
        }
#line 3694 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_copyRotated); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyRotated)
{
    dVAR; dXSARGS;
    if (items != 9)
       croak_xs_usage(cv,  "dst, src, dstX, dstY, srcX, srcY, srcW, srcH, angle");
    {
	GD__Image	dst;
	GD__Image	src;
	double	dstX = (double)SvNV(ST(2))
;
	double	dstY = (double)SvNV(ST(3))
;
	int	srcX = (int)SvIV(ST(4))
;
	int	srcY = (int)SvIV(ST(5))
;
	int	srcW = (int)SvIV(ST(6))
;
	int	srcH = (int)SvIV(ST(7))
;
	int	angle = (int)SvIV(ST(8))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    dst = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyRotated",
			"dst", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyRotated",
			"src", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 1654 "GD.xs"
    {
#ifdef VERSION_33
        gdImageCopyRotated(dst,src,dstX,dstY,srcX,srcY,srcW,srcH,angle);
#else
        PERL_UNUSED_ARG(dst);
        PERL_UNUSED_ARG(src);
        PERL_UNUSED_ARG(dstX);
        PERL_UNUSED_ARG(dstY);
        PERL_UNUSED_ARG(srcX);
        PERL_UNUSED_ARG(srcY);
        PERL_UNUSED_ARG(srcW);
        PERL_UNUSED_ARG(srcH);
        PERL_UNUSED_ARG(angle);
        die("libgd 2.0.33 or higher required for copyRotated support");
#endif
    }
#line 3768 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_flipHorizontal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_flipHorizontal)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1676 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3784 "GD.c"

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::flipHorizontal",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1678 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);

	for (j=0; j<y; j++) {
          for (i=0; i<x2; i++) {
            int tmp = GDGetImagePixel(src, x1-i, j);
            GDCopyImagePixel(src, x1-i, j, src, i, j);
            GDSetImagePixel(src, i, j, tmp);
          }
        }
#line 3809 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_flipVertical); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_flipVertical)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "src");
    {
	GD__Image	src;
#line 1693 "GD.xs"
	int x, y, x1, y1, x2, y2, i, j;
#line 3825 "GD.c"

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::flipVertical",
			"src", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1695 "GD.xs"
	get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);

	for (j=0; j<y2; j++) {
          for (i=0; i<x; i++) {
            int tmp = GDGetImagePixel(src, i, y1-j);
            GDCopyImagePixel(src, i, y1-j, src, i, j);
            GDSetImagePixel(src, i, j, tmp);
          }
        }
#line 3850 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_line); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_line)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, x1, y1, x2, y2, color");
    {
	GD__Image	image;
	int	x1 = (int)SvIV(ST(1))
;
	int	y1 = (int)SvIV(ST(2))
;
	int	x2 = (int)SvIV(ST(3))
;
	int	y2 = (int)SvIV(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::line",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1715 "GD.xs"
    gdImageLine(image, x1, y1, x2, y2, color);
#line 3890 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_dashedLine); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_dashedLine)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, x1, y1, x2, y2, color");
    {
	GD__Image	image;
	int	x1 = (int)SvIV(ST(1))
;
	int	y1 = (int)SvIV(ST(2))
;
	int	x2 = (int)SvIV(ST(3))
;
	int	y2 = (int)SvIV(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::dashedLine",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1727 "GD.xs"
    gdImageDashedLine(image, x1, y1, x2, y2, color);
#line 3930 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_openPolygon); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_openPolygon)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, poly, color");
    {
	GD__Image	image;
	SV *	poly = ST(1)
;
	int	color = (int)SvIV(ST(2))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::openPolygon",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1736 "GD.xs"
	{
		dSP ;
		int length,count ;
		int x,y,i ;
		gdPointPtr polyptr;

		ENTER ;
		SAVETMPS ;
		PUSHMARK(sp) ;
		XPUSHs(poly) ;
		PUTBACK ;
		count = perl_call_method("length",G_SCALAR) ;
		SPAGAIN ;
		if (count != 1)
                  croak("Didn't get a single result from GD::Poly::length() call.\n");
		length = POPi ;
		PUTBACK ;
		FREETMPS ;
		LEAVE ;

		polyptr = (gdPointPtr)safemalloc(sizeof(gdPoint)*length);
		if (polyptr == NULL)
                  croak("safemalloc() returned NULL in GD::Image::poly().\n");

		for (i=0; i<length; i++) {
                  ENTER ;
                  SAVETMPS ;
                  PUSHMARK(sp) ;
                  XPUSHs(poly) ;
                  mXPUSHi(i) ;
                  PUTBACK ;
                  count = perl_call_method("getPt",G_ARRAY) ;
                  SPAGAIN ;
                  if (count != 2)
                    croak("Didn't get a single result from GD::Poly::length() call.\n");
                  y = POPi ;
                  x = POPi ;
                  PUTBACK ;
                  FREETMPS ;
                  LEAVE ;

                  polyptr[i].x = x;
                  polyptr[i].y = y;
		}

		gdImagePolygon(image,polyptr,length,color);
		safefree((char*) polyptr);
	}
#line 4011 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_unclosedPolygon); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_unclosedPolygon)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, poly, color");
    {
	GD__Image	image;
	SV *	poly = ST(1)
;
	int	color = (int)SvIV(ST(2))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::unclosedPolygon",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1792 "GD.xs"
	{
		dSP ;
		int length,count ;
		int x,y,i ;
		gdPointPtr polyptr;
#ifdef HAVE_UNCLOSEDPOLY
		ENTER ;
		SAVETMPS ;
		PUSHMARK(sp) ;
		XPUSHs(poly) ;
		PUTBACK ;
		count = perl_call_method("length",G_SCALAR) ;
		SPAGAIN ;
		if (count != 1)
                  croak("Didn't get a single result from GD::Poly::length() call.\n");
		length = POPi ;
		PUTBACK ;
		FREETMPS ;
		LEAVE ;

		polyptr = (gdPointPtr)safemalloc(sizeof(gdPoint)*length);
		if (polyptr == NULL)
                  croak("safemalloc() returned NULL in GD::Image::poly().\n");

		for (i=0; i<length; i++) {
                  ENTER ;
                  SAVETMPS ;
                  PUSHMARK(sp) ;
                  XPUSHs(poly) ;
                  mXPUSHi(i) ;
                  PUTBACK ;
                  count = perl_call_method("getPt",G_ARRAY) ;
                  SPAGAIN ;
                  if (count != 2)
                    croak("Didn't get a single result from GD::Poly::length() call.\n");
                  y = POPi ;
                  x = POPi ;
                  PUTBACK ;
                  FREETMPS ;
                  LEAVE ;

                  polyptr[i].x = x;
                  polyptr[i].y = y;
		}

		gdImageOpenPolygon(image,polyptr,length,color);
		safefree((char*) polyptr);
#else
                die("libgd 2.0.33 or higher required for unclosed polygon support");
#endif
	}
#line 4095 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_filledPolygon); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_filledPolygon)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, poly, color");
    {
	GD__Image	image;
	SV *	poly = ST(1)
;
	int	color = (int)SvIV(ST(2))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::filledPolygon",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1851 "GD.xs"
	{
		dSP ;
		int length,count ;
		int x,y,i ;
		gdPointPtr polyptr;

		ENTER ;
		SAVETMPS ;
		PUSHMARK(sp) ;
		XPUSHs(poly) ;
		PUTBACK ;
		count = perl_call_method("length",G_SCALAR) ;
		SPAGAIN ;
		if (count != 1)
                  croak("Didn't get a single result from GD::Poly::length() call.\n");
		length = POPi ;
		PUTBACK ;
		FREETMPS ;
		LEAVE ;

		polyptr = (gdPointPtr)safemalloc(sizeof(gdPoint)*length);
		if (polyptr == NULL)
                  croak("safemalloc() returned NULL in GD::Image::poly().\n");

		for (i=0; i<length; i++) {
                  ENTER ;
                  SAVETMPS ;
                  PUSHMARK(sp) ;
                  XPUSHs(poly) ;
                  mXPUSHi(i) ;
                  PUTBACK ;
                  count = perl_call_method("getPt",G_ARRAY) ;
                  SPAGAIN ;
                  if (count != 2)
                    croak("Didn't get a single result from GD::Poly::length() call.\n");
                  y = POPi ;
                  x = POPi ;
                  PUTBACK ;
                  FREETMPS ;
                  LEAVE ;

                  polyptr[i].x = x;
                  polyptr[i].y = y;
		}

		gdImageFilledPolygon(image,polyptr,length,color);
		safefree((char*) polyptr);
	}
#line 4176 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_rectangle); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_rectangle)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, x1, y1, x2, y2, color");
    {
	GD__Image	image;
	int	x1 = (int)SvIV(ST(1))
;
	int	y1 = (int)SvIV(ST(2))
;
	int	x2 = (int)SvIV(ST(3))
;
	int	y2 = (int)SvIV(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::rectangle",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1910 "GD.xs"
    gdImageRectangle(image,x1,y1,x2,y2,color);
#line 4216 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_filledRectangle); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_filledRectangle)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, x1, y1, x2, y2, color");
    {
	GD__Image	image;
	int	x1 = (int)SvIV(ST(1))
;
	int	y1 = (int)SvIV(ST(2))
;
	int	x2 = (int)SvIV(ST(3))
;
	int	y2 = (int)SvIV(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::filledRectangle",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1922 "GD.xs"
    gdImageFilledRectangle(image,x1,y1,x2,y2,color);
#line 4256 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_filledEllipse); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_filledEllipse)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, cx, cy, w, h, color");
    {
	GD__Image	image;
	int	cx = (int)SvIV(ST(1))
;
	int	cy = (int)SvIV(ST(2))
;
	int	w = (int)SvIV(ST(3))
;
	int	h = (int)SvIV(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::filledEllipse",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1934 "GD.xs"
    gdImageFilledEllipse(image,cx,cy,w,h,color);
#line 4296 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_arc); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_arc)
{
    dVAR; dXSARGS;
    if (items != 8)
       croak_xs_usage(cv,  "image, cx, cy, w, h, s, e, color");
    {
	GD__Image	image;
	int	cx = (int)SvIV(ST(1))
;
	int	cy = (int)SvIV(ST(2))
;
	int	w = (int)SvIV(ST(3))
;
	int	h = (int)SvIV(ST(4))
;
	int	s = (int)SvIV(ST(5))
;
	int	e = (int)SvIV(ST(6))
;
	int	color = (int)SvIV(ST(7))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::arc",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1948 "GD.xs"
    gdImageArc(image,cx,cy,w,h,s,e,color);
#line 4340 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_filledArc); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_filledArc)
{
    dVAR; dXSARGS;
    if (items < 8 || items > 9)
       croak_xs_usage(cv,  "image, cx, cy, w, h, s, e, color, arc_style=0");
    {
	GD__Image	image;
	int	cx = (int)SvIV(ST(1))
;
	int	cy = (int)SvIV(ST(2))
;
	int	w = (int)SvIV(ST(3))
;
	int	h = (int)SvIV(ST(4))
;
	int	s = (int)SvIV(ST(5))
;
	int	e = (int)SvIV(ST(6))
;
	int	color = (int)SvIV(ST(7))
;
	int	arc_style;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::filledArc",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 9)
	    arc_style = 0;
	else {
	    arc_style = (int)SvIV(ST(8))
;
	}
#line 1963 "GD.xs"
    gdImageFilledArc(image,cx,cy,w,h,s,e,color,arc_style);
#line 4392 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_fillToBorder); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_fillToBorder)
{
    dVAR; dXSARGS;
    if (items != 5)
       croak_xs_usage(cv,  "image, x, y, border, color");
    {
	GD__Image	image;
	int	x = (int)SvIV(ST(1))
;
	int	y = (int)SvIV(ST(2))
;
	int	border = (int)SvIV(ST(3))
;
	int	color = (int)SvIV(ST(4))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::fillToBorder",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1974 "GD.xs"
    gdImageFillToBorder(image,x,y,border,color);
#line 4430 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_fill); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_fill)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, x, y, color");
    {
	GD__Image	image;
	int	x = (int)SvIV(ST(1))
;
	int	y = (int)SvIV(ST(2))
;
	int	color = (int)SvIV(ST(3))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::fill",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 1984 "GD.xs"
    gdImageFill(image,x,y,color);
#line 4466 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_setBrush); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_setBrush)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, brush");
    {
	GD__Image	image;
	GD__Image	brush;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setBrush",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    brush = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setBrush",
			"brush", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 1992 "GD.xs"
    gdImageSetBrush(image,brush);
#line 4511 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_setTile); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_setTile)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, tile");
    {
	GD__Image	image;
	GD__Image	tile;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setTile",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    tile = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setTile",
			"tile", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2000 "GD.xs"
    gdImageSetTile(image,tile);
#line 4556 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_setThickness); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_setThickness)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, thickness");
    {
	GD__Image	image;
	int	thickness = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setThickness",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2008 "GD.xs"
    gdImageSetThickness(image,thickness);
#line 4588 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_setStyle); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_setStyle)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    {
	GD__Image	image;
#line 2015 "GD.xs"
	int	*style;
	int	i;
#line 4605 "GD.c"

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setStyle",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2018 "GD.xs"
	if (items < 2)
          return;
	style = (int*) safemalloc(sizeof(int)*(items-1));
	if (style == NULL)
          croak("malloc returned NULL at setStyle().\n");
	for(i=1; i<items; i++) {
          style[i-1] = (int)SvIV(ST(i));
        }
	gdImageSetStyle(image, style, items-1);
	safefree((char*) style);
#line 4631 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_colorAllocate); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorAllocate)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, r, g, b");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorAllocate",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2037 "GD.xs"
    RETVAL = gdImageColorAllocate(image,r,g,b);
#line 4669 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorAllocateAlpha); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorAllocateAlpha)
{
    dVAR; dXSARGS;
    if (items != 5)
       croak_xs_usage(cv,  "image, r, g, b, a");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	a = (int)SvIV(ST(4))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorAllocateAlpha",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2050 "GD.xs"
    RETVAL = gdImageColorAllocateAlpha(image,r,g,b,a);
#line 4711 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorClosest); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorClosest)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, r, g, b");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorClosest",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2062 "GD.xs"
    RETVAL = gdImageColorClosest(image,r,g,b);
#line 4751 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorClosestAlpha); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorClosestAlpha)
{
    dVAR; dXSARGS;
    if (items != 5)
       croak_xs_usage(cv,  "image, r, g, b, a");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	a = (int)SvIV(ST(4))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorClosestAlpha",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2075 "GD.xs"
    RETVAL = gdImageColorClosestAlpha(image,r,g,b,a);
#line 4793 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorClosestHWB); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorClosestHWB)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, r, g, b");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorClosestHWB",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2087 "GD.xs"
    RETVAL = gdImageColorClosestHWB(image,r,g,b);
#line 4833 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorExact); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorExact)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, r, g, b");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorExact",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2099 "GD.xs"
    RETVAL = gdImageColorExact(image,r,g,b);
#line 4873 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorExactAlpha); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorExactAlpha)
{
    dVAR; dXSARGS;
    if (items != 5)
       croak_xs_usage(cv,  "image, r, g, b, a");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	a = (int)SvIV(ST(4))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorExactAlpha",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2112 "GD.xs"
    RETVAL = gdImageColorExactAlpha(image,r,g,b,a);
#line 4915 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorResolve); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorResolve)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, r, g, b");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorResolve",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2124 "GD.xs"
    RETVAL = gdImageColorResolve(image,r,g,b);
#line 4955 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorResolveAlpha); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorResolveAlpha)
{
    dVAR; dXSARGS;
    if (items != 5)
       croak_xs_usage(cv,  "image, r, g, b, a");
    {
	GD__Image	image;
	int	r = (int)SvIV(ST(1))
;
	int	g = (int)SvIV(ST(2))
;
	int	b = (int)SvIV(ST(3))
;
	int	a = (int)SvIV(ST(4))
;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorResolveAlpha",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2137 "GD.xs"
    RETVAL = gdImageColorResolveAlpha(image,r,g,b,a);
#line 4997 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorsTotal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorsTotal)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorsTotal",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2146 "GD.xs"
    if (gdImageTrueColor(image))
      XSRETURN_UNDEF;
    RETVAL = gdImageColorsTotal(image);
#line 5033 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_interlaced); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_interlaced)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    {
	GD__Image	image;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::interlaced",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2158 "GD.xs"
    if (items > 1) {
      if (SvOK(ST(1)))
        gdImageInterlace(image,1);
      else
        gdImageInterlace(image,0);
    }
    RETVAL = gdImageGetInterlaced(image);
#line 5073 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_compare); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_compare)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image1, image2");
    {
	GD__Image	image1;
	GD__Image	image2;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image1 = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::compare",
			"image1", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    image2 = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::compare",
			"image2", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2174 "GD.xs"
    RETVAL = gdImageCompare(image1,image2);
#line 5122 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_colorDeallocate); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_colorDeallocate)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, color");
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::colorDeallocate",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2184 "GD.xs"
    gdImageColorDeallocate(image,color);
#line 5156 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_copy); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copy)
{
    dVAR; dXSARGS;
    if (items != 8)
       croak_xs_usage(cv,  "destination, source, dstX, dstY, srcX, srcY, w, h");
    {
	GD__Image	destination;
	GD__Image	source;
	int	dstX = (int)SvIV(ST(2))
;
	int	dstY = (int)SvIV(ST(3))
;
	int	srcX = (int)SvIV(ST(4))
;
	int	srcY = (int)SvIV(ST(5))
;
	int	w = (int)SvIV(ST(6))
;
	int	h = (int)SvIV(ST(7))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copy",
			"destination", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copy",
			"source", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2198 "GD.xs"
    gdImageCopy(destination,source,dstX,dstY,srcX,srcY,w,h);
#line 5213 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_copyResized); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyResized)
{
    dVAR; dXSARGS;
    if (items != 10)
       croak_xs_usage(cv,  "destination, source, dstX, dstY, srcX, srcY, destW, destH, srcW, srcH");
    {
	GD__Image	destination;
	GD__Image	source;
	int	dstX = (int)SvIV(ST(2))
;
	int	dstY = (int)SvIV(ST(3))
;
	int	srcX = (int)SvIV(ST(4))
;
	int	srcY = (int)SvIV(ST(5))
;
	int	destW = (int)SvIV(ST(6))
;
	int	destH = (int)SvIV(ST(7))
;
	int	srcW = (int)SvIV(ST(8))
;
	int	srcH = (int)SvIV(ST(9))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyResized",
			"destination", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyResized",
			"source", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2214 "GD.xs"
    gdImageCopyResized(destination,source,dstX,dstY,srcX,srcY,destW,destH,srcW,srcH);
#line 5274 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_copyResampled); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyResampled)
{
    dVAR; dXSARGS;
    if (items != 10)
       croak_xs_usage(cv,  "destination, source, dstX, dstY, srcX, srcY, destW, destH, srcW, srcH");
    {
	GD__Image	destination;
	GD__Image	source;
	int	dstX = (int)SvIV(ST(2))
;
	int	dstY = (int)SvIV(ST(3))
;
	int	srcX = (int)SvIV(ST(4))
;
	int	srcY = (int)SvIV(ST(5))
;
	int	destW = (int)SvIV(ST(6))
;
	int	destH = (int)SvIV(ST(7))
;
	int	srcW = (int)SvIV(ST(8))
;
	int	srcH = (int)SvIV(ST(9))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyResampled",
			"destination", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyResampled",
			"source", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2230 "GD.xs"
    gdImageCopyResampled(destination,source,dstX,dstY,srcX,srcY,destW,destH,srcW,srcH);
#line 5335 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_copyMerge); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyMerge)
{
    dVAR; dXSARGS;
    if (items != 9)
       croak_xs_usage(cv,  "destination, source, dstX, dstY, srcX, srcY, w, h, pct");
    {
	GD__Image	destination;
	GD__Image	source;
	int	dstX = (int)SvIV(ST(2))
;
	int	dstY = (int)SvIV(ST(3))
;
	int	srcX = (int)SvIV(ST(4))
;
	int	srcY = (int)SvIV(ST(5))
;
	int	w = (int)SvIV(ST(6))
;
	int	h = (int)SvIV(ST(7))
;
	int	pct = (int)SvIV(ST(8))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyMerge",
			"destination", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyMerge",
			"source", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2245 "GD.xs"
    gdImageCopyMerge(destination,source,dstX,dstY,srcX,srcY,w,h,pct);
#line 5394 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_copyMergeGray); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyMergeGray)
{
    dVAR; dXSARGS;
    if (items != 9)
       croak_xs_usage(cv,  "destination, source, dstX, dstY, srcX, srcY, w, h, pct");
    {
	GD__Image	destination;
	GD__Image	source;
	int	dstX = (int)SvIV(ST(2))
;
	int	dstY = (int)SvIV(ST(3))
;
	int	srcX = (int)SvIV(ST(4))
;
	int	srcY = (int)SvIV(ST(5))
;
	int	w = (int)SvIV(ST(6))
;
	int	h = (int)SvIV(ST(7))
;
	int	pct = (int)SvIV(ST(8))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyMergeGray",
			"destination", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyMergeGray",
			"source", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2260 "GD.xs"
    gdImageCopyMergeGray(destination,source,dstX,dstY,srcX,srcY,w,h,pct);
#line 5453 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_paletteCopy); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_paletteCopy)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "destination, source");
    {
	GD__Image	destination;
	GD__Image	source;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::paletteCopy",
			"destination", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::paletteCopy",
			"source", "GD::Image",
			refstr, ST(1)
		);
	}
;
#line 2268 "GD.xs"
    gdImagePaletteCopy(destination,source);
#line 5498 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_char); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_char)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, font, x, y, c, color");
    {
	GD__Image	image;
	GD__Font	font;
	int	x = (int)SvIV(ST(2))
;
	int	y = (int)SvIV(ST(3))
;
	char *	c = (char *)SvPV_nolen(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::char",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::char",
			"font", "GD::Font",
			refstr, ST(1)
		);
	}
;
#line 2280 "GD.xs"
    gdImageChar(image,font,x,y,*c,color);
#line 5551 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_charUp); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_charUp)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, font, x, y, c, color");
    {
	GD__Image	image;
	GD__Font	font;
	int	x = (int)SvIV(ST(2))
;
	int	y = (int)SvIV(ST(3))
;
	char *	c = (char *)SvPV_nolen(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::charUp",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::charUp",
			"font", "GD::Font",
			refstr, ST(1)
		);
	}
;
#line 2292 "GD.xs"
    gdImageCharUp(image,font,x,y,*c,color);
#line 5604 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_string); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_string)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, font, x, y, s, color");
    {
	GD__Image	image;
	GD__Font	font;
	int	x = (int)SvIV(ST(2))
;
	int	y = (int)SvIV(ST(3))
;
	char *	s = (char *)SvPV_nolen(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::string",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::string",
			"font", "GD::Font",
			refstr, ST(1)
		);
	}
;
#line 2304 "GD.xs"
    gdImageString(image,font,x,y,(unsigned char*)s,color);
#line 5657 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_stringUp); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_stringUp)
{
    dVAR; dXSARGS;
    if (items != 6)
       croak_xs_usage(cv,  "image, font, x, y, s, color");
    {
	GD__Image	image;
	GD__Font	font;
	int	x = (int)SvIV(ST(2))
;
	int	y = (int)SvIV(ST(3))
;
	char *	s = (char *)SvPV_nolen(ST(4))
;
	int	color = (int)SvIV(ST(5))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::stringUp",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (SvROK(ST(1)) && sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(1)) ? "" : SvOK(ST(1)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::stringUp",
			"font", "GD::Font",
			refstr, ST(1)
		);
	}
;
#line 2316 "GD.xs"
    gdImageStringUp(image,font,x,y,(unsigned char*)s,color);
#line 5710 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_stringFT); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_stringFT)
{
    dVAR; dXSARGS;
    if (items < 8)
       croak_xs_usage(cv,  "image, fgcolor, fontname, ptsize, angle, x, y, string, ...");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	SV *	image = ST(0)
;
	int	fgcolor = (int)SvIV(ST(1))
;
	char *	fontname = (char *)SvPV_nolen(ST(2))
;
	double	ptsize = (double)SvNV(ST(3))
;
	double	angle = (double)SvNV(ST(4))
;
	int	x = (int)SvIV(ST(5))
;
	int	y = (int)SvIV(ST(6))
;
	char *	string = (char *)SvPV_nolen(ST(7))
;
#line 2330 "GD.xs"
	  gdImagePtr img;
	  int        brect[8];
	  char       *err;
          char       *a;
	  SV*        errormsg;
          HV*        hash;
          SV**       value;
	  int        i;
          int        hdpi;
          int        vdpi;
          gdFTStringExtra strex;
#line 5753 "GD.c"
#line 2342 "GD.xs"
  {
#ifndef HAVE_FT
  	errormsg = perl_get_sv("@",0);
	sv_setpv(errormsg,"libgd was not built with FreeType font support\n");
	XSRETURN_EMPTY;
#endif
        if (sv_isobject(image) && sv_derived_from(image, "GD::Image")) {
          IV tmp = SvIV((SV*)SvRV(image));
          img = (gdImagePtr) tmp;
        } else {
          img = NULL;
        }

        if (items == 9) {  /* hashref options at end */
          if (SvTYPE(SvRV(ST(8))) != SVt_PVHV)
            croak ("Usage: $gd->stringFT(image,fgcolor,fontname,ptsize,angle,x,y,string,[{options}])");
          hash  = (HV*)SvRV(ST(8));
          strex.flags       = 0;
          strex.linespacing = 0;
          strex.charmap     = 0;
          if ((value = hv_fetchs(hash,"linespacing",0))) {
            strex.flags |= gdFTEX_LINESPACE;
            strex.linespacing = SvNV(*value);
          }
          if ((value = hv_fetchs(hash,"charmap",0))) {
            strex.flags |= gdFTEX_CHARMAP;
            if (strEQ(SvPV_nolen(*value),"Unicode"))
              strex.charmap = gdFTEX_Unicode;
            else if (strEQ(SvPV_nolen(*value),"Shift_JIS"))
              strex.charmap = gdFTEX_Shift_JIS;
            else if (strEQ(SvPV_nolen(*value),"Big5"))
              strex.charmap = gdFTEX_Big5;
            else
              croak("Unknown charmap %s",SvPV_nolen(*value));
          }
#ifdef VERSION_33
          if ((value = hv_fetchs(hash,"resolution",0))) {
            strex.flags |= gdFTEX_RESOLUTION;
            a = SvPV_nolen(*value);
            if (sscanf(a,"%d,%d",&hdpi,&vdpi) == 2) {
              strex.hdpi = hdpi;
              strex.vdpi = vdpi;
            }
          }
          if ((value = hv_fetchs(hash,"kerning",0))) {
            if (!SvTRUE(*value)) {
              strex.flags |= gdFTEX_DISABLE_KERNING;
            }
            else
              strex.flags &= gdFTEX_DISABLE_KERNING;
          }
#endif
          err = gdImageStringFTEx(img,brect,fgcolor,fontname,ptsize,angle,x,y,string,&strex);
        }

        else {
          err = gdImageStringFT(img,brect,fgcolor,fontname,ptsize,angle,x,y,string);
        }
        if (err) {
          errormsg = perl_get_sv("@",0);
          if (errormsg != NULL)
            sv_setpv(errormsg,err);
          XSRETURN_EMPTY;
        } else {
          EXTEND(sp,8);
          for (i=0; i<8; i++) {
            mPUSHi(brect[i]);
          }
        }
  }
#line 5825 "GD.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_GD__Image_stringFTCircle); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_stringFTCircle)
{
    dVAR; dXSARGS;
    if (items != 11)
       croak_xs_usage(cv,  "image, cx, cy, radius, textRadius, fillPortion, fontname, points, top, bottom, fgcolor");
    {
	GD__Image	image;
	int	cx = (int)SvIV(ST(1))
;
	int	cy = (int)SvIV(ST(2))
;
	double	radius = (double)SvNV(ST(3))
;
	double	textRadius = (double)SvNV(ST(4))
;
	double	fillPortion = (double)SvNV(ST(5))
;
	char *	fontname = (char *)SvPV_nolen(ST(6))
;
	double	points = (double)SvNV(ST(7))
;
	char *	top = (char *)SvPV_nolen(ST(8))
;
	char *	bottom = (char *)SvPV_nolen(ST(9))
;
	int	fgcolor = (int)SvIV(ST(10))
;
#line 2428 "GD.xs"
        char*      err;        
        SV*        errormsg;
#line 5863 "GD.c"
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::stringFTCircle",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2431 "GD.xs"
  {
#ifdef HAVE_FT
#ifdef HAVE_FTCIRCLE
	fprintf(stderr,"cx=%d,cy=%d,radius=%f,textRadius=%f,fillPortion=%f,fontname=%s,points=%f,top=%s,bottom=%s,fgcolor=%d",
		cx,cy,radius,textRadius,
		fillPortion,fontname,points,top,bottom,fgcolor);
        err = gdImageStringFTCircle(image,cx,cy,radius,textRadius,
				    fillPortion,fontname,points,top,bottom,fgcolor);
        if (err) {
	    errormsg = perl_get_sv("@",0);
	    if (errormsg != NULL)
	      sv_setpv(errormsg,err);
	    XSRETURN_EMPTY;
	  } else {
            RETVAL = 1;
	  }
#else
        /* if we have FT but not FTCIRCLE, this is all that's compiled */
        PERL_UNUSED_ARG(image);
        PERL_UNUSED_ARG(cx);
        PERL_UNUSED_ARG(cy);
        PERL_UNUSED_ARG(radius);
        PERL_UNUSED_ARG(textRadius);
        PERL_UNUSED_ARG(fillPortion);
        PERL_UNUSED_ARG(fontname);
        PERL_UNUSED_ARG(points);
        PERL_UNUSED_ARG(top);
        PERL_UNUSED_ARG(bottom);
        PERL_UNUSED_ARG(fgcolor);
  	errormsg = perl_get_sv("@",0);
	sv_setpv(errormsg,"libgd must be version 2.0.33 or higher to use this function\n");
	XSRETURN_EMPTY;
#endif
#else
        /* if we don't have FT, this is all that's compiled */
        PERL_UNUSED_ARG(image);
        PERL_UNUSED_ARG(cx);
        PERL_UNUSED_ARG(cy);
        PERL_UNUSED_ARG(radius);
        PERL_UNUSED_ARG(textRadius);
        PERL_UNUSED_ARG(fillPortion);
        PERL_UNUSED_ARG(fontname);
        PERL_UNUSED_ARG(points);
        PERL_UNUSED_ARG(top);
        PERL_UNUSED_ARG(bottom);
        PERL_UNUSED_ARG(fgcolor);
  	errormsg = perl_get_sv("@",0);
	sv_setpv(errormsg,"libgd was not built with FreeType support\n");
	XSRETURN_EMPTY;
#endif
  }
#line 5932 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_useFontConfig); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_useFontConfig)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, flag");
    {
	SV*	image = ST(0)
;
	int	flag = (int)SvIV(ST(1))
;
	int	RETVAL;
	dXSTARG;
#line 2491 "GD.xs"
  {
    PERL_UNUSED_ARG(image);
#ifdef HAVE_FONTCONFIG
    RETVAL = gdFTUseFontConfig(flag);
#else
    SV* errormsg;
    PERL_UNUSED_ARG(flag);
    errormsg = perl_get_sv("@",0);
    sv_setpv(errormsg,"libgd was not built with fontconfig support\n");
    XSRETURN_EMPTY;
#endif
  }
#line 5966 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_alphaBlending); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_alphaBlending)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, blending");
    {
	GD__Image	image;
	int	blending = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::alphaBlending",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2512 "GD.xs"
    gdImageAlphaBlending(image,blending);
#line 6000 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_saveAlpha); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_saveAlpha)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, saveAlphaArg");
    {
	GD__Image	image;
	int	saveAlphaArg = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::saveAlpha",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2520 "GD.xs"
    gdImageSaveAlpha(image,saveAlphaArg);
#line 6032 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_clip); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_clip)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "image, ...");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	GD__Image	image;
#line 2527 "GD.xs"
        int		coords[4];
        int             i;
#line 6051 "GD.c"

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::clip",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2530 "GD.xs"
    if (items == 5) {
      for (i=0; i<4; i++)
        coords[i] = (int)SvIV(ST(i+1));
      gdImageSetClip(image,coords[0],coords[1],coords[2],coords[3]);
    }
    else if (items > 1) /* something weird */
      croak("Usage: $gd->clip() or $gd->clip(x1,x2,y1,y2)");

    gdImageGetClip(image,&coords[0],&coords[1],&coords[2],&coords[3]);
    EXTEND(sp,4);
    for (i=0; i<4; i++)
      mPUSHi(coords[i]);
#line 6079 "GD.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_GD__Image_setAntiAliased); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_setAntiAliased)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, color");
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setAntiAliased",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2549 "GD.xs"
    gdImageSetAntiAliased(image,color);
#line 6112 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Image_setAntiAliasedDontBlend); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_setAntiAliasedDontBlend)
{
    dVAR; dXSARGS;
    if (items < 2 || items > 3)
       croak_xs_usage(cv,  "image, color, flag=1");
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1))
;
	int	flag;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::setAntiAliasedDontBlend",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 3)
	    flag = 1;
	else {
	    flag = (int)SvIV(ST(2))
;
	}
#line 2558 "GD.xs"
    gdImageSetAntiAliasedDontBlend(image,color,flag);
#line 6152 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Font_load); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_load)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "packname=\"GD::Font\", fontpath");
    {
	char *	packname;
	char *	fontpath = (char *)SvPV_nolen(ST(1))
;
#line 2568 "GD.xs"
       int             fontfile;
       int             datasize;
       SV*             errormsg;
       char            errstr[256];
       gdFontPtr       font;
       unsigned char   word[4];
       char*           fontdata;
#line 6176 "GD.c"
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 2576 "GD.xs"
    PERL_UNUSED_ARG(packname);
    fontfile = open(fontpath,O_RDONLY);
    if (fontfile < 0) {
      errormsg = perl_get_sv("@",0);
      snprintf(errstr,256,"could not open font file %s: %s",fontpath,strerror(errno));
      sv_setpv(errormsg,errstr);
      XSRETURN_EMPTY;
    }
    font = (gdFontPtr)safemalloc(sizeof(gdFont));
    if (font == NULL)
      croak("safemalloc() returned NULL while trying to allocate font struct.\n");
    /* read header from font - note that the file is assumed to be littleendian*/
    if (read(fontfile,word,4) < 4)
      croak("error while reading font file: %s",strerror(errno));
    font->nchars = littleendian(word);

    if (read(fontfile,word,4) < 4)
      croak("error while reading font file: %s",strerror(errno));
    font->offset = littleendian(word);

    if (read(fontfile,word,4) < 4)
      croak("error while reading font file: %s",strerror(errno));
    font->w = littleendian(word);

    if (read(fontfile,word,4) < 4)
      croak("error while reading font file: %s",strerror(errno));
    font->h = littleendian(word);

    datasize = font->nchars * font->w * font->h;
    fontdata = (char*)safemalloc(datasize);
    if (fontdata == NULL)
      croak("safemalloc() returned NULL while trying to allocate font bitmap.\n");

    if (read(fontfile,fontdata,datasize) < datasize)
      croak("error while reading font file: %s",strerror(errno));

    font->data = fontdata;

    close(fontfile); /* please don't leak file descriptors! */
    RETVAL = font;
#line 6226 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Font", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_DESTROY)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "self");
    {
	GD__Font	self;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    self = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"GD::Font::DESTROY",
			"self")
;
#line 2624 "GD.xs"
    if (self == gdFontGetSmall()      ||
        self == gdFontGetLarge()      ||
        self == gdFontGetGiant()      ||
        self == gdFontGetMediumBold() ||
        self == gdFontGetTiny() )
      XSRETURN_EMPTY;
    safefree(self->data);
    safefree(self);
#line 6265 "GD.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_GD__Font_Small); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_Small)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "packname=\"GD::Font\"");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 2638 "GD.xs"
    PERL_UNUSED_ARG(packname);
    RETVAL = gdFontGetSmall();
    if (!RETVAL)
      croak("gdFontGetSmall error");
#line 6292 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Font", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_Large); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_Large)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "packname=\"GD::Font\"");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 2650 "GD.xs"
    PERL_UNUSED_ARG(packname);
    RETVAL = gdFontGetLarge();
    if (!RETVAL)
      croak("gdFontGetLarge error");
#line 6325 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Font", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_Giant); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_Giant)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "packname=\"GD::Font\"");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 2662 "GD.xs"
    PERL_UNUSED_ARG(packname);
    RETVAL = gdFontGetGiant();	
    if (!RETVAL)
      croak("gdFontGetGiant error");
#line 6358 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Font", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_MediumBold); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_MediumBold)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "packname=\"GD::Font\"");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 2674 "GD.xs"
    PERL_UNUSED_ARG(packname);
    RETVAL = gdFontGetMediumBold();
    if (!RETVAL)
      croak("gdFontGetMediumBold error");
#line 6391 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Font", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_Tiny); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_Tiny)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "packname=\"GD::Font\"");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0))
;
	}
#line 2686 "GD.xs"
    PERL_UNUSED_ARG(packname);
    RETVAL = gdFontGetTiny();
    if (!RETVAL)
      croak("gdFontGetTiny error");
#line 6424 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Font", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_nchars); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_nchars)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "font");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Font::nchars",
			"font", "GD::Font",
			refstr, ST(0)
		);
	}
;
#line 2698 "GD.xs"
    RETVAL = font->nchars;
#line 6462 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_offset); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_offset)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "font");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Font::offset",
			"font", "GD::Font",
			refstr, ST(0)
		);
	}
;
#line 2707 "GD.xs"
    RETVAL = font->offset;
#line 6496 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_width); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_width)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "font");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Font::width",
			"font", "GD::Font",
			refstr, ST(0)
		);
	}
;
#line 2716 "GD.xs"
    RETVAL = font->w;
#line 6530 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Font_height); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Font_height)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "font");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Font::height",
			"font", "GD::Font",
			refstr, ST(0)
		);
	}
;
#line 2725 "GD.xs"
    RETVAL = font->h;
#line 6564 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}

#if GD_VERSION >= 20100
#define XSubPPtmpAAAZ 1


XS_EUPXS(XS_GD__Image_scatter); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_scatter)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, sub, plus");
    {
	GD__Image	image;
	int	sub = (int)SvIV(ST(1))
;
	int	plus = (int)SvIV(ST(2))
;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::scatter",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2742 "GD.xs"
    RETVAL = (bool)gdImageScatter(image,sub,plus);
#line 6604 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_scatterColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_scatterColor)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "image, sub, plus, colorav");
    {
	GD__Image	image;
	int	sub = (int)SvIV(ST(1))
;
	int	plus = (int)SvIV(ST(2))
;
	AV *	colorav;
#line 2754 "GD.xs"
	int i;
	int *colors;
	int numcolors;
#line 6628 "GD.c"
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::scatterColor",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	STMT_START {
		SV* const xsub_tmp_sv = ST(3);
		SvGETMAGIC(xsub_tmp_sv);
		if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVAV){
		    colorav = (AV*)SvRV(xsub_tmp_sv);
		}
		else{
		    Perl_croak_nocontext("%s: %s is not an ARRAY reference",
				"GD::Image::scatterColor",
				"colorav");
		}
	} STMT_END
;
#line 2758 "GD.xs"
    numcolors = AvFILL(colorav);
    colors = safemalloc(numcolors * sizeof(int));
    for (i=0; i<numcolors; i++) {
      SV** svp = av_fetch(colorav, i, 0);
      if (svp && SvIOK(*svp))
        colors[i] = SvIV(*svp);
    }
    RETVAL = (bool)gdImageScatterColor(image,sub,plus,colors,numcolors);
    safefree(colors);
#line 6668 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_pixelate); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_pixelate)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, blocksize, mode");
    {
	GD__Image	image;
	int	blocksize = (int)SvIV(ST(1))
;
	int	mode = (int)SvIV(ST(2))
;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::pixelate",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2777 "GD.xs"
    RETVAL = (bool)gdImagePixelate(image,blocksize,mode);
#line 6704 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_negate); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_negate)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::negate",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2786 "GD.xs"
    RETVAL = (bool)gdImageNegate(image);
#line 6736 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_grayscale); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_grayscale)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::grayscale",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2795 "GD.xs"
    RETVAL = (bool)gdImageGrayScale(image);
#line 6768 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_brightness); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_brightness)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, brightness");
    {
	GD__Image	image;
	int	brightness = (int)SvIV(ST(1))
;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::brightness",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2805 "GD.xs"
    RETVAL = (bool)gdImageBrightness(image,brightness);
#line 6802 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_contrast); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_contrast)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, contrast");
    {
	GD__Image	image;
	NV	contrast = (NV)SvNV(ST(1))
;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::contrast",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2815 "GD.xs"
    RETVAL = (bool)gdImageContrast(image,(double)contrast);
#line 6836 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_color); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_color)
{
    dVAR; dXSARGS;
    if (items != 5)
       croak_xs_usage(cv,  "image, red, green, blue, alpha");
    {
	GD__Image	image;
	int	red = (int)SvIV(ST(1))
;
	int	green = (int)SvIV(ST(2))
;
	int	blue = (int)SvIV(ST(3))
;
	int	alpha = (int)SvIV(ST(4))
;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::color",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2828 "GD.xs"
    RETVAL = (bool)gdImageColor(image,red,green,blue,alpha);
#line 6876 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_selectiveBlur); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_selectiveBlur)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::selectiveBlur",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2837 "GD.xs"
    RETVAL = (bool)gdImageSelectiveBlur(image);
#line 6908 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_edgeDetectQuick); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_edgeDetectQuick)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::edgeDetectQuick",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2846 "GD.xs"
    RETVAL = (bool)gdImageEdgeDetectQuick(image);
#line 6940 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_gaussianBlur); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_gaussianBlur)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::gaussianBlur",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2855 "GD.xs"
    RETVAL = (bool)gdImageGaussianBlur(image);
#line 6972 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_emboss); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_emboss)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::emboss",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2864 "GD.xs"
    RETVAL = (bool)gdImageEmboss(image);
#line 7004 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_meanRemoval); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_meanRemoval)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "image");
    {
	GD__Image	image;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::meanRemoval",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2873 "GD.xs"
    RETVAL = (bool)gdImageMeanRemoval(image);
#line 7036 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_smooth); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_smooth)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "image, weight");
    {
	GD__Image	image;
	double	weight = (double)SvNV(ST(1))
;
	bool	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::smooth",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2883 "GD.xs"
    RETVAL = (bool)gdImageSmooth(image, (float)weight);
#line 7070 "GD.c"
	ST(0) = boolSV(RETVAL);
    }
    XSRETURN(1);
}

#endif
#if GD_VERSION >= 20200
#define XSubPPtmpAABA 1


XS_EUPXS(XS_GD__Image_copyGaussianBlurred); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyGaussianBlurred)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, radius, sigma");
    {
	GD__Image	image;
	int	radius = (int)SvIV(ST(1))
;
	double	sigma = (double)SvNV(ST(2))
;
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyGaussianBlurred",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2897 "GD.xs"
    RETVAL = gdImageCopyGaussianBlurred(image, radius, sigma);
    if (!RETVAL)
       croak("gdImageCopyGaussianBlurred error");
#line 7112 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#if GD_VERSION >= 20100
#define XSubPPtmpAABB 1


XS_EUPXS(XS_GD__Image_copyScaleInterpolated); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyScaleInterpolated)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, width, height");
    {
	GD__Image	image;
	int	width = (int)SvIV(ST(1))
;
	int	height = (int)SvIV(ST(2))
;
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyScaleInterpolated",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2916 "GD.xs"
    RETVAL = gdImageScale(image,width,height);
    if (!RETVAL)
      XSRETURN_UNDEF;
#line 7159 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_GD__Image_copyRotateInterpolated); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_copyRotateInterpolated)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "image, angle, bgcolor");
    {
	GD__Image	image;
	NV	angle = (NV)SvNV(ST(1))
;
	int	bgcolor = (int)SvIV(ST(2))
;
	GD__Image	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::copyRotateInterpolated",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;
#line 2929 "GD.xs"
    RETVAL = gdImageRotateInterpolated(image,(float)angle,bgcolor);
    if (!RETVAL)
      XSRETURN_UNDEF;
#line 7202 "GD.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "GD::Image", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}

#endif
#if GD_VERSION >= 20200
#define XSubPPtmpAABC 1


XS_EUPXS(XS_GD__Image_interpolationMethod); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_GD__Image_interpolationMethod)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "image, interpolationmethod=-1");
    {
	GD__Image	image;
	int	interpolationmethod;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else {
		const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
	    Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
			"GD::Image::interpolationMethod",
			"image", "GD::Image",
			refstr, ST(0)
		);
	}
;

	if (items < 2)
	    interpolationmethod = -1;
	else {
	    interpolationmethod = (int)SvIV(ST(1))
;
	}
#line 2944 "GD.xs"
    if (items > 1 && interpolationmethod >= 0) {
      gdImageSetInterpolationMethod(image, interpolationmethod);
    }
    RETVAL = gdImageGetInterpolationMethod(image);
#line 7255 "GD.c"
	TARGi((IV)RETVAL, 1);
	ST(0) = TARG;
    }
    XSRETURN(1);
}

#endif
#ifdef __cplusplus
extern "C" {
#endif
XS_EXTERNAL(boot_GD); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_GD)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
    char* file = __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

        newXS_deffile("GD::constant", XS_GD_constant);
        newXS_deffile("GD::VERSION_STRING", XS_GD_VERSION_STRING);
        newXS_deffile("GD::LIBGD_VERSION", XS_GD_LIBGD_VERSION);
#if XSubPPtmpAAAA
        (void)newXSproto_portable("GD::supportsFileType", XS_GD_supportsFileType, file, "$;$");
#endif
        (void)newXSproto_portable("GD::Image::trueColor", XS_GD__Image_trueColor, file, "$$");
        (void)newXSproto_portable("GD::Image::_new", XS_GD__Image__new, file, "$;$$$");
#if XSubPPtmpAAAB
        (void)newXSproto_portable("GD::Image::_file", XS_GD__Image__file, file, "$$");
#endif
#if XSubPPtmpAAAC
        (void)newXSproto_portable("GD::Image::_newFromPng", XS_GD__Image__newFromPng, file, "$$;$");
        (void)newXSproto_portable("GD::Image::newFromPngData", XS_GD__Image_newFromPngData, file, "$$;$");
#endif
#if XSubPPtmpAAAD
        (void)newXSproto_portable("GD::Image::newFromGdData", XS_GD__Image_newFromGdData, file, "$$");
        (void)newXSproto_portable("GD::Image::newFromGd2Data", XS_GD__Image_newFromGd2Data, file, "$$");
#endif
#if XSubPPtmpAAAE
        (void)newXSproto_portable("GD::Image::newFromJpegData", XS_GD__Image_newFromJpegData, file, "$$;$");
#endif
#if XSubPPtmpAAAF
        (void)newXSproto_portable("GD::Image::newFromBmpData", XS_GD__Image_newFromBmpData, file, "$$;$");
#endif
        (void)newXSproto_portable("GD::Image::newFromWBMPData", XS_GD__Image_newFromWBMPData, file, "$$;$");
        (void)newXSproto_portable("GD::Image::_newFromXbm", XS_GD__Image__newFromXbm, file, "$$");
#if XSubPPtmpAAAG
        (void)newXSproto_portable("GD::Image::_newFromGd", XS_GD__Image__newFromGd, file, "$$");
        (void)newXSproto_portable("GD::Image::_newFromGd2", XS_GD__Image__newFromGd2, file, "$$");
        (void)newXSproto_portable("GD::Image::_newFromGd2Part", XS_GD__Image__newFromGd2Part, file, "$$$$$$");
#endif
#if XSubPPtmpAAAH
        (void)newXSproto_portable("GD::Image::_newFromJpeg", XS_GD__Image__newFromJpeg, file, "$$;$");
#endif
#if XSubPPtmpAAAI
        (void)newXSproto_portable("GD::Image::_newFromTiff", XS_GD__Image__newFromTiff, file, "$$;$");
        (void)newXSproto_portable("GD::Image::newFromTiffData", XS_GD__Image_newFromTiffData, file, "$$;$");
#endif
#if XSubPPtmpAAAJ
        (void)newXSproto_portable("GD::Image::_newFromBmp", XS_GD__Image__newFromBmp, file, "$$");
#endif
        (void)newXSproto_portable("GD::Image::_newFromWBMP", XS_GD__Image__newFromWBMP, file, "$$");
#if XSubPPtmpAAAK
        (void)newXSproto_portable("GD::Image::newFromXpm", XS_GD__Image_newFromXpm, file, "$$");
#endif
#if XSubPPtmpAAAL
        (void)newXSproto_portable("GD::Image::_newFromGif", XS_GD__Image__newFromGif, file, "$$");
        (void)newXSproto_portable("GD::Image::newFromGifData", XS_GD__Image_newFromGifData, file, "$$");
#endif
#if XSubPPtmpAAAM
        (void)newXSproto_portable("GD::Image::_newFromWebp", XS_GD__Image__newFromWebp, file, "$$");
        (void)newXSproto_portable("GD::Image::newFromWebpData", XS_GD__Image_newFromWebpData, file, "$$");
#endif
#if XSubPPtmpAAAN
        (void)newXSproto_portable("GD::Image::_newFromHeif", XS_GD__Image__newFromHeif, file, "$$");
        (void)newXSproto_portable("GD::Image::newFromHeifData", XS_GD__Image_newFromHeifData, file, "$$");
#endif
#if XSubPPtmpAAAO
        (void)newXSproto_portable("GD::Image::_newFromAvif", XS_GD__Image__newFromAvif, file, "$$");
        (void)newXSproto_portable("GD::Image::newFromAvifData", XS_GD__Image_newFromAvifData, file, "$$");
#endif
        (void)newXSproto_portable("GD::Image::DESTROY", XS_GD__Image_DESTROY, file, "$");
        (void)newXSproto_portable("GD::Image::STORABLE_freeze", XS_GD__Image_STORABLE_freeze, file, "$$");
        newXS_deffile("GD::Image::STORABLE_thaw", XS_GD__Image_STORABLE_thaw);
#if XSubPPtmpAAAP
        (void)newXSproto_portable("GD::Image::png", XS_GD__Image_png, file, "$;$");
#endif
#if XSubPPtmpAAAQ
        (void)newXSproto_portable("GD::Image::jpeg", XS_GD__Image_jpeg, file, "$");
#endif
        (void)newXSproto_portable("GD::Image::gifanimbegin", XS_GD__Image_gifanimbegin, file, "$$$");
        (void)newXSproto_portable("GD::Image::gifanimadd", XS_GD__Image_gifanimadd, file, "$$$$$$$");
        (void)newXSproto_portable("GD::Image::gifanimend", XS_GD__Image_gifanimend, file, "$");
#if XSubPPtmpAAAR
        (void)newXSproto_portable("GD::Image::bmp", XS_GD__Image_bmp, file, "$");
#endif
        (void)newXSproto_portable("GD::Image::wbmp", XS_GD__Image_wbmp, file, "$");
#if XSubPPtmpAAAS
        (void)newXSproto_portable("GD::Image::gif", XS_GD__Image_gif, file, "$");
#endif
#if XSubPPtmpAAAT
        (void)newXSproto_portable("GD::Image::gd", XS_GD__Image_gd, file, "$");
        (void)newXSproto_portable("GD::Image::gd2", XS_GD__Image_gd2, file, "$");
#endif
#if XSubPPtmpAAAU
        (void)newXSproto_portable("GD::Image::tiff", XS_GD__Image_tiff, file, "$");
#endif
#if XSubPPtmpAAAV
        (void)newXSproto_portable("GD::Image::webp", XS_GD__Image_webp, file, "$;$");
#endif
#if XSubPPtmpAAAW
        (void)newXSproto_portable("GD::Image::heif", XS_GD__Image_heif, file, "$;$");
#endif
#if XSubPPtmpAAAX
        (void)newXSproto_portable("GD::Image::avif", XS_GD__Image_avif, file, "$;$$");
#endif
        (void)newXSproto_portable("GD::Image::transparent", XS_GD__Image_transparent, file, "$;$");
        (void)newXSproto_portable("GD::Image::getBounds", XS_GD__Image_getBounds, file, "$");
        (void)newXSproto_portable("GD::Image::isTrueColor", XS_GD__Image_isTrueColor, file, "$");
        (void)newXSproto_portable("GD::Image::trueColorToPalette", XS_GD__Image_trueColorToPalette, file, "$;$$");
        (void)newXSproto_portable("GD::Image::createPaletteFromTrueColor", XS_GD__Image_createPaletteFromTrueColor, file, "$;$$");
#if XSubPPtmpAAAY
        (void)newXSproto_portable("GD::Image::neuQuant", XS_GD__Image_neuQuant, file, "$;$$");
        (void)newXSproto_portable("GD::Image::colorMatch", XS_GD__Image_colorMatch, file, "$$");
#endif
        (void)newXSproto_portable("GD::Image::rgb", XS_GD__Image_rgb, file, "$$");
        (void)newXSproto_portable("GD::Image::alpha", XS_GD__Image_alpha, file, "$$");
        (void)newXSproto_portable("GD::Image::boundsSafe", XS_GD__Image_boundsSafe, file, "$$$");
        (void)newXSproto_portable("GD::Image::getPixel", XS_GD__Image_getPixel, file, "$$$");
        (void)newXSproto_portable("GD::Image::setPixel", XS_GD__Image_setPixel, file, "$$$$");
        (void)newXSproto_portable("GD::Image::copyRotate90", XS_GD__Image_copyRotate90, file, "$");
        (void)newXSproto_portable("GD::Image::copyRotate180", XS_GD__Image_copyRotate180, file, "$");
        (void)newXSproto_portable("GD::Image::copyRotate270", XS_GD__Image_copyRotate270, file, "$");
        (void)newXSproto_portable("GD::Image::copyFlipHorizontal", XS_GD__Image_copyFlipHorizontal, file, "$");
        (void)newXSproto_portable("GD::Image::copyFlipVertical", XS_GD__Image_copyFlipVertical, file, "$");
        (void)newXSproto_portable("GD::Image::copyTranspose", XS_GD__Image_copyTranspose, file, "$");
        (void)newXSproto_portable("GD::Image::copyReverseTranspose", XS_GD__Image_copyReverseTranspose, file, "$");
        (void)newXSproto_portable("GD::Image::rotate180", XS_GD__Image_rotate180, file, "$");
        (void)newXSproto_portable("GD::Image::copyRotated", XS_GD__Image_copyRotated, file, "$$$$$$$$$");
        (void)newXSproto_portable("GD::Image::flipHorizontal", XS_GD__Image_flipHorizontal, file, "$");
        (void)newXSproto_portable("GD::Image::flipVertical", XS_GD__Image_flipVertical, file, "$");
        (void)newXSproto_portable("GD::Image::line", XS_GD__Image_line, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::dashedLine", XS_GD__Image_dashedLine, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::openPolygon", XS_GD__Image_openPolygon, file, "$$$");
        (void)newXSproto_portable("GD::Image::unclosedPolygon", XS_GD__Image_unclosedPolygon, file, "$$$");
        (void)newXSproto_portable("GD::Image::filledPolygon", XS_GD__Image_filledPolygon, file, "$$$");
        (void)newXSproto_portable("GD::Image::rectangle", XS_GD__Image_rectangle, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::filledRectangle", XS_GD__Image_filledRectangle, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::filledEllipse", XS_GD__Image_filledEllipse, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::arc", XS_GD__Image_arc, file, "$$$$$$$$");
        (void)newXSproto_portable("GD::Image::filledArc", XS_GD__Image_filledArc, file, "$$$$$$$$$");
        (void)newXSproto_portable("GD::Image::fillToBorder", XS_GD__Image_fillToBorder, file, "$$$$$");
        (void)newXSproto_portable("GD::Image::fill", XS_GD__Image_fill, file, "$$$$");
        (void)newXSproto_portable("GD::Image::setBrush", XS_GD__Image_setBrush, file, "$$");
        (void)newXSproto_portable("GD::Image::setTile", XS_GD__Image_setTile, file, "$$");
        (void)newXSproto_portable("GD::Image::setThickness", XS_GD__Image_setThickness, file, "$$");
        (void)newXSproto_portable("GD::Image::setStyle", XS_GD__Image_setStyle, file, "$;$");
        (void)newXSproto_portable("GD::Image::colorAllocate", XS_GD__Image_colorAllocate, file, "$$$$");
        (void)newXSproto_portable("GD::Image::colorAllocateAlpha", XS_GD__Image_colorAllocateAlpha, file, "$$$$$");
        (void)newXSproto_portable("GD::Image::colorClosest", XS_GD__Image_colorClosest, file, "$$$$");
        (void)newXSproto_portable("GD::Image::colorClosestAlpha", XS_GD__Image_colorClosestAlpha, file, "$$$$$");
        (void)newXSproto_portable("GD::Image::colorClosestHWB", XS_GD__Image_colorClosestHWB, file, "$$$$");
        (void)newXSproto_portable("GD::Image::colorExact", XS_GD__Image_colorExact, file, "$$$$");
        (void)newXSproto_portable("GD::Image::colorExactAlpha", XS_GD__Image_colorExactAlpha, file, "$$$$$");
        (void)newXSproto_portable("GD::Image::colorResolve", XS_GD__Image_colorResolve, file, "$$$$");
        (void)newXSproto_portable("GD::Image::colorResolveAlpha", XS_GD__Image_colorResolveAlpha, file, "$$$$$");
        (void)newXSproto_portable("GD::Image::colorsTotal", XS_GD__Image_colorsTotal, file, "$");
        (void)newXSproto_portable("GD::Image::interlaced", XS_GD__Image_interlaced, file, "$;$");
        (void)newXSproto_portable("GD::Image::compare", XS_GD__Image_compare, file, "$$");
        (void)newXSproto_portable("GD::Image::colorDeallocate", XS_GD__Image_colorDeallocate, file, "$$");
        (void)newXSproto_portable("GD::Image::copy", XS_GD__Image_copy, file, "$$$$$$$$");
        (void)newXSproto_portable("GD::Image::copyResized", XS_GD__Image_copyResized, file, "$$$$$$$$$$");
        (void)newXSproto_portable("GD::Image::copyResampled", XS_GD__Image_copyResampled, file, "$$$$$$$$$$");
        (void)newXSproto_portable("GD::Image::copyMerge", XS_GD__Image_copyMerge, file, "$$$$$$$$$");
        (void)newXSproto_portable("GD::Image::copyMergeGray", XS_GD__Image_copyMergeGray, file, "$$$$$$$$$");
        (void)newXSproto_portable("GD::Image::paletteCopy", XS_GD__Image_paletteCopy, file, "$$");
        (void)newXSproto_portable("GD::Image::char", XS_GD__Image_char, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::charUp", XS_GD__Image_charUp, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::string", XS_GD__Image_string, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::stringUp", XS_GD__Image_stringUp, file, "$$$$$$");
        (void)newXSproto_portable("GD::Image::stringFT", XS_GD__Image_stringFT, file, "$$$$$$$$;$");
        (void)newXSproto_portable("GD::Image::stringFTCircle", XS_GD__Image_stringFTCircle, file, "$$$$$$$$$$$");
        (void)newXSproto_portable("GD::Image::useFontConfig", XS_GD__Image_useFontConfig, file, "$$");
        (void)newXSproto_portable("GD::Image::alphaBlending", XS_GD__Image_alphaBlending, file, "$$");
        (void)newXSproto_portable("GD::Image::saveAlpha", XS_GD__Image_saveAlpha, file, "$$");
        (void)newXSproto_portable("GD::Image::clip", XS_GD__Image_clip, file, "$;$$$$");
        (void)newXSproto_portable("GD::Image::setAntiAliased", XS_GD__Image_setAntiAliased, file, "$$");
        (void)newXSproto_portable("GD::Image::setAntiAliasedDontBlend", XS_GD__Image_setAntiAliasedDontBlend, file, "$$$");
        (void)newXSproto_portable("GD::Font::load", XS_GD__Font_load, file, "$$");
        (void)newXSproto_portable("GD::Font::DESTROY", XS_GD__Font_DESTROY, file, "$");
        (void)newXSproto_portable("GD::Font::Small", XS_GD__Font_Small, file, "$");
        (void)newXSproto_portable("GD::Font::Large", XS_GD__Font_Large, file, "$");
        (void)newXSproto_portable("GD::Font::Giant", XS_GD__Font_Giant, file, "$");
        (void)newXSproto_portable("GD::Font::MediumBold", XS_GD__Font_MediumBold, file, "$");
        (void)newXSproto_portable("GD::Font::Tiny", XS_GD__Font_Tiny, file, "$");
        (void)newXSproto_portable("GD::Font::nchars", XS_GD__Font_nchars, file, "$");
        (void)newXSproto_portable("GD::Font::offset", XS_GD__Font_offset, file, "$");
        (void)newXSproto_portable("GD::Font::width", XS_GD__Font_width, file, "$");
        (void)newXSproto_portable("GD::Font::height", XS_GD__Font_height, file, "$");
#if XSubPPtmpAAAZ
        (void)newXSproto_portable("GD::Image::scatter", XS_GD__Image_scatter, file, "$$$");
        (void)newXSproto_portable("GD::Image::scatterColor", XS_GD__Image_scatterColor, file, "$$$\\@");
        (void)newXSproto_portable("GD::Image::pixelate", XS_GD__Image_pixelate, file, "$$$");
        (void)newXSproto_portable("GD::Image::negate", XS_GD__Image_negate, file, "$");
        (void)newXSproto_portable("GD::Image::grayscale", XS_GD__Image_grayscale, file, "$");
        (void)newXSproto_portable("GD::Image::brightness", XS_GD__Image_brightness, file, "$$");
        (void)newXSproto_portable("GD::Image::contrast", XS_GD__Image_contrast, file, "$$");
        (void)newXSproto_portable("GD::Image::color", XS_GD__Image_color, file, "$$$$$");
        (void)newXSproto_portable("GD::Image::selectiveBlur", XS_GD__Image_selectiveBlur, file, "$");
        (void)newXSproto_portable("GD::Image::edgeDetectQuick", XS_GD__Image_edgeDetectQuick, file, "$");
        (void)newXSproto_portable("GD::Image::gaussianBlur", XS_GD__Image_gaussianBlur, file, "$");
        (void)newXSproto_portable("GD::Image::emboss", XS_GD__Image_emboss, file, "$");
        (void)newXSproto_portable("GD::Image::meanRemoval", XS_GD__Image_meanRemoval, file, "$");
        (void)newXSproto_portable("GD::Image::smooth", XS_GD__Image_smooth, file, "$$");
#endif
#if XSubPPtmpAABA
        (void)newXSproto_portable("GD::Image::copyGaussianBlurred", XS_GD__Image_copyGaussianBlurred, file, "$$$");
#endif
#if XSubPPtmpAABB
        (void)newXSproto_portable("GD::Image::copyScaleInterpolated", XS_GD__Image_copyScaleInterpolated, file, "$$$");
        (void)newXSproto_portable("GD::Image::copyRotateInterpolated", XS_GD__Image_copyRotateInterpolated, file, "$$$");
#endif
#if XSubPPtmpAABC
        (void)newXSproto_portable("GD::Image::interpolationMethod", XS_GD__Image_interpolationMethod, file, "$;$");
#endif

    /* Initialisation Section */

#if XSubPPtmpAAAA
#endif
#line 353 "GD.xs"
{
#ifdef START_MY_CXT
   MY_CXT_INIT;
#endif
   truecolor_default = 0;
}

#if XSubPPtmpAAAB
#endif
#if XSubPPtmpAAAC
#endif
#if XSubPPtmpAAAD
#endif
#if XSubPPtmpAAAE
#endif
#if XSubPPtmpAAAF
#endif
#if XSubPPtmpAAAG
#endif
#if XSubPPtmpAAAH
#endif
#if XSubPPtmpAAAI
#endif
#if XSubPPtmpAAAJ
#endif
#if XSubPPtmpAAAK
#endif
#if XSubPPtmpAAAL
#endif
#if XSubPPtmpAAAM
#endif
#if XSubPPtmpAAAN
#endif
#if XSubPPtmpAAAO
#endif
#if XSubPPtmpAAAP
#endif
#if XSubPPtmpAAAQ
#endif
#if XSubPPtmpAAAR
#endif
#if XSubPPtmpAAAS
#endif
#if XSubPPtmpAAAT
#endif
#if XSubPPtmpAAAU
#endif
#if XSubPPtmpAAAV
#endif
#if XSubPPtmpAAAW
#endif
#if XSubPPtmpAAAX
#endif
#if XSubPPtmpAAAY
#endif
#if XSubPPtmpAAAZ
#endif
#if XSubPPtmpAABA
#endif
#if XSubPPtmpAABB
#endif
#if XSubPPtmpAABC
#endif
#line 7566 "GD.c"

    /* End of Initialisation Section */

#if PERL_VERSION_LE(5, 21, 5)
#  if PERL_VERSION_GE(5, 9, 0)
    if (PL_unitcheckav)
        call_list(PL_scopestack_ix, PL_unitcheckav);
#  endif
    XSRETURN_YES;
#else
    Perl_xs_boot_epilog(aTHX_ ax);
#endif
}

#ifdef __cplusplus
}
#endif
