diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-10-07 05:13:38 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-10-07 05:13:38 +0000 |
commit | ca17ccc9401a86b8c9ab1a4858599d3f67365a06 (patch) | |
tree | 93909584e9fdd6f639c76487649119e004588870 /converter | |
parent | 1bdb731976b708d57a322b0a103b635036041493 (diff) | |
download | netpbm-mirror-ca17ccc9401a86b8c9ab1a4858599d3f67365a06.tar.gz netpbm-mirror-ca17ccc9401a86b8c9ab1a4858599d3f67365a06.tar.xz netpbm-mirror-ca17ccc9401a86b8c9ab1a4858599d3f67365a06.zip |
whitespace
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4731 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r-- | converter/pgm/asciitopgm.c | 7 | ||||
-rw-r--r-- | converter/pgm/bioradtopgm.c | 133 | ||||
-rw-r--r-- | converter/pgm/fstopgm.c | 6 | ||||
-rw-r--r-- | converter/pgm/hipstopgm.c | 50 | ||||
-rw-r--r-- | converter/pgm/lispmtopgm.c | 2 | ||||
-rw-r--r-- | converter/pgm/pgmtofs.c | 30 | ||||
-rw-r--r-- | converter/pgm/pgmtolispm.c | 9 | ||||
-rw-r--r-- | converter/pgm/pgmtopgm.c | 7 | ||||
-rw-r--r-- | converter/pgm/pgmtosbig.c | 3 | ||||
-rw-r--r-- | converter/pgm/pgmtost4.c | 5 | ||||
-rw-r--r-- | converter/pgm/psidtopgm.c | 1 | ||||
-rw-r--r-- | converter/pgm/sbigtopgm.c | 8 | ||||
-rw-r--r-- | converter/pgm/spottopgm.c | 20 | ||||
-rw-r--r-- | converter/pgm/st4topgm.c | 14 |
14 files changed, 169 insertions, 126 deletions
diff --git a/converter/pgm/asciitopgm.c b/converter/pgm/asciitopgm.c index f4179de8..d8bc263b 100644 --- a/converter/pgm/asciitopgm.c +++ b/converter/pgm/asciitopgm.c @@ -124,7 +124,7 @@ convertAsciiToPgm(FILE * const ifP, else { if (beginningOfLine) { if (c == '+') { - /* + at start of line means rest of line + /* + at start of line means rest of line overstrikes previous */ c = getc(ifP); @@ -192,7 +192,7 @@ main(int argc, const char ** argv) { rows = 0; /* initial value */ cols = 0; /* initial value */ divisor = 1; /* initial value */ - + argn = 1; if ( argc < 3 || argc > 6 ) @@ -246,3 +246,6 @@ main(int argc, const char ** argv) { return 0; } + + + diff --git a/converter/pgm/bioradtopgm.c b/converter/pgm/bioradtopgm.c index e0bc3584..471709c1 100644 --- a/converter/pgm/bioradtopgm.c +++ b/converter/pgm/bioradtopgm.c @@ -44,32 +44,32 @@ main( argc, argv ) while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { - if ( ISDIGIT( argv[argn][1] )) - { - image_num = atoi( (argv[argn]+1) ); - } - else - pm_usage( usage ); - ++argn; + if ( ISDIGIT( argv[argn][1] )) + { + image_num = atoi( (argv[argn]+1) ); + } + else + pm_usage( usage ); + ++argn; } if ( argn < argc ) - { - ifp = pm_openr( argv[argn] ); - ++argn; - } + { + ifp = pm_openr( argv[argn] ); + ++argn; + } else - ifp = stdin; + ifp = stdin; if ( argn != argc ) - pm_usage( usage ); + pm_usage( usage ); for ( i = 0; i < BIORAD_HEADER_LENGTH; ++i ) { - val = getc( ifp ); - if ( val == EOF ) - pm_error( "EOF / read error" ); - buf[ i ] = val; + val = getc( ifp ); + if ( val == EOF ) + pm_error( "EOF / read error" ); + buf[ i ] = val; } cols = BYTE_TO_WORD(buf[0], buf[1]); @@ -79,74 +79,77 @@ main( argc, argv ) check_word = BYTE_TO_WORD(buf[54], buf[55]); if ( check_word != 12345 ) - pm_error( "Not a Biorad file" ); + pm_error( "Not a Biorad file" ); if ( cols <= 0 ) - pm_error( "Strange image size, cols = %d", cols); + pm_error( "Strange image size, cols = %d", cols); if ( rows <= 0 ) - pm_error( "Strange image size, rows = %d", rows); + pm_error( "Strange image size, rows = %d", rows); if ( image_count <= 0 ) - pm_error( "Number of images in file is %d", image_count); + pm_error( "Number of images in file is %d", image_count); if ( byte_word ) - maxval = 255; + maxval = 255; else { - maxval = 65535; /* Perhaps this should be something else */ + maxval = 65535; /* Perhaps this should be something else */ } pm_message( "Image size: %d cols, %d rows", cols, rows); pm_message( "%s", - (byte_word) ? "Byte image (8 bits)" : "Word image (16 bits)"); + (byte_word) ? "Byte image (8 bits)" : "Word image (16 bits)"); if ( image_num < 0 ) - pm_message( "Input contains %d image%c", - image_count, (image_count > 1) ? 's' : '\0'); + pm_message( "Input contains %d image%c", + image_count, (image_count > 1) ? 's' : '\0'); else { - if ( image_num >= image_count ) - pm_error( "Cannot extract image %d, input contains only %d image%s", - image_num, image_count, (image_count > 1) ? "s" : "" ); - for ( i = (byte_word) ? image_num : image_num*2 ; i > 0 ; --i ) { - for ( row = 0; row < rows; ++row) - for ( col = 0; col < cols; ++col ) - { - val = getc( ifp ); - if ( val == EOF ) { - pm_error( "EOF / read error" ); - } - } - } - - pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); - grayrow = pgm_allocrow( cols ); - - for ( row = 0; row < rows; ++row) - { - for ( col = 0, gP = grayrow; col < cols; ++col ) - { - val = getc( ifp ); - if ( val == EOF ) - pm_error( "EOF / read error" ); - if (byte_word) - *gP++ = val; - else - { - val2 = getc( ifp ); - if ( val2 == EOF ) - pm_error( "EOF / read error" ); - *gP++ = BYTE_TO_WORD(val, val2); - } - } - pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 ); - } - - pm_close( ifp ); - pm_close( stdout ); + if ( image_num >= image_count ) + pm_error( "Cannot extract image %d, input contains only %d image%s", + image_num, image_count, (image_count > 1) ? "s" : "" ); + for ( i = (byte_word) ? image_num : image_num*2 ; i > 0 ; --i ) { + for ( row = 0; row < rows; ++row) + for ( col = 0; col < cols; ++col ) + { + val = getc( ifp ); + if ( val == EOF ) { + pm_error( "EOF / read error" ); + } + } + } + + pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); + grayrow = pgm_allocrow( cols ); + + for ( row = 0; row < rows; ++row) + { + for ( col = 0, gP = grayrow; col < cols; ++col ) + { + val = getc( ifp ); + if ( val == EOF ) + pm_error( "EOF / read error" ); + if (byte_word) + *gP++ = val; + else + { + val2 = getc( ifp ); + if ( val2 == EOF ) + pm_error( "EOF / read error" ); + *gP++ = BYTE_TO_WORD(val, val2); + } + } + pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 ); + } + + pm_close( ifp ); + pm_close( stdout ); } exit( 0 ); } + + + diff --git a/converter/pgm/fstopgm.c b/converter/pgm/fstopgm.c index 1f574604..63ccb3c5 100644 --- a/converter/pgm/fstopgm.c +++ b/converter/pgm/fstopgm.c @@ -47,7 +47,7 @@ warnNonsquarePixels(unsigned int const cols, unsigned int const xcols, unsigned int const rows, unsigned int const xrows) { - + const char * const baseMsg = "warning, non-square pixels"; if (pm_have_float_format()) { @@ -57,7 +57,7 @@ warnNonsquarePixels(unsigned int const cols, pm_message("%s; to fix do a 'pamscale -%cscale %g'", baseMsg, rowratio > colratio ? 'y' : 'x', - rowratio > colratio ? + rowratio > colratio ? rowratio / colratio : colratio / rowratio); } else pm_message("%s", baseMsg); @@ -153,3 +153,5 @@ main(int argc, const char ** argv) { return 0; } + + diff --git a/converter/pgm/hipstopgm.c b/converter/pgm/hipstopgm.c index 2f5956e1..17048ce7 100644 --- a/converter/pgm/hipstopgm.c +++ b/converter/pgm/hipstopgm.c @@ -16,21 +16,21 @@ #include "pgm.h" struct HIPS_Header { - char* orig_name; /* An indication of the originator of this sequence. */ - char* seq_name; /* The sequence name. */ - int num_frame; /* The number of frames in this sequence. */ - char* orig_date; /* The date the sequence was originated. */ - int rows; /* The number of rows in each image, the height. */ - int cols; /* The number of columns in each image, the width. */ - int bits_per_pixel; /* The number of significant bits per pixel. */ - int bit_packing; /* Nonzero if the bits were packed such as to + char* orig_name; /* An indication of the originator of this sequence. */ + char* seq_name; /* The sequence name. */ + int num_frame; /* The number of frames in this sequence. */ + char* orig_date; /* The date the sequence was originated. */ + int rows; /* The number of rows in each image, the height. */ + int cols; /* The number of columns in each image, the width. */ + int bits_per_pixel; /* The number of significant bits per pixel. */ + int bit_packing; /* Nonzero if the bits were packed such as to eliminate any unused bits resulting from a bits_per_pixel value which was not an even multiple of eight. */ - int pixel_format; /* An indication of the format of each pixel. */ - char* seq_history; /* A description of the sequence of transformations + int pixel_format; /* An indication of the format of each pixel. */ + char* seq_history; /* A description of the sequence of transformations leading up to the current image. */ - char* seq_desc; /* A free form description of the contents of the + char* seq_desc; /* A free form description of the contents of the sequence. */ }; #define HIPS_PFBYTE 0 @@ -52,7 +52,6 @@ read_line(FILE * const fd, - static void read_hips_header( fd, hP ) FILE* fd; @@ -95,9 +94,9 @@ read_hips_header( fd, hP ) /* Now read and toss lines until we get one with just a period. */ do - { + { read_line( fd, buf, 5000 ); - } + } while ( !streq( buf, ".\n" ) ); } @@ -121,10 +120,10 @@ main(int argc, char * argv[]) { argn = 1; if ( argn < argc ) - { + { ifp = pm_openr( argv[argn] ); argn++; - } + } else ifp = stdin; @@ -137,8 +136,8 @@ main(int argc, char * argv[]) { rows = h.rows * h.num_frame; switch ( h.pixel_format ) - { - case HIPS_PFBYTE: + { + case HIPS_PFBYTE: if ( h.bits_per_pixel != 8 ) pm_error( "can't handle unusual bits_per_pixel %d", h.bits_per_pixel ); @@ -147,16 +146,16 @@ main(int argc, char * argv[]) { maxval = 255; break; - default: + default: pm_error( "unknown pixel format %d", h.pixel_format ); - } + } pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); grayrow = pgm_allocrow( cols ); for ( row = 0; row < rows; row++) - { + { for ( col = 0, gP = grayrow; col < cols; col++, gP++ ) - { + { int ich; switch ( h.pixel_format ) @@ -171,11 +170,14 @@ main(int argc, char * argv[]) { default: pm_error( "can't happen" ); } - } + } pgm_writepgmrow( stdout, grayrow, cols, (gray) maxval, 0 ); - } + } pm_close( ifp ); pm_close( stdout ); return 0; } + + + diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c index 03bcb512..29f280f3 100644 --- a/converter/pgm/lispmtopgm.c +++ b/converter/pgm/lispmtopgm.c @@ -182,3 +182,5 @@ main(int argc, const char ** argv) { exit(0); } + + diff --git a/converter/pgm/pgmtofs.c b/converter/pgm/pgmtofs.c index 53a2e7b3..8780b35a 100644 --- a/converter/pgm/pgmtofs.c +++ b/converter/pgm/pgmtofs.c @@ -35,14 +35,14 @@ main( argc, argv ) argn = 1; if ( argn < argc ) - { + { ifp = pm_openr( argv[argn] ); ++argn; - } + } else - { + { ifp = stdin; - } + } if ( argn != argc ) pm_usage( usage ); @@ -60,19 +60,19 @@ main( argc, argv ) pm_error( "maxval of %d is too large for FaceSaver(tm)", maxval ); nmaxval = pm_bitstomaxval( bps ); - + /* Compute padding to round cols * bps up to the nearest multiple of 8. */ padright = ( ( cols * bps + 7 ) / 8 ) * 8 - cols * bps; putinit( cols, rows, bps ); for ( row = rows - 1; row >= 0; --row ) - { + { for ( col = 0, gP = grays[row]; col < cols; ++col, ++gP ) - { + { if ( maxval != nmaxval ) *gP = (int) *gP * nmaxval / maxval; putgray( *gP ); - } + } for ( col = 0; col < padright; ++col ) putgray( 0 ); } @@ -83,6 +83,7 @@ main( argc, argv ) } + static int bitspersample, item, bitsperitem, bitshift, itemsperline, items; static void @@ -109,16 +110,18 @@ putinit( cols, rows, bps ) bitshift = 8 - bitspersample; } + + static void putitem( ) { const char* const hexits = "0123456789abcdef"; if ( itemsperline == 30 ) - { + { putchar( '\n' ); itemsperline = 0; - } + } putchar( hexits[item >> 4] ); putchar( hexits[item & 15] ); ++itemsperline; @@ -128,6 +131,8 @@ putitem( ) bitshift = 8 - bitspersample; } + + static void putgray( gray g ) { @@ -138,6 +143,8 @@ putgray( gray g ) bitshift -= bitspersample; } + + static void putrest( ) { @@ -145,3 +152,6 @@ putrest( ) putitem( ); printf( "\n" ); } + + + diff --git a/converter/pgm/pgmtolispm.c b/converter/pgm/pgmtolispm.c index 7d931fb3..4309228e 100644 --- a/converter/pgm/pgmtolispm.c +++ b/converter/pgm/pgmtolispm.c @@ -1,4 +1,4 @@ -/* pgmtolispm.c - read a pgm and write a file acceptable to the +/* pgmtolispm.c - read a pgm and write a file acceptable to the ** tv:read-bit-array-file function of TI Explorer and Symbolics Lisp Machines. ** ** Written by Jamie Zawinski based on code (C) 1988 by Jef Poskanzer. @@ -12,7 +12,7 @@ ** ** When one writes a multi-plane bitmap with tv:write-bit-array-file, it is ** usually a color image; but a color map is not written in the file, so we -** treat this as a graymap instead. To convert a color image to Lispm +** treat this as a graymap instead. To convert a color image to Lispm ** format, you must convert it to a pgm, and hand-edit a color map... Ick. ** ** Feb 2010 afu @@ -37,7 +37,7 @@ depth_to_word_size(unsigned int const depth) { /* out with a depth of 5, it really has a depth of 8, and */ /* is stored that way in the file. */ - unsigned int const wordSize = + unsigned int const wordSize = depth == 1 ? 1 : depth == 2 ? 2 : depth <= 4 ? 4 : @@ -178,3 +178,6 @@ main(int argc, const char * argv[]) { return 0; } + + + diff --git a/converter/pgm/pgmtopgm.c b/converter/pgm/pgmtopgm.c index 250bb4dc..71b12754 100644 --- a/converter/pgm/pgmtopgm.c +++ b/converter/pgm/pgmtopgm.c @@ -20,9 +20,9 @@ main(int argc, char *argv[]) { gray maxval; int row; gray * grayrow; - + pgm_init(&argc, argv); - + if (argc-1 != 0) pm_error("Program takes no arguments. Input is from Standard Input"); @@ -42,3 +42,6 @@ main(int argc, char *argv[]) { return 0; } + + + diff --git a/converter/pgm/pgmtosbig.c b/converter/pgm/pgmtosbig.c index 0a302dd8..cdc867cb 100644 --- a/converter/pgm/pgmtosbig.c +++ b/converter/pgm/pgmtosbig.c @@ -128,3 +128,6 @@ main(int argc, const char * argv[]) { return 0; } + + + diff --git a/converter/pgm/pgmtost4.c b/converter/pgm/pgmtost4.c index fa101ac9..aa691464 100644 --- a/converter/pgm/pgmtost4.c +++ b/converter/pgm/pgmtost4.c @@ -76,7 +76,7 @@ main(int argc, const char * argv[]) { if (inpam.width != st4Width) pm_error("Image is wrong width for ST-4 SBIG: %u pixels. " "Must be %u", inpam.width, st4Width); - + /* Really, we should just scale to maxval 255. There are library routines for that, but we're too lazy even for that, since nobody is really going to use this program. @@ -102,3 +102,6 @@ main(int argc, const char * argv[]) { return 0; } + + + diff --git a/converter/pgm/psidtopgm.c b/converter/pgm/psidtopgm.c index 99ce3710..58e84855 100644 --- a/converter/pgm/psidtopgm.c +++ b/converter/pgm/psidtopgm.c @@ -132,3 +132,4 @@ main(int argc, } + diff --git a/converter/pgm/sbigtopgm.c b/converter/pgm/sbigtopgm.c index 7833cb62..8b28f740 100644 --- a/converter/pgm/sbigtopgm.c +++ b/converter/pgm/sbigtopgm.c @@ -53,13 +53,13 @@ parseCommandLine(int argc, const char ** argv, unsigned int option_def_index; MALLOCARRAY_NOFAIL(option_def, 100); - + OPTENTINIT; opt.opt_table = option_def; opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */ opt.allowNegNum = FALSE; /* We have no parms that are negative numbers */ - + pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others */ @@ -208,7 +208,7 @@ readSbigHeader(FILE * const ifP, *ep = ' '; } } - + looseCanon(cursor); /* Convert from standard SBIG to an internal format */ @@ -270,7 +270,7 @@ writeRaster(FILE * const ifP, unsigned short rowlen; /* Compressed row length */ pm_readlittleshortu(ifP, &rowlen); - + /* If compression results in a row length >= the uncompressed row length, that row is output uncompressed. We detect this by observing that the compressed row length is equal to diff --git a/converter/pgm/spottopgm.c b/converter/pgm/spottopgm.c index 59240ba8..26801cb2 100644 --- a/converter/pgm/spottopgm.c +++ b/converter/pgm/spottopgm.c @@ -37,7 +37,7 @@ static int Colbool = 0; /* 1 if color */ * requested by the user (i.e 1, 2 or 3). I could create a ppm file * but I couldn't be bothered with the rearranging of the data. */ -static int +static int get_image(long length) { int cnt; @@ -72,7 +72,7 @@ get_image(long length) pm_error ("seek error"); if (pm_readbiglong (spotfile, &numpixels) == -1) pm_error ("EOF / read error reading line ender"); - + /* Determine the picture size */ Bufptr = &linebuf[Firstcol]; if (Lastcol == 0 || Lastcol > numpixels) @@ -95,7 +95,7 @@ get_image(long length) fprintf(stderr, "Line %4d, %3d, %3d, time %4d, l/r " "pixmar %4d %4d len %d pixnum %d\n", - linehdr.linenum, linehdr.recseq, + linehdr.linenum, linehdr.recseq, linehdr.spectseq, linehdr.linetime, linehdr.leftpixmar, linehdr.rightpixmar, length, numpixels); #endif @@ -116,7 +116,7 @@ get_image(long length) * element 9 == S --> sequential (i.e only one color here) * element 9 == I --> interleaved (1 or more colors) */ -static int +static int get_imghdr(int length) { struct Imghdr @@ -145,7 +145,7 @@ get_imghdr(int length) #ifdef DEBUG fprintf(stderr, "Dummy str is >%s<\n", header.dummy1); - fprintf(stderr, "Imghdr str is >%s<, col %d\n", + fprintf(stderr, "Imghdr str is >%s<, col %d\n", header.description, Colbool); #endif /* Return the amount to fseek */ @@ -153,6 +153,7 @@ get_imghdr(int length) } + static void usage() { @@ -162,6 +163,8 @@ usage() exit(1); } + + int main(int argc, char *argv[]) { @@ -176,7 +179,7 @@ main(int argc, char *argv[]) } arecord; pgm_init( &argc, argv ); - + switch (argc) { case 7: @@ -219,7 +222,7 @@ main(int argc, char *argv[]) arecord.length = get_imghdr(arecord.length); #ifdef DEBUG else - fprintf(stderr, + fprintf(stderr, "Rcrd %3d, type %03o, stype %03o %03o %03o, length %d\n", arecord.record, arecord.type, arecord.sub1, arecord.sub2, (int) arecord.sub3 & 0xff, arecord.length); @@ -229,3 +232,6 @@ main(int argc, char *argv[]) } exit (0); } + + + diff --git a/converter/pgm/st4topgm.c b/converter/pgm/st4topgm.c index 791184b7..89ec930d 100644 --- a/converter/pgm/st4topgm.c +++ b/converter/pgm/st4topgm.c @@ -56,6 +56,7 @@ validateFileSize(FILE * const ifP) { } + static void writeRaster(FILE * const ifP, struct pam * const pamP) { @@ -188,15 +189,15 @@ readFooter(FILE * const ifP, static void reportFooter(struct St4Footer const footer) { - pm_message("Comment: %s", footer.comment); + pm_message("Comment: %s", footer.comment); - pm_message("Exposure time (1/100 s): %s", footer.exposureTime); + pm_message("Exposure time (1/100 s): %s", footer.exposureTime); - pm_message("Focal length (in): %s", footer.focalLength); + pm_message("Focal length (in): %s", footer.focalLength); - pm_message("Aperture area (sq in): %s", footer.apertureArea); + pm_message("Aperture area (sq in): %s", footer.apertureArea); - pm_message("Calibration factor: %s", footer.calibrationFactor); + pm_message("Calibration factor: %s", footer.calibrationFactor); } @@ -219,7 +220,7 @@ main(int argc, const char **argv) { pm_error("Too many arguments: %u. " "The only possible argument is the " "optional input file name", argc-1); - } + } /* We check the file size to catch the common problem of the input not being valid ST-4 SBIG input. Unlike most formats, this one does not @@ -258,3 +259,4 @@ main(int argc, const char **argv) { } + |