diff --git a/scikits/image/io/_plugins/freeimage_plugin.py b/scikits/image/io/_plugins/freeimage_plugin.py index 4e71312b..495c75e3 100644 --- a/scikits/image/io/_plugins/freeimage_plugin.py +++ b/scikits/image/io/_plugins/freeimage_plugin.py @@ -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()