388
388
return (PyObject*) decoder;
391
/* -------------------------------------------------------------------- */
393
/* -------------------------------------------------------------------- */
397
#include "TiffDecode.h"
401
#define strcasecmp(s1, s2) stricmp(s1, s2)
405
PyImaging_LibTiffDecoderNew(PyObject* self, PyObject* args)
407
ImagingDecoderObject* decoder;
414
if (! PyArg_ParseTuple(args, "sssi", &mode, &rawmode, &compname, &fp))
417
TRACE(("new tiff decoder %s\n", compname));
419
/* UNDONE -- we can probably do almost any arbitrary compression here,
420
* since we're effective passing in the whole file in one shot and
421
* getting back the data row by row. V2 maybe
424
if (strcasecmp(compname, "tiff_ccitt") == 0) {
425
compression = COMPRESSION_CCITTRLE;
427
} else if (strcasecmp(compname, "group3") == 0) {
428
compression = COMPRESSION_CCITTFAX3;
430
} else if (strcasecmp(compname, "group4") == 0) {
431
compression = COMPRESSION_CCITTFAX4;
433
} else if (strcasecmp(compname, "tiff_raw_16") == 0) {
434
compression = COMPRESSION_CCITTRLEW;
437
PyErr_SetString(PyExc_ValueError, "unknown compession");
441
decoder = PyImaging_DecoderNew(sizeof(TIFFSTATE));
445
if (get_unpacker(decoder, mode, rawmode) < 0)
448
if (! ImagingLibTiffInit(&decoder->state, compression, fp)) {
450
PyErr_SetString(PyExc_RuntimeError, "tiff codec initialization failed");
454
decoder->decode = ImagingLibTiffDecode;
456
return (PyObject*) decoder;
392
461
/* -------------------------------------------------------------------- */