Skip to content

Commit

Permalink
Merge pull request #4248 from uploadcare/La-packing
Browse files Browse the repository at this point in the history
Add La mode packing and unpacking
  • Loading branch information
radarhere committed Dec 5, 2019
2 parents d19b2c8 + a4a6a9e commit 5dc8abf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Tests/test_lib_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def test_LA(self):
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))

def test_La(self):
self.assert_pack("La", "La", 2, (1, 2), (3, 4), (5, 6))

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;2", b"\xe4", 3, 2, 1, 0)
Expand Down Expand Up @@ -269,6 +272,9 @@ def test_LA(self):
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))

def test_La(self):
self.assert_unpack("La", "La", 2, (1, 2), (3, 4), (5, 6))

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;2", b"\xe4", 3, 2, 1, 0)
Expand Down
3 changes: 3 additions & 0 deletions src/libImaging/Pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ static struct {
{"LA", "LA", 16, packLA},
{"LA", "LA;L", 16, packLAL},

/* greyscale w. alpha premultiplied */
{"La", "La", 16, packLA},

/* palette */
{"P", "P;1", 1, pack1},
{"P", "P;2", 2, packP2},
Expand Down
4 changes: 3 additions & 1 deletion src/libImaging/Unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,9 @@ static struct {
/* greyscale w. alpha */
{"LA", "LA", 16, unpackLA},
{"LA", "LA;L", 16, unpackLAL},

/* greyscale w. alpha premultiplied */
{"La", "La", 16, unpackLA},

/* palette */
{"P", "P;1", 1, unpackP1},
Expand Down Expand Up @@ -1384,7 +1387,6 @@ static struct {
{"RGBX", "RGBX;16N", 64, unpackRGBA16B},
#endif


/* true colour w. alpha premultiplied */
{"RGBa", "RGBa", 32, copy4},
{"RGBa", "BGRa", 32, unpackBGRA},
Expand Down

0 comments on commit 5dc8abf

Please sign in to comment.