grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

raster.c File Reference

GRASS cairo display driver - draw raster. More...

#include <math.h>
#include "cairodriver.h"
#include <grass/glocale.h>
Include dependency graph for raster.c:

Go to the source code of this file.

Macros

#define MAX_IMAGE_SIZE   32767
 
#define MIN(a, b)   ((a)<(b)?(a):(b))
 
#define MAX(a, b)   ((a)>(b)?(a):(b))
 

Functions

static double scale (double k, int src_0, int src_1, int dst_0, int dst_1)
 
static int scale_fwd_y (int sy)
 
static int scale_rev_x (int dx)
 
static int next_row (int sy, int dy)
 
void Cairo_begin_raster (int mask, int s[2][2], double d[2][2])
 Start drawing raster. More...
 
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. More...
 
void Cairo_end_raster (void)
 Finish drawing raster. More...
 

Variables

static int src_t
 
static int src_b
 
static int src_l
 
static int src_r
 
static int src_w
 
static int src_h
 
static int dst_t
 
static int dst_b
 
static int dst_l
 
static int dst_r
 
static int dst_w
 
static int dst_h
 
static int * trans
 
static cairo_surface_t * src_surf
 
static unsigned char * src_data
 
static int src_stride
 
static int ca_row
 
static int masked
 

Detailed Description

GRASS cairo display driver - draw raster.

(C) 2007-2014 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 contibutor)
Glynn Clements

Definition in file raster.c.

Macro Definition Documentation

◆ MAX

#define MAX (   a,
  b 
)    ((a)>(b)?(a):(b))

Definition at line 25 of file raster.c.

◆ MAX_IMAGE_SIZE

#define MAX_IMAGE_SIZE   32767

Definition at line 20 of file raster.c.

◆ MIN

#define MIN (   a,
  b 
)    ((a)<(b)?(a):(b))

Definition at line 22 of file raster.c.

Function Documentation

◆ 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 76 of file raster.c.

References _, ca, ca_row, d, dst_b, dst_h, dst_l, dst_r, dst_t, dst_w, G_debug(), G_fatal_error(), cairo_state::height, masked, MAX_IMAGE_SIZE, s, scale_rev_x(), src_b, src_data, src_h, src_l, src_r, src_stride, src_surf, src_t, src_w, trans, and cairo_state::width.

Referenced by Cairo_Driver().

◆ Cairo_end_raster()

void Cairo_end_raster ( void  )

Finish drawing raster.

Definition at line 180 of file raster.c.

References ca, cairo, G_debug(), G_free(), cairo_state::modified, src_surf, and trans.

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 
)

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 132 of file raster.c.

References a, b, c, ca, ca_row, dst_l, dst_w, g, G_debug(), cairo_state::height, masked, MAX, MIN, cairo_state::modified, next_row(), r, scale_fwd_y(), src_data, src_stride, trans, cairo_state::width, x, x0, and x1.

Referenced by Cairo_Driver().

◆ next_row()

static int next_row ( int  sy,
int  dy 
)
static

Definition at line 54 of file raster.c.

References scale_fwd_y().

Referenced by Cairo_raster().

◆ scale()

static double scale ( double  k,
int  src_0,
int  src_1,
int  dst_0,
int  dst_1 
)
static

◆ scale_fwd_y()

static int scale_fwd_y ( int  sy)
static

Definition at line 44 of file raster.c.

References dst_b, dst_t, scale(), src_b, and src_t.

Referenced by Cairo_raster(), and next_row().

◆ scale_rev_x()

static int scale_rev_x ( int  dx)
static

Definition at line 49 of file raster.c.

References dst_l, dst_r, scale(), src_l, and src_r.

Referenced by Cairo_begin_raster().

Variable Documentation

◆ ca_row

int ca_row
static

Definition at line 35 of file raster.c.

Referenced by Cairo_begin_raster(), and Cairo_raster().

◆ dst_b

int dst_b
static

Definition at line 29 of file raster.c.

Referenced by Cairo_begin_raster(), and scale_fwd_y().

◆ dst_h

int dst_h
static

Definition at line 29 of file raster.c.

Referenced by Cairo_begin_raster().

◆ dst_l

int dst_l
static

Definition at line 29 of file raster.c.

Referenced by Cairo_begin_raster(), Cairo_raster(), and scale_rev_x().

◆ dst_r

int dst_r
static

Definition at line 29 of file raster.c.

Referenced by Cairo_begin_raster(), and scale_rev_x().

◆ dst_t

int dst_t
static

Definition at line 29 of file raster.c.

Referenced by Cairo_begin_raster(), and scale_fwd_y().

◆ dst_w

int dst_w
static

Definition at line 29 of file raster.c.

Referenced by Cairo_begin_raster(), and Cairo_raster().

◆ masked

int masked
static

Definition at line 37 of file raster.c.

Referenced by Cairo_begin_raster(), and Cairo_raster().

◆ src_b

int src_b
static

Definition at line 28 of file raster.c.

Referenced by Cairo_begin_raster(), and scale_fwd_y().

◆ src_data

unsigned char* src_data
static

Definition at line 34 of file raster.c.

Referenced by Cairo_begin_raster(), and Cairo_raster().

◆ src_h

int src_h
static

Definition at line 28 of file raster.c.

Referenced by Cairo_begin_raster().

◆ src_l

int src_l
static

Definition at line 28 of file raster.c.

Referenced by Cairo_begin_raster(), and scale_rev_x().

◆ src_r

int src_r
static

Definition at line 28 of file raster.c.

Referenced by Cairo_begin_raster(), and scale_rev_x().

◆ src_stride

int src_stride
static

Definition at line 35 of file raster.c.

Referenced by Cairo_begin_raster(), and Cairo_raster().

◆ src_surf

cairo_surface_t* src_surf
static

Definition at line 33 of file raster.c.

Referenced by Cairo_begin_raster(), and Cairo_end_raster().

◆ src_t

int src_t
static

Definition at line 28 of file raster.c.

Referenced by Cairo_begin_raster(), and scale_fwd_y().

◆ src_w

int src_w
static

Definition at line 28 of file raster.c.

Referenced by Cairo_begin_raster().

◆ trans

int* trans
static

Definition at line 31 of file raster.c.

Referenced by Cairo_begin_raster(), Cairo_end_raster(), Cairo_raster(), read_png(), and write_png().