Пример #1
0
int jbig2_image_write_pbm_file(Jbig2Image *image, char *filename)
{
    FILE *out;
    int	error;
    
    if ((out = fopen(filename, "wb")) == NULL) {
        fprintf(stderr, "unable to open '%s' for writing", filename);
        return 1;
    }
    
    error = jbig2_image_write_pbm(image, out);
    
    fclose(out);
    return (error);
}
Пример #2
0
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;
}
Пример #3
0
/**
 * jbig2_end_of_page: parse and implement an end of page segment
 **/
int
jbig2_end_of_page(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment_data)
{
    uint32_t page_number = ctx->pages[ctx->current_page].number;

    if (segment->page_association != page_number) {
        jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
            "end of page marker for page %d doesn't match current page number %d",
            segment->page_association, page_number);
    }

    jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number,
        "end of page %d", page_number);

    jbig2_complete_page(ctx);

#ifdef OUTPUT_PBM
    jbig2_image_write_pbm(ctx->pages[ctx->current_page].image, stdout);
#endif

    return 0;
}