Force novice.Picture.from_size to return a uint8 image

Force Picure.from_size to return a uint8 image

Remove img_as_ubyte
This commit is contained in:
Steven Silvester
2015-01-30 19:42:55 -06:00
parent 1992c35a25
commit 2c635989d2
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -282,6 +282,7 @@ class Picture(object):
color = color_dict[color]
rgb_size = tuple(size) + (len(color),)
array = np.ones(rgb_size, dtype=np.uint8) * color
array = array.astype(np.uint8)
# Force RGBA internally (use max alpha)
if array.shape[-1] == 3:
+2
View File
@@ -86,6 +86,8 @@ def test_pixel_rgb():
pixel.rgb = np.arange(4)
assert_equal(pixel.rgb, np.arange(3))
assert pic.array.dtype == np.uint8
def test_pixel_rgba():
pic = novice.Picture.from_size((3, 3), color=(10, 10, 10))