Merge pull request #4248 from uploadcare/La-packing

Add La mode packing and unpacking
This commit is contained in:
Andrew Murray 2019-12-05 20:01:22 +11:00 committed by GitHub
commit 5dc8abfb16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -44,6 +44,9 @@ class TestLibPack(PillowTestCase):
self.assert_pack("LA", "LA", 2, (1, 2), (3, 4), (5, 6)) self.assert_pack("LA", "LA", 2, (1, 2), (3, 4), (5, 6))
self.assert_pack("LA", "LA;L", 2, (1, 4), (2, 5), (3, 6)) self.assert_pack("LA", "LA;L", 2, (1, 4), (2, 5), (3, 6))
def test_La(self):
self.assert_pack("La", "La", 2, (1, 2), (3, 4), (5, 6))
def test_P(self): def test_P(self):
self.assert_pack("P", "P;1", b"\xe4", 1, 1, 1, 0, 0, 255, 0, 0) self.assert_pack("P", "P;1", b"\xe4", 1, 1, 1, 0, 0, 255, 0, 0)
self.assert_pack("P", "P;2", b"\xe4", 3, 2, 1, 0) self.assert_pack("P", "P;2", b"\xe4", 3, 2, 1, 0)
@ -269,6 +272,9 @@ class TestLibUnpack(PillowTestCase):
self.assert_unpack("LA", "LA", 2, (1, 2), (3, 4), (5, 6)) self.assert_unpack("LA", "LA", 2, (1, 2), (3, 4), (5, 6))
self.assert_unpack("LA", "LA;L", 2, (1, 4), (2, 5), (3, 6)) self.assert_unpack("LA", "LA;L", 2, (1, 4), (2, 5), (3, 6))
def test_La(self):
self.assert_unpack("La", "La", 2, (1, 2), (3, 4), (5, 6))
def test_P(self): def test_P(self):
self.assert_unpack("P", "P;1", b"\xe4", 1, 1, 1, 0, 0, 1, 0, 0) self.assert_unpack("P", "P;1", b"\xe4", 1, 1, 1, 0, 0, 1, 0, 0)
self.assert_unpack("P", "P;2", b"\xe4", 3, 2, 1, 0) self.assert_unpack("P", "P;2", b"\xe4", 3, 2, 1, 0)

View File

@ -555,6 +555,9 @@ static struct {
{"LA", "LA", 16, packLA}, {"LA", "LA", 16, packLA},
{"LA", "LA;L", 16, packLAL}, {"LA", "LA;L", 16, packLAL},
/* greyscale w. alpha premultiplied */
{"La", "La", 16, packLA},
/* palette */ /* palette */
{"P", "P;1", 1, pack1}, {"P", "P;1", 1, pack1},
{"P", "P;2", 2, packP2}, {"P", "P;2", 2, packP2},

View File

@ -1307,6 +1307,9 @@ static struct {
{"LA", "LA", 16, unpackLA}, {"LA", "LA", 16, unpackLA},
{"LA", "LA;L", 16, unpackLAL}, {"LA", "LA;L", 16, unpackLAL},
/* greyscale w. alpha premultiplied */
{"La", "La", 16, unpackLA},
/* palette */ /* palette */
{"P", "P;1", 1, unpackP1}, {"P", "P;1", 1, unpackP1},
{"P", "P;2", 2, unpackP2}, {"P", "P;2", 2, unpackP2},
@ -1384,7 +1387,6 @@ static struct {
{"RGBX", "RGBX;16N", 64, unpackRGBA16B}, {"RGBX", "RGBX;16N", 64, unpackRGBA16B},
#endif #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},