int main(int argc, char **argv) { setlocale(LC_ALL,""); djvu_programname(argv[0]); GArray<GUTF8String> dargv(0,argc-1); for(int i=0;i<argc;++i) dargv[i]=GNativeString(argv[i]); G_TRY { if (argc<=1) usage(); for (int i=1; i<argc; i++) { const GURL::Filename::UTF8 url(dargv[i]); display(url); } } G_CATCH(ex) { ex.perror(); exit(1); } G_ENDCATCH; return 0; }
int main(int argc, char **argv) { setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); djvu_programname(argv[0]); // get output file name if (argc>2 && !strcmp(argv[1],"-o")) { outputfile = argv[2]; argv += 2; argc -= 2; } // convert iff file name GArray<GUTF8String> dargv(0, argc-1); for(int i=0;i<argc;++i) dargv[i]=GNativeString(argv[i]); if (argc <= 1) usage(); if (outputfile && !(outputf = fopen(outputfile,"w"))) { DjVuPrintErrorUTF8("djvudump: Cannot open output file.\n"); exit(1); } G_TRY { for (int i=1; i<argc; i++) { const GURL::Filename::UTF8 url(dargv[i]); display(url); } } G_CATCH(ex) { ex.perror(); exit(1); } G_ENDCATCH; return 0; }
int main(int argc, char **argv) { setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); djvu_programname(argv[0]); GArray<GUTF8String> dargv(0,argc-1); for(int i=0;i<argc;++i) dargv[i]=GNativeString(argv[i]); G_TRY { // Print usage when called without enough arguments if (argc <= 2) usage(); // Open djvu file remove(dargv[1]); GP<IFFByteStream> giff = IFFByteStream::create(ByteStream::create(GURL::Filename::UTF8(dargv[1]),"wb")); IFFByteStream &iff=*giff; // Create header iff.put_chunk("FORM:DJVU", 1); // Check if shared dicts are present check_for_shared_dict(dargv); // Create information chunk create_info_chunk(iff, dargv); // Parse all arguments for (int i=2; i<argc; i++) { if (!dargv[i].cmp("INFO=",5)) { if (i>2) DjVuPrintErrorUTF8("%s","djvumake: 'INFO' chunk should appear first (ignored)\n"); } else if (!dargv[i].cmp("Sjbz=",5)) { if (flag_contains_stencil) DjVuPrintErrorUTF8("%s","djvumake: duplicate stencil chunk\n"); create_jb2_chunk(iff, "Sjbz", GURL::Filename::UTF8(5+(const char *)dargv[i])); flag_contains_stencil = 1; if (flag_fg_needs_palette && blit_count >= 0) create_fgbz_chunk(iff); flag_fg_needs_palette = 0; } else if (!dargv[i].cmp("Smmr=",5)) { create_mmr_chunk(iff, "Smmr", GURL::Filename::UTF8(5+(const char *)dargv[i])); if (flag_contains_stencil) DjVuPrintErrorUTF8("%s","djvumake: duplicate stencil chunk\n"); flag_contains_stencil = 1; } else if (!dargv[i].cmp("FGbz=",5)) { const char *c = 5 + (const char*)dargv[i]; if (flag_contains_fg) DjVuPrintErrorUTF8("%s","djvumake: duplicate 'FGxx' chunk\n"); if (c[0] != '#') { create_raw_chunk(iff, "FGbz", GURL::Filename::UTF8(c)); } else { parse_color_zones(c); if (flag_contains_stencil && blit_count >= 0) create_fgbz_chunk(iff); else flag_fg_needs_palette = 1; } flag_contains_fg = 1; } else if (!dargv[i].cmp("FG44=",5)) { if (flag_contains_fg) DjVuPrintErrorUTF8("%s","djvumake: duplicate 'FGxx' chunk\n"); create_fg44_chunk(iff, "FG44", GURL::Filename::UTF8(5+(const char *)dargv[i])); } else if (!dargv[i].cmp("BG44=",5)) { create_bg44_chunk(iff, "BG44", 5+(const char *)dargv[i]); } else if (!dargv[i].cmp("BGjp=",5) || !dargv[i].cmp("BG2k=",5) ) { if (flag_contains_bg) DjVuPrintErrorUTF8("%s","djvumake: Duplicate BGxx chunk\n"); GUTF8String chkid = dargv[i].substr(0,4); create_raw_chunk(iff, chkid, GURL::Filename::UTF8(5+(const char *)dargv[i])); flag_contains_bg = 1; } else if (!dargv[i].cmp("FGjp=",5) || !dargv[i].cmp("FG2k=",5)) { if (flag_contains_fg) DjVuPrintErrorUTF8("%s","djvumake: duplicate 'FGxx' chunk\n"); GUTF8String chkid = dargv[i].substr(0,4); create_raw_chunk(iff, chkid, GURL::Filename::UTF8(5+(const char *)dargv[i])); flag_contains_fg = 1; } else if (!dargv[i].cmp("INCL=",5)) { create_incl_chunk(iff, "INCL", GURL::Filename::UTF8(5+(const char *)dargv[i]).fname()); flag_contains_incl = 1; } else if (!dargv[i].cmp("PPM=",4)) { if (flag_contains_bg || flag_contains_fg) DjVuPrintErrorUTF8("%s","djvumake: Duplicate 'FGxx' or 'BGxx' chunk\n"); create_masksub_chunks(iff, GURL::Filename::UTF8(4+(const char *)dargv[i])); flag_contains_bg = 1; flag_contains_fg = 1; } else if (dargv[i].length() > 4 && dargv[i][4] == '=') { GNativeString chkid = dargv[i].substr(0,4); if (chkid != "TXTz" && chkid != "TXTa" && chkid != "ANTz" && chkid != "ANTa" && chkid != "Djbz" ) DjVuPrintErrorUTF8("djvumake: creating chunk of unknown type ``%s''.\n", (const char*)chkid); create_raw_chunk(iff, chkid, GURL::Filename::UTF8(5+(const char *)dargv[i])); } else { DjVuPrintErrorUTF8("djvumake: illegal argument : ``%s'' (ignored)\n", (const char *)dargv[i]); } } // Common cases for missing chunks if (flag_contains_stencil) { if (flag_contains_bg && ! flag_contains_fg) { DjVuPrintErrorUTF8("%s","djvumake: generating black FGbz chunk\n"); g().colorzones.empty(); g().colorpalette = ByteStream::create(); char rgb[3] = {0,0,0}; g().colorpalette->writall(rgb, 3); create_fgbz_chunk(iff); flag_contains_fg = 1; } if (flag_contains_fg && !flag_contains_bg) { DjVuPrintErrorUTF8("%s","djvumake: generating white BG44 chunk\n"); GPixel bgcolor = GPixel::WHITE; GP<GPixmap> inputsub=GPixmap::create((h+11)/12, (w+11)/12, &bgcolor); GP<IW44Image> iw = IW44Image::create_encode(*inputsub, 0, IW44Image::CRCBnone); IWEncoderParms iwparms; iff.put_chunk("BG44"); iwparms.slices = 97; iw->encode_chunk(iff.get_bytestream(), iwparms); iff.close_chunk(); flag_contains_bg = 1; } } // Close iff.close_chunk(); // Sanity checks if (flag_contains_stencil) { // Compound or Bilevel if (flag_contains_bg && ! flag_contains_fg) DjVuPrintErrorUTF8("%s","djvumake: djvu file contains a BGxx chunk but no FGxx chunk\n"); if (flag_contains_fg && ! flag_contains_bg) DjVuPrintErrorUTF8("%s","djvumake: djvu file contains a FGxx chunk but no BGxx chunk\n"); } else if (flag_contains_bg) { // Photo DjVu Image if (flag_contains_bg!=1) DjVuPrintErrorUTF8("%s","djvumake: photo djvu image has subsampled BGxx chunk\n"); if (flag_fg_needs_palette) DjVuPrintErrorUTF8("%s","djvumake: could not generate FGbz chunk, as stencil is not available\n"); else if (flag_contains_fg) DjVuPrintErrorUTF8("%s","djvumake: photo djvu file contains FGxx chunk\n"); } else DjVuPrintErrorUTF8("%s","djvumake: djvu file contains neither Sxxx nor BGxx chunks\n"); } G_CATCH(ex) { remove(dargv[1]); ex.perror(); exit(1); } G_ENDCATCH; return 0; }
int main(int argc, const char **argv) { setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); djvu_programname(argv[0]); GArray<GUTF8String> dargv(0,argc-1); for(int i=0;i<argc;++i) dargv[i]=GNativeString(argv[i]); G_TRY { GURL inputppmurl; GURL outputdjvuurl; // Defaults cpaldjvuopts opts; opts.dpi = 100; opts.ncolors = 256; opts.verbose = false; opts.bgwhite = false; // Parse options for (int i=1; i<argc; i++) { GUTF8String arg = dargv[i]; if (arg == "-colors" && i+1<argc) { char *end; opts.ncolors = strtol(dargv[++i], &end, 10); if (*end || opts.ncolors<2 || opts.ncolors>4096) usage(); } else if (arg == "-dpi" && i+1<argc) { char *end; opts.dpi = strtol(dargv[++i], &end, 10); if (*end || opts.dpi<25 || opts.dpi>6000) usage(); } else if (arg == "-verbose" || arg == "-v") opts.verbose = true; else if (arg == "-bgwhite") opts.bgwhite = true; else if (arg[0] == '-' && arg[1]) usage(); else if (inputppmurl.is_empty()) inputppmurl = GURL::Filename::UTF8(arg); else if (outputdjvuurl.is_empty()) outputdjvuurl = GURL::Filename::UTF8(arg); else usage(); } if (inputppmurl.is_empty() || outputdjvuurl.is_empty()) usage(); // Load and run GP<ByteStream> ibs=ByteStream::create(inputppmurl,"rb"); cpaldjvu(ibs, outputdjvuurl, opts); } G_CATCH(ex) { ex.perror(); exit(1); } G_ENDCATCH; return 0; }
int main(int argc, const char **argv) { setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); djvu_programname(argv[0]); GArray<GUTF8String> dargv(0,argc-1); for(int i=0;i<argc;++i) dargv[i]=GNativeString(argv[i]); G_TRY { GURL inputpbmurl; GURL outputdjvuurl; cjb2opts opts; // Defaults opts.forcedpi = 0; opts.dpi = 300; opts.losslevel = 0; opts.verbose = false; // Parse options for (int i=1; i<argc; i++) { GUTF8String arg = dargv[i]; if (arg == "-dpi" && i+1<argc) { char *end; opts.dpi = opts.forcedpi = strtol(dargv[++i], &end, 10); if (*end || opts.dpi<25 || opts.dpi>1200) usage(); } else if (arg == "-losslevel") { char *end; opts.losslevel = strtol(dargv[++i], &end, 10); if (*end || opts.losslevel<0 || opts.losslevel>200) usage(); } else if (arg == "-lossless") opts.losslevel = 0; else if (arg == "-lossy") opts.losslevel = 100; else if (arg == "-clean") // almost deprecated opts.losslevel = 1; else if (arg == "-verbose" || arg == "-v") opts.verbose = true; else if (arg[0] == '-' && arg[1]) usage(); else if (inputpbmurl.is_empty()) inputpbmurl = GURL::Filename::UTF8(arg); else if (outputdjvuurl.is_empty()) outputdjvuurl = GURL::Filename::UTF8(arg); else usage(); } if (inputpbmurl.is_empty() || outputdjvuurl.is_empty()) usage(); // Execute cjb2(inputpbmurl, outputdjvuurl, opts); } G_CATCH(ex) { ex.perror(); exit(1); } G_ENDCATCH; return 0; }