forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgd_ss.c
49 lines (40 loc) · 1.07 KB
/
gd_ss.c
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
#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)
{
gd_error("PNG support is not available");
}
gdImagePtr gdImageCreateFromPngSource (gdSourcePtr inSource)
{
gd_error("PNG support is not available");
return NULL;
}
#endif /* HAVE_LIBPNG */