/*
 * This file was generated automatically by xsubpp version 1.9508 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>
#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 */

static int
not_here(char *s)
{
    croak("%s not implemented on this architecture", s);
    return -1;
}

static double
constant(char *name, int arg)
{
    errno = 0;
    switch (*name) {
    case 'A':
	break;
    case 'B':
	break;
    case 'C':
	break;
    case 'D':
	break;
    case 'E':
	break;
    case 'F':
	break;
    case 'G':
	if (strEQ(name, "GD_CMP_IMAGE"))
#ifdef GD_CMP_IMAGE
	  return GD_CMP_IMAGE;
#else
	    goto not_there;
#endif
	if (strEQ(name, "GD_CMP_NUM_COLORS"))
#ifdef GD_CMP_NUM_COLORS
	  return GD_CMP_NUM_COLORS;
#else
	goto not_there;
#endif
	if (strEQ(name, "GD_CMP_COLOR"))
#ifdef GD_CMP_COLOR
	  return GD_CMP_COLOR;
#else
	goto not_there;
#endif
	if (strEQ(name, "GD_CMP_SIZE_X"))
#ifdef GD_CMP_SIZE_X
	  return GD_CMP_SIZE_X;
#else
	goto not_there;
#endif
	if (strEQ(name, "GD_CMP_SIZE_Y"))
#ifdef GD_CMP_SIZE_Y
	  return GD_CMP_SIZE_Y;
#else
	goto not_there;
#endif
	if (strEQ(name, "GD_CMP_TRANSPARENT"))
#ifdef GD_CMP_TRANSPARENT
	  return GD_CMP_TRANSPARENT;
#else
	goto not_there;
#endif
	if (strEQ(name, "GD_CMP_BACKGROUND"))
#ifdef GD_CMP_BACKGROUND
	  return GD_CMP_BACKGROUND;
#else
	goto not_there;
#endif
	if (strEQ(name, "GD_CMP_INTERLACE"))
#ifdef GD_CMP_INTERLACE
	  return GD_CMP_INTERLACE;
#else
	goto not_there;
#endif
	if (strEQ(name, "GD_CMP_TRUECOLOR"))
#ifdef GD_CMP_TRUECOLOR
	  return GD_CMP_TRUECOLOR;
#else
	goto not_there;
#endif
	break;
    case 'H':
	break;
    case 'I':
	break;
    case 'J':
	break;
    case 'K':
	break;
    case 'L':
	break;
    case 'M':
	break;
    case 'N':
	break;
    case 'O':
	break;
    case 'P':
	break;
    case 'Q':
	break;
    case 'R':
	break;
    case 'S':
	break;
    case 'T':
	break;
    case 'U':
	break;
    case 'V':
	break;
    case 'W':
	break;
    case 'X':
	break;
    case 'Y':
	break;
    case 'Z':
	break;
    case 'a':
	break;
    case 'b':
	break;
    case 'c':
	break;
    case 'd':
	break;
    case 'e':
	break;
    case 'f':
	break;
    case 'g':
	if (strEQ(name, "gdBrushed"))
#ifdef gdBrushed
	    return gdBrushed;
#else
	    goto not_there;
#endif
	if (strEQ(name, "gdDashSize"))
#ifdef gdDashSize
	    return gdDashSize;
#else
	    goto not_there;
#endif
	if (strEQ(name, "gdMaxColors"))
#ifdef gdMaxColors
	    return gdMaxColors;
#else
	    goto not_there;
#endif
	if (strEQ(name, "gdStyled"))
#ifdef gdStyled
	    return gdStyled;
#else
	    goto not_there;
#endif
	if (strEQ(name, "gdStyledBrushed"))
#ifdef gdStyledBrushed
	    return gdStyledBrushed;
#else
	    goto not_there;
#endif
	if (strEQ(name, "gdTiled"))
#ifdef gdTiled
	    return gdTiled;
#else
	    goto not_there;
#endif
	if (strEQ(name, "gdTransparent"))
#ifdef gdTransparent
	    return gdTransparent;
#else
	    goto not_there;
#endif
        if (strEQ(name,"gdAntiAliased"))
#ifdef gdAntiAliased
	    return gdAntiAliased;
#else
	    goto not_there;
#endif
        if (strEQ(name,"gdAntiAliased"))
#ifdef gdAntiAliased
	    return gdAntiAliased;
#else
	    goto not_there;
#endif
        if (strEQ(name,"gdArc"))
#ifdef gdArc
	  return gdArc;
#else
	    goto not_there;
#endif
        if (strEQ(name,"gdPie"))
#ifdef gdPie
	  return gdPie;
#else
	    goto not_there;
#endif
        if (strEQ(name,"gdChord"))
#ifdef gdChord
	  return gdChord;
#else
	    goto not_there;
#endif
        if (strEQ(name,"gdNoFill"))
#ifdef gdNoFill
	  return gdNoFill;
#else
	    goto not_there;
#endif
        if (strEQ(name,"gdEdged"))
#ifdef gdEdged
	  return gdEdged;
#else
	    goto not_there;
#endif
		if (strEQ(name,"gdAlphaMax"))
#ifdef gdAlphaMax
		return gdAlphaMax;
#else
		goto not_there;
#endif
		if (strEQ(name,"gdAlphaOpaque"))
#ifdef gdAlphaOpaque
		return gdAlphaOpaque;
#else
		goto not_there;
#endif
		if (strEQ(name,"gdAlphaTransparent"))
#ifdef gdAlphaTransparent
		return gdAlphaTransparent;
#else
		goto not_there;
#endif

	break;
    case 'h':
	break;
    case 'i':
	break;
    case 'j':
	break;
    case 'k':
	break;
    case 'l':
	break;
    case 'm':
	break;
    case 'n':
	break;
    case 'o':
	break;
    case 'p':
	break;
    case 'q':
	break;
    case 'r':
	break;
    case 's':
	break;
    case 't':
	break;
    case 'u':
	break;
    case 'v':
	break;
    case 'w':
	break;
    case 'x':
	break;
    case 'y':
	break;
    case 'z':
	break;
    }
    errno = EINVAL;
    return 0;

not_there:
    errno = ENOENT;
    return 0;
}

typedef gdImagePtr	GD__Image;
typedef gdFontPtr	GD__Font;
typedef PerlIO          * InputStream;
extern 	gdFontPtr	gdFontGiant;
extern 	gdFontPtr	gdFontLarge;
extern	gdFontPtr	gdFontSmall;
extern	gdFontPtr	gdFontMediumBold;
extern	gdFontPtr	gdFontTiny;

#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 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)
#  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 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)
#  else
#define GDIMAGECREATEFROMPNG(x) gdImageCreateFromPng(x)
#define GDIMAGECREATEFROMXBM(x) gdImageCreateFromXbm(x)
#define GDIMAGECREATEFROMJPEG(x) gdImageCreateFromJpeg(x)
#define GDIMAGECREATEFROMGIF(x) gdImageCreateFromJpeg(x)
#define GDIMAGECREATEFROMWBMP(x) gdImageCreateFromWBMP(x)
#define GDIMAGECREATEFROMGD(x) gdImageCreateFromGd(x)
#define GDIMAGECREATEFROMGD2(x) gdImageCreateFromGd2(x)
#define GDIMAGECREATEFROMGD2PART(x,a,b,c,d) gdImageCreateFromGd2Part(x,a,b,c,d)
#  endif
#endif

#define bigendian(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;
  
  Newz(0,ctx,1,bufIOCtx);
  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);
  } else {
     int i;
     dst = (GD__Image) gdImageCreatePalette(x,y);
     /* 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))

/* Current image true color default
 *  0 - create palette based images by default
 *  1 - create true color images by default
 */
static int truecolor_default = 0;

/* 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);
     }
  }
}

#line 522 "GD.c"
XS(XS_GD_constant); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD_constant)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::constant(name, arg)");
    {
	char *	name = (char *)SvPV_nolen(ST(0));
	int	arg = (int)SvIV(ST(1));
	double	RETVAL;
	dXSTARG;

	RETVAL = constant(name, arg);
	XSprePUSH; PUSHn((double)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_trueColor); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_trueColor)
{
    dXSARGS;
    {
	char *	packname;
#line 529 "GD.xs"
        int previous_value;
#line 549 "GD.c"
	int	RETVAL;
	dXSTARG;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 531 "GD.xs"
	{
	  previous_value = truecolor_default;
          if (items > 1)
	    truecolor_default = (int)SvIV(ST(1));
          RETVAL = previous_value;
	}
#line 565 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__new); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__new)
{
    dXSARGS;
    {
	char *	packname;
	int	x;
	int	y;
#line 547 "GD.xs"
	int truecolor = truecolor_default;
#line 581 "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 549 "GD.xs"
	{
		gdImagePtr theImage;
                if (items > 3)
		  truecolor = (int)SvIV(ST(3));
		if (truecolor) {
		   theImage = (GD__Image) gdImageCreateTrueColor(x,y);
		} else {
		   theImage = (GD__Image) gdImageCreate(x,y);
		}
		RETVAL = theImage;
	}
#line 613 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__newFromPng); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromPng)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromPng(packname=\"GD::Image\", filehandle, ...)");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)));
#line 569 "GD.xs"
	int truecolor = truecolor_default;
#line 631 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 571 "GD.xs"
	RETVAL = (GD__Image) GDIMAGECREATEFROMPNG(filehandle);
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#line 643 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_newFromPngData); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_newFromPngData)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::newFromPngData(packname=\"GD::Image\", imageData, ...)");
    {
	char *	packname;
	SV *	imageData = ST(1);
#line 583 "GD.xs"
	  gdIOCtx* ctx;
          char*    data;
          STRLEN   len;
	  int truecolor = truecolor_default;
#line 664 "GD.c"
	GD__Image	RETVAL;

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

XS(XS_GD__Image_newFromGdData); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_newFromGdData)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Image::newFromGdData(packname=\"GD::Image\", imageData)");
    {
	char *	packname;
	SV *	imageData = ST(1);
#line 603 "GD.xs"
	  gdIOCtx* ctx;
          char*    data;
          STRLEN   len;
#line 699 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 607 "GD.xs"
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromGdCtx(ctx);
        (ctx->gd_free)(ctx);
#line 712 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_newFromGd2Data); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_newFromGd2Data)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Image::newFromGd2Data(packname=\"GD::Image\", imageData)");
    {
	char *	packname;
	SV *	imageData = ST(1);
#line 620 "GD.xs"
	  gdIOCtx* ctx;
          char*    data;
          STRLEN   len;
#line 732 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 624 "GD.xs"
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromGd2Ctx(ctx);
        (ctx->gd_free)(ctx);
#line 745 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_newFromJpegData); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_newFromJpegData)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::newFromJpegData(packname=\"GD::Image\", imageData, ...)");
    {
	char *	packname;
	SV *	imageData = ST(1);
#line 637 "GD.xs"
	  gdIOCtx* ctx;
          char*    data;
          STRLEN   len;
	  SV* errormsg;
          int     truecolor = truecolor_default;
#line 767 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 643 "GD.xs"
#ifdef HAVE_JPEG
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromJpegCtx(ctx);
        (ctx->gd_free)(ctx);
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#else
        errormsg = perl_get_sv("@",0);
        sv_setpv(errormsg,"libgd was not built with jpeg support\n");
        XSRETURN_EMPTY;
#endif
#line 788 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_newFromWBMPData); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_newFromWBMPData)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::newFromWBMPData(packname=\"GD::Image\", imageData, ...)");
    {
	char *	packname;
	SV *	imageData = ST(1);
#line 664 "GD.xs"
	  gdIOCtx* ctx;
          char*    data;
          STRLEN   len;
         int     truecolor = truecolor_default;
#line 809 "GD.c"
	GD__Image	RETVAL;

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

XS(XS_GD__Image__newFromXbm); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromXbm)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromXbm(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 684 "GD.xs"
	RETVAL = GDIMAGECREATEFROMXBM(filehandle);
#line 849 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__newFromGd); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromGd)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromGd(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 694 "GD.xs"
	RETVAL = GDIMAGECREATEFROMGD(filehandle);
#line 874 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__newFromGd2); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromGd2)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromGd2(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 704 "GD.xs"
	RETVAL = GDIMAGECREATEFROMGD2(filehandle);
#line 899 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__newFromJpeg); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromJpeg)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromJpeg(packname=\"GD::Image\", filehandle, ...)");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)));
#line 714 "GD.xs"
	  gdImagePtr img;
	  SV* errormsg;
          int     truecolor = truecolor_default;
#line 919 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 718 "GD.xs"
#ifdef HAVE_JPEG
	img = GDIMAGECREATEFROMJPEG(filehandle);
        if (img == NULL) {
          errormsg = perl_get_sv("@",0);
	  if (errormsg != NULL)
	    sv_setpv(errormsg,"libgd was not built with jpeg support\n");
	  XSRETURN_EMPTY;
        }
        RETVAL = img;
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#else
        errormsg = perl_get_sv("@",0);
        sv_setpv(errormsg,"libgd was not built with jpeg support\n");
        XSRETURN_EMPTY;
#endif
#line 944 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__newFromWBMP); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromWBMP)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromWBMP(packname=\"GD::Image\", filehandle)");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)));
#line 743 "GD.xs"
	  gdImagePtr img;
	  SV* errormsg;
#line 963 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 746 "GD.xs"
	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");
	  XSRETURN_EMPTY;
        }
        RETVAL = img;
#line 980 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

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

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 766 "GD.xs"
#ifdef HAVE_XPM
        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");
            XSRETURN_EMPTY;
        }
        RETVAL = img;
#else
        errormsg = perl_get_sv("@",0);
        sv_setpv(errormsg,"libgd was not built with xpm support\n");
        XSRETURN_EMPTY;
#endif
#line 1022 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__newFromGd2Part); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromGd2Part)
{
    dXSARGS;
    if (items < 5 || items > 6)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromGd2Part(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 793 "GD.xs"
	RETVAL = GDIMAGECREATEFROMGD2PART(filehandle,srcX,srcY,width,height);
#line 1051 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image__newFromGif); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image__newFromGif)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::_newFromGif(packname=\"GD::Image\", filehandle, ...)");
    {
	char *	packname;
	InputStream	filehandle = IoIFP(sv_2io(ST(1)));
#line 803 "GD.xs"
	  gdImagePtr img;
	  SV* errormsg;
          int     truecolor = truecolor_default;
#line 1071 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 807 "GD.xs"
#ifdef HAVE_GIF
	img = GDIMAGECREATEFROMGIF(filehandle);
        if (img == NULL) {
          errormsg = perl_get_sv("@",0);
	  if (errormsg != NULL)
	    sv_setpv(errormsg,"libgd was not built with jpeg support\n");
	  XSRETURN_EMPTY;
        }
        RETVAL = img;
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#else
        errormsg = perl_get_sv("@",0);
        sv_setpv(errormsg,"libgd was not built with gif support\n");
        XSRETURN_EMPTY;
#endif
#line 1096 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_newFromGifData); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_newFromGifData)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::newFromGifData(packname=\"GD::Image\", imageData, ...)");
    {
	char *	packname;
	SV *	imageData = ST(1);
#line 832 "GD.xs"
	  gdIOCtx* ctx;
          char*    data;
          STRLEN   len;
	  SV* errormsg;
          int     truecolor = truecolor_default;
#line 1118 "GD.c"
	GD__Image	RETVAL;

	if (items < 1)
	    packname = "GD::Image";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 838 "GD.xs"
#ifdef HAVE_JPEG
	data = SvPV(imageData,len);
        ctx = newDynamicCtx(data,len);
	RETVAL = (GD__Image) gdImageCreateFromGifCtx(ctx);
        (ctx->gd_free)(ctx);
        if (items > 2) truecolor = (int)SvIV(ST(2));
	gd_chkimagefmt(RETVAL, truecolor);
#else
        errormsg = perl_get_sv("@",0);
        sv_setpv(errormsg,"libgd was not built with GIF support\n");
        XSRETURN_EMPTY;
#endif
#line 1139 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Image", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::DESTROY(image)");
    {
	GD__Image	image;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not a reference");
#line 858 "GD.xs"
	{
		gdImageDestroy(image);
	}
#line 1165 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_png); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_png)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::png(image, ...)");
    {
	GD__Image	image;
	SV *	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 867 "GD.xs"
  {
	void*         data;
	int           size;
	int           level;
        if (items > 1) {
	  level = (int)SvIV(ST(1));
	  data  = (void *) gdImagePngPtrEx(image,&size,level);
	} else {
	  data = (void *) gdImagePngPtr(image,&size);
	}
	RETVAL = newSVpv((char*) data,size);
	gdFree(data);
  }
#line 1200 "GD.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_GD__Image_jpeg); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_jpeg)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Image::jpeg(image, quality=-1)");
    {
	GD__Image	image;
	int	quality;
#line 889 "GD.xs"
  SV* errormsg;
#line 1218 "GD.c"
	SV *	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

	if (items < 2)
	    quality = -1;
	else {
	    quality = (int)SvIV(ST(1));
	}
#line 891 "GD.xs"
  {
	void*         data;
	int           size;
#ifdef HAVE_JPEG
	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");
	  XSRETURN_EMPTY;
        }
	RETVAL = newSVpv((char*) data,size);
	gdFree(data);
#else
        errormsg = perl_get_sv("@",0);
        sv_setpv(errormsg,"libgd was not built with jpeg support\n");
        XSRETURN_EMPTY;
#endif
  }
#line 1253 "GD.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_GD__Image_wbmp); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_wbmp)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::wbmp(image, fg)");
    {
	GD__Image	image;
	int	fg = (int)SvIV(ST(1));
#line 919 "GD.xs"
  SV* errormsg;
#line 1271 "GD.c"
	SV *	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 921 "GD.xs"
  {
	void*         data;
	int           size;
	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");
	  XSRETURN_EMPTY;
        }
	RETVAL = newSVpv((char*) data,size);
	gdFree(data);
  }
#line 1294 "GD.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_GD__Image_gif); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_gif)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::gif(image)");
    {
	GD__Image	image;
#line 942 "GD.xs"
  SV* errormsg;
#line 1311 "GD.c"
	SV *	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 944 "GD.xs"
  {
	void*         data;
	int           size;
#ifdef HAVE_GIF
	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");
	  XSRETURN_EMPTY;
        }
	RETVAL = newSVpv((char*) data,size);
	gdFree(data);
#else
        errormsg = perl_get_sv("@",0);
        sv_setpv(errormsg,"libgd was not built with gif support\n");
        XSRETURN_EMPTY;
#endif
  }
#line 1340 "GD.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_GD__Image_gd); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_gd)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::gd(image)");
    {
	GD__Image	image;
	SV *	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 971 "GD.xs"
  {
	void*         data;
	int           size;
	data = gdImageGdPtr(image,&size);
	RETVAL = newSVpv((char*) data,size);
	gdFree(data);
  }
#line 1371 "GD.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_GD__Image_gd2); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_gd2)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::gd2(image)");
    {
	GD__Image	image;
	SV *	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 986 "GD.xs"
  {
	void*         data;
	int           size;
	data = gdImageGd2Ptr(image,0,GD2_FMT_COMPRESSED,&size);
	RETVAL = newSVpv((char*) data,size);
	gdFree(data);
  }
#line 1402 "GD.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_GD__Image_transparent); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_transparent)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::transparent(image, ...)");
    {
	GD__Image	image;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1001 "GD.xs"
	{
		int color;
		if (items > 1) {
			color=(int)SvIV(ST(1));
			gdImageColorTransparent(image,color);
		}
		RETVAL = gdImageGetTransparent(image);
	}
#line 1435 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_getBounds); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_getBounds)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::getBounds(image)");
    SP -= items;
    {
	GD__Image	image;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1017 "GD.xs"
	{
		int sx,sy;
		sx = gdImageSX(image);
		sy = gdImageSY(image);
		EXTEND(sp,2);
		PUSHs(sv_2mortal(newSViv(sx)));
		PUSHs(sv_2mortal(newSViv(sy)));
	}
#line 1466 "GD.c"
	PUTBACK;
	return;
    }
}

XS(XS_GD__Image_isTrueColor); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_isTrueColor)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::isTrueColor(image)");
    {
	GD__Image	image;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1031 "GD.xs"
	{
		RETVAL=gdImageTrueColor(image);
	}
#line 1493 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_trueColorToPalette); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_trueColorToPalette)
{
    dXSARGS;
    if (items < 1 || items > 3)
	Perl_croak(aTHX_ "Usage: GD::Image::trueColorToPalette(image, dither=0, colors=gdMaxColors)");
    {
	GD__Image	image;
	int	dither;
	int	colors;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

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

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

XS(XS_GD__Image_rgb); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_rgb)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::rgb(image, color)");
    SP -= items;
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1054 "GD.xs"
	{
		int r,g,b;
		r = gdImageRed(image,color);
		g = gdImageGreen(image,color);
		b = gdImageBlue(image,color);
		EXTEND(sp,3);
		PUSHs(sv_2mortal(newSViv(r)));
		PUSHs(sv_2mortal(newSViv(g)));
		PUSHs(sv_2mortal(newSViv(b)));
	}
#line 1565 "GD.c"
	PUTBACK;
	return;
    }
}

XS(XS_GD__Image_boundsSafe); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_boundsSafe)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: GD::Image::boundsSafe(image, x, y)");
    {
	GD__Image	image;
	int	x = (int)SvIV(ST(1));
	int	y = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1072 "GD.xs"
	{
	  RETVAL=gdImageBoundsSafe(image,x,y);
	  if (RETVAL == 0)
	    XSRETURN_UNDEF;
	}
#line 1596 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_getPixel); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_getPixel)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: GD::Image::getPixel(image, x, y)");
    {
	GD__Image	image;
	int	x = (int)SvIV(ST(1));
	int	y = (int)SvIV(ST(2));
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1087 "GD.xs"
	{
		RETVAL=gdImageGetPixel(image,x,y);
	}
#line 1625 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_setPixel); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_setPixel)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: GD::Image::setPixel(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1101 "GD.xs"
	{
		gdImageSetPixel(image,x,y,color);
	}
#line 1653 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_copyRotate90); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyRotate90)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::copyRotate90(src)");
    {
	GD__Image	src;
	GD__Image	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1110 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j;
		GD__Image dst;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
		dst = (GD__Image) gd_cloneDim(src, y, x);

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

XS(XS_GD__Image_copyRotate180); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyRotate180)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::copyRotate180(src)");
    {
	GD__Image	src;
	GD__Image	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1131 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j;
		GD__Image dst;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
		dst = (GD__Image) gd_cloneDim(src, x, y);

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

XS(XS_GD__Image_copyRotate270); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyRotate270)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::copyRotate270(src)");
    {
	GD__Image	src;
	GD__Image	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1152 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j;
		GD__Image dst;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
		dst = (GD__Image) gd_cloneDim(src, y, x);

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

XS(XS_GD__Image_copyFlipHorizontal); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyFlipHorizontal)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::copyFlipHorizontal(src)");
    {
	GD__Image	src;
	GD__Image	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1173 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j;
		GD__Image dst;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
		dst = (GD__Image) gd_cloneDim(src, x, y);

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

XS(XS_GD__Image_copyFlipVertical); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyFlipVertical)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::copyFlipVertical(src)");
    {
	GD__Image	src;
	GD__Image	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1194 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j;
		GD__Image dst;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
		dst = (GD__Image) gd_cloneDim(src, x, y);

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

XS(XS_GD__Image_copyTranspose); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyTranspose)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::copyTranspose(src)");
    {
	GD__Image	src;
	GD__Image	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1215 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j;
		GD__Image dst;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
		dst = (GD__Image) gd_cloneDim(src, y, x);

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

XS(XS_GD__Image_copyReverseTranspose); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyReverseTranspose)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::copyReverseTranspose(src)");
    {
	GD__Image	src;
	GD__Image	RETVAL;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1236 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j;
		GD__Image dst;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);
		dst = (GD__Image) gd_cloneDim(src, y, x);

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

XS(XS_GD__Image_rotate180); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_rotate180)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::rotate180(src)");
    {
	GD__Image	src;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1257 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j, tmp;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);

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

XS(XS_GD__Image_flipHorizontal); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_flipHorizontal)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::flipHorizontal(src)");
    {
	GD__Image	src;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1275 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j, tmp;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);

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

XS(XS_GD__Image_flipVertical); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_flipVertical)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::flipVertical(src)");
    {
	GD__Image	src;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    src = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "src is not of type GD::Image");
#line 1293 "GD.xs"
	{
		int x, y, x1, y1, x2, y2, i, j, tmp;
		get_xformbounds(src, &x, &y, &x1, &y1, &x2, &y2);

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

XS(XS_GD__Image_line); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_line)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::line(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1316 "GD.xs"
	{
		gdImageLine(image,x1,y1,x2,y2,color);
	}
#line 2040 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_dashedLine); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_dashedLine)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::dashedLine(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1330 "GD.xs"
	{
		gdImageDashedLine(image,x1,y1,x2,y2,color);
	}
#line 2069 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_openPolygon); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_openPolygon)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: GD::Image::openPolygon(image, poly, color)");
    {
	GD__Image	image;
	SV *	poly = ST(1);
	int	color = (int)SvIV(ST(2));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1341 "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) ;
			XPUSHs(sv_2mortal(newSViv(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 2140 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_filledPolygon); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_filledPolygon)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: GD::Image::filledPolygon(image, poly, color)");
    {
	GD__Image	image;
	SV *	poly = ST(1);
	int	color = (int)SvIV(ST(2));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1397 "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) ;
			XPUSHs(sv_2mortal(newSViv(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 2211 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_rectangle); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_rectangle)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::rectangle(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1456 "GD.xs"
	{
		gdImageRectangle(image,x1,y1,x2,y2,color);
	}
#line 2240 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_filledRectangle); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_filledRectangle)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::filledRectangle(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1470 "GD.xs"
	{
		gdImageFilledRectangle(image,x1,y1,x2,y2,color);
	}
#line 2269 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_filledEllipse); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_filledEllipse)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::filledEllipse(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1484 "GD.xs"
	{
		gdImageFilledEllipse(image,cx,cy,w,h,color);
	}
#line 2298 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_arc); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_arc)
{
    dXSARGS;
    if (items != 8)
	Perl_croak(aTHX_ "Usage: GD::Image::arc(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1500 "GD.xs"
	{
		gdImageArc(image,cx,cy,w,h,s,e,color);
	}
#line 2329 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_filledArc); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_filledArc)
{
    dXSARGS;
    if (items < 8 || items > 9)
	Perl_croak(aTHX_ "Usage: GD::Image::filledArc(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

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

XS(XS_GD__Image_fillToBorder); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_fillToBorder)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: GD::Image::fillToBorder(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1530 "GD.xs"
	{
		gdImageFillToBorder(image,x,y,border,color);
	}
#line 2395 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_fill); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_fill)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: GD::Image::fill(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1542 "GD.xs"
	{
		gdImageFill(image,x,y,color);
	}
#line 2422 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_setBrush); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_setBrush)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::setBrush(image, brush)");
    {
	GD__Image	image;
	GD__Image	brush;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    brush = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "brush is not of type GD::Image");
#line 1552 "GD.xs"
	{
		gdImageSetBrush(image,brush);
	}
#line 2454 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_setTile); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_setTile)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::setTile(image, tile)");
    {
	GD__Image	image;
	GD__Image	tile;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    tile = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "tile is not of type GD::Image");
#line 1562 "GD.xs"
	{
		gdImageSetTile(image,tile);
	}
#line 2486 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_setThickness); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_setThickness)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::setThickness(image, thickness)");
    {
	GD__Image	image;
	int	thickness = (int)SvIV(ST(1));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1572 "GD.xs"
	{
	  gdImageSetThickness(image,thickness);
	}
#line 2511 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_setStyle); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_setStyle)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::setStyle(image, ...)");
    {
	GD__Image	image;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1582 "GD.xs"
	{
		int	*style;
		int	i;

		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 2547 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_colorAllocate); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorAllocate)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: GD::Image::colorAllocate(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1606 "GD.xs"
	{
		RETVAL = gdImageColorAllocate(image,r,g,b);
	}
#line 2576 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorAllocateAlpha); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorAllocateAlpha)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: GD::Image::colorAllocateAlpha(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1621 "GD.xs"
	{
		RETVAL = gdImageColorAllocateAlpha(image,r,g,b,a);
	}
#line 2607 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorClosest); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorClosest)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: GD::Image::colorClosest(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1635 "GD.xs"
	{
		RETVAL = gdImageColorClosest(image,r,g,b);
	}
#line 2637 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorClosestAlpha); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorClosestAlpha)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: GD::Image::colorClosestAlpha(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1650 "GD.xs"
	{
		RETVAL = gdImageColorClosest(image,r,g,b);
	}
#line 2668 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorClosestHWB); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorClosestHWB)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: GD::Image::colorClosestHWB(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1664 "GD.xs"
	{
		RETVAL = gdImageColorClosestHWB(image,r,g,b);
	}
#line 2698 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorExact); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorExact)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: GD::Image::colorExact(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1678 "GD.xs"
	{
		RETVAL = gdImageColorExact(image,r,g,b);
	}
#line 2728 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorExactAlpha); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorExactAlpha)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: GD::Image::colorExactAlpha(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1693 "GD.xs"
	{
		RETVAL = gdImageColorExactAlpha(image,r,g,b,a);
	}
#line 2759 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorResolve); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorResolve)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: GD::Image::colorResolve(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1707 "GD.xs"
	{
		RETVAL = gdImageColorResolve(image,r,g,b);
	}
#line 2789 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorResolveAlpha); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorResolveAlpha)
{
    dXSARGS;
    if (items != 5)
	Perl_croak(aTHX_ "Usage: GD::Image::colorResolveAlpha(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1722 "GD.xs"
	{
		RETVAL = gdImageColorResolveAlpha(image,r,g,b,a);
	}
#line 2820 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorsTotal); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorsTotal)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Image::colorsTotal(image)");
    {
	GD__Image	image;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1733 "GD.xs"
	{
	   if (gdImageTrueColor(image))
 	     XSRETURN_UNDEF;
	   RETVAL = gdImageColorsTotal(image);
	}
#line 2849 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_interlaced); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_interlaced)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::interlaced(image, ...)");
    {
	GD__Image	image;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1747 "GD.xs"
	{
	  if (items > 1) {
	    if (SvOK(ST(1)))
	      gdImageInterlace(image,1);
	    else
	      gdImageInterlace(image,0);
	  }
	  RETVAL = gdImageGetInterlaced(image);
	}
#line 2882 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_compare); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_compare)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::compare(image1, image2)");
    {
	GD__Image	image1;
	GD__Image	image2;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image1 = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image1 is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    image2 = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image2 is not of type GD::Image");
#line 1765 "GD.xs"
	{
	  RETVAL = gdImageCompare(image1,image2);
	}
#line 2917 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Image_colorDeallocate); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_colorDeallocate)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::colorDeallocate(image, color)");
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 1777 "GD.xs"
	{
		gdImageColorDeallocate(image,color);
	}
#line 2943 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_copy); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copy)
{
    dXSARGS;
    if (items != 8)
	Perl_croak(aTHX_ "Usage: GD::Image::copy(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "destination is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "source is not of type GD::Image");
#line 1793 "GD.xs"
	{
		gdImageCopy(destination,source,dstX,dstY,srcX,srcY,w,h);
	}
#line 2981 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_copyResized); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyResized)
{
    dXSARGS;
    if (items != 10)
	Perl_croak(aTHX_ "Usage: GD::Image::copyResized(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "destination is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "source is not of type GD::Image");
#line 1811 "GD.xs"
	{
		gdImageCopyResized(destination,source,dstX,dstY,srcX,srcY,destW,destH,srcW,srcH);
	}
#line 3021 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_copyResampled); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyResampled)
{
    dXSARGS;
    if (items != 10)
	Perl_croak(aTHX_ "Usage: GD::Image::copyResampled(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "destination is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "source is not of type GD::Image");
#line 1829 "GD.xs"
	{
		gdImageCopyResampled(destination,source,dstX,dstY,srcX,srcY,destW,destH,srcW,srcH);
	}
#line 3061 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_copyMerge); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyMerge)
{
    dXSARGS;
    if (items != 9)
	Perl_croak(aTHX_ "Usage: GD::Image::copyMerge(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "destination is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "source is not of type GD::Image");
#line 1846 "GD.xs"
	{
		gdImageCopyMerge(destination,source,dstX,dstY,srcX,srcY,w,h,pct);
	}
#line 3100 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_copyMergeGray); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_copyMergeGray)
{
    dXSARGS;
    if (items != 9)
	Perl_croak(aTHX_ "Usage: GD::Image::copyMergeGray(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "destination is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "source is not of type GD::Image");
#line 1863 "GD.xs"
	{
		gdImageCopyMergeGray(destination,source,dstX,dstY,srcX,srcY,w,h,pct);
	}
#line 3139 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_paletteCopy); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_paletteCopy)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::paletteCopy(destination, source)");
    {
	GD__Image	destination;
	GD__Image	source;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    destination = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "destination is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    source = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "source is not of type GD::Image");
#line 1873 "GD.xs"
	{
		gdImagePaletteCopy(destination,source);
	}
#line 3171 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_char); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_char)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::char(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 1887 "GD.xs"
	{
		gdImageChar(image,font,x,y,*c,color);
	}
#line 3207 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_charUp); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_charUp)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::charUp(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 1901 "GD.xs"
	{
		gdImageCharUp(image,font,x,y,*c,color);
	}
#line 3243 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_string); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_string)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::string(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 1915 "GD.xs"
	{
		gdImageString(image,font,x,y,(unsigned char*)s,color);
	}
#line 3279 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_stringUp); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_stringUp)
{
    dXSARGS;
    if (items != 6)
	Perl_croak(aTHX_ "Usage: GD::Image::stringUp(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 (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

	if (sv_derived_from(ST(1), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 1929 "GD.xs"
	{
		gdImageStringUp(image,font,x,y,(unsigned char*)s,color);
	}
#line 3315 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_stringFT); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_stringFT)
{
    dXSARGS;
    if (items < 8)
	Perl_croak(aTHX_ "Usage: GD::Image::stringFT(image, fgcolor, fontname, ptsize, angle, x, y, string, ...)");
    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 1945 "GD.xs"
	  gdImagePtr img;
	  int        brect[8];
	  char       *err;
	  SV*        errormsg;
          HV*        hash;
          SV**       value;
	  int        i;
          gdFTStringExtra strex;
#line 3345 "GD.c"
#line 1954 "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_fetch(hash,"linespacing",strlen("linespacing"),0)) {
	      strex.flags |= gdFTEX_LINESPACE;
	      strex.linespacing = SvNV(*value);
	    }
	    if (value = hv_fetch(hash,"charmap",strlen("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));
	    }
	    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++) {
	      PUSHs(sv_2mortal(newSViv(brect[i])));
	    }
	  }

	}
#line 3401 "GD.c"
	PUTBACK;
	return;
    }
}

XS(XS_GD__Image_alphaBlending); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_alphaBlending)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::alphaBlending(image, blending)");
    {
	GD__Image	image;
	int	blending = (int)SvIV(ST(1));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 2015 "GD.xs"
{
  gdImageAlphaBlending(image,blending);
}
#line 3427 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_saveAlpha); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_saveAlpha)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::saveAlpha(image, saveAlphaArg)");
    {
	GD__Image	image;
	int	saveAlphaArg = (int)SvIV(ST(1));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 2025 "GD.xs"
{
  gdImageSaveAlpha(image,saveAlphaArg) ;
}
#line 3452 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_clip); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_clip)
{
    dXSARGS;
    if (items < 1)
	Perl_croak(aTHX_ "Usage: GD::Image::clip(image, ...)");
    SP -= items;
    {
	GD__Image	image;
#line 2034 "GD.xs"
        int		coords[4];
        int             i;
#line 3469 "GD.c"

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 2037 "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++)
	    PUSHs(sv_2mortal(newSViv(coords[i])));
	}
#line 3492 "GD.c"
	PUTBACK;
	return;
    }
}

XS(XS_GD__Image_setAntiAliased); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_setAntiAliased)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: GD::Image::setAntiAliased(image, color)");
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1));

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");
#line 2058 "GD.xs"
{
  gdImageSetAntiAliased(image,color);
}
#line 3518 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Image_setAntiAliasedDontBlend); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Image_setAntiAliasedDontBlend)
{
    dXSARGS;
    if (items < 2 || items > 3)
	Perl_croak(aTHX_ "Usage: GD::Image::setAntiAliasedDontBlend(image, color, flag=1)");
    {
	GD__Image	image;
	int	color = (int)SvIV(ST(1));
	int	flag;

	if (sv_derived_from(ST(0), "GD::Image")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    image = INT2PTR(GD__Image,tmp);
	}
	else
	    Perl_croak(aTHX_ "image is not of type GD::Image");

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

XS(XS_GD__Font_load); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_load)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: GD::Font::load(packname=\"GD::Font\", fontpath)");
    {
	char *	packname;
	char *	fontpath = (char *)SvPV_nolen(ST(1));
#line 2083 "GD.xs"
       int       fontfile;
       int       datasize;
       SV*       errormsg;
       char      errstr[256];
       gdFontPtr font;
       char      word[4];
       char*     fontdata;
#line 3572 "GD.c"
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 2091 "GD.xs"
     {
       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 bigendian*/
       if (read(fontfile,word,4) < 4)
	 croak(strerror(errno));
       font->nchars = bigendian(word);

       if (read(fontfile,word,4) < 4)
	 croak(strerror(errno));
       font->offset = bigendian(word);

       if (read(fontfile,word,4) < 4)
	 croak(strerror(errno));
       font->w = bigendian(word);

       if (read(fontfile,word,4) < 4)
	 croak(strerror(errno));
       font->h = bigendian(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(strerror(errno));

       font->data = fontdata;

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

XS(XS_GD__Font_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Font::DESTROY(self)");
    {
	GD__Font	self;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    self = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "self is not a reference");
#line 2140 "GD.xs"
     {
       if (self == gdFontSmall ||
	   self == gdFontLarge ||
	   self == gdFontGiant ||
	   self == gdFontMediumBold ||
	   self == gdFontTiny)
	 XSRETURN_EMPTY;
       safefree(self->data);
       safefree(self);
     }
#line 3655 "GD.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_GD__Font_Small); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_Small)
{
    dXSARGS;
    if (items < 0 || items > 1)
	Perl_croak(aTHX_ "Usage: GD::Font::Small(packname=\"GD::Font\")");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 2156 "GD.xs"
	{
		RETVAL = gdFontSmall;
	}
#line 3679 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Font", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_Large); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_Large)
{
    dXSARGS;
    if (items < 0 || items > 1)
	Perl_croak(aTHX_ "Usage: GD::Font::Large(packname=\"GD::Font\")");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 2167 "GD.xs"
	{
		RETVAL = gdFontLarge;
	}
#line 3705 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Font", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_Giant); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_Giant)
{
    dXSARGS;
    if (items < 0 || items > 1)
	Perl_croak(aTHX_ "Usage: GD::Font::Giant(packname=\"GD::Font\")");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 2178 "GD.xs"
	{
		RETVAL = gdFontGiant;
	}
#line 3731 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Font", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_MediumBold); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_MediumBold)
{
    dXSARGS;
    if (items < 0 || items > 1)
	Perl_croak(aTHX_ "Usage: GD::Font::MediumBold(packname=\"GD::Font\")");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 2189 "GD.xs"
	{
		RETVAL = gdFontMediumBold;
	}
#line 3757 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Font", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_Tiny); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_Tiny)
{
    dXSARGS;
    if (items < 0 || items > 1)
	Perl_croak(aTHX_ "Usage: GD::Font::Tiny(packname=\"GD::Font\")");
    {
	char *	packname;
	GD__Font	RETVAL;

	if (items < 1)
	    packname = "GD::Font";
	else {
	    packname = (char *)SvPV_nolen(ST(0));
	}
#line 2200 "GD.xs"
	{
		RETVAL = gdFontTiny;
	}
#line 3783 "GD.c"
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "GD::Font", (void*)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_nchars); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_nchars)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Font::nchars(font)");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 2211 "GD.xs"
	{
		RETVAL = font->nchars;
	}
#line 3811 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_offset); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_offset)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Font::offset(font)");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 2222 "GD.xs"
	{
		RETVAL = font->offset;
	}
#line 3838 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_width); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_width)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Font::width(font)");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 2233 "GD.xs"
	{
		RETVAL = font->w;
	}
#line 3865 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_GD__Font_height); /* prototype to pass -Wmissing-prototypes */
XS(XS_GD__Font_height)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: GD::Font::height(font)");
    {
	GD__Font	font;
	int	RETVAL;
	dXSTARG;

	if (sv_derived_from(ST(0), "GD::Font")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    font = INT2PTR(GD__Font,tmp);
	}
	else
	    Perl_croak(aTHX_ "font is not of type GD::Font");
#line 2244 "GD.xs"
	{
		RETVAL = font->h;
	}
#line 3892 "GD.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef __cplusplus
extern "C"
#endif
XS(boot_GD); /* prototype to pass -Wmissing-prototypes */
XS(boot_GD)
{
    dXSARGS;
    char* file = __FILE__;

    XS_VERSION_BOOTCHECK ;

        newXS("GD::constant", XS_GD_constant, file);
        newXSproto("GD::Image::trueColor", XS_GD__Image_trueColor, file, "$$");
        newXSproto("GD::Image::_new", XS_GD__Image__new, file, "$;$$$");
        newXSproto("GD::Image::_newFromPng", XS_GD__Image__newFromPng, file, "$$;$");
        newXSproto("GD::Image::newFromPngData", XS_GD__Image_newFromPngData, file, "$$;$");
        newXSproto("GD::Image::newFromGdData", XS_GD__Image_newFromGdData, file, "$$");
        newXSproto("GD::Image::newFromGd2Data", XS_GD__Image_newFromGd2Data, file, "$$");
        newXSproto("GD::Image::newFromJpegData", XS_GD__Image_newFromJpegData, file, "$$;$");
        newXSproto("GD::Image::newFromWBMPData", XS_GD__Image_newFromWBMPData, file, "$$;$");
        newXSproto("GD::Image::_newFromXbm", XS_GD__Image__newFromXbm, file, "$$");
        newXSproto("GD::Image::_newFromGd", XS_GD__Image__newFromGd, file, "$$");
        newXSproto("GD::Image::_newFromGd2", XS_GD__Image__newFromGd2, file, "$$");
        newXSproto("GD::Image::_newFromJpeg", XS_GD__Image__newFromJpeg, file, "$$;$");
        newXSproto("GD::Image::_newFromWBMP", XS_GD__Image__newFromWBMP, file, "$$");
        newXSproto("GD::Image::newFromXpm", XS_GD__Image_newFromXpm, file, "$$");
        newXSproto("GD::Image::_newFromGd2Part", XS_GD__Image__newFromGd2Part, file, "$$$$$$");
        newXSproto("GD::Image::_newFromGif", XS_GD__Image__newFromGif, file, "$$;$");
        newXSproto("GD::Image::newFromGifData", XS_GD__Image_newFromGifData, file, "$$;$");
        newXSproto("GD::Image::DESTROY", XS_GD__Image_DESTROY, file, "$");
        newXSproto("GD::Image::png", XS_GD__Image_png, file, "$;$");
        newXSproto("GD::Image::jpeg", XS_GD__Image_jpeg, file, "$");
        newXSproto("GD::Image::wbmp", XS_GD__Image_wbmp, file, "$");
        newXSproto("GD::Image::gif", XS_GD__Image_gif, file, "$");
        newXSproto("GD::Image::gd", XS_GD__Image_gd, file, "$");
        newXSproto("GD::Image::gd2", XS_GD__Image_gd2, file, "$");
        newXSproto("GD::Image::transparent", XS_GD__Image_transparent, file, "$;$");
        newXSproto("GD::Image::getBounds", XS_GD__Image_getBounds, file, "$");
        newXSproto("GD::Image::isTrueColor", XS_GD__Image_isTrueColor, file, "$");
        newXSproto("GD::Image::trueColorToPalette", XS_GD__Image_trueColorToPalette, file, "$;$$");
        newXSproto("GD::Image::rgb", XS_GD__Image_rgb, file, "$$");
        newXSproto("GD::Image::boundsSafe", XS_GD__Image_boundsSafe, file, "$$$");
        newXSproto("GD::Image::getPixel", XS_GD__Image_getPixel, file, "$$$");
        newXSproto("GD::Image::setPixel", XS_GD__Image_setPixel, file, "$$$$");
        newXSproto("GD::Image::copyRotate90", XS_GD__Image_copyRotate90, file, "$");
        newXSproto("GD::Image::copyRotate180", XS_GD__Image_copyRotate180, file, "$");
        newXSproto("GD::Image::copyRotate270", XS_GD__Image_copyRotate270, file, "$");
        newXSproto("GD::Image::copyFlipHorizontal", XS_GD__Image_copyFlipHorizontal, file, "$");
        newXSproto("GD::Image::copyFlipVertical", XS_GD__Image_copyFlipVertical, file, "$");
        newXSproto("GD::Image::copyTranspose", XS_GD__Image_copyTranspose, file, "$");
        newXSproto("GD::Image::copyReverseTranspose", XS_GD__Image_copyReverseTranspose, file, "$");
        newXSproto("GD::Image::rotate180", XS_GD__Image_rotate180, file, "$");
        newXSproto("GD::Image::flipHorizontal", XS_GD__Image_flipHorizontal, file, "$");
        newXSproto("GD::Image::flipVertical", XS_GD__Image_flipVertical, file, "$");
        newXSproto("GD::Image::line", XS_GD__Image_line, file, "$$$$$$");
        newXSproto("GD::Image::dashedLine", XS_GD__Image_dashedLine, file, "$$$$$$");
        newXSproto("GD::Image::openPolygon", XS_GD__Image_openPolygon, file, "$$$");
        newXSproto("GD::Image::filledPolygon", XS_GD__Image_filledPolygon, file, "$$$");
        newXSproto("GD::Image::rectangle", XS_GD__Image_rectangle, file, "$$$$$$");
        newXSproto("GD::Image::filledRectangle", XS_GD__Image_filledRectangle, file, "$$$$$$");
        newXSproto("GD::Image::filledEllipse", XS_GD__Image_filledEllipse, file, "$$$$$$");
        newXSproto("GD::Image::arc", XS_GD__Image_arc, file, "$$$$$$$$");
        newXSproto("GD::Image::filledArc", XS_GD__Image_filledArc, file, "$$$$$$$$$");
        newXSproto("GD::Image::fillToBorder", XS_GD__Image_fillToBorder, file, "$$$$$");
        newXSproto("GD::Image::fill", XS_GD__Image_fill, file, "$$$$");
        newXSproto("GD::Image::setBrush", XS_GD__Image_setBrush, file, "$$");
        newXSproto("GD::Image::setTile", XS_GD__Image_setTile, file, "$$");
        newXSproto("GD::Image::setThickness", XS_GD__Image_setThickness, file, "$$");
        newXSproto("GD::Image::setStyle", XS_GD__Image_setStyle, file, "$;$");
        newXSproto("GD::Image::colorAllocate", XS_GD__Image_colorAllocate, file, "$$$$");
        newXSproto("GD::Image::colorAllocateAlpha", XS_GD__Image_colorAllocateAlpha, file, "$$$$");
        newXSproto("GD::Image::colorClosest", XS_GD__Image_colorClosest, file, "$$$$");
        newXSproto("GD::Image::colorClosestAlpha", XS_GD__Image_colorClosestAlpha, file, "$$$$");
        newXSproto("GD::Image::colorClosestHWB", XS_GD__Image_colorClosestHWB, file, "$$$$");
        newXSproto("GD::Image::colorExact", XS_GD__Image_colorExact, file, "$$$$");
        newXSproto("GD::Image::colorExactAlpha", XS_GD__Image_colorExactAlpha, file, "$$$$");
        newXSproto("GD::Image::colorResolve", XS_GD__Image_colorResolve, file, "$$$$");
        newXSproto("GD::Image::colorResolveAlpha", XS_GD__Image_colorResolveAlpha, file, "$$$$");
        newXSproto("GD::Image::colorsTotal", XS_GD__Image_colorsTotal, file, "$");
        newXSproto("GD::Image::interlaced", XS_GD__Image_interlaced, file, "$;$");
        newXSproto("GD::Image::compare", XS_GD__Image_compare, file, "$$");
        newXSproto("GD::Image::colorDeallocate", XS_GD__Image_colorDeallocate, file, "$$");
        newXSproto("GD::Image::copy", XS_GD__Image_copy, file, "$$$$$$$$");
        newXSproto("GD::Image::copyResized", XS_GD__Image_copyResized, file, "$$$$$$$$$$");
        newXSproto("GD::Image::copyResampled", XS_GD__Image_copyResampled, file, "$$$$$$$$$$");
        newXSproto("GD::Image::copyMerge", XS_GD__Image_copyMerge, file, "$$$$$$$$$");
        newXSproto("GD::Image::copyMergeGray", XS_GD__Image_copyMergeGray, file, "$$$$$$$$$");
        newXSproto("GD::Image::paletteCopy", XS_GD__Image_paletteCopy, file, "$$");
        newXSproto("GD::Image::char", XS_GD__Image_char, file, "$$$$$$");
        newXSproto("GD::Image::charUp", XS_GD__Image_charUp, file, "$$$$$$");
        newXSproto("GD::Image::string", XS_GD__Image_string, file, "$$$$$$");
        newXSproto("GD::Image::stringUp", XS_GD__Image_stringUp, file, "$$$$$$");
        newXSproto("GD::Image::stringFT", XS_GD__Image_stringFT, file, "$$$$$$$$;$");
        newXSproto("GD::Image::alphaBlending", XS_GD__Image_alphaBlending, file, "$$");
        newXSproto("GD::Image::saveAlpha", XS_GD__Image_saveAlpha, file, "$$");
        newXSproto("GD::Image::clip", XS_GD__Image_clip, file, "$;$$$$");
        newXSproto("GD::Image::setAntiAliased", XS_GD__Image_setAntiAliased, file, "$$");
        newXSproto("GD::Image::setAntiAliasedDontBlend", XS_GD__Image_setAntiAliasedDontBlend, file, "$$$");
        newXSproto("GD::Font::load", XS_GD__Font_load, file, "$$");
        newXSproto("GD::Font::DESTROY", XS_GD__Font_DESTROY, file, "$");
        newXSproto("GD::Font::Small", XS_GD__Font_Small, file, "$");
        newXSproto("GD::Font::Large", XS_GD__Font_Large, file, "$");
        newXSproto("GD::Font::Giant", XS_GD__Font_Giant, file, "$");
        newXSproto("GD::Font::MediumBold", XS_GD__Font_MediumBold, file, "$");
        newXSproto("GD::Font::Tiny", XS_GD__Font_Tiny, file, "$");
        newXSproto("GD::Font::nchars", XS_GD__Font_nchars, file, "$");
        newXSproto("GD::Font::offset", XS_GD__Font_offset, file, "$");
        newXSproto("GD::Font::width", XS_GD__Font_width, file, "$");
        newXSproto("GD::Font::height", XS_GD__Font_height, file, "$");
    XSRETURN_YES;
}

