51 #define GetJBIGState(tif) ((JBIGState*)(tif)->tif_data) 53 #define FIELD_RECVPARAMS (FIELD_CODEC+0) 54 #define FIELD_SUBADDRESS (FIELD_CODEC+1) 55 #define FIELD_RECVTIME (FIELD_CODEC+2) 56 #define FIELD_FAXDCS (FIELD_CODEC+3) 66 static int JBIGSetupDecode(
TIFF* tif)
70 TIFFError(
"JBIG",
"Multistrip images not supported in decoder");
79 struct jbg_dec_state decoder;
81 unsigned char* pImage = NULL;
82 (void) size, (
void) s;
89 jbg_dec_init(&decoder);
91 #if defined(HAVE_JBG_NEWLEN) 105 decodeStatus = jbg_dec_in(&decoder, tif->
tif_rawdata,
107 if (JBG_EOK != decodeStatus)
114 TIFFError(
"JBIG",
"Error (%d) decoding: %s", decodeStatus,
116 jbg_strerror(decodeStatus, JBG_EN)
118 jbg_strerror(decodeStatus)
124 pImage = jbg_dec_getimage(&decoder, 0);
125 _TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder));
126 jbg_dec_free(&decoder);
130 static int JBIGSetupEncode(
TIFF* tif)
134 TIFFError(
"JBIG",
"Multistrip images not supported in encoder");
169 static void JBIGOutputBie(
unsigned char* buffer,
size_t len,
void *userData)
178 JBIGCopyEncodedData(tif, buffer, len, 0);
184 struct jbg_enc_state encoder;
186 (void) size, (
void) s;
188 jbg_enc_init(&encoder,
199 jbg_enc_out(&encoder);
200 jbg_enc_free(&encoder);
205 static
void JBIGCleanup(
TIFF* tif)
207 JBIGState *sp = GetJBIGState(tif);
211 tif->tif_tagmethods.vgetfield = sp->vgetparent;
212 tif->tif_tagmethods.vsetfield = sp->vsetparent;
215 tif->tif_data = NULL;
220 static void JBIGPrintDir(
TIFF* tif, FILE* fd,
long flags)
222 JBIGState* codec = GetJBIGState(tif);
228 " Fax Receive Parameters: %08lx\n",
229 (
unsigned long)codec->recvparams);
235 " Fax SubAddress: %s\n",
242 " Fax Receive Time: %lu secs\n",
243 (
unsigned long)codec->recvtime);
254 static int JBIGVGetField(
TIFF* tif,
ttag_t tag, va_list ap)
256 JBIGState* codec = GetJBIGState(tif);
261 *va_arg(ap, uint32*) = codec->recvparams;
265 *va_arg(ap,
char**) = codec->subaddress;
269 *va_arg(ap, uint32*) = codec->recvtime;
273 *va_arg(ap,
char**) = codec->faxdcs;
277 return (*codec->vgetparent)(tif, tag, ap);
283 static int JBIGVSetField(
TIFF* tif,
ttag_t tag, va_list ap)
285 JBIGState* codec = GetJBIGState(tif);
290 codec->recvparams = va_arg(ap, uint32);
298 codec->recvtime = va_arg(ap, uint32);
306 return (*codec->vsetparent)(tif, tag, ap);
316 JBIGState* codec = NULL;
326 "Merging JBIG codec-specific tags failed");
334 TIFFError(
"TIFFInitJBIG",
"Not enough memory for JBIGState");
338 codec = GetJBIGState(tif);
341 codec->recvparams = 0;
342 codec->subaddress = NULL;
343 codec->faxdcs = NULL;
TIFFTagMethods tif_tagmethods
void TIFFReverseBits(register unsigned char *cp, register unsigned long n)
void _TIFFsetString(char **cpp, char *cp)
TIFFCodeMethod tif_encodestrip
void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
#define TIFFSetFieldBit(tif, field)
TIFFCodeMethod tif_decodestrip
#define TIFFTAG_FAXRECVTIME
int _TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], int)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
#define TIFFFieldSet(tif, field)
TIFFVoidMethod tif_cleanup
#define TIFFArrayCount(a)
void _TIFFmemset(tdata_t p, int v, tsize_t c)
void _TIFFSetDefaultCompressionState(TIFF *tif)
tstrip_t TIFFNumberOfStrips(TIFF *tif)
void TIFFError(const char *module, const char *fmt,...)
const TIFFFieldInfo * _TIFFFieldWithTag(TIFF *tif, ttag_t tag)
int(* TIFFVGetMethod)(TIFF *, ttag_t, va_list)
#define isFillOrder(tif, o)
void * _TIFFmalloc(tsize_t s)
#define TIFFTAG_FAXSUBADDRESS
void _TIFFfree(tdata_t p)
int(* TIFFVSetMethod)(TIFF *, ttag_t, va_list)
TIFFBoolMethod tif_setupencode
int TIFFFlushData1(TIFF *tif)
#define TIFFTAG_FAXRECVPARAMS
TIFFBoolMethod tif_setupdecode