gd_ss.c 1.1 KB

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