write.c 608 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <grass/config.h>
  5. #include <grass/gis.h>
  6. #include "pngdriver.h"
  7. void write_image(void)
  8. {
  9. char *p = png.file_name + strlen(png.file_name) - 4;
  10. if (!png.modified)
  11. return;
  12. if (png.mapped)
  13. return;
  14. if (G_strcasecmp(p, ".ppm") == 0) {
  15. write_ppm();
  16. if (png.has_alpha)
  17. write_pgm();
  18. }
  19. else if (G_strcasecmp(p, ".bmp") == 0)
  20. write_bmp();
  21. #ifdef HAVE_PNG_H
  22. else if (G_strcasecmp(p, ".png") == 0)
  23. write_png();
  24. #endif
  25. else
  26. G_fatal_error("write_image: unknown file type: %s", p);
  27. png.modified = 0;
  28. }