write_img.c 812 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*!
  2. \file write_img.c
  3. \brief Save current GL screen to image file.
  4. (C) 2008, 2010 by the GRASS Development Team
  5. This program is free software under the GNU General Public
  6. License (>=v2). Read the file COPYING that comes with GRASS
  7. for details.
  8. Based on visualization/nviz/src/anim_support.c
  9. \author Updated/modified by Martin Landa <landa.martin gmail.com>
  10. */
  11. #include "local_proto.h"
  12. #include <grass/ogsf.h>
  13. /*!
  14. \brief Save current GL screen to an ppm file.
  15. \param name filename
  16. \return 1 on success
  17. \return 0 on failure (unsupported format)
  18. */
  19. int write_img(const char *name, int format)
  20. {
  21. if (format == FORMAT_PPM)
  22. GS_write_ppm(name);
  23. #ifdef HAVE_TIFFIO_H
  24. else if (format == FORMAT_TIF)
  25. GS_write_tif(name);
  26. #endif
  27. else
  28. return 0;
  29. return 1;
  30. }