mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Support reading I;16R TIFF images
This commit is contained in:
parent
15dc291469
commit
ebdb47e693
BIN
Tests/images/16bit.r.tif
Normal file
BIN
Tests/images/16bit.r.tif
Normal file
Binary file not shown.
|
@ -225,6 +225,15 @@ class TestFileTiff:
|
||||||
assert b[0] == ord(b"\x01")
|
assert b[0] == ord(b"\x01")
|
||||||
assert b[1] == ord(b"\xe0")
|
assert b[1] == ord(b"\xe0")
|
||||||
|
|
||||||
|
def test_16bit_r(self):
|
||||||
|
with Image.open("Tests/images/16bit.r.tif") as im:
|
||||||
|
assert im.getpixel((0, 0)) == 480
|
||||||
|
assert im.mode == "I;16"
|
||||||
|
|
||||||
|
b = im.tobytes()
|
||||||
|
assert b[0] == ord(b"\xe0")
|
||||||
|
assert b[1] == ord(b"\x01")
|
||||||
|
|
||||||
def test_16bit_s(self):
|
def test_16bit_s(self):
|
||||||
with Image.open("Tests/images/16bit.s.tif") as im:
|
with Image.open("Tests/images/16bit.s.tif") as im:
|
||||||
im.load()
|
im.load()
|
||||||
|
|
|
@ -175,6 +175,7 @@ OPEN_INFO = {
|
||||||
(II, 1, (1,), 1, (12,), ()): ("I;16", "I;12"),
|
(II, 1, (1,), 1, (12,), ()): ("I;16", "I;12"),
|
||||||
(II, 1, (1,), 1, (16,), ()): ("I;16", "I;16"),
|
(II, 1, (1,), 1, (16,), ()): ("I;16", "I;16"),
|
||||||
(MM, 1, (1,), 1, (16,), ()): ("I;16B", "I;16B"),
|
(MM, 1, (1,), 1, (16,), ()): ("I;16B", "I;16B"),
|
||||||
|
(II, 1, (1,), 2, (16,), ()): ("I;16", "I;16R"),
|
||||||
(II, 1, (2,), 1, (16,), ()): ("I", "I;16S"),
|
(II, 1, (2,), 1, (16,), ()): ("I", "I;16S"),
|
||||||
(MM, 1, (2,), 1, (16,), ()): ("I", "I;16BS"),
|
(MM, 1, (2,), 1, (16,), ()): ("I", "I;16BS"),
|
||||||
(II, 0, (3,), 1, (32,), ()): ("F", "F;32F"),
|
(II, 0, (3,), 1, (32,), ()): ("F", "F;32F"),
|
||||||
|
|
|
@ -1124,6 +1124,16 @@ unpackI16N_I16(UINT8 *out, const UINT8 *in, int pixels) {
|
||||||
tmp += 2;
|
tmp += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void
|
||||||
|
unpackI16R_I16(UINT8 *out, const UINT8 *in, int pixels) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < pixels; i++) {
|
||||||
|
out[0] = BITFLIP[in[0]];
|
||||||
|
out[1] = BITFLIP[in[1]];
|
||||||
|
in += 2;
|
||||||
|
out += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unpackI12_I16(UINT8 *out, const UINT8 *in, int pixels) {
|
unpackI12_I16(UINT8 *out, const UINT8 *in, int pixels) {
|
||||||
|
@ -1731,6 +1741,8 @@ static struct {
|
||||||
{"I;16L", "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},
|
{"I;16B", "I;16N", 16, unpackI16N_I16B},
|
||||||
|
|
||||||
|
{"I;16", "I;16R", 16, unpackI16R_I16},
|
||||||
|
|
||||||
{"I;16", "I;12", 12, unpackI12_I16}, // 12 bit Tiffs stored in 16bits.
|
{"I;16", "I;12", 12, unpackI12_I16}, // 12 bit Tiffs stored in 16bits.
|
||||||
|
|
||||||
{NULL} /* sentinel */
|
{NULL} /* sentinel */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user