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

Display Driver - draw raster data. More...

#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/display.h>
#include "driver.h"
Include dependency graph for raster.c:

Go to the source code of this file.

Functions

static int draw_cell (int, const void *, struct Colors *, RASTER_MAP_TYPE)
 
int D_draw_raster (int A_row, const void *array, struct Colors *colors, RASTER_MAP_TYPE data_type)
 Draw raster row. More...
 
int D_draw_d_raster (int A_row, const DCELL *darray, struct Colors *colors)
 Draw raster row (DCELL) More...
 
int D_draw_f_raster (int A_row, const FCELL *farray, struct Colors *colors)
 Draw raster row (FCELL) More...
 
int D_draw_c_raster (int A_row, const CELL *carray, struct Colors *colors)
 Draw raster row (CELL) More...
 
void D_raster_draw_begin (void)
 Prepare for raster graphic. More...
 
int D_draw_raster_RGB (int A_row, const void *r_raster, const void *g_raster, const void *b_raster, struct Colors *r_colors, struct Colors *g_colors, struct Colors *b_colors, RASTER_MAP_TYPE r_type, RASTER_MAP_TYPE g_type, RASTER_MAP_TYPE b_type)
 Draw raster row in RGB mode. More...
 
void D_raster_draw_end (void)
 Finish raster rendering. More...
 

Variables

int D__overlay_mode
 
static int src [2][2]
 
static double dst [2][2]
 

Detailed Description

Display Driver - draw raster data.

(C) 2006-2011 by 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
Glynn Clements <glynn gclements.plus.com> (original contributor)
Huidae Cho <grass4u gmail.com>

Definition in file raster.c.

Function Documentation

◆ D_draw_c_raster()

int D_draw_c_raster ( int  A_row,
const CELL carray,
struct Colors colors 
)

Draw raster row (CELL)

The row gives the map array row. The carray array provides the categories for each raster value in that row. This routine is called consecutively with the information necessary to draw a raster image from north to south. No rows can be skipped. All screen pixel rows which represent the current map array row are rendered. The routine returns the map array row which is needed to draw the next screen pixel row.

Parameters
A_rowrow number (starts at 0)
carraydata buffer
colorspointer to Colors structure
Returns
row number needed for next pixel row
-1 nothing to draw (on error or end of raster)

Definition at line 105 of file raster.c.

References CELL_TYPE, colors, and draw_cell().

◆ D_draw_d_raster()

int D_draw_d_raster ( int  A_row,
const DCELL darray,
struct Colors colors 
)

Draw raster row (DCELL)

Parameters
A_rowrow number (starts at 0)
darraydata buffer
colorspointer to Colors structure
Returns

Definition at line 67 of file raster.c.

References colors, DCELL_TYPE, and draw_cell().

◆ D_draw_f_raster()

int D_draw_f_raster ( int  A_row,
const FCELL farray,
struct Colors colors 
)

Draw raster row (FCELL)

Parameters
A_rowrow number (starts at 0)
farraydata buffer
colorspointer to Colors structure
Returns
row number needed for next pixel row
-1 nothing to draw (on error or end of raster)

Definition at line 82 of file raster.c.

References colors, draw_cell(), and FCELL_TYPE.

◆ D_draw_raster()

int D_draw_raster ( int  A_row,
const void *  array,
struct Colors colors,
RASTER_MAP_TYPE  data_type 
)

Draw raster row.

  • determine which pixel row gets the data
  • resamples the data to create a pixel array
  • determines best way to draw the array a - for single cat array, a move and a draw b - otherwise, a call to D_raster()

Presumes the map is drawn from north to south.

If overlay mode is desired, then call D_set_overlay_mode() first.

Parameters
A_rowrow number (starts at 0)
arraydata buffer
colorspointer to Colors structure
data_typeraster type (CELL, FCELL, DCELL)
Returns
row number needed for next pixel row
-1 nothing to draw (on error or end of raster)

Definition at line 51 of file raster.c.

References colors, and draw_cell().

◆ D_draw_raster_RGB()

int D_draw_raster_RGB ( int  A_row,
const void *  r_raster,
const void *  g_raster,
const void *  b_raster,
struct Colors r_colors,
struct Colors g_colors,
struct Colors b_colors,
RASTER_MAP_TYPE  r_type,
RASTER_MAP_TYPE  g_type,
RASTER_MAP_TYPE  b_type 
)

Draw raster row in RGB mode.

Parameters
A_rowrow number (starts at 0)
r_rasterred data buffer
g_rastergreen data buffer
b_rasterblue data buffer
r_colorscolors used for red channel
g_colorscolors used for green channel
b_colorscolors used for blue channel
r_typeraster type used for red channel
g_typeraster type used for red channel
b_typeraster type used for red channel
Returns
row number needed for next pixel row
-1 nothing to draw (on error or end of raster)

Definition at line 177 of file raster.c.

References COM_raster(), D__overlay_mode, G_incr_void_ptr(), nalloc, ncols, NULL, Rast_cell_size(), Rast_is_null_value(), Rast_lookup_colors(), and src.

◆ D_raster_draw_begin()

void D_raster_draw_begin ( void  )

Prepare for raster graphic.

The raster display subsystem establishes conversion parameters based on the screen extent defined by top, bottom, left, and right, all of which are obtainable from D_get_dst() for the current frame.

Definition at line 152 of file raster.c.

References COM_begin_raster(), D__overlay_mode, D_get_a(), D_get_d(), dst, and src.

◆ D_raster_draw_end()

void D_raster_draw_end ( void  )

Finish raster rendering.

Definition at line 231 of file raster.c.

References COM_end_raster().

◆ draw_cell()

static int draw_cell ( int  A_row,
const void *  array,
struct Colors colors,
RASTER_MAP_TYPE  data_type 
)
static

Variable Documentation

◆ D__overlay_mode

int D__overlay_mode
extern

code in this file is designed to send raster data to the graphics driver. It handles raster->color lookup translation, as well as loading appropriate colormaps into the driver and the sending of raster data to the plotter. The loading of colors is designed to never send more colors than the hardware can support - even though the GRASS drivers will allocate virtual colormaps to pretend there are more This code effectively disables that driver feature/mistake.

To simply plot raster data:

to specify if overlay mode is to be used D_set_overlay_mode(flag) int flag; /1=yes,0=no/

to select a raster color for line drawing D_color (cat, colors) CELL cat struct Colors *colors; /color info/

D_color_of_type(raster, colors, data_type); void *raster; struct Colors *colors; /color info/ RASTER_MAP_TYPE data_type;

Note: the same Colors structure must be passed to all routines.

Definition at line 36 of file raster2.c.

Referenced by D_draw_raster_RGB(), D_raster_draw_begin(), D_set_overlay_mode(), and draw_cell().

◆ dst

double dst[2][2]
static

Definition at line 26 of file raster.c.

Referenced by calc_conv(), clip_path_plane(), COM_begin_raster(), conv_path(), copy_file(), copy_node(), cull_path_plane(), D__clip_path(), D__cull_path(), D_raster_draw_begin(), datetime_copy(), datetime_is_same(), db_copy_dbmscap_entry(), db_copy_string(), db_copy_value(), G_adjust_window_to_box(), G_bz2_compress(), G_bz2_expand(), G_compress(), G_expand(), G_fpcompress_rearrangeDecodeDoubles(), G_fpcompress_rearrangeDecodeFloats(), G_fpcompress_rearrangeEncodeDoubles(), G_fpcompress_rearrangeEncodeFloats(), G_lz4_compress(), G_lz4_expand(), G_no_compress(), G_no_expand(), G_read_compressed(), G_recursive_copy(), G_rle_compress(), G_rle_expand(), G_write_compressed(), G_xdr_get_double(), G_xdr_get_float(), G_xdr_get_int(), G_xdr_put_double(), G_xdr_put_float(), G_xdr_put_int(), G_zstd_compress(), G_zstd_expand(), ll_wrap_path(), LZ4_compress_destSize(), LZ4_compress_destSize_extState(), LZ4_compress_fast_extState_fastReset(), LZ4_compress_limitedOutput_continue(), LZ4_compress_limitedOutput_withState(), LZ4_compress_withState(), LZ4_decompress_generic(), NetA_betweenness_closeness(), NetA_distance_from_points(), NetA_distance_to_points(), path_copy(), print_escaped_for_xml(), PS_begin_raster(), put_data_gdal(), Rast3d_cache_get_elt(), Rast3d_copy_double2Float(), Rast3d_copy_float2Double(), Rast3d_copy_from_xdr(), Rast3d_copy_values(), Rast3d_fpcompress_read_xdr_nums(), Rast3d_long_decode(), Rast3d_long_encode(), Rast3d_rle_decode(), Rast3d_rle_encode(), Rast_abs_log_colors(), Rast_close_gdal_write_link(), Rast_histogram_eq_colors(), Rast_histogram_eq_fp_colors(), Rast_log_colors(), reduce_path(), rle_compress(), rle_decompress(), rle_length2code(), swap_double(), swap_float(), and swap_int().

◆ src

int src[2][2]
static

Definition at line 25 of file raster.c.

Referenced by _datetime_add_field(), _datetime_subtract_field(), avl_t_copy(), cache_test_load_fun(), calc_conv(), clip_path_plane(), COM_begin_raster(), conv_path(), copy_file(), copy_node(), count_run(), cull_path_plane(), D__clip_path(), D__cull_path(), D_draw_raster_RGB(), D_raster_draw_begin(), datetime_check_increment(), datetime_copy(), datetime_increment(), datetime_is_same(), datetime_is_valid_increment(), datetime_set_increment_type(), db_clone_table(), db_copy_column(), db_copy_dbmscap_entry(), db_copy_string(), db_copy_value(), db_double_quote_string(), draw_cell(), G_adjust_window_to_box(), G_bz2_compress(), G_bz2_expand(), G_compress(), G_expand(), G_fpcompress_rearrangeDecodeDoubles(), G_fpcompress_rearrangeDecodeFloats(), G_fpcompress_rearrangeEncodeDoubles(), G_fpcompress_rearrangeEncodeFloats(), G_lz4_compress(), G_lz4_expand(), G_no_compress(), G_no_expand(), G_recursive_copy(), G_rle_compress(), G_rle_expand(), G_write_compressed(), G_write_uncompressed(), G_xdr_get_double(), G_xdr_get_float(), G_xdr_get_int(), G_xdr_put_double(), G_xdr_put_float(), G_xdr_put_int(), G_zstd_compress(), G_zstd_expand(), gpd_2dsite(), GS_get_att(), gs_set_att_src(), gvd_vect(), GVL_isosurf_get_att(), gvl_isosurf_set_att_src(), ll_wrap_path(), LZ4_compress_destSize(), LZ4_compress_destSize_extState(), LZ4_compress_fast_extState_fastReset(), LZ4_compress_limitedOutput_continue(), LZ4_compress_limitedOutput_withState(), LZ4_compress_withState(), LZ4_decompress_generic(), Nviz_set_attr(), path_copy(), print_escaped_for_xml(), PS_begin_raster(), put_data_gdal(), Rast3d_cache_put_elt(), Rast3d_copy_double2Float(), Rast3d_copy_float2Double(), Rast3d_copy_to_xdr(), Rast3d_copy_values(), Rast3d_fpcompress_read_xdr_nums(), Rast3d_fpcompress_write_xdr_nums(), Rast3d_long_encode(), Rast3d_rle_count_only(), Rast3d_rle_decode(), Rast3d_rle_encode(), Rast_abs_log_colors(), Rast_histogram_eq_colors(), Rast_histogram_eq_fp_colors(), Rast_log_colors(), reduce_path(), rle_code2length(), rle_compress(), rle_decompress(), swap_double(), swap_float(), swap_int(), tavl_t_copy(), xdr_get(), and xdr_put().