read.c 880 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*!
  2. \file lib/pngdriver/read.c
  3. \brief GRASS png display driver - read 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 read_image(void)
  16. {
  17. char *p = png.file_name + strlen(png.file_name) - 4;
  18. if (G_strcasecmp(p, ".ppm") == 0) {
  19. read_ppm();
  20. if (png.has_alpha)
  21. read_pgm();
  22. }
  23. else if (G_strcasecmp(p, ".bmp") == 0)
  24. read_bmp();
  25. #ifdef HAVE_PNG_H
  26. else if (G_strcasecmp(p, ".png") == 0)
  27. read_png();
  28. #endif
  29. else
  30. G_fatal_error("read_image: unknown file type: %s", p);
  31. png.modified = 0;
  32. }