]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - QRScanner/mobile/jni/thirdparty/jbig2dec/pbm2png.c
Add MuPDF native source codes
[hornmich/skoda-qr-demo.git] / QRScanner / mobile / jni / thirdparty / jbig2dec / pbm2png.c
1 /* Copyright (C) 2001-2012 Artifex Software, Inc.
2    All Rights Reserved.
3
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6
7    This software is distributed under license and may not be copied,
8    modified or distributed except as expressly authorized under the terms
9    of the license contained in the file LICENSE in this distribution.
10
11    Refer to licensing information at http://www.artifex.com or contact
12    Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134, San Rafael,
13    CA  94903, U.S.A., +1(415)492-9861, for further information.
14 */
15
16 /*
17     jbig2dec
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #include "config_types.h"
23 #elif _WIN32
24 #include "config_win32.h"
25 #endif
26 #ifdef HAVE_STDINT_H
27 #include <stdint.h>
28 #endif
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33
34 #include "jbig2.h"
35 #include "jbig2_image.h"
36
37 int main(int argc, char *argv[])
38 {
39     Jbig2Ctx *ctx;
40     Jbig2Image *image;
41     int error;
42
43     /* we need a context for the allocators */
44     ctx = jbig2_ctx_new(NULL, 0, NULL, NULL, NULL);
45
46     if (argc != 3) {
47         fprintf(stderr, "usage: %s <in.pbm> <out.png>\n\n", argv[0]);
48         return 1;
49     }
50
51     image = jbig2_image_read_pbm_file(ctx, argv[1]);
52     if(image == NULL) {
53         fprintf(stderr, "error reading pbm file '%s'\n", argv[1]);
54         return 1;
55     } else {
56         fprintf(stderr, "converting %dx%d image to png format\n", image->width, image->height);
57     }
58
59     error = jbig2_image_write_png_file(image, argv[2]);
60     if (error) {
61         fprintf(stderr, "error writing png file '%s' error %d\n", argv[2], error);
62     }
63
64     return (error);
65 }