Added unpacker from I;16B to I;16

This commit is contained in:
Andrew Murray 2023-04-30 14:49:40 +10:00
parent b62c3baeee
commit ff003bfbcc
2 changed files with 12 additions and 0 deletions

View File

@ -757,6 +757,7 @@ class TestLibUnpack:
def test_I16(self): def test_I16(self):
self.assert_unpack("I;16", "I;16", 2, 0x0201, 0x0403, 0x0605) self.assert_unpack("I;16", "I;16", 2, 0x0201, 0x0403, 0x0605)
self.assert_unpack("I;16", "I;16B", 2, 0x0102, 0x0304, 0x0506)
self.assert_unpack("I;16B", "I;16B", 2, 0x0102, 0x0304, 0x0506) self.assert_unpack("I;16B", "I;16B", 2, 0x0102, 0x0304, 0x0506)
self.assert_unpack("I;16L", "I;16L", 2, 0x0201, 0x0403, 0x0605) self.assert_unpack("I;16L", "I;16L", 2, 0x0201, 0x0403, 0x0605)
self.assert_unpack("I;16", "I;12", 2, 0x0010, 0x0203, 0x0040) self.assert_unpack("I;16", "I;12", 2, 0x0010, 0x0203, 0x0040)

View File

@ -1149,6 +1149,16 @@ unpackI16N_I16(UINT8 *out, const UINT8 *in, int pixels) {
} }
} }
static void static void
unpackI16B_I16(UINT8 *out, const UINT8 *in, int pixels) {
int i;
for (i = 0; i < pixels; i++) {
out[0] = in[1];
out[1] = in[0];
in += 2;
out += 2;
}
}
static void
unpackI16R_I16(UINT8 *out, const UINT8 *in, int pixels) { unpackI16R_I16(UINT8 *out, const UINT8 *in, int pixels) {
int i; int i;
for (i = 0; i < pixels; i++) { for (i = 0; i < pixels; i++) {
@ -1764,6 +1774,7 @@ static struct {
{"I;16L", "I;16L", 16, copy2}, {"I;16L", "I;16L", 16, copy2},
{"I;16N", "I;16N", 16, copy2}, {"I;16N", "I;16N", 16, copy2},
{"I;16", "I;16B", 16, unpackI16B_I16},
{"I;16", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian. {"I;16", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian.
{"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},