static int write_page_image(jbig2dec_params_t *params, Jbig2Image *image) { if (!strncmp(params->output_file, "-", 2)) { switch (params->output_format) { #ifdef HAVE_LIBPNG case jbig2dec_format_png: jbig2_image_write_png(image, stdout); break; #endif case jbig2dec_format_pbm: jbig2_image_write_pbm(image, stdout); break; default: fprintf(stderr, "unsupported output format.\n"); return 1; } } else { if (params->verbose > 1) fprintf(stderr, "saving decoded page as '%s'\n", params->output_file); switch (params->output_format) { #ifdef HAVE_LIBPNG case jbig2dec_format_png: jbig2_image_write_png_file(image, params->output_file); break; #endif case jbig2dec_format_pbm: jbig2_image_write_pbm_file(image, params->output_file); break; default: fprintf(stderr, "unsupported output format.\n"); return 1; } } return 0; }
void jbig2_dump_symbol_dict(Jbig2Ctx *ctx, Jbig2Segment *segment) { Jbig2SymbolDict *dict = (Jbig2SymbolDict *)segment->result; int index; char filename[24]; if (dict == NULL) return; jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number, "dumping symbol dict as %d individual png files\n", dict->n_symbols); for (index = 0; index < dict->n_symbols; index++) { snprintf(filename, sizeof(filename), "symbol_%02d-%04d.png", segment->number, index); jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "dumping symbol %d/%d as '%s'", index, dict->n_symbols, filename); #ifdef HAVE_LIBPNG jbig2_image_write_png_file(dict->glyphs[index], filename); #else jbig2_image_write_pbm_file(dict->glyphs[index], filename); #endif } }