From b1bb4601306e9c6fa4fc9bdda14457609bc07f3d Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 6 Sep 2020 09:44:03 +0000 Subject: Add diagnostics git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3945 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- .../other/jpeg2000/libjasper/base/jas_image.c | 41 ++++++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'converter/other/jpeg2000/libjasper/base') diff --git a/converter/other/jpeg2000/libjasper/base/jas_image.c b/converter/other/jpeg2000/libjasper/base/jas_image.c index 5c2822be..d474dfe4 100644 --- a/converter/other/jpeg2000/libjasper/base/jas_image.c +++ b/converter/other/jpeg2000/libjasper/base/jas_image.c @@ -126,6 +126,8 @@ #include #include +#include "netpbm/nstring.h" + #include "jasper/jas_math.h" #include "jasper/jas_image.h" #include "jasper/jas_malloc.h" @@ -379,22 +381,47 @@ static void jas_image_cmpt_destroy(jas_image_cmpt_t *cmpt) * Load and save operations. \*****************************************************************************/ -jas_image_t *jas_image_decode(jas_stream_t *in, int fmt, char *optstr) -{ +void +jas_image_decode(jas_stream_t * const in, + int const fmtArg, + const char * const optstr, + jas_image_t ** const imagePP, + const char ** const errorP) { +/*---------------------------------------------------------------------------- + Create an image from a stream in some specified format +-----------------------------------------------------------------------------*/ jas_image_fmtinfo_t *fmtinfo; + int fmt; /* If possible, try to determine the format of the input data. */ - if (fmt < 0) { + if (fmtArg < 0) { if ((fmt = jas_image_getfmt(in)) < 0) { - return 0; + pm_asprintf(errorP, "jas_image_getfmt failed"); + return; } - } + } else + fmt = fmtArg; + if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) { - return 0; + pm_asprintf(errorP, "jas_image_lookupfmtbyid of format %d failed", + fmt); + return; + } + { + const char * error; + + (*fmtinfo->ops.decode)(in, optstr, imagePP, &error); + if (error) { + pm_asprintf(errorP, "decoder failed. %s", error); + pm_strfree(error); + } else { + *errorP = NULL; + } } - return (fmtinfo->ops.decode) ? (*fmtinfo->ops.decode)(in, optstr) : 0; } + + int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt, char *optstr) { jas_image_fmtinfo_t *fmtinfo; -- cgit 1.4.1