summaryrefslogtreecommitdiff
path: root/ext/gd/libgd/gd_ss.c
blob: 08edea3eca2093770db7b4b7555d329fccb61490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#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)

#ifdef HAVE_LIBPNG
void gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
{
	gdIOCtx *out = gdNewSSCtx(NULL, outSink);
	gdImagePngCtx(im, out);
	out->gd_free(out);
}

gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource)
{
	gdIOCtx *in = gdNewSSCtx(inSource, NULL);
	gdImagePtr im;

	im = gdImageCreateFromPngCtx(in);

	in->gd_free(in);

	return im;
}
#else /* no HAVE_LIBPNG */
void gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
{
	php_gd_error("PNG support is not available");
}
gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource)
{
	php_gd_error("PNG support is not available");
	return NULL;
}
#endif /* HAVE_LIBPNG */