/*! * \brief pixToGif() * * \param[in] pix 1, 2, 4, 8, 16 or 32 bpp * \param[in] gif opened gif stream * \return 0 if OK, 1 on error * * <pre> * Notes: * (1) This encodes the pix to the gif stream. The stream is not * closes by this function. * (2) It is static to make this function private. * </pre> */ static l_int32 pixToGif(PIX *pix, GifFileType *gif) { char *text; l_int32 wpl, i, j, w, h, d, ncolor, rval, gval, bval; l_int32 gif_ncolor = 0; l_uint32 *data, *line; PIX *pixd; PIXCMAP *cmap; ColorMapObject *gif_cmap; GifByteType *gif_line; #if (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1) || GIFLIB_MAJOR > 5 int giferr; #endif /* 5.1 and beyond */ PROCNAME("pixToGif"); if (!pix) return ERROR_INT("pix not defined", procName, 1); if (!gif) return ERROR_INT("gif not defined", procName, 1); d = pixGetDepth(pix); if (d == 32) { pixd = pixConvertRGBToColormap(pix, 1); } else if (d > 1) { pixd = pixConvertTo8(pix, TRUE); } else { /* d == 1; make sure there's a colormap */ pixd = pixClone(pix); if (!pixGetColormap(pixd)) { cmap = pixcmapCreate(1); pixcmapAddColor(cmap, 255, 255, 255); pixcmapAddColor(cmap, 0, 0, 0); pixSetColormap(pixd, cmap); } } if (!pixd) return ERROR_INT("failed to convert image to indexed", procName, 1); d = pixGetDepth(pixd); if ((cmap = pixGetColormap(pixd)) == NULL) { pixDestroy(&pixd); return ERROR_INT("cmap is missing", procName, 1); } /* 'Round' the number of gif colors up to a power of 2 */ ncolor = pixcmapGetCount(cmap); for (i = 0; i <= 8; i++) { if ((1 << i) >= ncolor) { gif_ncolor = (1 << i); break; } } if (gif_ncolor < 1) { pixDestroy(&pixd); return ERROR_INT("number of colors is invalid", procName, 1); } /* Save the cmap colors in a gif_cmap */ if ((gif_cmap = GifMakeMapObject(gif_ncolor, NULL)) == NULL) { pixDestroy(&pixd); return ERROR_INT("failed to create GIF color map", procName, 1); } for (i = 0; i < gif_ncolor; i++) { rval = gval = bval = 0; if (ncolor > 0) { if (pixcmapGetColor(cmap, i, &rval, &gval, &bval) != 0) { pixDestroy(&pixd); GifFreeMapObject(gif_cmap); return ERROR_INT("failed to get color from color map", procName, 1); } ncolor--; } gif_cmap->Colors[i].Red = rval; gif_cmap->Colors[i].Green = gval; gif_cmap->Colors[i].Blue = bval; } pixGetDimensions(pixd, &w, &h, NULL); if (EGifPutScreenDesc(gif, w, h, gif_cmap->BitsPerPixel, 0, gif_cmap) != GIF_OK) { pixDestroy(&pixd); GifFreeMapObject(gif_cmap); return ERROR_INT("failed to write screen description", procName, 1); } GifFreeMapObject(gif_cmap); /* not needed after this point */ if (EGifPutImageDesc(gif, 0, 0, w, h, FALSE, NULL) != GIF_OK) { pixDestroy(&pixd); return ERROR_INT("failed to image screen description", procName, 1); } data = pixGetData(pixd); wpl = pixGetWpl(pixd); if (d != 1 && d != 2 && d != 4 && d != 8) { pixDestroy(&pixd); return ERROR_INT("image depth is not in {1, 2, 4, 8}", procName, 1); } if ((gif_line = (GifByteType *)LEPT_CALLOC(sizeof(GifByteType), w)) == NULL) { pixDestroy(&pixd); return ERROR_INT("mem alloc fail for data line", procName, 1); } for (i = 0; i < h; i++) { line = data + i * wpl; /* Gif's way of setting the raster line up for compression */ for (j = 0; j < w; j++) { switch(d) { case 8: gif_line[j] = GET_DATA_BYTE(line, j); break; case 4: gif_line[j] = GET_DATA_QBIT(line, j); break; case 2: gif_line[j] = GET_DATA_DIBIT(line, j); break; case 1: gif_line[j] = GET_DATA_BIT(line, j); break; } } /* Compress and save the line */ if (EGifPutLine(gif, gif_line, w) != GIF_OK) { LEPT_FREE(gif_line); pixDestroy(&pixd); return ERROR_INT("failed to write data line into GIF", procName, 1); } } /* Write a text comment. This must be placed after writing the * data (!!) Note that because libgif does not provide a function * for reading comments from file, you will need another way * to read comments. */ if ((text = pixGetText(pix)) != NULL) { if (EGifPutComment(gif, text) != GIF_OK) L_WARNING("gif comment not written\n", procName); } LEPT_FREE(gif_line); pixDestroy(&pixd); return 0; }
static l_int32 TestImage(const char *filename, l_int32 i, L_REGPARAMS *rp) { char buf[256]; l_int32 w, h; l_float32 factor; PIX *pix, *pixs, *pixc, *pix32, *pixt, *pixd; PIXA *pixa; PROCNAME("TestImage"); if ((pix = pixRead(filename)) == NULL) { rp->success = FALSE; return ERROR_INT("pix not made", procName, 1); } pixGetDimensions(pix, &w, &h, NULL); if (w > MAX_WIDTH) { factor = (l_float32)MAX_WIDTH / (l_float32)w; pixs = pixScale(pix, factor, factor); } else pixs = pixClone(pix); pixDestroy(&pix); pixa = pixaCreate(0); /* Median cut quantizer (no dither; 5 sigbits) */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixMedianCutQuantGeneral(pixs, 0, 0, 16, 5, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 0, 0, 128, 5, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 0, 0, 256, 5, 1, 1); PixSave32(pixa, pixc, rp); /* Median cut quantizer (with dither; 5 sigbits) */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 0); pixc = pixMedianCutQuantGeneral(pixs, 1, 0, 16, 5, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 1, 0, 128, 5, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 1, 0, 256, 5, 1, 1); PixSave32(pixa, pixc, rp); /* Median cut quantizer (no dither; 6 sigbits) */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixMedianCutQuantGeneral(pixs, 0, 0, 16, 6, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 0, 0, 128, 6, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 0, 0, 256, 6, 1, 1); PixSave32(pixa, pixc, rp); /* Median cut quantizer (with dither; 6 sigbits) */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 0); pixc = pixMedianCutQuantGeneral(pixs, 1, 0, 16, 6, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 1, 0, 128, 6, 1, 1); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantGeneral(pixs, 1, 0, 256, 6, 10, 1); PixSave32(pixa, pixc, rp); /* Median cut quantizer (mixed color/gray) */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 0); pixc = pixMedianCutQuantMixed(pixs, 20, 10, 0, 0, 0); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantMixed(pixs, 60, 20, 0, 0, 0); PixSave32(pixa, pixc, rp); pixc = pixMedianCutQuantMixed(pixs, 180, 40, 0, 0, 0); PixSave32(pixa, pixc, rp); /* Simple 256 cube octcube quantizer */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 0); pixc = pixFixedOctcubeQuant256(pixs, 0); /* no dither */ PixSave32(pixa, pixc, rp); pixc = pixFixedOctcubeQuant256(pixs, 1); /* dither */ PixSave32(pixa, pixc, rp); /* 2-pass octree quantizer */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 0); pixc = pixOctreeColorQuant(pixs, 128, 0); /* no dither */ PixSave32(pixa, pixc, rp); pixc = pixOctreeColorQuant(pixs, 240, 0); /* no dither */ PixSave32(pixa, pixc, rp); pixc = pixOctreeColorQuant(pixs, 128, 1); /* dither */ PixSave32(pixa, pixc, rp); pixc = pixOctreeColorQuant(pixs, 240, 1); /* dither */ PixSave32(pixa, pixc, rp); /* Simple adaptive quantization to 4 or 8 bpp, specifying ncolors */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 0); pixc = pixOctreeQuantNumColors(pixs, 8, 0); /* fixed: 8 colors */ PixSave32(pixa, pixc, rp); pixc = pixOctreeQuantNumColors(pixs, 16, 0); /* fixed: 16 colors */ PixSave32(pixa, pixc, rp); pixc = pixOctreeQuantNumColors(pixs, 64, 0); /* fixed: 64 colors */ PixSave32(pixa, pixc, rp); pixc = pixOctreeQuantNumColors(pixs, 256, 0); /* fixed: 256 colors */ PixSave32(pixa, pixc, rp); /* Quantize to fully populated octree (RGB) at given level */ pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 0); pixc = pixFixedOctcubeQuantGenRGB(pixs, 2); /* level 2 */ PixSave32(pixa, pixc, rp); pixc = pixFixedOctcubeQuantGenRGB(pixs, 3); /* level 3 */ PixSave32(pixa, pixc, rp); pixc = pixFixedOctcubeQuantGenRGB(pixs, 4); /* level 4 */ PixSave32(pixa, pixc, rp); pixc = pixFixedOctcubeQuantGenRGB(pixs, 5); /* level 5 */ PixSave32(pixa, pixc, rp); /* Generate 32 bpp RGB image with num colors <= 256 */ pixt = pixOctreeQuantNumColors(pixs, 256, 0); /* cmapped version */ pix32 = pixRemoveColormap(pixt, REMOVE_CMAP_BASED_ON_SRC); /* Quantize image with few colors at fixed octree leaf level */ pixSaveTiled(pixt, pixa, 1.0, 1, SPACE, 0); pixc = pixFewColorsOctcubeQuant1(pix32, 2); /* level 2 */ PixSave32(pixa, pixc, rp); pixc = pixFewColorsOctcubeQuant1(pix32, 3); /* level 3 */ PixSave32(pixa, pixc, rp); pixc = pixFewColorsOctcubeQuant1(pix32, 4); /* level 4 */ PixSave32(pixa, pixc, rp); pixc = pixFewColorsOctcubeQuant1(pix32, 5); /* level 5 */ PixSave32(pixa, pixc, rp); /* Quantize image by population */ pixSaveTiled(pixt, pixa, 1.0, 1, SPACE, 0); pixc = pixOctreeQuantByPopulation(pixs, 3, 0); /* level 3, no dither */ PixSave32(pixa, pixc, rp); pixc = pixOctreeQuantByPopulation(pixs, 3, 1); /* level 3, dither */ PixSave32(pixa, pixc, rp); pixc = pixOctreeQuantByPopulation(pixs, 4, 0); /* level 4, no dither */ PixSave32(pixa, pixc, rp); pixc = pixOctreeQuantByPopulation(pixs, 4, 1); /* level 4, dither */ PixSave32(pixa, pixc, rp); /* Mixed color/gray octree quantizer */ pixSaveTiled(pixt, pixa, 1.0, 1, SPACE, 0); pixc = pixOctcubeQuantMixedWithGray(pix32, 8, 64, 10); /* max delta = 10 */ PixSave32(pixa, pixc, rp); pixc = pixOctcubeQuantMixedWithGray(pix32, 8, 64, 30); /* max delta = 30 */ PixSave32(pixa, pixc, rp); pixc = pixOctcubeQuantMixedWithGray(pix32, 8, 64, 50); /* max delta = 50 */ PixSave32(pixa, pixc, rp); /* Run the high-level converter */ pixSaveTiled(pixt, pixa, 1.0, 1, SPACE, 0); pixc = pixConvertRGBToColormap(pix32, 1); PixSave32(pixa, pixc, rp); pixDestroy(&pix32); pixDestroy(&pixt); pixd = pixaDisplay(pixa, 0, 0); pixDisplayWithTitle(pixd, 100, 100, NULL, rp->display); sprintf(buf, "/tmp/regout/disp.%d.jpg", i); pixWrite(buf, pixd, IFF_JFIF_JPEG); pixDestroy(&pixs); pixDestroy(&pixd); pixaDestroy(&pixa); return 0; }
main(int argc, char **argv) { l_int32 errorfound, same; PIX *pixs, *pixt1, *pixt2, *pixt3, *pixt4; static char mainName[] = "equal_reg"; if (argc != 1) exit(ERROR_INT(" Syntax: equal_reg", mainName, 1)); errorfound = FALSE; pixs = pixRead(FEYN1); pixWrite("/tmp/junkfeyn.png", pixs, IFF_PNG); pixt1 = pixRead("/tmp/junkfeyn.png"); pixEqual(pixs, pixt1, &same); if (same) L_INFO("equal for feyn1", mainName); else { L_INFO("FAILURE for equal for feyn1", mainName); errorfound = TRUE; } pixDestroy(&pixs); pixDestroy(&pixt1); pixs = pixRead(DREYFUS2); pixt1 = pixRemoveColormap(pixs, REMOVE_CMAP_BASED_ON_SRC); pixWrite("/tmp/junkdrey2-1.png", pixt1, IFF_PNG); pixt2 = pixRemoveColormap(pixs, REMOVE_CMAP_TO_FULL_COLOR); pixWrite("/tmp/junkdrey2-2.png", pixt2, IFF_PNG); pixt3 = pixOctreeQuantNumColors(pixt2, 64, 1); pixWrite("/tmp/junkdrey2-3.png", pixt3, IFF_PNG); pixt4 = pixConvertRGBToColormap(pixt2, 1); pixWrite("/tmp/junkdrey2-4.png", pixt4, IFF_PNG); pixEqual(pixs, pixt1, &same); if (same) L_INFO("equal for pixt1 of dreyfus2", mainName); else { L_INFO("FAILURE for pixt1 of dreyfus2", mainName); errorfound = TRUE; } pixEqual(pixs, pixt2, &same); if (same) L_INFO("equal for pixt2 of dreyfus2", mainName); else { L_INFO("FAILURE for pixt2 of dreyfus2", mainName); errorfound = TRUE; } pixEqual(pixs, pixt3, &same); if (same) L_INFO("equal for pixt3 of dreyfus2", mainName); else { L_INFO("FAILURE for pixt3 of dreyfus2", mainName); errorfound = TRUE; } pixEqual(pixs, pixt4, &same); if (same) L_INFO("equal for pixt4 of dreyfus2", mainName); else { L_INFO("FAILURE for pixt4 of dreyfus2", mainName); errorfound = TRUE; } pixDestroy(&pixs); pixDestroy(&pixt1); pixDestroy(&pixt2); pixDestroy(&pixt3); pixDestroy(&pixt4); pixs = pixRead(DREYFUS4); pixt1 = pixRemoveColormap(pixs, REMOVE_CMAP_BASED_ON_SRC); pixWrite("/tmp/junkdrey4-1.png", pixt1, IFF_PNG); pixt2 = pixRemoveColormap(pixs, REMOVE_CMAP_TO_FULL_COLOR); pixWrite("/tmp/junkdrey4-2.png", pixt2, IFF_PNG); pixt3 = pixOctreeQuantNumColors(pixt2, 256, 1); pixWrite("/tmp/junkdrey4-3.png", pixt3, IFF_PNG); pixt4 = pixConvertRGBToColormap(pixt2, 1); pixWrite("/tmp/junkdrey4-4.png", pixt4, IFF_PNG); pixEqual(pixs, pixt1, &same); if (same) L_INFO("equal for pixt1 of dreyfus4", mainName); else { L_INFO("FAILURE for pixt1 of dreyfus4", mainName); errorfound = TRUE; } pixEqual(pixs, pixt2, &same); if (same) L_INFO("equal for pixt2 of dreyfus4", mainName); else { L_INFO("FAILURE for pixt2 of dreyfus4", mainName); errorfound = TRUE; } pixEqual(pixs, pixt3, &same); if (same) L_INFO("equal for pixt3 of dreyfus4", mainName); else { L_INFO("FAILURE for pixt3 of dreyfus4", mainName); errorfound = TRUE; } pixEqual(pixs, pixt4, &same); if (same) L_INFO("equal for pixt4 of dreyfus4", mainName); else { L_INFO("FAILURE for pixt4 of dreyfus4", mainName); errorfound = TRUE; } pixDestroy(&pixs); pixDestroy(&pixt1); pixDestroy(&pixt2); pixDestroy(&pixt3); pixDestroy(&pixt4); pixs = pixRead(DREYFUS8); pixt1 = pixRemoveColormap(pixs, REMOVE_CMAP_BASED_ON_SRC); pixWrite("/tmp/junkdrey8-1.png", pixt1, IFF_PNG); pixt2 = pixRemoveColormap(pixs, REMOVE_CMAP_TO_FULL_COLOR); pixWrite("/tmp/junkdrey8-2.png", pixt2, IFF_PNG); pixt3 = pixConvertRGBToColormap(pixt2, 1); pixWrite("/tmp/junkdrey8-3.png", pixt3, IFF_PNG); pixEqual(pixs, pixt1, &same); if (same) L_INFO("equal for pixt1 of dreyfus8", mainName); else { L_INFO("FAILURE for pixt1 of dreyfus8", mainName); errorfound = TRUE; } pixEqual(pixs, pixt2, &same); if (same) L_INFO("equal for pixt2 of dreyfus8", mainName); else { L_INFO("FAILURE for pixt2 of dreyfus8", mainName); errorfound = TRUE; } pixDestroy(&pixs); pixDestroy(&pixt1); pixDestroy(&pixt2); pixDestroy(&pixt3); pixs = pixRead(KAREN8); pixt1 = pixThresholdTo4bpp(pixs, 16, 1); pixWrite("/tmp/junkkar8-1.png", pixt1, IFF_PNG); pixt2 = pixRemoveColormap(pixt1, REMOVE_CMAP_BASED_ON_SRC); pixWrite("/tmp/junkkar8-2.png", pixt2, IFF_PNG); pixt3 = pixRemoveColormap(pixt1, REMOVE_CMAP_TO_FULL_COLOR); pixWrite("/tmp/junkkar8-3.png", pixt3, IFF_PNG); pixt4 = pixConvertRGBToColormap(pixt3, 1); pixEqual(pixt1, pixt2, &same); if (same) L_INFO("equal for pixt2 of karen8", mainName); else { L_INFO("FAILURE for pixt2 of karen8", mainName); errorfound = TRUE; } pixEqual(pixt1, pixt3, &same); if (same) L_INFO("equal for pixt3 of karen8", mainName); else { L_INFO("FAILURE for pixt3 of karen8", mainName); errorfound = TRUE; } pixEqual(pixt1, pixt4, &same); if (same) L_INFO("equal for pixt4 of karen8", mainName); else { L_INFO("FAILURE for pixt4 of karen8", mainName); errorfound = TRUE; } pixDestroy(&pixs); pixDestroy(&pixt1); pixDestroy(&pixt2); pixDestroy(&pixt3); pixDestroy(&pixt4); pixs = pixRead(MARGE32); pixt1 = pixOctreeQuantNumColors(pixs, 32, 0); pixWrite("/tmp/junkmarge8-1.png", pixt1, IFF_PNG); pixt2 = pixRemoveColormap(pixt1, REMOVE_CMAP_TO_FULL_COLOR); pixWrite("/tmp/junkmarge8-2.png", pixt2, IFF_PNG); pixt3 = pixConvertRGBToColormap(pixt2, 1); pixWrite("/tmp/junkmarge8-3.png", pixt3, IFF_PNG); pixt4 = pixOctreeQuantNumColors(pixt2, 64, 0); pixWrite("/tmp/junkmarge8-4.png", pixt4, IFF_PNG); pixEqual(pixt1, pixt2, &same); if (same) L_INFO("equal for pixt2 of marge32", mainName); else { L_INFO("FAILURE for pixt2 of marge32", mainName); errorfound = TRUE; } pixEqual(pixt1, pixt3, &same); if (same) L_INFO("equal for pixt3 of marge32", mainName); else { L_INFO("FAILURE for pixt3 of marge32", mainName); errorfound = TRUE; } pixEqual(pixt1, pixt4, &same); if (same) L_INFO("equal for pixt4 of marge32", mainName); else { L_INFO("FAILURE for pixt4 of marge32", mainName); errorfound = TRUE; } pixDestroy(&pixs); pixDestroy(&pixt1); pixDestroy(&pixt2); pixDestroy(&pixt3); pixDestroy(&pixt4); if (errorfound) L_INFO("FAILURE in processing this test", mainName); else L_INFO("SUCCESS in processing this test", mainName); exit(0); }
main(int argc, char **argv) { l_int32 w, h, d, wpl, count, i, format, xres, yres; FILE *fp; PIX *pix, *pixt1, *pixt2; PIXCMAP *cmap; char *filein; char *fileout = NULL; static char mainName[] = "iotest"; if (argc != 2 && argc != 3) exit(ERROR_INT(" Syntax: iotest filein [fileout]", mainName, 1)); filein = argv[1]; if (argc == 3) fileout = argv[2]; #if 1 if ((pix = pixRead(filein)) == NULL) exit(ERROR_INT("pix not made", mainName, 1)); #else if ((pix = pixReadJpeg(filein, 0, 4, NULL)) == NULL) exit(ERROR_INT("pix not made", mainName, 1)); #endif pixGetDimensions(pix, &w, &h, &d); wpl = pixGetWpl(pix); fprintf(stderr, "w = %d, h = %d, d = %d, wpl = %d\n", w, h, d, wpl); xres = pixGetXRes(pix); yres = pixGetXRes(pix); if (xres != 0 && yres != 0) fprintf(stderr, "xres = %d, yres = %d\n", xres, yres); if (pixGetColormap(pix)) { /* Write and read back the colormap */ pixcmapWriteStream(stderr, pixGetColormap(pix)); fp = lept_fopen("/tmp/junkcmap1", "wb"); pixcmapWriteStream(fp, pixGetColormap(pix)); lept_fclose(fp); fp = lept_fopen("/tmp/junkcmap1", "rb"); cmap = pixcmapReadStream(fp); lept_fclose(fp); fp = lept_fopen("/tmp/junkcmap2", "wb"); pixcmapWriteStream(fp, cmap); lept_fclose(fp); pixcmapDestroy(&cmap); /* Remove and regenerate colormap */ pixt1 = pixRemoveColormap(pix, REMOVE_CMAP_BASED_ON_SRC); if (pixGetDepth(pixt1) == 8) { fprintf(stderr, "Colormap: represents grayscale image\n"); pixt2 = pixConvertGrayToColormap(pixt1); } else { /* 32 bpp */ fprintf(stderr, "Colormap: represents RGB image\n"); pixt2 = pixConvertRGBToColormap(pixt1, 1); } pixWrite("/tmp/junkpixt2.png", pixt2, IFF_PNG); pixDestroy(&pixt1); pixDestroy(&pixt2); } else { fprintf(stderr, "no colormap\n"); } format = pixGetInputFormat(pix); fprintf(stderr, "Input format extension: %s\n", ImageFileFormatExtensions[format]); if (format == IFF_JFIF_JPEG) fprintf(stderr, "Jpeg comment: %s\n", pixGetText(pix)); if (d == 1) { pixCountPixels(pix, &count, NULL); fprintf(stderr, "pixel ratio ON/OFF = %6.3f\n", (l_float32)count / (l_float32)(pixGetWidth(pix) * pixGetHeight(pix))); } if (argc == 3) { #if 1 d = pixGetDepth(pix); if (d == 16 || d < 8 || pixGetColormap(pix)) pixWrite(fileout, pix, IFF_PNG); else pixWriteJpeg(fileout, pix, 75, 0); #elif 0 pixWrite(fileout, pix, IFF_BMP); #elif 0 pixWrite(fileout, pix, IFF_PNG); #elif 0 pixWrite(fileout, pix, IFF_TIFF); fprintTiffInfo(stderr, fileout); #elif 0 pixWrite(fileout, pix, IFF_TIFF_PACKBITS); fprintTiffInfo(stderr, fileout); #elif 0 pixWrite(fileout, pix, IFF_TIFF_G3); fprintTiffInfo(stderr, fileout); #elif 0 pixWrite(fileout, pix, IFF_TIFF_G4); fprintTiffInfo(stderr, fileout); #elif 0 pixWrite(fileout, pix, IFF_JFIF_JPEG); #elif 0 pixWriteJpeg(fileout, pix, 75, 0); #elif 0 pixWrite(fileout, pix, IFF_PNM); #elif 0 pixWrite(fileout, pix, IFF_PS); #endif } pixDestroy(&pix); #if 0 /* test tiff header reader */ { l_int32 w, h, bps, spp, res, cmap; if (readHeaderTiff(filein, 0, &w, &h, &bps, &spp, &res, &cmap) == 0) fprintf(stderr, "w = %d, h = %d, bps = %d, spp = %d, res = %d, cmap = %d\n", w, h, bps, spp, res, cmap); } #endif return 0; }