summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/gd_ss.c
blob: 18fc50d2b90c8e27f674fc87e6434a7ff546601d (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
50

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "gd.h"

#define TRUE 1
#define FALSE 0

/* 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
BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
{
  gdIOCtx *out = gdNewSSCtx (NULL, outSink);
  gdImagePngCtx (im, out);
  out->gd_free (out);
}

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

  im = gdImageCreateFromPngCtx (in);

  in->gd_free (in);

  return im;
}
#else /* no HAVE_LIBPNG */
BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
{
  fprintf (stderr, "PNG support is not available\n");
}

BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr inSource)
{
  fprintf (stderr, "PNG support is not available\n");
  return NULL;
}
#endif /* HAVE_LIBPNG */