Added RGB*;16N Unpackers

This commit is contained in:
Eric Soroos 2017-12-20 13:53:14 +00:00
parent c816932f4b
commit 768668c1d7
3 changed files with 20 additions and 2 deletions

View File

@ -1278,8 +1278,13 @@ class TiffImageFile(ImageFile.ImageFile):
# we're expecting image byte order. So, if the rawmode # we're expecting image byte order. So, if the rawmode
# contains I;16, we need to convert from native to image # contains I;16, we need to convert from native to image
# byte order. # byte order.
if self.mode in ('I;16B', 'I;16') and 'I;16' in rawmode: if rawmode == 'I;16':
rawmode = 'I;16N' rawmode = 'I;16N'
if '16B' in rawmode:
rawmode = rawmode.replace('16B', '16N')
if '16L' in rawmode:
rawmode = rawmode.replace('16L', '16N')
# Offset in the tile tuple is 0, we go from 0,0 to # Offset in the tile tuple is 0, we go from 0,0 to
# w,h, and we only do this once -- eds # w,h, and we only do this once -- eds

View File

@ -577,7 +577,7 @@ class TestFileLibTiff(LibTiffTestCase):
self.assertEqual(im.mode, "RGBA") self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (100, 40)) self.assertEqual(im.size, (100, 40))
self.assertEqual(im.tile, [('tiff_lzw', (0, 0, 100, 40), 0, ('RGBa;16B', 'tiff_lzw', False))]) self.assertEqual(im.tile, [('tiff_lzw', (0, 0, 100, 40), 0, ('RGBa;16N', 'tiff_lzw', False))])
im.load() im.load()
self.assert_image_equal_tofile(im, "Tests/images/tiff_16bit_RGBa_target.png") self.assert_image_equal_tofile(im, "Tests/images/tiff_16bit_RGBa_target.png")

View File

@ -1301,6 +1301,19 @@ static struct {
{"RGBA", "B", 8, band2}, {"RGBA", "B", 8, band2},
{"RGBA", "A", 8, band3}, {"RGBA", "A", 8, band3},
#ifdef WORDS_BIGENDIAN
{"RGB", "RGB;16N", 64, unpackRGB16B},
{"RGBA", "RGBa;16N", 64, unpackRGBa16B},
{"RGBA", "RGBA;16N", 64, unpackRGBA16B},
{"RGBX", "RGBX;16N", 64, unpackRGBA16B},
#else
{"RGB", "RGB;16N", 64, unpackRGB16L},
{"RGBA", "RGBa;16N", 64, unpackRGBa16L},
{"RGBA", "RGBA;16N", 64, unpackRGBA16L},
{"RGBX", "RGBX;16N", 64, unpackRGBA16B},
#endif
/* true colour w. alpha premultiplied */ /* true colour w. alpha premultiplied */
{"RGBa", "RGBa", 32, copy4}, {"RGBa", "RGBa", 32, copy4},
{"RGBa", "BGRa", 32, unpackBGRA}, {"RGBa", "BGRa", 32, unpackBGRA},