jbig2dec

Ralph Giles <[email protected]> Mon, 08 Jul 2002 07:11:38 -0700
Newsgroups gmane.comp.printing.ghostscript.jbig2dec.cvs
Message-ID <[email protected]>
Update of /cvsroot/jbig2dec/jbig2dec
In directory usw-pr-cvs1:/tmp/cvs-serv29167

Modified Files:
	pbm2png.c 
Log Message:
Update pbm2png.c to pass a jbig2 context for the allocator, so that
it can be linked against the current routines.


Index: pbm2png.c
===================================================================
RCS file: /cvsroot/jbig2dec/jbig2dec/pbm2png.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pbm2png.c	4 Jun 2002 16:51:02 -0000	1.1
+++ pbm2png.c	8 Jul 2002 14:11:36 -0000	1.2
@@ -11,29 +11,47 @@
     $Id$
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "config_types.h"
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdint.h>
 #include <string.h>
+
+#include "jbig2.h"
 #include "jbig2_image.h"
 
 int main(int argc, char *argv[])
 {
-	Jbig2Image *image;
-        int error;
+    Jbig2Ctx *ctx;
+    Jbig2Image *image;
+    int error;
+    
+    /* we need a context for the allocators */
+    ctx = jbig2_ctx_new(NULL, 0, NULL, NULL, NULL);
 
-	image = jbig2_image_read_pbm_file(argv[1]);
-	if(image == NULL) {
-            fprintf(stderr, "error reading pbm file '%s'\n", argv[1]);
-            return 1;
-        } else {
-            fprintf(stderr, "converting %dx%d image to png format\n", image->width, image->height);
-        }
-        
-        error = jbig2_image_write_png_file(image, argv[2]);
-        if (error) {
-            fprintf(stderr, "error writing png file '%s' error %d\n", argv[2], error);
-	}
+    if (argc != 3) {
+        fprintf(stderr, "usage: %s <in.pbm> <out.png>\n\n", argv[0]);
+        return 1;
+    }
+    
+    image = jbig2_image_read_pbm_file(ctx, argv[1]);
+    if(image == NULL) {
+        fprintf(stderr, "error reading pbm file '%s'\n", argv[1]);
+        return 1;
+    } else {
+        fprintf(stderr, "converting %dx%d image to png format\n", image->width, image->height);
+    }
+    
+    error = jbig2_image_write_png_file(image, argv[2]);
+    if (error) {
+        fprintf(stderr, "error writing png file '%s' error %d\n", argv[2], error);
+    }
 
-	return (error);
+    return (error);
 }