def test_extract_planes_1_2by2_all_1(self): """an image that has 2x2 pixels all set to color 1""" im = MockImage((2, 2), [1, 1, 1, 1]) planes, map_words_per_row = png_util.extract_planes(im, 1, False) self.assertEquals(1, map_words_per_row) row = 0b11 << (16 - 2) self.assertEquals([[row, row]], planes)
def test_extract_planes_1_2by32_all_1(self): """an image that has 16x2 pixels with each rows 16 pixels color 1 and 16 pixels color 0""" im = MockImage((32, 2), ([1] * 16) + ([0] * 16) + ([1] * 16) + ([0] * 16)) planes, map_words_per_row = png_util.extract_planes(im, 1, False) self.assertEquals(2, map_words_per_row) self.assertEquals([[65535, 0, 65535, 0]], planes)
def test_extract_planes_1_2by16_all_1(self): """an image that has 16x2 pixels all set to color 1""" im = MockImage((16, 2), [1] * 32) planes, map_words_per_row = png_util.extract_planes(im, 1, False) self.assertEquals(1, map_words_per_row) self.assertEquals([[65535, 65535]], planes)
def test_extract_planes_1_2by2_all_0(self): """an image that has 2x2 pixels all set to 0""" im = MockImage((2, 2), [0, 0, 0, 0]) planes, map_words_per_row = png_util.extract_planes(im, 1, False) self.assertEquals(1, map_words_per_row) self.assertEquals([[0, 0]], planes)
def test_extract_planes_0(self): """attempting to extract from an image with depth 0""" im = MockImage((2, 2), [1, 0, 0, 1]) planes, map_words_per_row = png_util.extract_planes(im, 0, False) self.assertEquals([], planes) self.assertEquals(1, map_words_per_row)