write.c 951 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*!
  2. \file lib/pngdriver/write.c
  3. \brief GRASS png display driver - write image (lower level functions)
  4. (C) 2007-2014 by Glynn Clements and the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Glynn Clements
  8. */
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <grass/config.h>
  13. #include <grass/gis.h>
  14. #include "pngdriver.h"
  15. void write_image(void)
  16. {
  17. char *p = png.file_name + strlen(png.file_name) - 4;
  18. if (!png.modified)
  19. return;
  20. if (png.mapped)
  21. return;
  22. if (G_strcasecmp(p, ".ppm") == 0) {
  23. write_ppm();
  24. if (png.has_alpha)
  25. write_pgm();
  26. }
  27. else if (G_strcasecmp(p, ".bmp") == 0)
  28. write_bmp();
  29. #ifdef HAVE_PNG_H
  30. else if (G_strcasecmp(p, ".png") == 0)
  31. write_png();
  32. #endif
  33. else
  34. G_fatal_error("write_image: unknown file type: %s", p);
  35. png.modified = 0;
  36. }