Merge pull request #1871 from wiredfool/pr_1865

Rebased #1865 + 1 test
This commit is contained in:
wiredfool 2016-05-01 10:14:08 +01:00
commit 9f9436ca2f
3 changed files with 6 additions and 0 deletions

View File

@ -245,6 +245,7 @@ _MODE_CONV = {
# official modes
"1": ('|b1', None), # broken
"L": ('|u1', None),
"LA": ('|u1', 2),
"I": (_ENDIAN + 'i4', None),
"F": (_ENDIAN + 'f4', None),
"P": ('|u1', None),
@ -2215,6 +2216,7 @@ _fromarray_typemap = {
((1, 1), ">f4"): ("F", "F;32BF"),
((1, 1), "<f8"): ("F", "F;64F"),
((1, 1), ">f8"): ("F", "F;64BF"),
((1, 1, 2), "|u1"): ("LA", "LA"),
((1, 1, 3), "|u1"): ("RGB", "RGB"),
((1, 1, 4), "|u1"): ("RGBA", "RGBA"),
}

View File

@ -19,6 +19,7 @@ class TestImageArray(PillowTestCase):
# FIXME: wrong?
self.assertEqual(test("F"), (3, (100, 128), Image._ENDIAN + 'f4', 51200))
self.assertEqual(test("LA"), (3, (100, 128, 2), '|u1', 25600))
self.assertEqual(test("RGB"), (3, (100, 128, 3), '|u1', 38400))
self.assertEqual(test("RGBA"), (3, (100, 128, 4), '|u1', 51200))
self.assertEqual(test("RGBX"), (3, (100, 128, 4), '|u1', 51200))
@ -35,6 +36,7 @@ class TestImageArray(PillowTestCase):
self.assertEqual(test("L"), ("L", (128, 100), True))
self.assertEqual(test("I"), ("I", (128, 100), True))
self.assertEqual(test("F"), ("F", (128, 100), True))
self.assertEqual(test("LA"), ("LA", (128, 100), True))
self.assertEqual(test("RGB"), ("RGB", (128, 100), True))
self.assertEqual(test("RGBA"), ("RGBA", (128, 100), True))
self.assertEqual(test("RGBX"), ("RGBA", (128, 100), True))

View File

@ -64,6 +64,7 @@ class TestNumpy(PillowTestCase):
self.assert_image(to_image(numpy.float32), "F", (10, 10))
self.assert_image(to_image(numpy.float64), "F", (10, 10))
self.assert_image(to_image(numpy.uint8, 2), "LA", (10, 10))
self.assert_image(to_image(numpy.uint8, 3), "RGB", (10, 10))
self.assert_image(to_image(numpy.uint8, 4), "RGBA", (10, 10))
@ -105,6 +106,7 @@ class TestNumpy(PillowTestCase):
modes = [("L", 'uint8'),
("I", 'int32'),
("F", 'float32'),
("LA", 'uint8'),
("RGB", 'uint8'),
("RGBA", 'uint8'),
("RGBX", 'uint8'),