GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
cairodriver/read.c
Go to the documentation of this file.
1 /*!
2  \file lib/cairodriver/read.c
3 
4  \brief GRASS cairo display driver - read image (lower level functions)
5 
6  (C) 2007-2008, 2011 by Lars Ahlzen and the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Lars Ahlzen <lars ahlzen.com> (original contibutor)
12  \author Glynn Clements
13 */
14 
15 #include "cairodriver.h"
16 
17 void cairo_read_image(void)
18 {
19  G_debug(1, "read_image");
20 
21  if (!cairo || !surface)
22  return;
23 
24  if (ca.file_type == FTYPE_PPM) {
25  G_debug(1, "Reading image from %s", ca.file_name);
27  }
28  else if (ca.file_type == FTYPE_BMP) {
29  G_debug(1, "Reading image from %s", ca.file_name);
31  }
32 #if CAIRO_HAS_PNG_FUNCTIONS
33  else if (ca.file_type == FTYPE_PNG) {
34  cairo_surface_t *img_surf;
35 
36  G_debug(1, "Reading image from %s", ca.file_name);
37 
38  img_surf = cairo_image_surface_create_from_png(ca.file_name);
39  if (!img_surf)
40  return;
41 
42  cairo_save(cairo);
43  cairo_set_source_surface(cairo, img_surf, 0, 0);
44  cairo_paint(cairo);
45  cairo_restore(cairo);
46 
47  cairo_surface_destroy(img_surf);
48  }
49 #endif
50 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
51  else if (ca.file_type == FTYPE_X11) {
52  G_debug(1, "Reading XID from %s", ca.file_name);
54  }
55 #endif
56  /* vector format files are written directly to file */
57 
58  ca.modified = 0;
59 }
void cairo_read_xid(void)
Definition: read_xid.c:5
#define FTYPE_BMP
Definition: cairodriver.h:54
void cairo_read_ppm(void)
void cairo_read_image(void)
struct cairo_state ca
#define FTYPE_PPM
Definition: cairodriver.h:53
#define FTYPE_X11
Definition: cairodriver.h:59
char * file_name
Definition: cairodriver.h:65
cairo_t * cairo
#define FTYPE_PNG
Definition: cairodriver.h:55
GRASS cairo display driver - header file.
void cairo_read_bmp(void)
cairo_surface_t * surface
int G_debug(int, const char *,...) __attribute__((format(printf