diff --git a/bob/io/image/data/img_gray_alpha.png b/bob/io/image/data/img_gray_alpha.png new file mode 100644 index 0000000000000000000000000000000000000000..7643ce025d21ec8385a93836180167d3ce62167e Binary files /dev/null and b/bob/io/image/data/img_gray_alpha.png differ diff --git a/bob/io/image/data/img_indexed_color_alpha.png b/bob/io/image/data/img_indexed_color_alpha.png new file mode 100644 index 0000000000000000000000000000000000000000..defabb829d44bcd28b8939afbc64c1b3f9143342 Binary files /dev/null and b/bob/io/image/data/img_indexed_color_alpha.png differ diff --git a/bob/io/image/data/img_trns.png b/bob/io/image/data/img_trns.png new file mode 100644 index 0000000000000000000000000000000000000000..7c16aab16960149a4762610eb8c6827c0814600d Binary files /dev/null and b/bob/io/image/data/img_trns.png differ diff --git a/bob/io/image/test.py b/bob/io/image/test.py index 48fa152238deb082bd3c1a1373f4233736952a83..16cc98e04c9f64508afd3b5de3c26d8703ee15b9 100644 --- a/bob/io/image/test.py +++ b/bob/io/image/test.py @@ -14,26 +14,48 @@ from bob.io.base import load, write, test_utils # These are some global parameters for the test. PNG_INDEXED_COLOR = test_utils.datafile('img_indexed_color.png', __name__) +PNG_INDEXED_COLOR_ALPHA = test_utils.datafile('img_indexed_color_alpha.png', __name__) PNG_RGBA_COLOR = test_utils.datafile('img_rgba_color.png', __name__) +PNG_GRAY_ALPHA = test_utils.datafile('img_gray_alpha.png', __name__) +PNG_tRNS = test_utils.datafile('img_trns.png', __name__) def test_png_indexed_color(): - # Read an indexed color PNG image, and compared with hardcoded values img = load(PNG_INDEXED_COLOR) assert img.shape == (3, 22, 32) assert img[0, 0, 0] == 255 assert img[0, 17, 17] == 117 - def test_png_rgba_color(): - # Read an indexed color PNG image, and compared with hardcoded values img = load(PNG_RGBA_COLOR) assert img.shape == (3, 22, 32) assert img[0, 0, 0] == 255 assert img[0, 17, 17] == 117 +def test_png_indexed_color_alpha(): + # Read an indexed color+alpha PNG image, and compared with hardcoded values + img = load(PNG_INDEXED_COLOR_ALPHA) + assert img.shape == (3,22,32) + assert img[0,0,0] == 255 + assert img[0,17,17] == 117 + +def test_png_indexed_trns(): + # Read an tRNS PNG image (without alpha), and compared with hardcoded values + img = load(PNG_tRNS) + assert img.shape == (3,22,32) + assert img[0,0,0] == 255 + assert img[0,17,17] == 117 + +def test_png_gray_alpha(): + # Read a gray+alpha PNG image, and compared with hardcoded values + img = load(PNG_GRAY_ALPHA) + assert img.shape == (22,32) + assert img[0,0] == 255 + assert img[17,17] == 51 + + def transcode(filename):