diff options
Diffstat (limited to 'editor/specialty')
-rw-r--r-- | editor/specialty/pamdeinterlace.c | 8 | ||||
-rw-r--r-- | editor/specialty/pamoil.c | 8 | ||||
-rw-r--r-- | editor/specialty/pampop9.c | 4 | ||||
-rw-r--r-- | editor/specialty/pbmlife.c | 114 | ||||
-rw-r--r-- | editor/specialty/pgmabel.c | 2 | ||||
-rw-r--r-- | editor/specialty/pgmbentley.c | 6 | ||||
-rw-r--r-- | editor/specialty/pgmmorphconv.c | 56 | ||||
-rw-r--r-- | editor/specialty/pnmmercator.c | 54 | ||||
-rw-r--r-- | editor/specialty/ppm3d.c | 30 | ||||
-rw-r--r-- | editor/specialty/ppmglobe.c | 14 | ||||
-rw-r--r-- | editor/specialty/ppmntsc.c | 124 | ||||
-rw-r--r-- | editor/specialty/ppmrelief.c | 2 | ||||
-rw-r--r-- | editor/specialty/ppmshift.c | 1 | ||||
-rw-r--r-- | editor/specialty/ppmtv.c | 167 |
14 files changed, 294 insertions, 296 deletions
diff --git a/editor/specialty/pamdeinterlace.c b/editor/specialty/pamdeinterlace.c index d6f6aee1..666daa16 100644 --- a/editor/specialty/pamdeinterlace.c +++ b/editor/specialty/pamdeinterlace.c @@ -2,7 +2,7 @@ pamdeinterlace ******************************************************************************* De-interlace an image, i.e. select every 2nd row. - + By Bryan Henderson, San Jose, CA 2001.11.11. Contributed to the public domain. @@ -81,7 +81,7 @@ main(int argc, char *argv[]) { tuple * tuplerow; /* Row from input image */ unsigned int row; struct cmdlineInfo cmdline; - struct pam inpam; + struct pam inpam; struct pam outpam; pnm_init( &argc, argv ); @@ -89,7 +89,7 @@ main(int argc, char *argv[]) { parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFilespec); - + pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); if (inpam.height < 2 && cmdline.rowsToTake == ODD) @@ -133,7 +133,7 @@ main(int argc, char *argv[]) { pnm_freepamrow(tuplerow); pm_close(inpam.file); pm_close(outpam.file); - + return 0; } diff --git a/editor/specialty/pamoil.c b/editor/specialty/pamoil.c index 6cb8d3ac..2618ac12 100644 --- a/editor/specialty/pamoil.c +++ b/editor/specialty/pamoil.c @@ -18,7 +18,7 @@ #include "pam.h" #include "mallocvar.h" -static void +static void convertRow(struct pam const inpam, tuple ** const tuples, tuple * const tuplerow, int const row, int const smearFactor, int * const hist) { @@ -34,7 +34,7 @@ convertRow(struct pam const inpam, tuple ** const tuples, of the pixel being examined */ - /* Compute hist[] - frequencies, in the neighborhood, of each + /* Compute hist[] - frequencies, in the neighborhood, of each sample value */ for (i = 0; i <= inpam.maxval; ++i) hist[i] = 0; @@ -42,8 +42,8 @@ convertRow(struct pam const inpam, tuple ** const tuples, for (drow = row - smearFactor; drow <= row + smearFactor; ++drow) { if (drow >= 0 && drow < inpam.height) { int dcol; - for (dcol = col - smearFactor; - dcol <= col + smearFactor; + for (dcol = col - smearFactor; + dcol <= col + smearFactor; ++dcol) { if ( dcol >= 0 && dcol < inpam.width ) ++hist[tuples[drow][dcol][sample]]; diff --git a/editor/specialty/pampop9.c b/editor/specialty/pampop9.c index b92c7d6b..7211c5eb 100644 --- a/editor/specialty/pampop9.c +++ b/editor/specialty/pampop9.c @@ -1,4 +1,4 @@ -/* +/* * * (c) Robert Tinsley, 2003 (http://www.thepoacher.net/contact) * @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) ydelta = atoi(argv[5]); if (filename == NULL || *filename == '\0' - || xtiles <= 0 || ytiles <= 0 || xdelta < 0 || ydelta < 0) + || xtiles <= 0 || ytiles <= 0 || xdelta < 0 || ydelta < 0) pm_error("invalid argument"); /* read src pam */ diff --git a/editor/specialty/pbmlife.c b/editor/specialty/pbmlife.c index be34cc69..03735d58 100644 --- a/editor/specialty/pbmlife.c +++ b/editor/specialty/pbmlife.c @@ -31,12 +31,12 @@ char* argv[]; pbm_init( &argc, argv ); if ( argc > 2 ) - pm_usage( "[pbmfile]" ); + pm_usage( "[pbmfile]" ); if ( argc == 2 ) - ifp = pm_openr( argv[1] ); + ifp = pm_openr( argv[1] ); else - ifp = stdin; + ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); prevrow = pbm_allocrow( cols ); @@ -49,63 +49,63 @@ char* argv[]; pbm_readpbmrow( ifp, nextrow, cols, format ); for ( row = 0; row < rows; ++row ) - { - temprow = prevrow; - prevrow = thisrow; - thisrow = nextrow; - nextrow = temprow; - if ( row < rows - 1 ) - pbm_readpbmrow( ifp, nextrow, cols, format ); + { + temprow = prevrow; + prevrow = thisrow; + thisrow = nextrow; + nextrow = temprow; + if ( row < rows - 1 ) + pbm_readpbmrow( ifp, nextrow, cols, format ); for ( col = 0; col < cols; ++col ) - { - /* Check the neighborhood, with an unrolled double loop. */ - count = 0; - if ( row > 0 ) - { - /* upper left */ - if ( col > 0 && prevrow[col - 1] == PBM_WHITE ) - ++count; - /* upper center */ - if ( prevrow[col] == PBM_WHITE ) - ++count; - /* upper right */ - if ( col < cols - 1 && prevrow[col + 1] == PBM_WHITE ) - ++count; - } - /* left */ - if ( col > 0 && thisrow[col - 1] == PBM_WHITE ) - ++count; - /* right */ - if ( col < cols - 1 && thisrow[col + 1] == PBM_WHITE ) - ++count; - if ( row < rows - 1 ) - { - /* lower left */ - if ( col > 0 && nextrow[col - 1] == PBM_WHITE ) - ++count; - /* lower center */ - if ( nextrow[col] == PBM_WHITE ) - ++count; - /* lower right */ - if ( col < cols - 1 && nextrow[col + 1] == PBM_WHITE ) - ++count; - } + { + /* Check the neighborhood, with an unrolled double loop. */ + count = 0; + if ( row > 0 ) + { + /* upper left */ + if ( col > 0 && prevrow[col - 1] == PBM_WHITE ) + ++count; + /* upper center */ + if ( prevrow[col] == PBM_WHITE ) + ++count; + /* upper right */ + if ( col < cols - 1 && prevrow[col + 1] == PBM_WHITE ) + ++count; + } + /* left */ + if ( col > 0 && thisrow[col - 1] == PBM_WHITE ) + ++count; + /* right */ + if ( col < cols - 1 && thisrow[col + 1] == PBM_WHITE ) + ++count; + if ( row < rows - 1 ) + { + /* lower left */ + if ( col > 0 && nextrow[col - 1] == PBM_WHITE ) + ++count; + /* lower center */ + if ( nextrow[col] == PBM_WHITE ) + ++count; + /* lower right */ + if ( col < cols - 1 && nextrow[col + 1] == PBM_WHITE ) + ++count; + } - /* And compute the new value. */ - if ( thisrow[col] == PBM_WHITE ) - if ( count == 2 || count == 3 ) - newrow[col] = PBM_WHITE; - else - newrow[col] = PBM_BLACK; - else - if ( count == 3 ) - newrow[col] = PBM_WHITE; - else - newrow[col] = PBM_BLACK; - } - pbm_writepbmrow( stdout, newrow, cols, 0 ); - } + /* And compute the new value. */ + if ( thisrow[col] == PBM_WHITE ) + if ( count == 2 || count == 3 ) + newrow[col] = PBM_WHITE; + else + newrow[col] = PBM_BLACK; + else + if ( count == 3 ) + newrow[col] = PBM_WHITE; + else + newrow[col] = PBM_BLACK; + } + pbm_writepbmrow( stdout, newrow, cols, 0 ); + } pm_close( ifp ); pm_close( stdout ); diff --git a/editor/specialty/pgmabel.c b/editor/specialty/pgmabel.c index 5badfd19..3e05be5e 100644 --- a/editor/specialty/pgmabel.c +++ b/editor/specialty/pgmabel.c @@ -117,7 +117,7 @@ abel ( float *y, int N, double *adl) for (n=0 ; n<N ; n++) { if (( n>=1 )&&( n<N-1 )) - (*y++) = ((rho[n-1]*0.5+rho[n]+rho[n+1]*0.5)/2.0);/*1D median filter*/ + (*y++) = ((rho[n-1]*0.5+rho[n]+rho[n+1]*0.5)/2.0);/*1D median filter*/ else (*y++) = rho[n]; } free(rho); diff --git a/editor/specialty/pgmbentley.c b/editor/specialty/pgmbentley.c index aed92074..87778a62 100644 --- a/editor/specialty/pgmbentley.c +++ b/editor/specialty/pgmbentley.c @@ -41,7 +41,7 @@ main(int argc, const char * argv[]) { pm_error("There are no options and only one argument. " "You specified %u", argc-1); } - ifP = pm_openr(inputFileName); + ifP = pm_openr(inputFileName); gin = pgm_readpgm(ifP, &cols, &rows, &maxval); @@ -62,9 +62,9 @@ main(int argc, const char * argv[]) { unsigned int const brow = MIN(rows-1, row + gin[row][col] / N); gout[brow][col] = gin[row][col]; - } + } } - + pgm_writepgm(stdout, gout, cols, rows, maxval, 0); pm_close(stdout); diff --git a/editor/specialty/pgmmorphconv.c b/editor/specialty/pgmmorphconv.c index 2ba2d62d..40ce5d76 100644 --- a/editor/specialty/pgmmorphconv.c +++ b/editor/specialty/pgmmorphconv.c @@ -1,9 +1,9 @@ -/* pgmmorphconv.c - morphological convolutions on a graymap: dilation and +/* pgmmorphconv.c - morphological convolutions on a graymap: dilation and ** erosion ** ** Copyright (C) 2000 by Luuk van Dijk/Mind over Matter ** -** Based on +** Based on ** pnmconvol.c - general MxN convolution on a portable anymap ** ** Copyright (C) 1989, 1991 by Jef Poskanzer. @@ -95,7 +95,7 @@ parseCommandLine(int argc, const char ** const argv, cmdlineP->inputFileName = "-"; else { cmdlineP->inputFileName = argv[2]; - + if (argc-1 > 2) pm_error("Too many arguments: %u. " "The only possible arguments " @@ -146,7 +146,7 @@ setAllPixel(gray ** const image, for (col = 0; col < cols; ++col) { unsigned int row; for (row = 0; row < rows; ++row) - image[row][col] = value; + image[row][col] = value; } } @@ -155,9 +155,9 @@ setAllPixel(gray ** const image, static void dilate(bit ** const template, int const trowso2, - int const tcolso2, + int const tcolso2, gray ** const inImage, - gray ** const outImage, + gray ** const outImage, unsigned int const rows, unsigned int const cols, unsigned int * const templateCountP) { @@ -198,9 +198,9 @@ dilate(bit ** const template, static void erode(bit ** const template, int const trowso2, - int const tcolso2, + int const tcolso2, gray ** const inImage, - gray ** const outImage, + gray ** const outImage, unsigned int const rows, unsigned int const cols, unsigned int * const templateCountP) { @@ -227,10 +227,10 @@ erode(bit ** const template, for (c = ((tc > 0) ? 0 : -tc); c < ((tc > 0) ? (cols-tc) : cols); ++c) { - + gray const source = inImage[r+tr][c+tc]; outImage[r][c] = MIN(source, outImage[r][c]); - + } } } @@ -244,9 +244,9 @@ erode(bit ** const template, static void openMorph(bit ** const template, int const trowso2, - int const tcolso2, + int const tcolso2, gray ** const inputImage, - gray ** const outputImage, + gray ** const outputImage, unsigned int const rows, unsigned int const cols, unsigned int * const templateCountP) { @@ -255,11 +255,11 @@ openMorph(bit ** const template, unsigned int erodedTemplateCount; erodedImage = pgm_allocarray(cols, rows); - - erode(template, trowso2, tcolso2, + + erode(template, trowso2, tcolso2, inputImage, erodedImage, rows, cols, &erodedTemplateCount); - dilate(template, trowso2, tcolso2, + dilate(template, trowso2, tcolso2, erodedImage, outputImage, rows, cols, templateCountP); pgm_freearray(erodedImage, rows); @@ -270,9 +270,9 @@ openMorph(bit ** const template, static void closeMorph(bit ** const template, int const trowso2, - int const tcolso2, + int const tcolso2, gray ** const inputImage, - gray ** const outputImage, + gray ** const outputImage, unsigned int const rows, unsigned int const cols, unsigned int * const templateCountP) { @@ -282,10 +282,10 @@ closeMorph(bit ** const template, dilatedImage = pgm_allocarray(cols, rows); - dilate(template, trowso2, tcolso2, + dilate(template, trowso2, tcolso2, inputImage, dilatedImage, rows, cols, &dilatedTemplateCount); - erode(template, trowso2, tcolso2, + erode(template, trowso2, tcolso2, dilatedImage, outputImage, rows, cols, templateCountP); pgm_freearray(dilatedImage, rows); @@ -296,7 +296,7 @@ closeMorph(bit ** const template, static void subtract(gray ** const subtrahendImage, gray ** const subtractorImage, - gray ** const outImage, + gray ** const outImage, unsigned int const rows, unsigned int const cols ) { @@ -318,9 +318,9 @@ subtract(gray ** const subtrahendImage, static void gradient(bit ** const template, int const trowso2, - int const tcolso2, + int const tcolso2, gray ** const inputImage, - gray ** const outputImage, + gray ** const outputImage, unsigned int const rows, unsigned int const cols, unsigned int * const templateCountP) { @@ -328,14 +328,14 @@ gradient(bit ** const template, gray ** dilatedImage; gray ** erodedImage; unsigned int dilatedTemplateCount; - + dilatedImage = pgm_allocarray(cols, rows); erodedImage = pgm_allocarray(cols, rows); - dilate(template, trowso2, tcolso2, + dilate(template, trowso2, tcolso2, inputImage, dilatedImage, rows, cols, &dilatedTemplateCount); - erode(template, trowso2, tcolso2, + erode(template, trowso2, tcolso2, inputImage, erodedImage, rows, cols, templateCountP); subtract(dilatedImage, erodedImage, outputImage, rows, cols); @@ -369,14 +369,14 @@ main(int argc, const char ** argv) { &template, &templateRows, &templateCols); /* Template coords run from -templateCols/2 .. 0 .. + templateCols/2 */ - + inputImage = pgm_readpgm(ifP, &cols, &rows, &maxval); if (cols < templateCols || rows < templateRows) pm_error("the image is smaller than the convolution matrix" ); - + outputImage = pgm_allocarray(cols, rows); - + switch (cmdline.operation) { case DILATE: dilate(template, templateRows/2, templateCols/2, diff --git a/editor/specialty/pnmmercator.c b/editor/specialty/pnmmercator.c index 81f7f148..0c5c790f 100644 --- a/editor/specialty/pnmmercator.c +++ b/editor/specialty/pnmmercator.c @@ -27,16 +27,16 @@ /* The pnm library allows us to code this program without branching cases for PGM and PPM, but we do the branch anyway to speed up processing of PGM - images. + images. */ -struct cmdlineInfo +struct cmdlineInfo { /* All the information the user supplied in the command line, - in a form easy for the program to use. + in a form easy for the program to use. */ const char * input_filespec; /* Filespecs of input files */ @@ -50,14 +50,14 @@ struct cmdlineInfo static void -parseCommandLine(int argc, +parseCommandLine(int argc, const char ** argv, struct cmdlineInfo * const cmdlineP ) { optEntry * option_def; optStruct3 opt; /* Instructions to pm_optParseOptions3 on how to parse our options. */ - + unsigned int option_def_index; MALLOCARRAY_NOFAIL(option_def, 100); @@ -85,9 +85,9 @@ parseCommandLine(int argc, static void -computeOutputDimensions(const struct cmdlineInfo cmdline, +computeOutputDimensions(const struct cmdlineInfo cmdline, const int rows, const int cols, - int * newrowsP, int * newcolsP) + int * newrowsP, int * newcolsP) { *newcolsP = cols; if (!cmdline.inverse) @@ -106,7 +106,7 @@ computeOutputDimensions(const struct cmdlineInfo cmdline, pm_message("Creating Degrees map, new size is %dx%d", *newcolsP, *newrowsP); } -} +} @@ -117,15 +117,15 @@ transformWithMixing(FILE * const ifP, int const newcols, int const newrows, xelval const newmaxval, int const newformat, bool const inverse, - bool const verbose, bool const vverbose) + bool const verbose, bool const vverbose) { - /* - Transform the map image on input file 'ifP' (which is described by + /* + Transform the map image on input file 'ifP' (which is described by 'cols', 'rows', 'format', and 'maxval') to a Mercator projection - and write the result to standard output as format 'newformat' and + and write the result to standard output as format 'newformat' and with maxval 'newmaxval'. - We'll blend colors from subsequent rows in the output pixels. + We'll blend colors from subsequent rows in the output pixels. */ xel* oddxelrow; /* an input row */ @@ -142,14 +142,14 @@ transformWithMixing(FILE * const ifP, double fLatRad; double fLatMerc; - oddxelrow = pnm_allocrow(cols); - evenxelrow = pnm_allocrow(cols); + oddxelrow = pnm_allocrow(cols); + evenxelrow = pnm_allocrow(cols); rowInXelrow = 0; newxelrow = pnm_allocrow(newcols); for (row = 0; row < newrows; ++row) { - + fRow = (double)row + 0.5; /* center on half the pixel */ if (!inverse) { /* the result is mercator, calculate back to degrees */ @@ -207,7 +207,7 @@ transformWithMixing(FILE * const ifP, } } - while ((rowInXelrow <= inputRow + 1) && + while ((rowInXelrow <= inputRow + 1) && (rowInXelrow < rows)) { /* we need to read one row ahead */ if (rowInXelrow % 2 == 0) { @@ -268,16 +268,16 @@ transformNoneMixing(FILE * const ifP, int const newcols, int const newrows, xelval const newmaxval, int const newformat, bool const inverse, - bool const verbose, bool const vverbose) + bool const verbose, bool const vverbose) { /* - Transform the map image on input file 'ifP' (which is described by + Transform the map image on input file 'ifP' (which is described by 'cols', 'rows', 'format', and 'maxval') to a Mercator projection and - write the result to standard output as format 'newformat' and with + write the result to standard output as format 'newformat' and with maxval 'newmaxval'. Don't mix colors from different input pixels together in the output - pixels. Each output pixel is an exact copy of some corresponding + pixels. Each output pixel is an exact copy of some corresponding input pixel. */ @@ -293,13 +293,13 @@ transformNoneMixing(FILE * const ifP, double fLatRad; double fLatMerc; - xelrow = pnm_allocrow(cols); + xelrow = pnm_allocrow(cols); rowInXelrow = 0; newxelrow = pnm_allocrow(newcols); for (row = 0; row < newrows; ++row) { - + fRow = (double)row + 0.5; /* center on half the pixel */ if (!inverse) { /* the result is mercator, calculate back to degrees */ @@ -377,7 +377,7 @@ transformNoneMixing(FILE * const ifP, int -main(int argc, const char ** argv ) +main(int argc, const char ** argv ) { struct cmdlineInfo cmdline; FILE* ifP; @@ -413,18 +413,18 @@ main(int argc, const char ** argv ) if (verbose) pm_message("Transforming map without mixing/blending colors"); transformNoneMixing(ifP, cols, rows, maxval, format, - newcols, newrows, newmaxval, newformat, + newcols, newrows, newmaxval, newformat, cmdline.inverse, verbose, cmdline.vverbose); } else { if (verbose) pm_message("Transforming map while using intermediate colors"); transformWithMixing(ifP, cols, rows, maxval, format, - newcols, newrows, newmaxval, newformat, + newcols, newrows, newmaxval, newformat, cmdline.inverse, verbose, cmdline.vverbose); } pm_close(ifP); pm_close(stdout); - + return 0; } diff --git a/editor/specialty/ppm3d.c b/editor/specialty/ppm3d.c index a6faa341..bb7cd1af 100644 --- a/editor/specialty/ppm3d.c +++ b/editor/specialty/ppm3d.c @@ -33,7 +33,7 @@ parseCommandLine(int argc, char ** argv, struct cmdlineInfo * const cmdlineP) { /*---------------------------------------------------------------------------- parse program command line described in Unix standard form by argc - and argv. Return the information in the options as *cmdlineP. + and argv. Return the information in the options as *cmdlineP. If command line is internally inconsistent (invalid options, etc.), issue error message to stderr and abort program. @@ -64,7 +64,7 @@ parseCommandLine(int argc, char ** argv, pm_optParseOptions3( &argc, argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others. */ - + if (argc-1 < 2) pm_error("You must specify at least two arguments: left and right " "input file names. You specified %u", argc-1); @@ -122,7 +122,7 @@ compute3dRowMono(gray * const lGrayrow, pixel * const pixelrow, unsigned int const cols, int const offset) { - + unsigned int col; gray * lgP; gray * rgP; @@ -133,7 +133,7 @@ compute3dRowMono(gray * const lGrayrow, for (col = 0, pP = pixelrow, lgP = lGrayrow, rgP = rGrayrow; col < cols + offset; ++col) { - + if ((int)col < offset/2) ++lgP; else if ((int)col < offset) { @@ -154,7 +154,7 @@ compute3dRowMono(gray * const lGrayrow, ++rgP; } } -} +} @@ -164,7 +164,7 @@ compute3dRowColor(pixel * const lPixelrow, pixel * const pixelrow, unsigned int const cols, unsigned int const offset) { - + unsigned int col; pixel * lP; pixel * rP; @@ -175,7 +175,7 @@ compute3dRowColor(pixel * const lPixelrow, for (col = 0, pP = pixelrow, lP = lPixelrow, rP = rPixelrow; col < cols + offset; ++col) { - + if ((int)col < offset/2) ++lP; else if ((int)col < offset) { @@ -196,7 +196,7 @@ compute3dRowColor(pixel * const lPixelrow, ++rP; } } -} +} @@ -265,11 +265,11 @@ main(int argc, char *argv[]) { int lRows, lCols; int lFormat; pixval lMaxval; - + int rRows, rCols; int rFormat; pixval rMaxval; - + ppm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); @@ -279,12 +279,12 @@ main(int argc, char *argv[]) { ppm_readppminit(lIfP, &lCols, &lRows, &lMaxval, &lFormat); ppm_readppminit(rIfP, &rCols, &rRows, &rMaxval, &rFormat); - - if ((lCols != rCols) || (lRows != rRows) || - (lMaxval != rMaxval) || + + if ((lCols != rCols) || (lRows != rRows) || + (lMaxval != rMaxval) || (PPM_FORMAT_TYPE(lFormat) != PPM_FORMAT_TYPE(rFormat))) pm_error ("Pictures are not of same size and format"); - + cols = lCols; rows = lRows; maxval = lMaxval; @@ -293,7 +293,7 @@ main(int argc, char *argv[]) { pm_error("Magnitude of -offset (%u columns) is not less than " "width of images " "(%u columns)", abs(cmdline.offset), cols); - + ppm_writeppminit(stdout, cols, rows, maxval, 0); write3dRaster(stdout, lIfP, rIfP, cols, rows, maxval, diff --git a/editor/specialty/ppmglobe.c b/editor/specialty/ppmglobe.c index bb043cc6..1ddaabc3 100644 --- a/editor/specialty/ppmglobe.c +++ b/editor/specialty/ppmglobe.c @@ -53,7 +53,7 @@ parseCommandLine(int argc, char ** argv, MALLOCARRAY_NOFAIL(option_def, 100); option_def_index = 0; /* incremented by OPTENT3 */ - OPTENT3(0, "background", OPT_STRING, &cmdlineP->background, + OPTENT3(0, "background", OPT_STRING, &cmdlineP->background, &backgroundSpec, 0); OPTENT3(0, "closeok", OPT_FLAG, NULL, &cmdlineP->closeok, 0); @@ -68,21 +68,21 @@ parseCommandLine(int argc, char ** argv, if (!backgroundSpec) cmdlineP->background = NULL; - if (argc - 1 < 1) + if (argc - 1 < 1) pm_error("You must specify at least one argument: the strip count"); else { int const stripcount = atoi(argv[1]); if (stripcount <= 0) pm_error("The strip count must be positive. You specified %d", stripcount); - + cmdlineP->stripcount = stripcount; if (argc-1 < 2) cmdlineP->inputFileName = "-"; else cmdlineP->inputFileName = argv[2]; - + if (argc - 1 > 2) pm_error("There are at most two arguments: strip count " "and input file name. " @@ -113,9 +113,9 @@ main(int argc, char *argv[]) { ppm_init(&argc, argv); parseCommandLine(argc, argv, &cmdline); - + ifP = pm_openr(cmdline.inputFileName); - + srcPixels = ppm_readppm(ifP, &srcCols, &srcRows, &srcMaxval); pm_close(ifP); @@ -139,7 +139,7 @@ main(int argc, char *argv[]) { &backgroundColor); dstPixels = ppm_allocarray(dstCols, dstRows); - + for (row = 0; row < dstRows; ++row) { double const factor = sin(M_PI * row / dstRows); /* Amount by which we squeeze the foreground image of each diff --git a/editor/specialty/ppmntsc.c b/editor/specialty/ppmntsc.c index 08fbc835..24edc3bd 100644 --- a/editor/specialty/ppmntsc.c +++ b/editor/specialty/ppmntsc.c @@ -6,21 +6,21 @@ The derivation was done by Bryan Henderson on 2000.04.21 to convert it from operating on the RLE format to operating on the PPM format and to rewrite it in a cleaner style, taking advantage of modern C - compiler technology. + compiler technology. */ /* * This software is copyrighted as noted below. It may be freely copied, - * modified, and redistributed, provided that the copyright notice is + * modified, and redistributed, provided that the copyright notice is * preserved on all copies. - * + * * There is no warranty or other guarantee of fitness for this software, * it is provided solely "as is". Bug reports or fixes may be sent * to the author, who may or may not act on them as he desires. * * You may not include this software in a program or other software product - * without supplying the source, or without informing the end-user that the + * without supplying the source, or without informing the end-user that the * source is available for no extra charge. * * If you modify this software, you should include a notice giving the @@ -28,12 +28,12 @@ * and the reason for such modification. */ -/* +/* * rlelegal.c - Make RGB colors legal in the YIQ or YUV color systems. - * - * Author: Wes Barris - * Minnesota Supercomputer Center, Inc. - * Date: Fri Oct 15, 1993 + * + * Author: Wes Barris + * Minnesota Supercomputer Center, Inc. + * Date: Fri Oct 15, 1993 * @Copyright, Research Equipment Inc., d/b/a Minnesota Supercomputer * Center, Inc., 1993 @@ -104,32 +104,32 @@ parseCommandLine(int argc, const char ** argv, cmdlineP->inputFilename = "-"; /* he wants stdin */ else if (argc - 1 == 1) cmdlineP->inputFilename = argv[1]; - else + else pm_error("Too many arguments. The only arguments accepted " "are the mask color and optional input file specification"); if (legalonly + illegalonly + correctedonly > 1) pm_error("--legalonly, --illegalonly, and --correctedonly are " "conflicting options. Specify at most one of these."); - - if (legalonly) + + if (legalonly) cmdlineP->output = LEGAL_ONLY; - else if (illegalonly) + else if (illegalonly) cmdlineP->output = ILLEGAL_ONLY; - else if (correctedonly) + else if (correctedonly) cmdlineP->output = CORRECTED_ONLY; - else + else cmdlineP->output = ALL; } -static void -rgbtoyiq(const int r, const int g, const int b, - double * const y_p, - double * const i_p, +static void +rgbtoyiq(const int r, const int g, const int b, + double * const y_p, + double * const i_p, double * const q_p) { - + *y_p = .299*(r/255.0) + .587*(g/255.0) + .114*(b/255.0); *i_p = .596*(r/255.0) - .274*(g/255.0) - .322*(b/255.0); *q_p = .211*(r/255.0) - .523*(g/255.0) + .312*(b/255.0); @@ -137,8 +137,8 @@ rgbtoyiq(const int r, const int g, const int b, -static void -yiqtorgb(const double y, const double i, const double q, +static void +yiqtorgb(const double y, const double i, const double q, int * const r_p, int * const g_p, int * const b_p) { *r_p = 255.0*(1.00*y + .9562*i + .6214*q); *g_p = 255.0*(1.00*y - .2727*i - .6468*q); @@ -147,10 +147,10 @@ yiqtorgb(const double y, const double i, const double q, -static void -rgbtoyuv(const int r, const int g, const int b, - double * const y_p, - double * const u_p, +static void +rgbtoyuv(const int r, const int g, const int b, + double * const y_p, + double * const u_p, double * const v_p) { *y_p = .299*(r/255.0) + .587*(g/255.0) + .114*(b/255.0); *u_p = -.147*(r/255.0) - .289*(g/255.0) + .437*(b/255.0); @@ -159,10 +159,10 @@ rgbtoyuv(const int r, const int g, const int b, -static void -yuvtorgb(const double y, const double u, const double v, +static void +yuvtorgb(const double y, const double u, const double v, int * const r_p, int * const g_p, int * const b_p) { - + *r_p = 255.0*(1.00*y + .0000*u +1.1398*v); *g_p = 255.0*(1.00*y - .3938*u - .5805*v); *b_p = 255.0*(1.00*y +2.0279*u + .0000*v); @@ -173,12 +173,12 @@ yuvtorgb(const double y, const double u, const double v, static void makeLegalYiq(double const y, double const i, - double const q, - double * const yNewP, - double * const iNewP, + double const q, + double * const yNewP, + double * const iNewP, double * const qNewP, enum legalize * const actionP) { - + double satOld, satNew; /* * I and Q are legs of a right triangle. Saturation is the hypotenuse. @@ -209,13 +209,13 @@ makeLegalYiq(double const y, static void -make_legal_yuv(const double y, const double u, const double v, - double * const y_new_p, - double * const u_new_p, +make_legal_yuv(const double y, const double u, const double v, + double * const y_new_p, + double * const u_new_p, double * const v_new_p, enum legalize * const action_p ) { - + double sat_old, sat_new; /* * U and V are legs of a right triangle. Saturation is the hypotenuse. @@ -246,13 +246,13 @@ make_legal_yuv(const double y, const double u, const double v, static void -make_legal_yiq_i(const int r_in, const int g_in, const int b_in, - int * const r_out_p, - int * const g_out_p, +make_legal_yiq_i(const int r_in, const int g_in, const int b_in, + int * const r_out_p, + int * const g_out_p, int * const b_out_p, enum legalize * const action_p ) { - + double y, i, q; double y_new, i_new, q_new; /* @@ -276,15 +276,15 @@ make_legal_yiq_i(const int r_in, const int g_in, const int b_in, static void -make_legal_yuv_i(const int r_in, const int g_in, const int b_in, - int * const r_out_p, - int * const g_out_p, +make_legal_yuv_i(const int r_in, const int g_in, const int b_in, + int * const r_out_p, + int * const g_out_p, int * const b_out_p, enum legalize * const action_p ){ - + double y, u, v; - double y_new, u_new, v_new; + double y_new, u_new, v_new; /* * Convert to YUV and compute the new saturation. */ @@ -305,7 +305,7 @@ make_legal_yuv_i(const int r_in, const int g_in, const int b_in, -static void +static void make_legal_yiq_b(const pixel input, pixel * const output_p, enum legalize * const action_p) { @@ -313,7 +313,7 @@ make_legal_yiq_b(const pixel input, int ir_in, ig_in, ib_in; int ir_out, ig_out, ib_out; - + ir_in = (int)PPM_GETR(input); ig_in = (int)PPM_GETG(input); ib_in = (int)PPM_GETB(input); @@ -327,14 +327,14 @@ make_legal_yiq_b(const pixel input, -static void +static void make_legal_yuv_b(const pixel input, pixel * const output_p, enum legalize * const action_p) { int ir_in, ig_in, ib_in; int ir_out, ig_out, ib_out; - + ir_in = (int)PPM_GETR(input); ig_in = (int)PPM_GETG(input); ib_in = (int)PPM_GETB(input); @@ -347,7 +347,7 @@ make_legal_yuv_b(const pixel input, -static void +static void reportMapping(pixel const oldPixel, pixel const newPixel) { /*---------------------------------------------------------------------------- @@ -358,7 +358,7 @@ reportMapping(pixel const oldPixel, static pixel lastChangedPixel; static bool firstTime = true; - if (!PPM_EQUAL(oldPixel, newPixel) && + if (!PPM_EQUAL(oldPixel, newPixel) && (firstTime || PPM_EQUAL(oldPixel, lastChangedPixel))) { pm_message("Mapping %u %u %u -> %u %u %u\n", PPM_GETR(oldPixel), @@ -371,14 +371,14 @@ reportMapping(pixel const oldPixel, lastChangedPixel = oldPixel; firstTime = false; - } + } } static void convertOneImage(FILE * const ifP, - struct cmdlineInfo const cmdline, + struct cmdlineInfo const cmdline, unsigned int * const hiCountP, unsigned int * const loCountP) { @@ -419,8 +419,8 @@ convertOneImage(FILE * const ifP, make_legal_yiq_b(inputRow[col], &corrected, &action); - - if (action == LOWER_SAT) + + if (action == LOWER_SAT) ++*hiCountP; if (action == RAISE_SAT) ++*loCountP; @@ -456,7 +456,7 @@ convertOneImage(FILE * const ifP, int main(int argc, const char **argv) { - + struct cmdlineInfo cmdline; FILE * ifP; unsigned int totalHiCount, totalLoCount; @@ -469,7 +469,7 @@ main(int argc, const char **argv) { parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFilename); - + imageCount = 0; /* initial value */ totalHiCount = 0; /* initial value */ totalLoCount = 0; /* initial value */ @@ -488,14 +488,14 @@ main(int argc, const char **argv) { } - if (cmdline.verbose) { + if (cmdline.verbose) { pm_message("%u images processed.", imageCount); - pm_message("%u pixels were above the saturation limit.", + pm_message("%u pixels were above the saturation limit.", totalHiCount); - pm_message("%u pixels were below the saturation limit.", + pm_message("%u pixels were below the saturation limit.", totalLoCount); } - + pm_close(ifP); return 0; diff --git a/editor/specialty/ppmrelief.c b/editor/specialty/ppmrelief.c index 14a6d0a8..94453bdd 100644 --- a/editor/specialty/ppmrelief.c +++ b/editor/specialty/ppmrelief.c @@ -85,7 +85,7 @@ main(int argc, const char * argv[]) { for (col = 0; col < cols - 2; ++col) { pixel const inputA = inputbuf[rowa][col]; pixel const inputB = inputbuf[rowb][col + 2]; - + pixval const r = clip(PPM_GETR(inputA) + (mv2 - PPM_GETR(inputB)), maxval); pixval const g = diff --git a/editor/specialty/ppmshift.c b/editor/specialty/ppmshift.c index 27cbb78c3..37ed3785 100644 --- a/editor/specialty/ppmshift.c +++ b/editor/specialty/ppmshift.c @@ -1,4 +1,3 @@ - /*********************************************************************/ /* ppmshift - shift lines of a picture left or right by x pixels */ /* Frank Neumann, October 1993 */ diff --git a/editor/specialty/ppmtv.c b/editor/specialty/ppmtv.c index da25102a..7e540e34 100644 --- a/editor/specialty/ppmtv.c +++ b/editor/specialty/ppmtv.c @@ -1,4 +1,3 @@ - /*********************************************************************/ /* ppmtv - make a 'look-alike ntsc' picture from a PPM file */ /* Frank Neumann, October 1993 */ @@ -18,88 +17,88 @@ int main(argc, argv) int argc; char *argv[]; { - FILE* ifp; - int argn, rows, cols, format, i = 0, j = 0; - pixel *srcrow, *destrow; - pixel *pP = NULL, *pP2 = NULL; - pixval maxval; - double dimfactor; - long longfactor; - const char * const usage = "dimfactor [ppmfile]\n dimfactor: 0.0 = total blackness, 1.0 = original picture\n"; - - /* parse in 'default' parameters */ - ppm_init(&argc, argv); - - argn = 1; - - /* parse in dim factor */ - if (argn == argc) - pm_usage(usage); - if (sscanf(argv[argn], "%lf", &dimfactor) != 1) - pm_usage(usage); - if (dimfactor < 0.0 || dimfactor > 1.0) - pm_error("dim factor must be in the range from 0.0 to 1.0 "); - ++argn; - - /* parse in filename (if present, stdin otherwise) */ - if (argn != argc) - { - ifp = pm_openr(argv[argn]); - ++argn; - } - else - ifp = stdin; - - if (argn != argc) - pm_usage(usage); - - /* read first data from file */ - ppm_readppminit(ifp, &cols, &rows, &maxval, &format); - - /* no error checking required here, ppmlib does it all for us */ - srcrow = ppm_allocrow(cols); - - longfactor = (long)(dimfactor * 65536); - - /* allocate a row of pixel data for the new pixels */ - destrow = ppm_allocrow(cols); - - ppm_writeppminit(stdout, cols, rows, maxval, 0); - - /** now do the ntsc'ing (actually very similar to ppmdim) **/ - for (i = 0; i < rows; i++) - { - ppm_readppmrow(ifp, srcrow, cols, maxval, format); - - pP = srcrow; - pP2 = destrow; - - for (j = 0; j < cols; j++) - { - /* every alternating row is left in unchanged condition */ - if (i & 1) - { - PPM_ASSIGN(*pP2, PPM_GETR(*pP), PPM_GETG(*pP), PPM_GETB(*pP)); - } - /* and the other lines are dimmed to the specified factor */ - else - { - PPM_ASSIGN(*pP2, (PPM_GETR(*pP) * longfactor) >> 16, - (PPM_GETG(*pP) * longfactor) >> 16, - (PPM_GETB(*pP) * longfactor) >> 16); - } - pP++; - pP2++; - } - - /* write out one line of graphic data */ - ppm_writeppmrow(stdout, destrow, cols, maxval, 0); - } - - pm_close(ifp); - ppm_freerow(srcrow); - ppm_freerow(destrow); - - exit(0); + FILE* ifp; + int argn, rows, cols, format, i = 0, j = 0; + pixel *srcrow, *destrow; + pixel *pP = NULL, *pP2 = NULL; + pixval maxval; + double dimfactor; + long longfactor; + const char * const usage = "dimfactor [ppmfile]\n dimfactor: 0.0 = total blackness, 1.0 = original picture\n"; + + /* parse in 'default' parameters */ + ppm_init(&argc, argv); + + argn = 1; + + /* parse in dim factor */ + if (argn == argc) + pm_usage(usage); + if (sscanf(argv[argn], "%lf", &dimfactor) != 1) + pm_usage(usage); + if (dimfactor < 0.0 || dimfactor > 1.0) + pm_error("dim factor must be in the range from 0.0 to 1.0 "); + ++argn; + + /* parse in filename (if present, stdin otherwise) */ + if (argn != argc) + { + ifp = pm_openr(argv[argn]); + ++argn; + } + else + ifp = stdin; + + if (argn != argc) + pm_usage(usage); + + /* read first data from file */ + ppm_readppminit(ifp, &cols, &rows, &maxval, &format); + + /* no error checking required here, ppmlib does it all for us */ + srcrow = ppm_allocrow(cols); + + longfactor = (long)(dimfactor * 65536); + + /* allocate a row of pixel data for the new pixels */ + destrow = ppm_allocrow(cols); + + ppm_writeppminit(stdout, cols, rows, maxval, 0); + + /** now do the ntsc'ing (actually very similar to ppmdim) **/ + for (i = 0; i < rows; i++) + { + ppm_readppmrow(ifp, srcrow, cols, maxval, format); + + pP = srcrow; + pP2 = destrow; + + for (j = 0; j < cols; j++) + { + /* every alternating row is left in unchanged condition */ + if (i & 1) + { + PPM_ASSIGN(*pP2, PPM_GETR(*pP), PPM_GETG(*pP), PPM_GETB(*pP)); + } + /* and the other lines are dimmed to the specified factor */ + else + { + PPM_ASSIGN(*pP2, (PPM_GETR(*pP) * longfactor) >> 16, + (PPM_GETG(*pP) * longfactor) >> 16, + (PPM_GETB(*pP) * longfactor) >> 16); + } + pP++; + pP2++; + } + + /* write out one line of graphic data */ + ppm_writeppmrow(stdout, destrow, cols, maxval, 0); + } + + pm_close(ifp); + ppm_freerow(srcrow); + ppm_freerow(destrow); + + exit(0); } |