Merge pull request #3 from juliantaylor/port-fix

fix debian ports
This commit is contained in:
Yaroslav Halchenko
2014-09-06 09:16:17 -04:00
4 changed files with 88 additions and 0 deletions
+7
View File
@@ -1,3 +1,10 @@
skimage (0.10.1-2) unstable; urgency=medium
* build with -fsigned-char to fix test failures on unsigned ports
* freeimage-fix.patch: fix freeimage save/load on big endian ports
-- Julian Taylor <jtaylor.debian@googlemail.com> Sat, 06 Sep 2014 00:08:12 +0200
skimage (0.10.1-1) unstable; urgency=medium
* New upstream release
+77
View File
@@ -0,0 +1,77 @@
Author: Stefan van der Walt <stefan@sun.ac.za>
Description: freeimage: Correctly handle saving uint16 images and fix big endian
Origin: 2b1dde20 051c54c577b3 84f3835106aaeb
Applied-Upstream: 0.11
--- a/skimage/io/_plugins/freeimage_plugin.py
+++ b/skimage/io/_plugins/freeimage_plugin.py
@@ -493,7 +493,6 @@ def _array_from_bitmap(bitmap):
# swizzle the color components and flip the scanlines to go from
# FreeImage's BGR[A] and upside-down internal memory format to something
# more normal
-
def n(arr):
return arr[..., ::-1].T
if len(shape) == 3 and _FI.FreeImage_IsLittleEndian() and \
@@ -637,17 +636,28 @@ def _array_to_bitmap(array):
raise RuntimeError('Could not allocate image for storage')
try:
def n(arr): # normalise to freeimage's in-memory format
- return arr.T[:, ::-1]
+ return arr.T[..., ::-1]
+
wrapped_array = _wrap_bitmap_bits_in_array(bitmap, w_shape, dtype)
# swizzle the color components and flip the scanlines to go to
# FreeImage's BGR[A] and upside-down internal memory format
- if len(shape) == 3 and _FI.FreeImage_IsLittleEndian() and \
- dtype.type == numpy.uint8:
- wrapped_array[0] = n(array[:, :, 2])
- wrapped_array[1] = n(array[:, :, 1])
- wrapped_array[2] = n(array[:, :, 0])
+ if len(shape) == 3 and _FI.FreeImage_IsLittleEndian():
+ R = array[:, :, 0]
+ G = array[:, :, 1]
+ B = array[:, :, 2]
+
+ if dtype.type == numpy.uint8:
+ wrapped_array[0] = n(B)
+ wrapped_array[1] = n(G)
+ wrapped_array[2] = n(R)
+ elif dtype.type == numpy.uint16:
+ wrapped_array[0] = n(R)
+ wrapped_array[1] = n(G)
+ wrapped_array[2] = n(B)
+
if shape[2] == 4:
- wrapped_array[3] = n(array[:, :, 3])
+ A = array[:, :, 3]
+ wrapped_array[3] = n(A)
else:
wrapped_array[:] = n(array)
if len(shape) == 2 and dtype.type == numpy.uint8:
diff --git a/skimage/io/tests/test_freeimage.py b/skimage/io/tests/test_freeimage.py
index 32e01bd..308f1ee 100644
--- a/skimage/io/tests/test_freeimage.py
+++ b/skimage/io/tests/test_freeimage.py
@@ -74,15 +74,15 @@ class TestSave:
f.close()
sio.imsave(fname, x)
y = sio.imread(fname)
- assert_array_equal(x, y)
+ assert_array_equal(y, x)
@skipif(not FI_available)
def test_imsave_roundtrip(self):
for shape, dtype, format in [
[(10, 10), (np.uint8, np.uint16), ('tif', 'png')],
[(10, 10), (np.float32,), ('tif',)],
- [(10, 10, 3), (np.uint8,), ('png',)],
- [(10, 10, 4), (np.uint8,), ('png',)]
+ [(10, 10, 3), (np.uint8, np.uint16), ('png',)],
+ [(10, 10, 4), (np.uint8, np.uint16), ('png',)]
]:
tests = [(d, f) for d in dtype for f in format]
for d, f in tests:
--
1.9.1
+1
View File
@@ -2,3 +2,4 @@ search-html.patch
fix-doc-links.patch
doc-privacy.patch
slicing-error.patch
freeimage-fix.patch
+3
View File
@@ -11,6 +11,9 @@ PYVERS = $(shell pyversions -vr)
PYVER = $(shell pyversions -vd)
PY3VERS = $(shell py3versions -vr)
# upstream relies on signed chars
export DEB_CFLAGS_MAINT_APPEND := -fsigned-char
export MPLCONFIGDIR=$(CURDIR)/build
export HOME=$(CURDIR)/build