xref: /PHP-7.1/ext/gd/libgd/gd_ss.c (revision 75d36222)
1 #include <stdio.h>
2 #include <math.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include "gd.h"
6 
7 #define TRUE 1
8 #define FALSE 0
9 
10 /* Exported functions: */
11 extern void gdImagePngToSink (gdImagePtr im, gdSinkPtr out);
12 extern gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource);
13 
14 /* Use this for commenting out debug-print statements. */
15 /* Just use the first '#define' to allow all the prints... */
16 /*#define GD_SS_DBG(s) (s) */
17 #define GD_SS_DBG(s)
18 
19 #ifdef HAVE_LIBPNG
gdImagePngToSink(gdImagePtr im,gdSinkPtr outSink)20 void gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
21 {
22 	gdIOCtx *out = gdNewSSCtx(NULL, outSink);
23 	gdImagePngCtx(im, out);
24 	out->gd_free(out);
25 }
26 
gdImageCreateFromPngSource(gdSourcePtr inSource)27 gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource)
28 {
29 	gdIOCtx *in = gdNewSSCtx(inSource, NULL);
30 	gdImagePtr im;
31 
32 	im = gdImageCreateFromPngCtx(in);
33 
34 	in->gd_free(in);
35 
36 	return im;
37 }
38 #else /* no HAVE_LIBPNG */
gdImagePngToSink(gdImagePtr im,gdSinkPtr outSink)39 void gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
40 {
41 	php_gd_error("PNG support is not available");
42 }
gdImageCreateFromPngSource(gdSourcePtr inSource)43 gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource)
44 {
45 	php_gd_error("PNG support is not available");
46 	return NULL;
47 }
48 #endif /* HAVE_LIBPNG */
49 
50