[GRASS-SVN] r53439 - grass/trunk/raster/r.out.ppm
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 17 06:16:03 PDT 2012
Author: annakrat
Date: 2012-10-17 06:16:00 -0700 (Wed, 17 Oct 2012)
New Revision: 53439
Modified:
grass/trunk/raster/r.out.ppm/main.c
Log:
r.out.ppm: added flag to suppress printing header of ppm file - needed by animation tool for loading raw image data
Modified: grass/trunk/raster/r.out.ppm/main.c
===================================================================
--- grass/trunk/raster/r.out.ppm/main.c 2012-10-17 12:46:50 UTC (rev 53438)
+++ grass/trunk/raster/r.out.ppm/main.c 2012-10-17 13:16:00 UTC (rev 53439)
@@ -34,7 +34,7 @@
{
struct GModule *module;
struct Option *rast, *ppm_file;
- struct Flag *gscale;
+ struct Flag *gscale, *header;
char *map, *p, ofile[1000];
unsigned char *set, *ored, *ogrn, *oblu;
CELL *cell_buf;
@@ -66,6 +66,10 @@
gscale->key = 'g';
gscale->description = _("Output greyscale instead of color");
+ header = G_define_flag();
+ header->key = 'h';
+ header->description = _("Suppress printing of PPM header");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -116,31 +120,32 @@
}
}
/* write header info */
+ if (!header->answer) {
+ if (!gscale->answer)
+ fprintf(fp, "P6\n");
+ /* Magic number meaning rawbits, 24bit color to ppm format */
+ else
+ fprintf(fp, "P5\n");
+ /* Magic number meaning rawbits, 8bit greyscale to ppm format */
- if (!gscale->answer)
- fprintf(fp, "P6\n");
- /* Magic number meaning rawbits, 24bit color to ppm format */
- else
- fprintf(fp, "P5\n");
- /* Magic number meaning rawbits, 8bit greyscale to ppm format */
+ if (!do_stdout) {
+ fprintf(fp, "# CREATOR: %s from GRASS raster map \"%s\"\n",
+ G_program_name(), rast->answer);
+ fprintf(fp, "# east-west resolution: %f\n", w.ew_res);
+ fprintf(fp, "# north-south resolution: %f\n", w.ns_res);
+ fprintf(fp, "# South edge: %f\n", w.south);
+ fprintf(fp, "# West edge: %f\n", w.west);
+ /* comments */
+ }
- if (!do_stdout) {
- fprintf(fp, "# CREATOR: %s from GRASS raster map \"%s\"\n",
- G_program_name(), rast->answer);
- fprintf(fp, "# east-west resolution: %f\n", w.ew_res);
- fprintf(fp, "# north-south resolution: %f\n", w.ns_res);
- fprintf(fp, "# South edge: %f\n", w.south);
- fprintf(fp, "# West edge: %f\n", w.west);
- /* comments */
+ fprintf(fp, "%d %d\n", w.cols, w.rows);
+ /* width & height */
+
+ fprintf(fp, "255\n");
+ /* max intensity val */
}
- fprintf(fp, "%d %d\n", w.cols, w.rows);
- /* width & height */
- fprintf(fp, "255\n");
- /* max intensity val */
-
-
G_important_message(_("Converting..."));
{
More information about the grass-commit
mailing list