write.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*!
  2. \file cairodriver/write.c
  3. \brief GRASS cairo display driver - write image (lower level functions)
  4. (C) 2007-2008 by Lars Ahlzen 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 Lars Ahlzen <lars ahlzen.com> (original contibutor)
  8. \author Glynn Clements
  9. */
  10. #include "cairodriver.h"
  11. #if CAIRO_HAS_XLIB_SURFACE
  12. #include <X11/Xlib.h>
  13. #include <cairo-xlib.h>
  14. #endif
  15. void cairo_write_image(void)
  16. {
  17. G_debug(1, "write_image");
  18. if (!ca.modified)
  19. return;
  20. if (ca.mapped)
  21. return;
  22. if (!cairo || !surface)
  23. return;
  24. if (ca.file_type == FTYPE_PPM) {
  25. G_debug(1, "Writing image to %s", ca.file_name);
  26. cairo_write_ppm();
  27. }
  28. else if (ca.file_type == FTYPE_BMP) {
  29. G_debug(1, "Writing image to %s", ca.file_name);
  30. cairo_write_bmp();
  31. }
  32. #if CAIRO_HAS_PNG_FUNCTIONS
  33. else if (ca.file_type == FTYPE_PNG) {
  34. G_debug(1, "Writing image to %s", ca.file_name);
  35. cairo_surface_write_to_png(surface, ca.file_name);
  36. }
  37. #endif
  38. #if CAIRO_HAS_XLIB_SURFACE
  39. else if (ca.file_type == FTYPE_X11) {
  40. XFlush(cairo_xlib_surface_get_display(surface));
  41. }
  42. #endif
  43. /* vector format files are written directly to file */
  44. ca.modified = 0;
  45. }