Loading...
Searching...
No Matches
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)
#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 driver * | Cairo_Driver (void)
| Initialize display driver.
void | Cairo_Client_Close (void)
int | Cairo_Graph_set (void)
| Initialize driver.
const char * | Cairo_Graph_get_file (void)
| Get render file.
void | Cairo_Graph_close (void)
| Close driver.
void | Cairo_Box (double, double, double, double)
| Draw a (filled) rectangle.
void | Cairo_Set_window (double, double, double, double)
| Set window.
void | Cairo_Bitmap (int, int, int, const unsigned char *)
| Draw bitmap.
void | Cairo_Color (int, int, int)
| Set source color (opaque).
void | Cairo_Erase (void)
| Erase screen.
void | Cairo_begin_raster (int, int[2][2], double[2][2])
| Start drawing raster.
int | Cairo_raster (int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
| Draw raster row.
void | Cairo_end_raster (void)
| Finish drawing raster.
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.
void | Cairo_Text (const char *)
| Draw text.
void | Cairo_text_box (const char *, double *, double *, double *, double *)
void | Cairo_set_font (const char *)
| Set font.
void | Cairo_font_list (char ***, int *)
| Get list of fonts.
void | Cairo_font_info (char ***, int *)
| Get fonts into.
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 | ) |

Value:
(((double)(a)) * COLORSCALE)
COLORSCALE
#define COLORSCALE
Definition cairodriver.h:49

Definition at line 50 of file cairodriver.h.

Referenced by Cairo_Color(), and Cairo_Graph_set().

## 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.

Referenced by cairo_read_image(), and cairo_write_image().

## 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.

Referenced by cairo_read_image(), and cairo_write_image().

## FTYPE_PPM

#define FTYPE_PPM 1

Definition at line 54 of file cairodriver.h.

Referenced by cairo_read_image(), and cairo_write_image().

## 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.

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

## HEADER_SIZE

#define HEADER_SIZE 64

Definition at line 46 of file cairodriver.h.

Referenced by cairo_read_bmp(), cairo_write_bmp(), read_bmp(), and write_bmp().

## Function Documentation

## Cairo_Begin()

void Cairo_Begin | ( | void |  | ) |

extern

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

References cairo.

Referenced by Cairo_Driver().

## Cairo_begin_raster()

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

extern

Start drawing raster.

Todo
  are top and left swapped?

Parameters

  mask | non-zero int for mask
  s | source (map) extent (left, right, top, bottom)
  d | destination (image) extent (left, right, top, bottom)

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

References ca, G_debug(), G_fatal_error(), and MAX_IMAGE_SIZE.

Referenced by Cairo_Driver().

## Cairo_Bitmap()

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

extern

Draw bitmap.

Parameters

  ncols,nrows | number of columns and rows
  threshold | threshold value
  buf | data buffer

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

References ca, cairo, cur_x, cur_y, G_debug(), and G_fatal_error().

Referenced by Cairo_Driver().

## Cairo_Box()

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

extern

Draw a (filled) rectangle.

Parameters

  x1,y1,x2,y2 | rectangle coordinates

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

References ca, cairo, and G_debug().

Referenced by Cairo_Driver().

## Cairo_Client_Close()

void Cairo_Client_Close | ( | void |  | ) |

extern

## Cairo_Close()

void Cairo_Close | ( | void |  | ) |

extern

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

References cairo.

Referenced by Cairo_Driver().

## Cairo_Color()

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

extern

Set source color (opaque).

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

Parameters

  r | red color value
  g | green color value
  b | blue color value

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

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

Referenced by Cairo_Driver().

## Cairo_Cont()

void Cairo_Cont | ( | double | x,
|  | double | y )

extern

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

References cairo, and x.

Referenced by Cairo_Driver().

## Cairo_Driver()

const struct driver * Cairo_Driver | ( | void |  | ) |

extern

Initialize display driver.

Returns
  pointer driver structure

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

References driver::Begin, driver::Begin_raster, driver::Bitmap, driver::Box, Cairo_Begin(), Cairo_begin_raster(), Cairo_Bitmap(), Cairo_Box(), Cairo_Close(), Cairo_Color(), Cairo_Cont(), Cairo_end_raster(), Cairo_Erase(), Cairo_Fill(), Cairo_font_info(), Cairo_font_list(), Cairo_Graph_close(), Cairo_Graph_get_file(), Cairo_Graph_set(), Cairo_Line_width(), Cairo_Move(), Cairo_Point(), Cairo_raster(), Cairo_set_font(), Cairo_Set_window(), Cairo_Stroke(), Cairo_Text(), Cairo_text_box(), driver::Close, driver::Color, driver::Cont, driver::End_raster, driver::Erase, driver::Fill, driver::Font_info, driver::Font_list, driver::Graph_close, driver::Graph_get_file, driver::Graph_set, driver::Line_width, driver::Move, driver::name, driver::Point, driver::Raster, driver::Set_font, driver::Set_window, driver::Stroke, driver::Text, and driver::Text_box.

## Cairo_end_raster()

void Cairo_end_raster | ( | void |  | ) |

extern

Finish drawing raster.

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

References ca, cairo, G_debug(), and G_free().

Referenced by Cairo_Driver().

## Cairo_Erase()

void Cairo_Erase | ( | void |  | ) |

extern

Erase screen.

Definition at line 20 of file cairodriver/erase.c.

References ca, cairo, and G_debug().

Referenced by Cairo_Driver().

## Cairo_Fill()

void Cairo_Fill | ( | void |  | ) |

extern

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

References ca, and cairo.

Referenced by Cairo_Driver().

## Cairo_font_info()

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

extern

Get fonts into.

Parameters

  [out] | list | font list
  [out] | count | number of items in the list

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

References count, and list.

Referenced by Cairo_Driver().

## Cairo_font_list()

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

extern

Get list of fonts.

Parameters

  [out] | list | font list
  [out] | count | number of items in the list

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

References count, and list.

Referenced by Cairo_Driver().

## Cairo_Graph_close()

void Cairo_Graph_close | ( | void |  | ) |

extern

Close driver.

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

References ca, cairo, cairo_write_image(), FTYPE_X11, G_debug(), NULL, and surface.

Referenced by Cairo_Driver().

## Cairo_Graph_get_file()

const char * Cairo_Graph_get_file | ( | void |  | ) |

extern

Get render file.

Returns
  file name

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

References ca.

Referenced by Cairo_Driver().

## Cairo_Graph_set()

int Cairo_Graph_set | ( | void |  | ) |

extern

Initialize driver.

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

Returns
  0

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

References ca, cairo, CAIROCOLOR, G_debug(), G_fatal_error(), G_str_to_color(), and G_strcasecmp().

Referenced by Cairo_Driver().

## Cairo_Line_width()

void Cairo_Line_width | ( | double | width | ) |

extern

Set line width.

Parameters

  width | line width (double precision)

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

References cairo, G_debug(), MAX, and MIN_WIDTH.

Referenced by Cairo_Driver().

## Cairo_Move()

void Cairo_Move | ( | double | x,
|  | double | y )

extern

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

References cairo, and x.

Referenced by Cairo_Driver().

## Cairo_Point()

void Cairo_Point | ( | double | x,
|  | double | y )

extern

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

References ca, cairo, and x.

Referenced by Cairo_Driver().

## 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 )

extern

Draw raster row.

Parameters

  n | number of cells
  row | raster row (starting at 0)
  red,grn,blu,nul | red,green,blue and null value

Returns
  next row

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

References b, ca, g, G_debug(), MAX, MIN, r, and x.

Referenced by Cairo_Driver().

## cairo_read_bmp()

void cairo_read_bmp | ( | void |  | ) |

extern

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

References ca, G_fatal_error(), and HEADER_SIZE.

Referenced by cairo_read_image().

## cairo_read_image()

void cairo_read_image | ( | void |  | ) |

extern

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

References ca, cairo, cairo_read_bmp(), cairo_read_ppm(), cairo_read_xid(), FTYPE_BMP, FTYPE_PNG, FTYPE_PPM, FTYPE_X11, G_debug(), and surface.

## cairo_read_ppm()

void cairo_read_ppm | ( | void |  | ) |

extern

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

References b, ca, g, G_fatal_error(), G_free(), G_store(), r, and x.

Referenced by cairo_read_image().

## cairo_read_xid()

void cairo_read_xid | ( | void |  | ) |

extern

Definition at line 5 of file read_xid.c.

References ca, and G_fatal_error().

Referenced by cairo_read_image().

## Cairo_set_font()

void Cairo_set_font | ( | const char * | name | ) |

extern

Set font.

Parameters

  name | font name

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

References name.

Referenced by Cairo_Driver().

## Cairo_Set_window()

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

extern

Set window.

Parameters

  t,b,l,r | top, bottom, left, right

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

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

Referenced by Cairo_Driver().

## Cairo_Stroke()

void Cairo_Stroke | ( | void |  | ) |

extern

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

References ca, and cairo.

Referenced by Cairo_Driver().

## Cairo_Text()

void Cairo_Text | ( | const char * | str | ) |

extern

Draw text.

Parameters

  str | string to be drawn

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

References ca, cairo, cur_x, cur_y, and G_free().

Referenced by Cairo_Driver().

## Cairo_text_box()

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

extern

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

References b, cairo, cur_x, cur_y, G_free(), l, r, and t.

Referenced by Cairo_Driver().

## cairo_write_bmp()

void cairo_write_bmp | ( | void |  | ) |

extern

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

References ca, G_fatal_error(), HEADER_SIZE, and output().

Referenced by cairo_write_image().

## cairo_write_image()

void cairo_write_image | ( | void |  | ) |

extern

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

References ca, cairo, cairo_write_bmp(), cairo_write_ppm(), cairo_write_xid(), FTYPE_BMP, FTYPE_PNG, FTYPE_PPM, FTYPE_X11, G_debug(), and surface.

Referenced by Cairo_Graph_close().

## cairo_write_ppm()

void cairo_write_ppm | ( | void |  | ) |

extern

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

References b, ca, g, G_fatal_error(), G_free(), G_store(), output(), r, and x.

Referenced by cairo_write_image().

## cairo_write_xid()

void cairo_write_xid | ( | void |  | ) |

extern

Definition at line 5 of file write_xid.c.

References ca, and G_fatal_error().

Referenced by cairo_write_image().

## Variable Documentation

## ca

struct cairo_state ca

extern

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

Referenced by Cairo_begin_raster(), Cairo_Bitmap(), Cairo_Box(), Cairo_end_raster(), Cairo_Erase(), Cairo_Fill(), Cairo_Graph_close(), Cairo_Graph_get_file(), Cairo_Graph_set(), Cairo_Point(), Cairo_raster(), cairo_read_bmp(), cairo_read_image(), cairo_read_ppm(), cairo_read_xid(), Cairo_Stroke(), Cairo_Text(), cairo_write_bmp(), cairo_write_image(), cairo_write_ppm(), and cairo_write_xid().

## cairo

cairo_t* cairo

extern

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

Referenced by Cairo_Begin(), Cairo_Bitmap(), Cairo_Box(), Cairo_Close(), Cairo_Color(), Cairo_Cont(), Cairo_end_raster(), Cairo_Erase(), Cairo_Fill(), Cairo_Graph_close(), Cairo_Graph_set(), Cairo_Line_width(), Cairo_Move(), Cairo_Point(), cairo_read_image(), Cairo_Set_window(), Cairo_Stroke(), Cairo_Text(), Cairo_text_box(), and cairo_write_image().

## 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().