GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-ce44da6b99
cairodriver.h File Reference

GRASS cairo display driver - header file. More...

#include <grass/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <grass/gis.h>
#include "driver.h"
#include "driverlib.h"
Include dependency graph for cairodriver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cairo_state
 

Macros

#define CAIRO_HAS_XLIB_XRENDER_SURFACE   0
 
#define DEFAULT_FILE_NAME   "map.png"
 
#define HEADER_SIZE   64
 
#define COLORSCALE   (1.0 / 255.0)
 
#define CAIROCOLOR(a)   (((double)(a)) * COLORSCALE)
 
#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
 

Functions

const struct driverCairo_Driver (void)
 Initialize display driver. More...
 
void Cairo_Client_Close (void)
 
int Cairo_Graph_set (void)
 Initialize driver. More...
 
const char * Cairo_Graph_get_file (void)
 Get render file. More...
 
void Cairo_Graph_close (void)
 Close driver. More...
 
void Cairo_Box (double, double, double, double)
 Draw a (filled) rectangle. More...
 
void Cairo_Set_window (double, double, double, double)
 Set window. More...
 
void Cairo_Bitmap (int, int, int, const unsigned char *)
 Draw bitmap. More...
 
void Cairo_Color (int, int, int)
 Set source color (opaque) More...
 
void Cairo_Erase (void)
 Erase screen. More...
 
void Cairo_begin_raster (int, int[2][2], double[2][2])
 Start drawing raster. More...
 
int Cairo_raster (int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
 Draw raster row. More...
 
void Cairo_end_raster (void)
 Finish drawing raster. More...
 
void Cairo_Begin (void)
 
void Cairo_Move (double, double)
 
void Cairo_Cont (double, double)
 
void Cairo_Close (void)
 
void Cairo_Stroke (void)
 
void Cairo_Fill (void)
 
void Cairo_Point (double, double)
 
void Cairo_Line_width (double)
 Set line width. More...
 
void Cairo_Text (const char *)
 Draw text. More...
 
void Cairo_text_box (const char *, double *, double *, double *, double *)
 
void Cairo_set_font (const char *)
 Set font. More...
 
void Cairo_font_list (char ***, int *)
 Get list of fonts. More...
 
void Cairo_font_info (char ***, int *)
 Get fonts into. More...
 
void cairo_read_image (void)
 
void cairo_read_ppm (void)
 
void cairo_read_bmp (void)
 
void cairo_read_xid (void)
 
void cairo_write_image (void)
 
void cairo_write_ppm (void)
 
void cairo_write_bmp (void)
 
void cairo_write_xid (void)
 

Variables

cairo_surface_t * surface
 
cairo_t * cairo
 
struct cairo_state ca
 

Detailed Description

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)
Glynn Clements

Definition in file cairodriver.h.

Macro Definition Documentation

◆ CAIRO_HAS_XLIB_XRENDER_SURFACE

#define CAIRO_HAS_XLIB_XRENDER_SURFACE   0

Definition at line 29 of file cairodriver.h.

◆ CAIROCOLOR

#define CAIROCOLOR (   a)    (((double)(a)) * COLORSCALE)

Definition at line 50 of file cairodriver.h.

◆ COLORSCALE

#define COLORSCALE   (1.0 / 255.0)

Definition at line 49 of file cairodriver.h.

◆ DEFAULT_FILE_NAME

#define DEFAULT_FILE_NAME   "map.png"

Definition at line 44 of file cairodriver.h.

◆ FTYPE_BMP

#define FTYPE_BMP   2

Definition at line 55 of file cairodriver.h.

◆ FTYPE_PDF

#define FTYPE_PDF   4

Definition at line 57 of file cairodriver.h.

◆ FTYPE_PNG

#define FTYPE_PNG   3

Definition at line 56 of file cairodriver.h.

◆ FTYPE_PPM

#define FTYPE_PPM   1

Definition at line 54 of file cairodriver.h.

◆ FTYPE_PS

#define FTYPE_PS   5

Definition at line 58 of file cairodriver.h.

◆ FTYPE_SVG

#define FTYPE_SVG   6

Definition at line 59 of file cairodriver.h.

◆ FTYPE_UNKNOWN

#define FTYPE_UNKNOWN   0

Definition at line 53 of file cairodriver.h.

◆ FTYPE_X11

#define FTYPE_X11   7

Definition at line 60 of file cairodriver.h.

◆ HEADER_SIZE

#define HEADER_SIZE   64

Definition at line 46 of file cairodriver.h.

Function Documentation

◆ Cairo_Begin()

void Cairo_Begin ( void  )

Definition at line 17 of file cairodriver/draw.c.

References cairo.

◆ Cairo_begin_raster()

void Cairo_begin_raster ( int  mask,
int  s[2][2],
double  d[2][2] 
)

Start drawing raster.

Todo:
are top and left swapped?
Parameters
masknon-zero int for mask
ssource (map) extent (left, right, top, bottom)
ddestination (image) extent (left, right, top, bottom)

Definition at line 71 of file cairodriver/raster.c.

◆ Cairo_Bitmap()

void Cairo_Bitmap ( int  ncols,
int  nrows,
int  threshold,
const unsigned char *  buf 
)

Draw bitmap.

Parameters
ncols,nrowsnumber of columns and rows
thresholdthreshold value
bufdata buffer

Definition at line 26 of file cairodriver/draw_bitmap.c.

◆ Cairo_Box()

void Cairo_Box ( double  x1,
double  y1,
double  x2,
double  y2 
)

Draw a (filled) rectangle.

Parameters
x1,y1,x2,y2rectangle coordinates

Definition at line 22 of file cairodriver/box.c.

◆ Cairo_Client_Close()

void Cairo_Client_Close ( void  )

◆ Cairo_Close()

void Cairo_Close ( void  )

Definition at line 32 of file cairodriver/draw.c.

References cairo.

◆ Cairo_Color()

void Cairo_Color ( int  r,
int  g,
int  b 
)

Set source color (opaque)

This color will then be used for any subsequent drawing operation until a new source pattern is set.

Parameters
rred color value
ggreen color value
bblue color value

Definition at line 27 of file cairodriver/color.c.

References b, cairo, CAIROCOLOR, g, G_debug(), and r.

◆ Cairo_Cont()

void Cairo_Cont ( double  x,
double  y 
)

Definition at line 27 of file cairodriver/draw.c.

References cairo, and x.

◆ Cairo_Driver()

const struct driver* Cairo_Driver ( void  )

Initialize display driver.

Returns
pointer driver structure

Definition at line 22 of file cairodriver/driver.c.

◆ Cairo_end_raster()

void Cairo_end_raster ( void  )

Finish drawing raster.

Definition at line 180 of file cairodriver/raster.c.

References cairo, and G_debug().

◆ Cairo_Erase()

void Cairo_Erase ( void  )

◆ Cairo_Fill()

void Cairo_Fill ( void  )

Definition at line 43 of file cairodriver/draw.c.

References ca, cairo, and cairo_state::modified.

◆ Cairo_font_info()

void Cairo_font_info ( char ***  list,
int *  count 
)

Get fonts into.

Parameters
[out]listfont list
[out]countnumber of items in the list

Definition at line 335 of file cairodriver/text.c.

◆ Cairo_font_list()

void Cairo_font_list ( char ***  list,
int *  count 
)

Get list of fonts.

Parameters
[out]listfont list
[out]countnumber of items in the list

Definition at line 321 of file cairodriver/text.c.

◆ Cairo_Graph_close()

void Cairo_Graph_close ( void  )

◆ Cairo_Graph_get_file()

const char* Cairo_Graph_get_file ( void  )

Get render file.

Returns
file name

Definition at line 294 of file cairodriver/graph.c.

References ca, and cairo_state::file_name.

◆ Cairo_Graph_set()

int Cairo_Graph_set ( void  )

Initialize driver.

Set background color, transparency, drawable, antialias mode, etc.

Returns
0

Definition at line 237 of file cairodriver/graph.c.

References cairo_state::bgcolor_a, cairo_state::bgcolor_b, cairo_state::bgcolor_g, cairo_state::bgcolor_r, ca, CAIROCOLOR, G_debug(), G_fatal_error(), G_gisinit, G_str_to_color(), and G_strcasecmp().

◆ Cairo_Line_width()

void Cairo_Line_width ( double  width)

Set line width.

Parameters
widthline width (double precision)

Definition at line 27 of file cairodriver/line_width.c.

◆ Cairo_Move()

void Cairo_Move ( double  x,
double  y 
)

Definition at line 22 of file cairodriver/draw.c.

References cairo, and x.

◆ Cairo_Point()

void Cairo_Point ( double  x,
double  y 
)

Definition at line 49 of file cairodriver/draw.c.

References ca, cairo, cairo_state::modified, and x.

◆ Cairo_raster()

int Cairo_raster ( int  n,
int  row,
const unsigned char *  red,
const unsigned char *  grn,
const unsigned char *  blu,
const unsigned char *  nul 
)

Draw raster row.

Parameters
nnumber of cells
rowraster row (starting at 0)
red,grn,blu,nulred,green,blue and null value
Returns
next row

Definition at line 130 of file cairodriver/raster.c.

◆ cairo_read_bmp()

void cairo_read_bmp ( void  )

Definition at line 82 of file cairodriver/read_bmp.c.

References HEADER_SIZE.

Referenced by cairo_read_image().

◆ cairo_read_image()

◆ cairo_read_ppm()

void cairo_read_ppm ( void  )

Definition at line 19 of file cairodriver/read_ppm.c.

References ca, cairo_state::file_name, and G_store().

Referenced by cairo_read_image().

◆ cairo_read_xid()

void cairo_read_xid ( void  )

Definition at line 5 of file read_xid.c.

References _, ca, cairo_state::file_name, and G_fatal_error().

Referenced by cairo_read_image().

◆ Cairo_set_font()

void Cairo_set_font ( const char *  name)

Set font.

Parameters
namefont name

Definition at line 280 of file cairodriver/text.c.

◆ Cairo_Set_window()

void Cairo_Set_window ( double  t,
double  b,
double  l,
double  r 
)

Set window.

Parameters
t,b,l,rtop, bottom, left, right

Definition at line 22 of file cairodriver/set_window.c.

References b, cairo, G_debug(), l, r, and t.

◆ Cairo_Stroke()

void Cairo_Stroke ( void  )

Definition at line 37 of file cairodriver/draw.c.

References ca, cairo, and cairo_state::modified.

◆ Cairo_Text()

void Cairo_Text ( const char *  str)

Draw text.

Parameters
strstring to be drawn

Definition at line 107 of file cairodriver/text.c.

◆ Cairo_text_box()

void Cairo_text_box ( const char *  str,
double *  t,
double *  b,
double *  l,
double *  r 
)

Definition at line 130 of file cairodriver/text.c.

◆ cairo_write_bmp()

void cairo_write_bmp ( void  )

Definition at line 65 of file cairodriver/write_bmp.c.

References _, ca, cairo_state::file_name, G_fatal_error(), HEADER_SIZE, and output().

Referenced by cairo_write_image().

◆ cairo_write_image()

◆ cairo_write_ppm()

◆ cairo_write_xid()

void cairo_write_xid ( void  )

Definition at line 5 of file write_xid.c.

References _, ca, cairo_state::file_name, and G_fatal_error().

Referenced by cairo_write_image().

Variable Documentation

◆ ca

◆ cairo

◆ surface

cairo_surface_t* surface
extern

Definition at line 45 of file cairodriver/graph.c.

Referenced by Cairo_Graph_close(), cairo_read_image(), and cairo_write_image().