mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Revert little-endian byte order for "I" and "F" rawmodes
This commit is contained in:
parent
922407e7f3
commit
aac0869ca7
|
@ -146,31 +146,34 @@ class TestLibPack(PillowTestCase):
|
|||
self.assert_pack("HSV", "V", 1, (9,9,1), (9,9,2), (9,9,3))
|
||||
|
||||
def test_I(self):
|
||||
self.assert_pack("I", "I", 4, 0x04030201, 0x08070605)
|
||||
self.assert_pack("I", "I;16B", 2, 0x0102, 0x0304)
|
||||
self.assert_pack("I", "I;32S",
|
||||
b'\x83\x00\x00\x01\x01\x00\x00\x83',
|
||||
0x01000083, -2097151999)
|
||||
|
||||
if sys.byteorder == 'little':
|
||||
self.assert_pack("I", "I", 4, 0x04030201, 0x08070605)
|
||||
self.assert_pack("I", "I;32NS",
|
||||
b'\x83\x00\x00\x01\x01\x00\x00\x83',
|
||||
0x01000083, -2097151999)
|
||||
else:
|
||||
self.assert_pack("I", "I", 4, 0x01020304, 0x05060708)
|
||||
self.assert_pack("I", "I;32NS",
|
||||
b'\x83\x00\x00\x01\x01\x00\x00\x83',
|
||||
-2097151999, 0x01000083)
|
||||
|
||||
def test_F_float(self):
|
||||
self.assert_pack("F", "F", 4,
|
||||
1.539989614439558e-36, 4.063216068939723e-34)
|
||||
self.assert_pack("F", "F;32F", 4,
|
||||
1.539989614439558e-36, 4.063216068939723e-34)
|
||||
|
||||
if sys.byteorder == 'little':
|
||||
self.assert_pack("F", "F", 4,
|
||||
1.539989614439558e-36, 4.063216068939723e-34)
|
||||
self.assert_pack("F", "F;32NF", 4,
|
||||
1.539989614439558e-36, 4.063216068939723e-34)
|
||||
else:
|
||||
self.assert_pack("F", "F", 4,
|
||||
2.387939260590663e-38, 6.301941157072183e-36)
|
||||
self.assert_pack("F", "F;32NF", 4,
|
||||
2.387939260590663e-38, 6.301941157072183e-36)
|
||||
|
||||
|
|
|
@ -87,10 +87,12 @@ class TestModeI16(PillowTestCase):
|
|||
def tobytes(mode):
|
||||
return Image.new(mode, (1, 1), 1).tobytes()
|
||||
|
||||
order = 1 if Image._ENDIAN == '<' else -1
|
||||
|
||||
self.assertEqual(tobytes("L"), b"\x01")
|
||||
self.assertEqual(tobytes("I;16"), b"\x01\x00")
|
||||
self.assertEqual(tobytes("I;16B"), b"\x00\x01")
|
||||
self.assertEqual(tobytes("I"), b"\x01\x00\x00\x00")
|
||||
self.assertEqual(tobytes("I"), b"\x01\x00\x00\x00"[::order])
|
||||
|
||||
def test_convert(self):
|
||||
|
||||
|
|
|
@ -599,13 +599,13 @@ static struct {
|
|||
{"HSV", "V", 8, band2},
|
||||
|
||||
/* integer */
|
||||
{"I", "I", 32, packI32S},
|
||||
{"I", "I", 32, copy4},
|
||||
{"I", "I;16B", 16, packI16B},
|
||||
{"I", "I;32S", 32, packI32S},
|
||||
{"I", "I;32NS", 32, copy4},
|
||||
|
||||
/* floating point */
|
||||
{"F", "F", 32, packI32S},
|
||||
{"F", "F", 32, copy4},
|
||||
{"F", "F;32F", 32, packI32S},
|
||||
{"F", "F;32NF", 32, copy4},
|
||||
|
||||
|
|
|
@ -1176,6 +1176,8 @@ static struct {
|
|||
endian byte order (default is little endian); "L" line
|
||||
interleave, "S" signed, "F" floating point */
|
||||
|
||||
/* exception: rawmodes "I" and "F" are always native endian byte order */
|
||||
|
||||
/* bilevel */
|
||||
{"1", "1", 1, unpack1},
|
||||
{"1", "1;I", 1, unpack1I},
|
||||
|
@ -1318,7 +1320,7 @@ static struct {
|
|||
{"HSV", "V", 8, band2},
|
||||
|
||||
/* integer variations */
|
||||
{"I", "I", 32, unpackI32},
|
||||
{"I", "I", 32, copy4},
|
||||
{"I", "I;8", 8, unpackI8},
|
||||
{"I", "I;8S", 8, unpackI8S},
|
||||
{"I", "I;16", 16, unpackI16},
|
||||
|
@ -1335,7 +1337,7 @@ static struct {
|
|||
{"I", "I;32NS", 32, unpackI32NS},
|
||||
|
||||
/* floating point variations */
|
||||
{"F", "F", 32, unpackI32},
|
||||
{"F", "F", 32, copy4},
|
||||
{"F", "F;8", 8, unpackF8},
|
||||
{"F", "F;8S", 8, unpackF8S},
|
||||
{"F", "F;16", 16, unpackF16},
|
||||
|
|
Loading…
Reference in New Issue
Block a user