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 c53e85f877b020da5daf8b6fc80d99f64d0e47ad..52c8032b4ef329023357c1d83ada50a019506d86 100644 --- a/bob/io/image/test.py +++ b/bob/io/image/test.py @@ -16,26 +16,48 @@ import nose # 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):