write.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*!
  2. \file lib/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. void cairo_write_image(void)
  12. {
  13. G_debug(1, "write_image");
  14. if (!ca.modified)
  15. return;
  16. if (ca.mapped)
  17. return;
  18. if (!cairo || !surface)
  19. return;
  20. if (ca.file_type == FTYPE_PPM) {
  21. G_debug(1, "Writing image to %s", ca.file_name);
  22. cairo_write_ppm();
  23. }
  24. else if (ca.file_type == FTYPE_BMP) {
  25. G_debug(1, "Writing image to %s", ca.file_name);
  26. cairo_write_bmp();
  27. }
  28. #if CAIRO_HAS_PNG_FUNCTIONS
  29. else if (ca.file_type == FTYPE_PNG) {
  30. G_debug(1, "Writing image to %s", ca.file_name);
  31. cairo_surface_write_to_png(surface, ca.file_name);
  32. }
  33. #endif
  34. #if CAIRO_HAS_XLIB_XRENDER_SURFACE
  35. else if (ca.file_type == FTYPE_X11) {
  36. G_debug(1, "Writing XID to %s", ca.file_name);
  37. cairo_write_xid();
  38. }
  39. #endif
  40. /* vector format files are written directly to file */
  41. ca.modified = 0;
  42. }