int main(int argc, char** argv) { int R, G, B; if (argc > 1) { refBlackWhite[0] = 16; refBlackWhite[1] = 235; refBlackWhite[2] = 128; refBlackWhite[3] = 240; refBlackWhite[4] = 128; refBlackWhite[5] = 240; } D3 = 2 - 2*LumaRed; D4 = 2 - 2*LumaBlue; D1 = 1. / D3; D2 = 1. / D4; D5 = D3*LumaRed / LumaGreen; D6 = D4*LumaBlue / LumaGreen; setupLumaTables(); for (R = 0; R < 256; R++) { for (G = 0; G < 256; G++) for (B = 0; B < 256; B++) check(R, G, B); printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n" , R , eCodes - preveCodes, eCodes , eBits - preveBits, eBits , abs(AbseRtotal - preveRtotal), eRtotal , AbseRtotal , abs(AbseGtotal - preveGtotal), eGtotal , AbseGtotal , abs(AbseBtotal - preveBtotal), eBtotal , AbseBtotal ); preveRtotal = AbseRtotal; preveGtotal = AbseGtotal; preveBtotal = AbseBtotal; preveCodes = eCodes; preveBits = eBits; } printf("%u total codes\n", 256*256*256); printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n" , eCodes , eBits , eRtotal , AbseRtotal , eGtotal , AbseGtotal , eBtotal , AbseBtotal ); return (0); }
int main(int argc, char* argv[]) { TIFF *in, *out; int c; extern int optind; extern char *optarg; while ((c = getopt(argc, argv, "c:h:r:v:z")) != -1) switch (c) { case 'c': if (streq(optarg, "none")) compression = COMPRESSION_NONE; else if (streq(optarg, "packbits")) compression = COMPRESSION_PACKBITS; else if (streq(optarg, "lzw")) compression = COMPRESSION_LZW; else if (streq(optarg, "jpeg")) compression = COMPRESSION_JPEG; else if (streq(optarg, "zip")) compression = COMPRESSION_ADOBE_DEFLATE; else usage(-1); break; case 'h': horizSubSampling = atoi(optarg); break; case 'v': vertSubSampling = atoi(optarg); break; case 'r': rowsperstrip = atoi(optarg); break; case 'z': /* CCIR Rec 601-1 w/ headroom/footroom */ refBlackWhite[0] = 16.; refBlackWhite[1] = 235.; refBlackWhite[2] = 128.; refBlackWhite[3] = 240.; refBlackWhite[4] = 128.; refBlackWhite[5] = 240.; break; case '?': usage(0); /*NOTREACHED*/ } if (argc - optind < 2) usage(-1); out = TIFFOpen(argv[argc-1], "w"); if (out == NULL) return (-2); setupLumaTables(); for (; optind < argc-1; optind++) { in = TIFFOpen(argv[optind], "r"); if (in != NULL) { do { if (!tiffcvt(in, out) || !TIFFWriteDirectory(out)) { (void) TIFFClose(out); return (1); } } while (TIFFReadDirectory(in)); (void) TIFFClose(in); } } (void) TIFFClose(out); return (0); }