mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 04:19:36 +08:00
BUG: Correctly handle images with an alpha channel
Bug caught by Zachary Pincus on scipy-user.
This commit is contained in:
@@ -320,10 +320,17 @@ def _array_from_bitmap(bitmap):
|
||||
return arr[..., ::-1].T
|
||||
if len(shape) == 3 and _FI.FreeImage_IsLittleEndian() and \
|
||||
dtype.type == numpy.uint8:
|
||||
b = array[0]
|
||||
g = array[1]
|
||||
r = array[2]
|
||||
return numpy.dstack( (n(r), n(g), n(b)) )
|
||||
b = n(array[0])
|
||||
g = n(array[1])
|
||||
r = n(array[2])
|
||||
if shape[0] == 3:
|
||||
return numpy.dstack( (r, g, b) )
|
||||
elif shape[0] == 4:
|
||||
a = n(array[3])
|
||||
return numpy.dstack( (r, g, b, a) )
|
||||
else:
|
||||
raise ValueError('Cannot handle images of shape %s' % shape)
|
||||
|
||||
# We need to copy because array does *not* own its memory
|
||||
# after bitmap is freed.
|
||||
return n(array).copy()
|
||||
|
||||
Reference in New Issue
Block a user