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

TEST: Test different numbers of channels

parent 1a811c11
No related branches found
No related tags found
No related merge requests found
...@@ -19,22 +19,27 @@ def test_bitmap(): ...@@ -19,22 +19,27 @@ def test_bitmap():
from PIL import Image from PIL import Image
nchannels = (1, 3, 4)
with tempdir.tempdir(): with tempdir.tempdir():
data = np.random.randint(0, 255, (100, 200, 4), dtype=np.uint8)
img = Image.fromarray(data, mode='RGBA')
img.save('image.png') for nch in nchannels:
data = np.random.randint(0, 255, (100, 200, nch), dtype=np.uint8)
img = Image.fromarray(data.squeeze())
fname = 'image.png'
img.save(fname)
bmp = fslbmp.Bitmap('image.png') bmp = fslbmp.Bitmap(fname)
assert bmp.name == 'image.png' assert bmp.name == fname
assert bmp.dataSource == 'image.png' assert bmp.dataSource == fname
assert bmp.shape == (200, 100, 4) assert bmp.shape == (200, 100, nch)
repr(bmp) repr(bmp)
hash(bmp) hash(bmp)
assert np.all(bmp.data == np.fliplr(data.transpose(1, 0, 2))) assert np.all(bmp.data == np.fliplr(data.transpose(1, 0, 2)))
@pytest.mark.piltest @pytest.mark.piltest
......
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