mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
MM and II 16 bit integer tiffs unpack properly using libtiff on bigendian platform
This commit is contained in:
parent
1945fecdb6
commit
6f8d968cbb
|
@ -804,6 +804,12 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
# fillorder==2 modes have a corresponding
|
||||
# fillorder=1 mode
|
||||
self.mode, rawmode = OPEN_INFO[key]
|
||||
# libtiff always returns the bytes in native order.
|
||||
# we're expecting image byte order. So, if the rawmode
|
||||
# contains I;16, we need to convert from native to image
|
||||
# byte order.
|
||||
if self.mode in ('I;16B', 'I;16'):
|
||||
rawmode = 'I;16N'
|
||||
|
||||
# Offset in the tile tuple is 0, we go from 0,0 to
|
||||
# w,h, and we only do this once -- eds
|
||||
|
|
|
@ -105,7 +105,8 @@ ImagingNewPrologueSubtype(const char *mode, unsigned xsize, unsigned ysize,
|
|||
im->linesize = xsize * 4;
|
||||
im->type = IMAGING_TYPE_INT32;
|
||||
|
||||
} else if (strcmp(mode, "I;16") == 0 || strcmp(mode, "I;16L") == 0 || strcmp(mode, "I;16B") == 0) {
|
||||
} else if (strcmp(mode, "I;16") == 0 || strcmp(mode, "I;16L") == 0 \
|
||||
|| strcmp(mode, "I;16B") == 0 || strcmp(mode, "I;16N") == 0) {
|
||||
/* EXPERIMENTAL */
|
||||
/* 16-bit raw integer images */
|
||||
im->bands = 1;
|
||||
|
|
|
@ -775,6 +775,26 @@ ImagingUnpackLAB(UINT8* out, const UINT8* in, int pixels)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unpackI16N_I16B(UINT8* out, const UINT8* in, int pixels){
|
||||
int i;
|
||||
UINT8* tmp = (UINT8*) out;
|
||||
for (i = 0; i < pixels; i++) {
|
||||
C16B;
|
||||
in += 2; tmp += 2;
|
||||
}
|
||||
|
||||
}
|
||||
static void
|
||||
unpackI16N_I16(UINT8* out, const UINT8* in, int pixels){
|
||||
int i;
|
||||
UINT8* tmp = (UINT8*) out;
|
||||
for (i = 0; i < pixels; i++) {
|
||||
C16L;
|
||||
in += 2; tmp += 2;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
copy1(UINT8* out, const UINT8* in, int pixels)
|
||||
{
|
||||
|
@ -1139,6 +1159,10 @@ static struct {
|
|||
{"I;16B", "I;16B", 16, copy2},
|
||||
{"I;16L", "I;16L", 16, copy2},
|
||||
|
||||
{"I;16", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian.
|
||||
{"I;16L", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian.
|
||||
{"I;16B", "I;16N", 16, unpackI16N_I16B},
|
||||
|
||||
{NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user