def test_GetPixel(): img = Image(5, 5) img.draw_pixel((0, 0), 'white') img.draw_pixel((1, 1), 'red') img.draw_pixel((2, 2), 'green') img.draw_pixel((3, 3), 'blue') assert img.get_pixel_color((0, 0)) == 'white' assert img.get_pixel_color((1, 1)) == 'red' assert img.get_pixel_color((2, 2)) == 'green' assert img.get_pixel_color((3, 3)) == 'blue'
def test_array_set(): arr = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]], dtype=np.uint8, order='f') img = Image(arr.shape[0], arr.shape[1], preset_colors='web') img.set_data(arr) img.save(outfile('test_image_array1.bmp')) print img.get_color_names() for i in range(4): for j in range(3): print img.get_pixel_color((i, j)), print img.get_pixel_value((i, j)) for y in range(img.height): for x in range(img.width): assert arr[x, y] == img.get_pixel_value((x, y))