Beispiel #1
0
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))
Beispiel #2
0
def test_set_pixel_value():
    """
    test if setting the pixel value directly works.
    """
    img = Image(4, 5)

    for i in range(4):
        for j in range(5):
            img.set_pixel_value((i, j), i)

    # check:
    for i in range(4):
        for j in range(5):
            assert img.get_pixel_value((i, j)) == i