43
44
struct GModule *module;
44
45
struct Option *ppm_file;
46
/* please, remove before GRASS 7 released */
47
struct Flag *bequiet, *comment;
48
47
struct Cell_head w;
50
49
unsigned char *dummy;
52
char *tmpstr1, *tmpstr2;
54
54
G_gisinit(argv[0]);
56
56
module = G_define_module();
57
module->keywords = _("raster");
59
_("Converts 3 GRASS raster layers (R,G,B) to a PPM image file "
60
"at the pixel resolution of the CURRENTLY DEFINED REGION.");
57
G_add_keyword(_("raster"));
58
G_add_keyword(_("export"));
59
module->description = _("Converts 3 GRASS raster layers (R,G,B) to a PPM image file.");
62
61
for (i = 0; i < 3; i++) {
82
81
ppm_file->multiple = NO;
83
82
ppm_file->answer = NULL;
84
83
ppm_file->description =
85
_("Name for new PPM file. (use out=- for stdout)");
87
/* please, remove before GRASS 7 released */
88
bequiet = G_define_flag();
90
bequiet->description = _("Run quietly");
84
_("Name for new PPM file. (use '-' for stdout)");
92
86
comment = G_define_flag();
93
87
comment->key = 'c';
96
90
if (G_parser(argc, argv))
97
91
exit(EXIT_FAILURE);
99
/* please, remove before GRASS 7 released */
100
if (bequiet->answer) {
101
putenv("GRASS_VERBOSE=0");
102
G_warning(_("The '-q' flag is superseded and will be removed "
103
"in future. Please use '--quiet' instead."));
109
G_message(_("rows = %d, cols = %d"), w.rows, w.cols);
95
G_asprintf(&tmpstr1, _n("row = %d", "rows = %d", w.rows), w.rows);
96
/* GTC Raster columns */
97
G_asprintf(&tmpstr2, _n("column = %d", "columns = %d", w.cols), w.cols);
98
G_message("%s, %s", tmpstr1, tmpstr2);
111
102
/* open raster map for reading */
112
103
for (i = 0; i < 3; i++) {
113
104
/* Get name of layer */
114
105
char *name = B[i].opt->answer;
117
/* Get mapset of layer */
118
mapset = G_find_cell2(name, "");
120
G_fatal_error(_("Raster map <%s> not found"), name);
122
107
/* Open raster map */
123
if ((B[i].file = G_open_cell_old(name, mapset)) == -1)
124
G_fatal_error(_("Unable to open raster map <%s>"), name);
108
B[i].file = Rast_open_old(name, "");
126
110
/* Get map type (CELL/FCELL/DCELL) */
127
B[i].type = G_get_raster_map_type(B[i].file);
111
B[i].type = Rast_get_map_type(B[i].file);
129
113
/* Get color table */
130
if (G_read_colors(name, mapset, &B[i].colors) == -1)
114
if (Rast_read_colors(name, "", &B[i].colors) == -1)
131
115
G_fatal_error(_("Color file for <%s> not available"), name);
133
117
/* Allocate input buffer */
134
B[i].array = G_allocate_raster_buf(B[i].type);
118
B[i].array = Rast_allocate_buf(B[i].type);
136
120
/* Allocate output buffers */
137
121
B[i].buf = (unsigned char *)G_malloc(w.cols);
179
163
G_percent(row, w.rows, 5);
181
165
for (i = 0; i < 3; i++) {
182
if (G_get_raster_row(B[i].file, B[i].array, row, B[i].type) < 0)
183
G_fatal_error("G_get_raster_row failed");
166
Rast_get_row(B[i].file, B[i].array, row, B[i].type);
185
G_lookup_raster_colors(B[i].array,
168
Rast_lookup_colors(B[i].array,
186
169
(i == 0) ? B[i].buf : dummy,
187
170
(i == 1) ? B[i].buf : dummy,
188
171
(i == 2) ? B[i].buf : dummy,