Skip to content
Snippets Groups Projects
Commit f0a7333b authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

BF: Support palette images

parent cd79e13e
No related branches found
No related tags found
No related merge requests found
......@@ -61,12 +61,20 @@ class Bitmap(object):
except ImportError:
raise RuntimeError('Install Pillow to use the Bitmap class')
source = bmp
data = np.array(Image.open(source))
src = bmp
img = Image.open(src)
# If this is a palette/LUT
# image, convert it into a
# regular rgb(a) image.
if img.mode == 'P':
img = img.convert()
data = np.array(img)
elif isinstance(bmp, np.ndarray):
source = 'array'
data = np.copy(bmp)
src = 'array'
data = np.copy(bmp)
else:
raise ValueError('unknown bitmap: {}'.format(bmp))
......@@ -83,8 +91,8 @@ class Bitmap(object):
w, h = data.shape[:2]
self.__data = data
self.__dataSource = source
self.__name = op.basename(source)
self.__dataSource = src
self.__name = op.basename(src)
def __hash__(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment