GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
color_write.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <grass/gis.h>
Include dependency graph for color_write.c:

Go to the source code of this file.

Functions

int G_write_colors (const char *name, const char *mapset, struct Colors *colors)
 write map layer color table More...
 
int G__write_colors (FILE *fd, struct Colors *colors)
 

Function Documentation

int G__write_colors ( FILE *  fd,
struct Colors *  colors 
)

Definition at line 105 of file color_write.c.

References getenv().

Referenced by G_write_colors().

int G_write_colors ( const char *  name,
const char *  mapset,
struct Colors *  colors 
)

write map layer color table

The color table is written for the raster map name in the specified mapset from the colors structure. If there is an error, -1 is returned. No diagnostic is printed. Otherwise, 1 is returned. The colors structure must be created properly, i.e., G_init_colors to initialize the structure and G_add_color_rule to set the category colors.

Remarks
{These routines are called by higher level routines which read or create entire color tables, such asG_read_colors or G_make_ramp_colors.} Note. The calling sequence for this function deserves special attention. The mapset parameter seems to imply that it is possible to overwrite the color table for a raster map which is in another mapset. However, this is not what actually happens. It is very useful for users to create their own color tables for raster maps in other mapsets, but without overwriting other users' color tables for the same raster map. If mapset is the current mapset, then the color file for name will be overwritten by the new color table. But if mapset is not the current mapset, then the color table is actually written in the current mapset under the colr2 element as: colr2/mapset/name.
Parameters
name
mapset
colors
Returns
int

The rules are written out using floating-point format, removing trailing zeros (possibly producing integers). The flag marking the colors as floating-point is not written.

Returns
int

Definition at line 74 of file color_write.c.

References fclose(), fd, G__name_is_fully_qualified(), G__write_colors(), G_fopen_new(), G_mapset(), G_remove(), sprintf(), stat, xmapset, and xname.

Referenced by IL_output_2d(), and IL_resample_output_2d().