2002-04-13 02:03:09 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "gd.h"
|
|
|
|
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
|
|
|
|
/* Exported functions: */
|
|
|
|
extern void gdImagePngToSink (gdImagePtr im, gdSinkPtr out);
|
|
|
|
extern gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource);
|
|
|
|
|
|
|
|
/* Use this for commenting out debug-print statements. */
|
|
|
|
/* Just use the first '#define' to allow all the prints... */
|
|
|
|
/*#define GD_SS_DBG(s) (s) */
|
|
|
|
#define GD_SS_DBG(s)
|
|
|
|
|
2002-10-29 23:08:01 +00:00
|
|
|
#ifdef HAVE_LIBPNG
|
2003-03-14 16:56:38 +00:00
|
|
|
void gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
|
2002-04-13 02:03:09 +00:00
|
|
|
{
|
2003-03-14 16:56:38 +00:00
|
|
|
gdIOCtx *out = gdNewSSCtx(NULL, outSink);
|
|
|
|
gdImagePngCtx(im, out);
|
|
|
|
out->gd_free(out);
|
2002-04-13 02:03:09 +00:00
|
|
|
}
|
|
|
|
|
2003-03-14 16:56:38 +00:00
|
|
|
gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource)
|
2002-04-13 02:03:09 +00:00
|
|
|
{
|
2003-03-14 16:56:38 +00:00
|
|
|
gdIOCtx *in = gdNewSSCtx(inSource, NULL);
|
|
|
|
gdImagePtr im;
|
2002-04-13 02:03:09 +00:00
|
|
|
|
2003-03-14 16:56:38 +00:00
|
|
|
im = gdImageCreateFromPngCtx(in);
|
2002-04-13 02:03:09 +00:00
|
|
|
|
2003-03-14 16:56:38 +00:00
|
|
|
in->gd_free(in);
|
2002-04-13 02:03:09 +00:00
|
|
|
|
2003-03-14 16:56:38 +00:00
|
|
|
return im;
|
2002-04-13 02:03:09 +00:00
|
|
|
}
|
2002-10-29 23:08:01 +00:00
|
|
|
#else /* no HAVE_LIBPNG */
|
2003-03-14 16:56:38 +00:00
|
|
|
void gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
|
2002-10-29 23:08:01 +00:00
|
|
|
{
|
2003-03-14 16:56:38 +00:00
|
|
|
php_gd_error("PNG support is not available\n");
|
2002-10-29 23:08:01 +00:00
|
|
|
}
|
2003-03-14 16:56:38 +00:00
|
|
|
gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource)
|
2002-10-29 23:08:01 +00:00
|
|
|
{
|
2003-03-14 16:56:38 +00:00
|
|
|
php_gd_error("PNG support is not available\n");
|
|
|
|
return NULL;
|
2002-10-29 23:08:01 +00:00
|
|
|
}
|
|
|
|
#endif /* HAVE_LIBPNG */
|
|
|
|
|