Mercurial > hgrepos > Python2 > PyMuPDF
diff mupdf-source/thirdparty/jbig2dec/pbm2png.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mupdf-source/thirdparty/jbig2dec/pbm2png.c Mon Sep 15 11:43:07 2025 +0200 @@ -0,0 +1,67 @@ +/* Copyright (C) 2001-2023 Artifex Software, Inc. + All Rights Reserved. + + This software is provided AS-IS with no warranty, either express or + implied. + + This software is distributed under license and may not be copied, + modified or distributed except as expressly authorized under the terms + of the license contained in the file LICENSE in this distribution. + + Refer to licensing information at http://www.artifex.com or contact + Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, + CA 94129, USA, for further information. +*/ + +/* + jbig2dec +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#include "config_types.h" +#elif _WIN32 +#include "config_win32.h" +#endif +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "jbig2.h" +#include "jbig2_image.h" +#include "jbig2_image_rw.h" + +int +main(int argc, char *argv[]) +{ + Jbig2Ctx *ctx; + Jbig2Image *image; + int code; + + /* we need a context for the allocators */ + ctx = jbig2_ctx_new(NULL, 0, NULL, NULL, NULL); + + 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); + } + + code = jbig2_image_write_png_file(image, argv[2]); + if (code) { + fprintf(stderr, "error writing png file '%s' error %d\n", argv[2], code); + } + + return (code); +}
