Blame pbm2png.c

Packit 3f21c4
/* Copyright (C) 2001-2012 Artifex Software, Inc.
Packit 3f21c4
   All Rights Reserved.
Packit 3f21c4
Packit 3f21c4
   This software is provided AS-IS with no warranty, either express or
Packit 3f21c4
   implied.
Packit 3f21c4
Packit 3f21c4
   This software is distributed under license and may not be copied,
Packit 3f21c4
   modified or distributed except as expressly authorized under the terms
Packit 3f21c4
   of the license contained in the file LICENSE in this distribution.
Packit 3f21c4
Packit 3f21c4
   Refer to licensing information at http://www.artifex.com or contact
Packit 3f21c4
   Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
Packit 3f21c4
   CA  94903, U.S.A., +1(415)492-9861, for further information.
Packit 3f21c4
*/
Packit 3f21c4
Packit 3f21c4
/*
Packit 3f21c4
    jbig2dec
Packit 3f21c4
*/
Packit 3f21c4
Packit 3f21c4
#ifdef HAVE_CONFIG_H
Packit 3f21c4
#include "config.h"
Packit 3f21c4
#include "config_types.h"
Packit 3f21c4
#elif _WIN32
Packit 3f21c4
#include "config_win32.h"
Packit 3f21c4
#endif
Packit 3f21c4
#ifdef HAVE_STDINT_H
Packit 3f21c4
#include <stdint.h>
Packit 3f21c4
#endif
Packit 3f21c4
Packit 3f21c4
#include <stdio.h>
Packit 3f21c4
#include <stdlib.h>
Packit 3f21c4
#include <string.h>
Packit 3f21c4
Packit 3f21c4
#include "jbig2.h"
Packit 3f21c4
#include "jbig2_image.h"
Packit 3f21c4
Packit 3f21c4
int
Packit 3f21c4
main(int argc, char *argv[])
Packit 3f21c4
{
Packit 3f21c4
    Jbig2Ctx *ctx;
Packit 3f21c4
    Jbig2Image *image;
Packit 3f21c4
    int error;
Packit 3f21c4
Packit 3f21c4
    /* we need a context for the allocators */
Packit 3f21c4
    ctx = jbig2_ctx_new(NULL, 0, NULL, NULL, NULL);
Packit 3f21c4
Packit 3f21c4
    if (argc != 3) {
Packit 3f21c4
        fprintf(stderr, "usage: %s <in.pbm> <out.png>\n\n", argv[0]);
Packit 3f21c4
        return 1;
Packit 3f21c4
    }
Packit 3f21c4
Packit 3f21c4
    image = jbig2_image_read_pbm_file(ctx, argv[1]);
Packit 3f21c4
    if (image == NULL) {
Packit 3f21c4
        fprintf(stderr, "error reading pbm file '%s'\n", argv[1]);
Packit 3f21c4
        return 1;
Packit 3f21c4
    } else {
Packit 3f21c4
        fprintf(stderr, "converting %dx%d image to png format\n", image->width, image->height);
Packit 3f21c4
    }
Packit 3f21c4
Packit 3f21c4
    error = jbig2_image_write_png_file(image, argv[2]);
Packit 3f21c4
    if (error) {
Packit 3f21c4
        fprintf(stderr, "error writing png file '%s' error %d\n", argv[2], error);
Packit 3f21c4
    }
Packit 3f21c4
Packit 3f21c4
    return (error);
Packit 3f21c4
}