int main(int argc, const char ** argv) { struct cmdlineInfo cmdline; FILE * ifP; IPDB * pdbP; int status; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); pdbP = ipdb_alloc(NULL); if (pdbP == NULL) pm_error("Could not allocate IPDB structure."); status = ipdbRead(pdbP, ifP, cmdline.verbose); if (status != 0) pm_error("Image header read error: %s.", ipdb_err(status)); writeImgPam(pdbP, stdout); writeText(pdbP, cmdline.notefile); ipdb_free(pdbP); pm_close(ifP); return EXIT_SUCCESS; }
int main(int argc, const char * argv[]) { struct cmdlineInfo cmdline; FILE * ifP; struct script * scriptP; int eof; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); verbose = cmdline.verbose; ifP = pm_openr(cmdline.inputFilename); getScript(cmdline, &scriptP); eof = FALSE; while (!eof) { doOneImage(ifP, scriptP); ppm_nextimage(ifP, &eof); } freeScript(scriptP); pm_close(ifP); /* If the program failed, it previously aborted with nonzero completion code, via various function calls. */ return 0; }
int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; FILE * ifP; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); switch (cmdline.direction) { case DIR_TB: wipeoutTb(ifP, stdout); break; case DIR_LR: wipeoutLr(ifP, stdout); break; } pm_close(ifP); pm_close(stdout); return 0; }
int main(int argc, const char *argv[]) { struct pam inPam; gray ** inImage; int eyeSep; struct cmdlineInfo cmdline; pm_proginit( &argc, argv ); parseCommandLine( argc, argv, &cmdline ); inImage = readAsGray( cmdline.inputFilename, cmdline.maxGrayVal, &inPam ); if (cmdline.separation >= 0) eyeSep = cmdline.separation; else { int const minSeparation = cmdline.minSeparation > 0 ? cmdline.minSeparation : inPam.width / 10; /* Minimum separation in pixels between eyes. Heuristic: Eye separation must be at least 10% of image width. */ eyeSep = findEyeSeparation ( &inPam, inImage, minSeparation ); } pm_message( "Separation between left/right views = %d pixels", eyeSep ); writeAnaglyph ( stdout, inImage, cmdline.maxGrayVal, eyeSep, cmdline.swapEyes, &inPam ); return 0; }
int main(int argc, const char ** argv) { FILE * ifP; struct CmdlineInfo cmdline; struct SbigHeader hdr; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); readSbigHeader(ifP, &hdr); pm_message("SBIG '%s' %ux%u %s image, saturation level = %u", (hdr.haveCameraType ? hdr.cameraType : "ST-?"), hdr.cols, hdr.rows, hdr.isCompressed ? "compressed" : "uncompressed", hdr.maxval); if (hdr.maxval > PGM_OVERALLMAXVAL) { pm_error("Saturation level (%u levels) is too large" "This program's limit is %u.", hdr.maxval, PGM_OVERALLMAXVAL); } pgm_writepgminit(stdout, hdr.cols, hdr.rows, hdr.maxval, 0); writeRaster(ifP, hdr, stdout); pm_close(ifP); pm_close(stdout); return 0; }
int main(int argc, const char ** argv) { struct cmdlineInfo cmdline; FILE * ifP; xel ** xels; xel * xelrow; xelval maxval; int rows, cols; int format; unsigned int row; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); xels = pnm_readpnm(ifP, &cols, &rows, &maxval, &format); pm_close(ifP); xelrow = pnm_allocrow(cmdline.width); pnm_writepnminit(stdout, cmdline.width, cmdline.height, maxval, format, 0); for (row = 0; row < cmdline.height; ++row) { unsigned int col; for (col = 0; col < cmdline.width; ++col) xelrow[col] = xels[row % rows][col % cols]; pnm_writepnmrow(stdout, xelrow, cmdline.width, maxval, format, 0); } pm_close(stdout); return 0; }
int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; int eof; /* No more images in input */ unsigned int imageSeq; /* Sequence of current image in input file. First = 0 */ pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); eof = FALSE; for (imageSeq = 0; !eof; ++imageSeq) { if (isMemberOfUintSet(&cmdline.imageSeqList, imageSeq)) { pm_message("Extracting Image #%u", imageSeq); extractOneImage(stdin, stdout); } else extractOneImage(stdin, NULL); pnm_nextimage(stdin, &eof); } failIfUnpickedImages(&cmdline.imageSeqList, imageSeq); destroyCmdline(&cmdline); pm_close(stdin); pm_close(stdout); return 0; }
int main(int argc, const char **argv) { struct CmdlineInfo cmdline; struct pam * imgPam; /* malloced */ struct pam outimg; unsigned int fileCt; Coord * coords; /* malloced */ FILE * headerFileP; FILE * dataFileP; const char ** names; /* malloced */ unsigned int qfactor; /* In per cent */ pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); headerFileP = cmdline.header ? pm_openw(cmdline.header) : NULL; dataFileP = cmdline.data ? pm_openw(cmdline.data) : NULL; qfactor = qfactorFromQuality(cmdline.quality, cmdline.quality2); openFiles(cmdline, &fileCt, &imgPam, &names); readFileHeaders(imgPam, fileCt); sortImagesByArea(fileCt, imgPam, names); findpack(imgPam, fileCt, &coords, cmdline.quality2, qfactor); computeOutputType(&outimg.maxval, &outimg.format, outimg.tuple_type, &outimg.depth, fileCt, imgPam); computeOutputDimensions(&outimg.width, &outimg.height, fileCt, imgPam, coords); outimg.size = sizeof(outimg); outimg.len = PAM_STRUCT_SIZE(allocation_depth); pnm_setminallocationdepth(&outimg, outimg.depth); outimg.plainformat = false; outimg.file = stdout; writePam(&outimg, fileCt, coords, imgPam); if (dataFileP) writeData(dataFileP, outimg.width, outimg.height, fileCt, names, coords, imgPam); if (headerFileP) writeHeader(headerFileP, cmdline.prefix, outimg.width, outimg.height, fileCt, names, coords, imgPam); closeFiles(imgPam, fileCt, headerFileP, dataFileP); free(coords); free(imgPam); free(names); return 0; }
int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; struct pam pam; tuple * tupleRow; tuple * leftEdge; tuple * rightEdge; unsigned int row; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); pam.size = sizeof pam; pam.len = PAM_STRUCT_SIZE(tuple_type); pam.file = stdout; pam.plainformat = 0; pam.width = cmdline.cols; pam.height = cmdline.rows; pam.maxval = cmdline.maxval; pam.bytes_per_sample = pnm_bytespersample(pam.maxval); pam.format = PAM_FORMAT; if (isgray(cmdline.colorTopLeft) && isgray(cmdline.colorTopRight) && isgray(cmdline.colorBottomLeft) && isgray(cmdline.colorBottomRight)) { pam.depth = 1; strcpy(pam.tuple_type, PAM_PGM_TUPLETYPE); } else { pam.depth = 3; strcpy(pam.tuple_type, PAM_PPM_TUPLETYPE); } pnm_writepaminit(&pam); tupleRow = pnm_allocpamrow(&pam); leftEdge = createEdge(&pam, cmdline.colorTopLeft, cmdline.colorBottomLeft); rightEdge = createEdge(&pam, cmdline.colorTopRight, cmdline.colorBottomRight); /* interpolate each row between the left edge and the right edge */ for (row = 0; row < pam.height; ++row) { interpolate(&pam, tupleRow, leftEdge[row], rightEdge[row]); pnm_writepamrow(&pam, tupleRow); } pm_close(stdout); pnm_freepamrow(rightEdge); pnm_freepamrow(leftEdge); pnm_freepamrow(tupleRow); freeCmdline(cmdline); return 0; }
int main(int argc, const char ** argv) { struct cmdlineInfo cmdline; FILE * ifP; int cols, rows; xelval maxval; int format; unsigned int histWidth; unsigned int range; unsigned int hmax; xelval startval, endval; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFilespec); pnm_readpnminit(ifP, &cols, &rows, &maxval, &format); startval = cmdline.lval; endval = MIN(maxval, cmdline.rval) + 1; range = endval - startval; if (cmdline.widthSpec) histWidth = cmdline.width; else histWidth = range; reportScale(histWidth, range, cmdline.verbose); if (cmdline.nmaxSpec) hmax = cols * rows / histWidth * cmdline.nmax; switch (PNM_FORMAT_TYPE(format)) { case PPM_TYPE: ppmHist(ifP, cols, rows, maxval, format, cmdline.dots, cmdline.white, cmdline.black, cmdline.colorWanted, cmdline.verbose, startval, endval, histWidth, cmdline.height, cmdline.nmaxSpec, hmax); break; case PGM_TYPE: pgmHist(ifP, cols, rows, maxval, format, cmdline.dots, cmdline.white, cmdline.black, cmdline.verbose, startval, endval, histWidth, cmdline.height, cmdline.nmaxSpec, hmax); break; case PBM_TYPE: pm_error("Cannot do a histogram of a a PBM file"); break; } pm_close(ifP); return 0; }
int main(int argc, const char * argv[]) { FILE * ifP; gray * grayrow; int rows; int cols; unsigned int depth; int format; unsigned int padright; unsigned int row; gray maxval; const char * inputFile; pm_proginit(&argc, argv); if (argc-1 < 1) inputFile = "-"; else { inputFile = argv[1]; if (argc-1 > 2) pm_error("Too many arguments. The only argument is the optional " "input file name"); } ifP = pm_openr(inputFile); pgm_readpgminit(ifP, &cols, &rows, &maxval, &format); grayrow = pgm_allocrow(cols); depth = pm_maxvaltobits(maxval); /* Compute padding to round cols up to the nearest multiple of 32. */ padright = ((cols + 31) / 32) * 32 - cols; putinit(cols, rows, depth); for (row = 0; row < rows; ++row) { unsigned int col; pgm_readpgmrow(ifP, grayrow, cols, maxval, format); for (col = 0; col < cols; ++col) putval(grayrow[col]); for (col = 0; col < padright; ++col) putval(0); } pm_close(ifP); putrest(); return 0; }
int main(int argc, const char *argv[]) { FILE * ifP; bit * bitrow; int rows; int cols; int format; unsigned int padright; unsigned int row; const char * inputFile; pm_proginit(&argc, argv); if (argc-1 < 1) inputFile = "-"; else { inputFile = argv[1]; if (argc-1 > 2) pm_error("Too many arguments. The only argument is the optional " "input file name"); } ifP = pm_openr(inputFile); pbm_readpbminit(ifP, &cols, &rows, &format); if (rows > INT16MAX || cols > INT16MAX) pm_error("Input image is too large."); bitrow = pbm_allocrow(cols); /* Compute padding to round cols up to the nearest multiple of 16. */ padright = ((cols + 15) / 16) * 16 - cols; putinit(cols, rows); for (row = 0; row < rows; ++row) { unsigned int col; pbm_readpbmrow(ifP, bitrow, cols, format); for (col = 0; col < cols; ++col) putbit(bitrow[col]); for (col = 0; col < padright; ++col) putbit(0); } if (ifP != stdin) fclose(ifP); putrest(); return 0; }
int main(int argc, const char * argv[]) { struct cmdlineInfo cmdline; FILE * ifP; bit ** bits; int rows, cols; unsigned int top, bottom, left, right; /* boundaries of principal part of image -- i.e. excluding white borders */ pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); bits = pbm_readpbm(ifP, &cols, &rows); pm_close(ifP); findPrincipalImage(bits, rows, cols, &top, &bottom, &left, &right); printf("%%!PS-Adobe-2.0 EPSF-1.2\n"); outputBoundingBox(top, bottom, left, right, rows, cmdline.dpiX, cmdline.dpiY); if (!cmdline.bbonly) { int row; printf("%%%%BeginPreview: %d %d 1 %d\n", right - left + 1, bottom - top + 1, bottom - top + 1); for (row = top; row <= bottom; row++) { unsigned int col; unsigned int outChars; printf("%% "); outChars = 2; /* initial value */ for (col = left; col <= right; col += 8) { if (outChars == 72) { printf("\n%% "); outChars = 2; } printf("%02x", eightPixels(bits, row, col, cols)); outChars += 2; } if (outChars > 0) printf("\n"); } printf("%%%%EndImage\n"); printf("%%%%EndPreview\n"); } return 0; }
int main(int argc, const char ** argv) { struct cmdlineInfo cmdline; FILE * ifP; tuple ** outTuples; /* Output image */ scaler * scalerP; struct pam inpam; struct pam outpam; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(allocation_depth)); pnm_setminallocationdepth(&inpam, 3); outpam.size = sizeof(outpam); outpam.len = PAM_STRUCT_SIZE(tuple_type); outpam.file = stdout; outpam.width = inpam.width; outpam.height = inpam.height; outpam.depth = 3; outpam.maxval = pm_lcm(cmdline.colorRes.c[RED]-1, cmdline.colorRes.c[GRN]-1, cmdline.colorRes.c[BLU]-1, PPM_MAXMAXVAL); outpam.bytes_per_sample = inpam.bytes_per_sample; STRSCPY(outpam.tuple_type, "RGB"); outpam.format = RPPM_FORMAT; outpam.plainformat = false; scaler_create(outpam.maxval, cmdline.colorRes, &scalerP); ditherImage(&inpam, scalerP, cmdline.dim, cmdline.colorRes, &outpam, &outTuples); pnm_writepam(&outpam, outTuples); scaler_destroy(scalerP); pnm_freepamarray(outTuples, &outpam); pm_close(ifP); return 0; }
int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; FILE * ifP; /* The program's regular input file. Could be a seekable copy of it in a temporary file. */ FILE * bdfP; /* The border file. NULL if none. */ int eof; /* no more images in input stream */ int beof; /* no more images in borderfile stream */ pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr_seekable(cmdline.inputFilespec); if (cmdline.borderfile) bdfP = pm_openr(cmdline.borderfile); else bdfP = NULL; eof = beof = FALSE; while (!eof) { cropOneImage(cmdline, ifP, bdfP, stdout); pnm_nextimage(ifP, &eof); if (bdfP) { pnm_nextimage(bdfP, &beof); if (eof != beof) { if (!eof) pm_error("Input file has more images than border file."); else pm_error("Border file has more images than image file."); } } } pm_close(stdout); pm_close(ifP); if (bdfP) pm_close(bdfP); return 0; }
int main(int argc, const char **argv) { struct CmdlineInfo cmdline; struct pam pam; int row; double normalizer; tuplen * tuplerown; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); pam.size = sizeof(pam); pam.len = PAM_STRUCT_SIZE(tuple_type); pam.file = stdout; pam.format = PAM_FORMAT; pam.plainformat = 0; pam.width = cmdline.width; pam.height = cmdline.height; pam.depth = 1; pam.maxval = cmdline.maxval; strcpy(pam.tuple_type, cmdline.tupletype); normalizer = imageNormalizer(&pam, cmdline.sigma); pnm_writepaminit(&pam); tuplerown = pnm_allocpamrown(&pam); for (row = 0; row < pam.height; ++row) { int col; for (col = 0; col < pam.width; ++col) { double const gauss1 = gauss(distFromCenter(&pam, col, row), cmdline.sigma); tuplerown[col][0] = gauss1 * normalizer; } pnm_writepamrown(&pam, tuplerown); } pnm_freepamrown(tuplerown); return 0; }
int main(int argc, const char ** const argv) { struct CmdlineInfo cmdline; struct pam inpam; FILE * ifP; struct pam lookuppam; tuple ** lookup; tuplehash lookupHash; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); getLookup(cmdline.lookupfile, &lookup, &lookuppam); if (inpam.depth != lookuppam.depth) pm_error("The lookup image has depth %u, but the input image " "has depth %u. They must be the same", lookuppam.depth, inpam.depth); if (!streq(inpam.tuple_type, lookuppam.tuple_type)) pm_error("The lookup image has tupel type '%s', " "but the input image " "has tuple type '%s'. They must be the same", lookuppam.tuple_type, inpam.tuple_type); makeReverseLookupHash(&lookuppam, lookup, &lookupHash); doUnlookup(&inpam, lookupHash, lookuppam.width-1, stdout); pm_close(ifP); pnm_destroytuplehash(lookupHash); pnm_freepamarray(lookup, &lookuppam); return 0; }
void pbm_init(int *argcP, char *argv[]) { pm_proginit(argcP, argv); }
int main(int argc, const char ** argv) { FILE * ifP; gray ** grays; int argn; unsigned int rows, cols; unsigned int divisor; unsigned int * obuf; /* malloced */ const char * const usage = "[-d <val>] height width [asciifile]"; pm_proginit(&argc, argv); rows = 0; /* initial value */ cols = 0; /* initial value */ divisor = 1; /* initial value */ argn = 1; if ( argc < 3 || argc > 6 ) pm_usage( usage ); if ( argv[argn][0] == '-' ) { if ( streq( argv[argn], "-d" ) ) { if ( argc == argn + 1 ) pm_usage( usage ); if ( sscanf( argv[argn+1], "%u", &divisor ) != 1 ) pm_usage( usage ); argn += 2; } else pm_usage( usage ); } if ( sscanf( argv[argn++], "%u", &rows ) != 1 ) pm_usage( usage ); if ( sscanf( argv[argn++], "%u", &cols ) != 1 ) pm_usage( usage ); if ( rows < 1 ) pm_error( "height is less than 1" ); if ( cols < 1 ) pm_error( "width is less than 1" ); if ( argc > argn + 1 ) pm_usage( usage ); if ( argc == argn + 1 ) ifP = pm_openr(argv[argn]); else ifP = stdin; MALLOCARRAY(obuf, cols); if (obuf == NULL) pm_error("Unable to allocate memory for %u columns", cols); grays = pgm_allocarray(cols, rows); convertAsciiToPgm(ifP, cols, rows, divisor, maxval, grays, obuf); pm_close(ifP); pgm_writepgm(stdout, grays, cols, rows, maxval, 0); free(obuf); pgm_freearray(grays, rows); return 0; }
int main(int argc, const char * argv[]) { FILE * ifP; xel * xelrow; xel * newxelrow; xel bgxel; int rows, cols, format; int newformat, newcols; int row; xelval maxval, newmaxval; double shearfac; struct CmdlineInfo cmdline; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFileName); pnm_readpnminit(ifP, &cols, &rows, &maxval, &format); xelrow = pnm_allocrow(cols); /* Promote PBM files to PGM. */ if (!cmdline.noantialias && PNM_FORMAT_TYPE(format) == PBM_TYPE) { newformat = PGM_TYPE; newmaxval = PGM_MAXMAXVAL; pm_message("promoting from PBM to PGM - " "use -noantialias to avoid this"); } else { newformat = format; newmaxval = maxval; } shearfac = fabs(tan(cmdline.angle)); newcols = rows * shearfac + cols + 0.999999; pnm_writepnminit(stdout, newcols, rows, newmaxval, newformat, 0); newxelrow = pnm_allocrow(newcols); for (row = 0; row < rows; ++row) { double shearCols; pnm_readpnmrow(ifP, xelrow, cols, newmaxval, format); if (row == 0) bgxel = backgroundColor(cmdline.background, xelrow, cols, newmaxval, format); if (cmdline.angle > 0.0) shearCols = row * shearfac; else shearCols = (rows - row) * shearfac; shearRow(xelrow, cols, newxelrow, newcols, shearCols, format, bgxel, !cmdline.noantialias); pnm_writepnmrow(stdout, newxelrow, newcols, newmaxval, newformat, 0); } pm_close(ifP); pm_close(stdout); return 0; }
void pbm_init(int * const argcP, char ** const argv) { pm_proginit(argcP, (const char **)argv); }
int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; FILE * underlayFileP; FILE * overlayFileP; FILE * alphaFileP; struct pam underlayPam; struct pam overlayPam; struct pam alphaPam; struct pam composedPam; int originLeft, originTop; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); overlayFileP = pm_openr(cmdline.overlayFilespec); overlayPam.comment_p = NULL; pnm_readpaminit(overlayFileP, &overlayPam, PAM_STRUCT_SIZE(opacity_plane)); if (overlayPam.len < PAM_STRUCT_SIZE(opacity_plane)) pm_error("Libnetpbm is too old. This program requires libnetpbm from " "Netpbm 10.56 (September 2011) or newer"); if (!overlayPam.visual) pm_error("Overlay image has tuple type '%s', which is not a " "standard visual type. We don't know how to compose.", overlayPam.tuple_type); initAlphaFile(cmdline, &overlayPam, &alphaFileP, &alphaPam); underlayFileP = pm_openr(cmdline.underlyingFilespec); underlayPam.comment_p = NULL; pnm_readpaminit(underlayFileP, &underlayPam, PAM_STRUCT_SIZE(opacity_plane)); assert(underlayPam.len >= PAM_STRUCT_SIZE(opacity_plane)); if (!overlayPam.visual) pm_error("Overlay image has tuple type '%s', which is not a " "standard visual type. We don't know how to compose.", overlayPam.tuple_type); computeOverlayPosition(underlayPam.width, underlayPam.height, overlayPam.width, overlayPam.height, cmdline, &originLeft, &originTop); composedPam.size = PAM_STRUCT_SIZE(opacity_plane); composedPam.len = PAM_STRUCT_SIZE(allocation_depth); composedPam.allocation_depth = 0; composedPam.file = pm_openw(cmdline.outputFilespec); composedPam.comment_p = NULL; determineOutputType(&underlayPam, &overlayPam, &composedPam); pnm_setminallocationdepth(&underlayPam, composedPam.depth); pnm_setminallocationdepth(&overlayPam, composedPam.depth); composite(originLeft, originTop, &underlayPam, &overlayPam, alphaFileP ? &alphaPam : NULL, cmdline.alphaInvert, cmdline.opacity, &composedPam, cmdline.linear, cmdline.mixtransparency); if (alphaFileP) pm_close(alphaFileP); pm_close(overlayFileP); pm_close(underlayFileP); pm_close(composedPam.file); /* If the program failed, it previously aborted with nonzero completion code, via various function calls. */ return 0; }
int main(int argc, const char ** const argv) { FILE * ifP; int rows, cols; int colorCt; int argn; unsigned int bitsPerPixel; pixval maxval; colorhist_vector chv; char rgb[CLUTCOLORCT]; const char * windowName; int display, expand; int winflag; const char* const usage = "[-windowname windowname] [-expand expand] [-display display] [ppmfile]"; pixel** pixels; colorhash_table cht; pm_proginit(&argc, argv); argn = 1; windowName = "untitled"; winflag = 0; expand = 1; display = 0; while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' ) { if ( pm_keymatch(argv[argn],"-windowname",2) && argn + 1 < argc ) { ++argn; windowName = argv[argn]; winflag = 1; } else if ( pm_keymatch(argv[argn],"-expand",2) && argn + 1 < argc ) { ++argn; if ( sscanf( argv[argn], "%d",&expand ) != 1 ) pm_usage( usage ); } else if ( pm_keymatch(argv[argn],"-display",2) && argn + 1 < argc ) { ++argn; if ( sscanf( argv[argn], "%d",&display ) != 1 ) pm_usage( usage ); } else pm_usage( usage ); } if ( argn < argc ) { ifP = pm_openr( argv[argn] ); if ( ! winflag ) windowName = argv[argn]; ++argn; } else ifP = stdin; if ( argn != argc ) pm_usage( usage ); pixels = ppm_readppm(ifP, &cols, &rows, &maxval); pm_close(ifP); /* Figure out the colormap. */ pm_message("Computing colormap..." ); chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORCT, &colorCt); if (!chv) pm_error("Too many colors - try doing a 'pnmquant %u'", MAXCOLORCT); pm_message("%u colors found", colorCt ); makeIcrColormap(chv, colorCt, maxval, rgb); bitsPerPixel = bppFromColorCt(colorCt); /* And make a hash table for fast lookup. */ cht = ppm_colorhisttocolorhash(chv, colorCt); ppm_freecolorhist(chv); /************** Create a new window using ICR protocol *********/ /* Format is "ESC^W;left;top;width;height;display;windowname" */ pm_message("Creating window %s ...", windowName); printf("\033^W;%d;%d;%d;%d;%d;%s^", 0, 0, cols * expand, rows * expand, display, windowName); fflush(stdout); /****************** Download the colormap. ********************/ downloadColormap(rgb, windowName); sendOutPicture(pixels, rows, cols, cht, expand, windowName); return 0; }
int main(int argc, const char * argv[]) { int argn; const char * const usage = "[-[no]black] [-[no]wpoint] [-[no]label] [-no[axes]] [-full]\n\ [-xy|-upvp] [-rec709|-ntsc|-ebu|-smpte|-hdtv|-cie]\n\ [-red <x> <y>] [-green <x> <y>] [-blue <x> <y>]\n\ [-white <x> <y>] [-gamma <g>]\n\ [-size <s>] [-xsize|-width <x>] [-ysize|-height <y>]"; const struct colorSystem *cs; bool widspec = false, hgtspec = false; unsigned int xBias, yBias; bool upvp = false; /* xy or u'v' color coordinates? */ bool showWhite = true; /* Show white point ? */ bool showBlack = true; /* Show black body curve ? */ bool fullChart = false; /* Fill entire tongue ? */ bool showLabel = true; /* Show labels ? */ bool showAxes = true; /* Plot axes ? */ pm_proginit(&argc, argv); argn = 1; cs = &Rec709system; /* default */ while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') { if (pm_keymatch(argv[argn], "-xy", 2)) { upvp = false; } else if (pm_keymatch(argv[argn], "-upvp", 1)) { upvp = true; } else if (pm_keymatch(argv[argn], "-xsize", 1) || pm_keymatch(argv[argn], "-width", 2)) { if (widspec) { pm_error("already specified a size/width/xsize"); } argn++; if ((argn == argc) || (sscanf(argv[argn], "%d", &sxsize) != 1)) pm_usage(usage); widspec = true; } else if (pm_keymatch(argv[argn], "-ysize", 1) || pm_keymatch(argv[argn], "-height", 2)) { if (hgtspec) { pm_error("already specified a size/height/ysize"); } argn++; if ((argn == argc) || (sscanf(argv[argn], "%d", &sysize) != 1)) pm_usage(usage); hgtspec = true; } else if (pm_keymatch(argv[argn], "-size", 2)) { if (hgtspec || widspec) { pm_error("already specified a size/height/ysize"); } argn++; if ((argn == argc) || (sscanf(argv[argn], "%d", &sysize) != 1)) pm_usage(usage); sxsize = sysize; hgtspec = widspec = true; } else if (pm_keymatch(argv[argn], "-rec709", 1)) { cs = &Rec709system; } else if (pm_keymatch(argv[argn], "-ntsc", 1)) { cs = &NTSCsystem; } else if (pm_keymatch(argv[argn], "-ebu", 1)) { cs = &EBUsystem; } else if (pm_keymatch(argv[argn], "-smpte", 2)) { cs = &SMPTEsystem; } else if (pm_keymatch(argv[argn], "-hdtv", 2)) { cs = &HDTVsystem; } else if (pm_keymatch(argv[argn], "-cie", 1)) { cs = &CIEsystem; } else if (pm_keymatch(argv[argn], "-black", 3)) { showBlack = true; /* Show black body curve */ } else if (pm_keymatch(argv[argn], "-wpoint", 2)) { showWhite = true; /* Show white point of color system */ } else if (pm_keymatch(argv[argn], "-noblack", 3)) { showBlack = false; /* Don't show black body curve */ } else if (pm_keymatch(argv[argn], "-nowpoint", 3)) { showWhite = false; /* Don't show white point of system */ } else if (pm_keymatch(argv[argn], "-label", 1)) { showLabel = true; /* Show labels. */ } else if (pm_keymatch(argv[argn], "-nolabel", 3)) { showLabel = false; /* Don't show labels */ } else if (pm_keymatch(argv[argn], "-axes", 1)) { showAxes = true; /* Show axes. */ } else if (pm_keymatch(argv[argn], "-noaxes", 3)) { showAxes = false; /* Don't show axes */ } else if (pm_keymatch(argv[argn], "-full", 1)) { fullChart = true; /* Fill whole tongue full-intensity */ } else if (pm_keymatch(argv[argn], "-gamma", 2)) { cs = &Customsystem; argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.gamma) != 1)) pm_usage(usage); } else if (pm_keymatch(argv[argn], "-red", 1)) { cs = &Customsystem; argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.xRed) != 1)) pm_usage(usage); argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.yRed) != 1)) pm_usage(usage); } else if (pm_keymatch(argv[argn], "-green", 1)) { cs = &Customsystem; argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.xGreen) != 1)) pm_usage(usage); argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.yGreen) != 1)) pm_usage(usage); } else if (pm_keymatch(argv[argn], "-blue", 1)) { cs = &Customsystem; argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.xBlue) != 1)) pm_usage(usage); argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.yBlue) != 1)) pm_usage(usage); } else if (pm_keymatch(argv[argn], "-white", 1)) { cs = &Customsystem; argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.xWhite) != 1)) pm_usage(usage); argn++; if ((argn == argc) || (sscanf(argv[argn], "%lf", &Customsystem.yWhite) != 1)) pm_usage(usage); } else { pm_usage(usage); } argn++; } if (argn != argc) { /* Extra bogus arguments ? */ pm_usage(usage); } pixcols = sxsize; pixrows = sysize; pixels = ppm_allocarray(pixcols, pixrows); /* Partition into plot area and axes and establish subwindow. */ xBias = Sz(32); yBias = Sz(20); makeAllBlack(pixels, pixcols, pixrows); drawTongueOutline(pixels, pixcols, pixrows, cieMaxval, upvp, xBias, yBias); fillInTongue(pixels, pixcols, pixrows, cieMaxval, cs, upvp, xBias, yBias, fullChart); if (showAxes) drawAxes(pixels, pixcols, pixrows, cieMaxval, upvp, xBias, yBias); if (showWhite) plotWhitePoint(pixels, pixcols, pixrows, cieMaxval, cs, upvp, xBias, yBias); if (showBlack) plotBlackBodyCurve(pixels, pixcols, pixrows, cieMaxval, upvp, xBias, yBias); /* Plot wavelengths around periphery of the tongue. */ if (showAxes) plotMonochromeWavelengths(pixels, pixcols, pixrows, cieMaxval, cs, upvp, xBias, yBias); if (showLabel) writeLabel(pixels, pixcols, pixrows, cieMaxval, cs); ppm_writeppm(stdout, pixels, pixcols, pixrows, cieMaxval, 0); return 0; }
int main (int argc, const char ** argv) { FILE * ifP; gray ** grays; unsigned int tone[PGM_MAXMAXVAL+1]; unsigned int r0, r45, r90; unsigned int d; unsigned int x, y; unsigned int row; int rows, cols; int argn; unsigned int itone; unsigned int toneCt; float ** p_matrix0, ** p_matrix45, ** p_matrix90, ** p_matrix135; float a2m[4], contrast[4], corr[4], var[4], idm[4], savg[4]; float sentropy[4], svar[4], entropy[4], dvar[4], dentropy[4]; float icorr[4], maxcorr[4]; gray maxval; unsigned int i; const char * const usage = "[-d <d>] [pgmfile]"; pm_proginit(&argc, argv); argn = 1; /* Check for flags. */ if ( argn < argc && argv[argn][0] == '-' ) { if ( argv[argn][1] == 'd' ) { ++argn; if ( argn == argc || sscanf( argv[argn], "%u", &d ) != 1 ) pm_usage( usage ); } else pm_usage( usage ); ++argn; } if ( argn < argc ) { ifP = pm_openr( argv[argn] ); ++argn; } else ifP = stdin; if ( argn != argc ) pm_usage( usage ); d = 1; grays = pgm_readpgm(ifP, &cols, &rows, &maxval); pm_close (ifP); /* Determine the number of different gray scales (not maxval) */ for (i = 0; i <= PGM_MAXMAXVAL; ++i) tone[i] = -1; for (row = 0; row < rows; ++row) { unsigned int col; for (col = 0; col < cols; ++col) tone[grays[row][col]] = grays[row][col]; } for (i = 0, toneCt = 0; i <= PGM_MAXMAXVAL; ++i) { if (tone[i] != -1) ++toneCt; } pm_message("(Image has %u gray levels.)", toneCt); /* Collapse array, taking out all zero values */ for (row = 0, itone = 0; row <= PGM_MAXMAXVAL; ++row) if (tone[row] != -1) tone[itone++] = tone[row]; /* Now array contains only the gray levels present (in ascending order) */ /* Allocate memory for gray-tone spatial dependence matrix */ p_matrix0 = matrix (0, toneCt, 0, toneCt); p_matrix45 = matrix (0, toneCt, 0, toneCt); p_matrix90 = matrix (0, toneCt, 0, toneCt); p_matrix135 = matrix (0, toneCt, 0, toneCt); for (row = 0; row < toneCt; ++row) { unsigned int col; for (col = 0; col < toneCt; ++col) { p_matrix0 [row][col] = p_matrix45 [row][col] = 0; p_matrix90[row][col] = p_matrix135[row][col] = 0; } } if (d > cols) pm_error("Image is narrower (%u columns) " "than specified distance (%u)", cols, d); /* Find gray-tone spatial dependence matrix */ pm_message("Computing spatial dependence matrix..."); for (row = 0; row < rows; ++row) { unsigned int col; for (col = 0; col < cols; ++col) { unsigned int angle; for (angle = 0, x = 0; angle <= 135; angle += 45) { while (tone[x] != grays[row][col]) ++x; if (angle == 0 && col + d < cols) { y = 0; while (tone[y] != grays[row][col + d]) ++y; ++p_matrix0[x][y]; ++p_matrix0[y][x]; } if (angle == 90 && row + d < rows) { y = 0; while (tone[y] != grays[row + d][col]) ++y; ++p_matrix90[x][y]; ++p_matrix90[y][x]; } if (angle == 45 && row + d < rows && col >= d) { y = 0; while (tone[y] != grays[row + d][col - d]) ++y; ++p_matrix45[x][y]; ++p_matrix45[y][x]; } if (angle == 135 && row + d < rows && col + d < cols) { y = 0; while (tone[y] != grays[row + d][col + d]) ++y; ++p_matrix135[x][y]; ++p_matrix135[y][x]; } } } } /* Gray-tone spatial dependence matrices are complete */ /* Find normalizing constants */ r0 = 2 * rows * (cols - d); r45 = 2 * (rows - d) * (cols - d); r90 = 2 * (rows - d) * cols; /* Normalize gray-tone spatial dependence matrix */ for (itone = 0; itone < toneCt; ++itone) { unsigned int jtone; for (jtone = 0; jtone < toneCt; ++jtone) { p_matrix0[itone][jtone] /= r0; p_matrix45[itone][jtone] /= r45; p_matrix90[itone][jtone] /= r90; p_matrix135[itone][jtone] /= r45; } } pm_message(" ...done."); pm_message("Computing textural features ..."); fprintf(stdout, "\n"); fprintf(stdout, "%s 0 45 90 135 Avg\n", BL); a2m[0] = f1_a2m(p_matrix0, toneCt); a2m[1] = f1_a2m(p_matrix45, toneCt); a2m[2] = f1_a2m(p_matrix90, toneCt); a2m[3] = f1_a2m(p_matrix135, toneCt); results(F1, a2m); contrast[0] = f2_contrast(p_matrix0, toneCt); contrast[1] = f2_contrast(p_matrix45, toneCt); contrast[2] = f2_contrast(p_matrix90, toneCt); contrast[3] = f2_contrast(p_matrix135, toneCt); results(F2, contrast); corr[0] = f3_corr(p_matrix0, toneCt); corr[1] = f3_corr(p_matrix45, toneCt); corr[2] = f3_corr(p_matrix90, toneCt); corr[3] = f3_corr(p_matrix135, toneCt); results(F3, corr); var[0] = f4_var(p_matrix0, toneCt); var[1] = f4_var(p_matrix45, toneCt); var[2] = f4_var(p_matrix90, toneCt); var[3] = f4_var(p_matrix135, toneCt); results(F4, var); idm[0] = f5_idm(p_matrix0, toneCt); idm[1] = f5_idm(p_matrix45, toneCt); idm[2] = f5_idm(p_matrix90, toneCt); idm[3] = f5_idm(p_matrix135, toneCt); results(F5, idm); savg[0] = f6_savg(p_matrix0, toneCt); savg[1] = f6_savg(p_matrix45, toneCt); savg[2] = f6_savg(p_matrix90, toneCt); savg[3] = f6_savg(p_matrix135, toneCt); results(F6, savg); svar[0] = f7_svar(p_matrix0, toneCt, savg[0]); svar[1] = f7_svar(p_matrix45, toneCt, savg[1]); svar[2] = f7_svar(p_matrix90, toneCt, savg[2]); svar[3] = f7_svar(p_matrix135, toneCt, savg[3]); results(F7, svar); sentropy[0] = f8_sentropy(p_matrix0, toneCt); sentropy[1] = f8_sentropy(p_matrix45, toneCt); sentropy[2] = f8_sentropy(p_matrix90, toneCt); sentropy[3] = f8_sentropy(p_matrix135, toneCt); results(F8, sentropy); entropy[0] = f9_entropy(p_matrix0, toneCt); entropy[1] = f9_entropy(p_matrix45, toneCt); entropy[2] = f9_entropy(p_matrix90, toneCt); entropy[3] = f9_entropy(p_matrix135, toneCt); results(F9, entropy); dvar[0] = f10_dvar(p_matrix0, toneCt); dvar[1] = f10_dvar(p_matrix45, toneCt); dvar[2] = f10_dvar(p_matrix90, toneCt); dvar[3] = f10_dvar(p_matrix135, toneCt); results(F10, dvar); dentropy[0] = f11_dentropy(p_matrix0, toneCt); dentropy[1] = f11_dentropy(p_matrix45, toneCt); dentropy[2] = f11_dentropy(p_matrix90, toneCt); dentropy[3] = f11_dentropy(p_matrix135, toneCt); results (F11, dentropy); icorr[0] = f12_icorr(p_matrix0, toneCt); icorr[1] = f12_icorr(p_matrix45, toneCt); icorr[2] = f12_icorr(p_matrix90, toneCt); icorr[3] = f12_icorr(p_matrix135, toneCt); results(F12, icorr); icorr[0] = f13_icorr(p_matrix0, toneCt); icorr[1] = f13_icorr(p_matrix45, toneCt); icorr[2] = f13_icorr(p_matrix90, toneCt); icorr[3] = f13_icorr(p_matrix135, toneCt); results(F13, icorr); maxcorr[0] = f14_maxcorr(p_matrix0, toneCt); maxcorr[1] = f14_maxcorr(p_matrix45, toneCt); maxcorr[2] = f14_maxcorr(p_matrix90, toneCt); maxcorr[3] = f14_maxcorr(p_matrix135, toneCt); results(F14, maxcorr); pm_message(" ...done."); return 0; }
int main(int argc, const char ** argv) { struct cmdlineInfo cmdline; struct imgInfo * img; /* malloc'ed array */ xelval newmaxval; int newformat; unsigned int i; unsigned int newrows, newcols; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); MALLOCARRAY_NOFAIL(img, cmdline.nfiles); for (i = 0; i < cmdline.nfiles; ++i) { img[i].ifP = pm_openr(cmdline.inputFilespec[i]); pnm_readpnminit(img[i].ifP, &img[i].cols, &img[i].rows, &img[i].maxval, &img[i].format); } computeOutputParms(cmdline.nfiles, cmdline.orientation, img, &newcols, &newrows, &newmaxval, &newformat); pnm_writepnminit(stdout, newcols, newrows, newmaxval, newformat, 0); if (PNM_FORMAT_TYPE(newformat) == PBM_TYPE) { switch (cmdline.orientation) { case LEFTRIGHT: concatenateLeftRightPbm(stdout, cmdline.nfiles, newcols, newrows, cmdline.justification, img, cmdline.backcolor); break; case TOPBOTTOM: concatenateTopBottomPbm(stdout, cmdline.nfiles, newcols, newrows, cmdline.justification, img, cmdline.backcolor); break; } } else { switch (cmdline.orientation) { case LEFTRIGHT: concatenateLeftRightGen(stdout, cmdline.nfiles, newcols, newrows, newmaxval, newformat, cmdline.justification, img, cmdline.backcolor); break; case TOPBOTTOM: concatenateTopBottomGen(stdout, cmdline.nfiles, newcols, newrows, newmaxval, newformat, cmdline.justification, img, cmdline.backcolor); break; } } for (i = 0; i < cmdline.nfiles; ++i) pm_close(img[i].ifP); free(cmdline.inputFilespec); free(img); pm_close(stdout); return 0; }
int main(int argc, const char ** argv) { FILE * ifP; unsigned int i; pixel * pixelrow; unsigned int row; Pal pal; short screen[ROWS*COLS/4]; /* simulates the Atari's video RAM */ pm_proginit(&argc, argv); /* Check args. */ if ( argc > 2 ) pm_usage( "[spufile]" ); if ( argc == 2 ) ifP = pm_openr( argv[1] ); else ifP = stdin; /* Read the SPU file */ /* Read the screen data. */ for (i = 0; i < ROWS*COLS/4; ++i) pm_readbigshort(ifP, &screen[i]); readPalettes(ifP, &pal); pm_close(ifP); /* Ok, get set for writing PPM. */ ppm_writeppminit(stdout, COLS, ROWS, MAXVAL, 0); pixelrow = ppm_allocrow(COLS); /* Now do the conversion. */ for (row = 0; row < ROWS; ++row) { unsigned int col; for (col = 0; col < COLS; ++col) { /* Compute pixel value. */ unsigned int const ind = 80 * row + ((col >> 4) << 2); unsigned int const b = 0x8000 >> (col & 0xf); unsigned int c; unsigned int plane; unsigned int x1; c = 0; /* initial value */ for (plane = 0; plane < 4; ++plane) { if (b & screen[ind + plane]) c |= (1 << plane); } /* Compute palette index. */ x1 = 10 * c; if ((c & 1) != 0) x1 -= 5; else ++x1; if ((col >= x1 ) && (col < (x1 + 160))) c += 16; if (col >= (x1 + 160)) c += 32; /* Set the proper color. */ pixelrow[col] = pal.pal[row][c]; } ppm_writeppmrow(stdout, pixelrow, COLS, MAXVAL, 0); } ppm_freerow(pixelrow); pm_close(stdout); return 0; }
int main(int argc, const char *argv[]) { struct cmdlineInfo cmdline; bit ** bits; unsigned int rows, cols; struct font * fontP; unsigned int vmargin, hmargin; struct text inputText; struct text formattedText; int maxleftb; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); computeFont(cmdline, &fontP); getText(cmdline.text, fontP, &inputText); if (cmdline.nomargins) { vmargin = 0; hmargin = 0; } else { if (inputText.lineCount == 1) { vmargin = fontP->maxheight / 2; hmargin = fontP->maxwidth; } else { vmargin = fontP->maxheight; hmargin = 2 * fontP->maxwidth; } } if (cmdline.width > 0) { if (cmdline.width > INT_MAX -10) pm_error("-width value too large: %u", cmdline.width); /* Flow or truncate lines to meet user's width request */ if (inputText.lineCount == 1) flowText(inputText, cmdline.width, fontP, cmdline.space, &formattedText); else truncateText(inputText, cmdline.width, fontP, cmdline.space, &formattedText); freeTextArray(inputText); } else formattedText = inputText; if (formattedText.lineCount == 0) pm_error("No input text."); computeImageHeight(formattedText, fontP, cmdline.lspace, vmargin, &rows); computeImageWidth(formattedText, fontP, cmdline.space, hmargin, &cols, &maxleftb); if (cols == 0 || rows == 0) pm_error("Input is all whitespace and/or non-renderable characters."); bits = pbm_allocarray(cols, rows); /* Fill background with white */ fill_rect(bits, 0, 0, rows, cols, PBM_WHITE); /* Put the text in */ insert_characters(bits, formattedText, fontP, vmargin, hmargin + maxleftb, cmdline.space, cmdline.lspace); pbm_writepbm(stdout, bits, cols, rows, 0); pbm_freearray(bits, rows); freeTextArray(formattedText); pm_close(stdout); return 0; }
int main(int argc, const char * argv[] ) { struct CmdlineInfo cmdline; FILE * ifP; struct pam outpamCommon; /* Describes the output images. Width and height fields are not meaningful, because different output images might have different dimensions. The rest of the information is common across all output images. */ tupletable colormap; unsigned int colormapSize; tuple specColor; /* A tuple of the color the user specified to use for input colors that are not in the colormap. Arbitrary tuple if he didn't specify any. */ tuple firstColor; /* A tuple of the first color present in the map file */ tuple defaultColor; /* The color to which we will map an input color that is not in the colormap. NULL if we are not to map such a color to a particular color (i.e. we'll choose an approximate match from the map). */ pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr(cmdline.inputFilespec); processMapFile(cmdline.mapFilespec, &outpamCommon, &colormap, &colormapSize, &firstColor); getSpecifiedMissingColor(&outpamCommon, cmdline.missingcolor, &specColor); switch (cmdline.missingMethod) { case MISSING_CLOSE: defaultColor = NULL; break; case MISSING_FIRST: defaultColor = firstColor; break; case MISSING_SPECIFIED: defaultColor = specColor; break; } remap(ifP, &outpamCommon, colormap, colormapSize, cmdline.floyd, !cmdline.norandom, defaultColor, cmdline.verbose); pnm_freepamtuple(firstColor); pnm_freepamtuple(specColor); pm_close(stdout); pm_close(ifP); return 0; }
int main(int argc, const char *argv[]) { CmdlineInfo cmdline; const char * inputFileDescription; FILE * ifP; TIFF * tifP; int ofd; int eof; unsigned int imageSeq; pm_proginit(&argc, argv); parseCommandLine(argc, argv, &cmdline); ifP = pm_openr_seekable(cmdline.inputFileName); if (streq(cmdline.inputFileName, "-")) inputFileDescription = "Standard Input"; else inputFileDescription = cmdline.inputFileName; switch (cmdline.writeMethod) { case DIRECT_APPEND: createTiffGeneratorDirect(cmdline.output, MUST_EXIST, &tifP, &ofd); break; case DIRECT_CREATE: createTiffGeneratorDirect(cmdline.output, MAY_CREATE, &tifP, &ofd); break; case TMPFILE: createTiffGeneratorTmpfile(&tifP, &ofd); break; } eof = FALSE; /* initial assumption */ imageSeq = 0; while (!eof) { bool success; pnm_nextimage(ifP, &eof); if (!eof) { if (imageSeq > 0) validateReadableOutputFile(ofd); if (cmdline.verbose) pm_message("Converting Image %u", imageSeq); convertImage(ifP, tifP, inputFileDescription, cmdline); success = TIFFWriteDirectory(tifP); if (!success) pm_error("Unable to write TIFF image %u to file. " "tifWriteDirectory() failed.", imageSeq); ++imageSeq; } } destroyTiffGenerator(cmdline.writeMethod, tifP, ofd); pm_close(ifP); return 0; }