Loading...
Searching...
No Matches
cairodriver.h
Go to the documentation of this file.
/*!
\file cairodriver/cairodriver.h
\brief GRASS cairo display driver - header file
(C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
\author Lars Ahlzen <lars ahlzen.com> (original contributor)
\author Glynn Clements
*/
#ifndef __CAIRODRIVER_H__
#define __CAIRODRIVER_H__
#include <grass/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#if !defined(USE_X11) || !CAIRO_HAS_XLIB_SURFACE || \
CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 6, 0)
#undef CAIRO_HAS_XLIB_XRENDER_SURFACE
#define CAIRO_HAS_XLIB_XRENDER_SURFACE 0
#endif
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xrender.h>
#endif
#include <grass/gis.h>
#include "driver.h"
#include "driverlib.h"
#define DEFAULT_FILE_NAME "map.png"
#define HEADER_SIZE 64
/* Scale for converting colors from [0..255] to cairo's [0.0..1.0] */
#define COLORSCALE (1.0 / 255.0)
#define CAIROCOLOR(a) (((double)(a)) * COLORSCALE)
/* File types */
#define FTYPE_UNKNOWN 0
#define FTYPE_PPM 1
#define FTYPE_BMP 2
#define FTYPE_PNG 3
#define FTYPE_PDF 4
#define FTYPE_PS 5
#define FTYPE_SVG 6
#define FTYPE_X11 7
extern cairo_surface_t *surface;
extern cairo_t *cairo;
struct cairo_state {
char *file_name;
int file_type;
int width, height, stride;
unsigned char *grid;
double bgcolor_r, bgcolor_g, bgcolor_b, bgcolor_a;
int modified;
int mapped;
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
Display *dpy;
Drawable win;
Screen *screen;
XRenderPictFormat *format;
int depth;
#endif
};
extern struct cairo_state ca;
extern const struct driver *Cairo_Driver(void);
extern void Cairo_Client_Close(void);
extern int Cairo_Graph_set(void);
extern const char *Cairo_Graph_get_file(void);
extern void Cairo_Graph_close(void);
extern void Cairo_Box(double, double, double, double);
extern void Cairo_Set_window(double, double, double, double);
extern void Cairo_Bitmap(int, int, int, const unsigned char *);
extern void Cairo_Color(int, int, int);
extern void Cairo_Erase(void);
extern void Cairo_begin_raster(int, int[2][2], double[2][2]);
extern int Cairo_raster(int, int, const unsigned char *, const unsigned char *,
const unsigned char *, const unsigned char *);
extern void Cairo_end_raster(void);
extern void Cairo_Begin(void);
extern void Cairo_Move(double, double);
extern void Cairo_Cont(double, double);
extern void Cairo_Close(void);
extern void Cairo_Stroke(void);
extern void Cairo_Fill(void);
extern void Cairo_Point(double, double);
extern void Cairo_Line_width(double);
extern void Cairo_Text(const char *);
extern void Cairo_text_box(const char *, double *, double *, double *,
double *);
extern void Cairo_set_font(const char *);
extern void Cairo_font_list(char ***, int *);
extern void Cairo_font_info(char ***, int *);
/* read.c */
extern void cairo_read_image(void);
extern void cairo_read_ppm(void);
extern void cairo_read_bmp(void);
extern void cairo_read_xid(void);
/* write.c */
extern void cairo_write_image(void);
extern void cairo_write_ppm(void);
extern void cairo_write_bmp(void);
extern void cairo_write_xid(void);
#endif /* __CAIRODRIVER_H__ */
Cairo_Point
void Cairo_Point(double, double)
Definition cairodriver/draw.c:49
Cairo_Color
void Cairo_Color(int, int, int)
Set source color (opaque).
Definition cairodriver/color.c:27
cairo_write_ppm
void cairo_write_ppm(void)
Definition cairodriver/write_ppm.c:19
Cairo_Driver
const struct driver * Cairo_Driver(void)
Initialize display driver.
Definition cairodriver/driver.c:22
Cairo_Graph_get_file
const char * Cairo_Graph_get_file(void)
Get render file.
Definition cairodriver/graph.c:294
cairo_write_bmp
void cairo_write_bmp(void)
Definition cairodriver/write_bmp.c:65
Cairo_Begin
void Cairo_Begin(void)
Definition cairodriver/draw.c:17
Cairo_Erase
void Cairo_Erase(void)
Erase screen.
Definition cairodriver/erase.c:20
Cairo_Move
void Cairo_Move(double, double)
Definition cairodriver/draw.c:22
Cairo_Close
void Cairo_Close(void)
Definition cairodriver/draw.c:32
Cairo_Stroke
void Cairo_Stroke(void)
Definition cairodriver/draw.c:37
Cairo_raster
int Cairo_raster(int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
Draw raster row.
Definition cairodriver/raster.c:130
cairo_read_bmp
void cairo_read_bmp(void)
Definition cairodriver/read_bmp.c:82
cairo_read_xid
void cairo_read_xid(void)
Definition read_xid.c:5
Cairo_Fill
void Cairo_Fill(void)
Definition cairodriver/draw.c:43
cairo_read_image
void cairo_read_image(void)
Definition cairodriver/read.c:17
Cairo_font_info
void Cairo_font_info(char ***, int *)
Get fonts into.
Definition cairodriver/text.c:338
Cairo_Line_width
void Cairo_Line_width(double)
Set line width.
Definition cairodriver/line_width.c:27
Cairo_font_list
void Cairo_font_list(char ***, int *)
Get list of fonts.
Definition cairodriver/text.c:324
surface
cairo_surface_t * surface
Definition cairodriver/graph.c:45
Cairo_Cont
void Cairo_Cont(double, double)
Definition cairodriver/draw.c:27
cairo_write_image
void cairo_write_image(void)
Definition cairodriver/write.c:17
Cairo_end_raster
void Cairo_end_raster(void)
Finish drawing raster.
Definition cairodriver/raster.c:180
Cairo_Box
void Cairo_Box(double, double, double, double)
Draw a (filled) rectangle.
Definition cairodriver/box.c:22
ca
struct cairo_state ca
Definition cairodriver/graph.c:42
Cairo_set_font
void Cairo_set_font(const char *)
Set font.
Definition cairodriver/text.c:283
Cairo_Graph_set
int Cairo_Graph_set(void)
Initialize driver.
Definition cairodriver/graph.c:237
cairo_write_xid
void cairo_write_xid(void)
Definition write_xid.c:5
Cairo_Client_Close
void Cairo_Client_Close(void)
Cairo_Graph_close
void Cairo_Graph_close(void)
Close driver.
Definition cairodriver/graph.c:302
Cairo_Text
void Cairo_Text(const char *)
Draw text.
Definition cairodriver/text.c:110
Cairo_begin_raster
void Cairo_begin_raster(int, int[2][2], double[2][2])
Start drawing raster.
Definition cairodriver/raster.c:71
Cairo_Bitmap
void Cairo_Bitmap(int, int, int, const unsigned char *)
Draw bitmap.
Definition cairodriver/draw_bitmap.c:26
cairo
cairo_t * cairo
Definition cairodriver/graph.c:46
Cairo_Set_window
void Cairo_Set_window(double, double, double, double)
Set window.
Definition cairodriver/set_window.c:22
cairo_read_ppm
void cairo_read_ppm(void)
Definition cairodriver/read_ppm.c:19
Cairo_text_box
void Cairo_text_box(const char *, double *, double *, double *, double *)
Definition cairodriver/text.c:133
driver.h
driverlib.h
cairo_state
Definition cairodriver.h:65
cairo_state::bgcolor_r
double bgcolor_r
Definition cairodriver.h:70
cairo_state::file_type
int file_type
Definition cairodriver.h:67
cairo_state::mapped
int mapped
Definition cairodriver.h:72
cairo_state::grid
unsigned char * grid
Definition cairodriver.h:69
cairo_state::height
int height
Definition cairodriver.h:68
cairo_state::width
int width
Definition cairodriver.h:68
cairo_state::bgcolor_a
double bgcolor_a
Definition cairodriver.h:70
cairo_state::stride
int stride
Definition cairodriver.h:68
cairo_state::bgcolor_g
double bgcolor_g
Definition cairodriver.h:70
cairo_state::file_name
char * file_name
Definition cairodriver.h:66
cairo_state::modified
int modified
Definition cairodriver.h:71
cairo_state::bgcolor_b
double bgcolor_b
Definition cairodriver.h:70
driver
Definition driver.h:27