Merge branch 'master' into 16-bit-rgb-tiff

This commit is contained in:
Alexander 2017-08-21 22:43:30 +03:00
commit 21d1c4cef5
6 changed files with 49 additions and 5 deletions

View File

@ -4,6 +4,12 @@ Changelog (Pillow)
4.3.0 (unreleased)
------------------
- Basic support for Termux (android) in setup.py #2684
[wiredfool]
- Bug: Fix Image.fromarray for numpy.bool type. #2683
[wiredfool]
- CI: Add Fedora 24 and 26 to Docker tests
[wiredfool]
@ -31,6 +37,9 @@ Changelog (Pillow)
- Remove unused im.copy2 and core.copy methods #2657
[homm]
- Fast Image.merge() #2677
[homm]
- Fast Image.split() #2676
[homm]

View File

@ -2423,7 +2423,7 @@ def fromqpixmap(im):
_fromarray_typemap = {
# (shape, typestr) => mode, rawmode
# first two members of shape are set to one
# ((1, 1), "|b1"): ("1", "1"), # broken
((1, 1), "|b1"): ("1", "1;8"),
((1, 1), "|u1"): ("L", "L"),
((1, 1), "|i1"): ("I", "I;8"),
((1, 1), "<u2"): ("I", "I;16"),

View File

@ -39,7 +39,7 @@ class TestNumpy(PillowTestCase):
def to_image(dtype, bands=1, boolean=0):
if bands == 1:
if boolean:
data = [0, 1] * 50
data = [0, 255] * 50
else:
data = list(range(100))
a = numpy.array(data, dtype=dtype)
@ -58,9 +58,9 @@ class TestNumpy(PillowTestCase):
return i
# Check supported 1-bit integer formats
self.assertRaises(TypeError, lambda: to_image(numpy.bool))
self.assertRaises(TypeError, lambda: to_image(numpy.bool8))
self.assert_image(to_image(numpy.bool, 1, 1), '1', TEST_IMAGE_SIZE)
self.assert_image(to_image(numpy.bool8, 1, 1), '1', TEST_IMAGE_SIZE)
# Check supported 8-bit integer formats
self.assert_image(to_image(numpy.uint8), "L", TEST_IMAGE_SIZE)
self.assert_image(to_image(numpy.uint8, 3), "RGB", TEST_IMAGE_SIZE)
@ -213,5 +213,13 @@ class TestNumpy(PillowTestCase):
self.assertEqual(im.size, (0, 0))
def test_bool(self):
# https://github.com/python-pillow/Pillow/issues/2044
a = numpy.zeros((10,2), dtype=numpy.bool)
a[0][0] = True
im2 = Image.fromarray(a)
self.assertEqual(im2.getdata()[0], 255)
if __name__ == '__main__':
unittest.main()

5
depends/termux.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
pkg -y install python python-dev ndk-sysroot clang make \
libjpeg-turbo-dev

View File

@ -185,6 +185,19 @@ unpack1IR(UINT8* out, const UINT8* in, int pixels)
}
}
static void
unpack18(UINT8* out, const UINT8* in, int pixels)
{
/* Unpack a '|b1' image, which is a numpy boolean.
1 == true, 0==false, in bytes */
int i;
for (i = 0; i < pixels; i++) {
out[i] = in[i] > 0 ? 255 : 0;
}
}
/* Unpack to "L" image */
@ -1244,6 +1257,7 @@ static struct {
{"1", "1;I", 1, unpack1I},
{"1", "1;R", 1, unpack1R},
{"1", "1;IR", 1, unpack1IR},
{"1", "1;8", 1, unpack18},
/* greyscale */
{"L", "L;2", 2, unpackL2},

View File

@ -365,6 +365,14 @@ class pil_build_ext(build_ext):
# work ;-)
self.add_multiarch_paths()
# termux support for android.
# system libraries (zlib) are installed in /system/lib
# headers are at $PREFIX/include
# user libs are at $PREFIX/lib
if os.environ.get('ANDROID_ROOT', None):
_add_directory(library_dirs,
os.path.join(os.environ['ANDROID_ROOT'],'lib'))
elif sys.platform.startswith("gnu"):
self.add_multiarch_paths()