write.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 defined(USE_X11) && 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 defined(USE_X11) && CAIRO_HAS_XLIB_SURFACE
  39. else if (ca.file_type == FTYPE_X11) {
  40. G_debug(1, "Writing XID to %s", ca.file_name);
  41. cairo_write_xid();
  42. }
  43. #endif
  44. /* vector format files are written directly to file */
  45. ca.modified = 0;
  46. }