def test_fix15_to_uint8_opaque(self): """Fully opaque tile stays fully opaque""" src = np.zeros((N, N, 4), 'uint16') src[:, :, 3] = 1 << 15 src[:, :, :3] = np.random.randint(0, 1 << 15, (N, N, 3)) dst = np.zeros((N, N, 4), 'uint8') mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) self.assertTrue((dst[:, :, 3] == 255).all(), msg="Not fully opaque")
def tileConversions(): # fully transparent tile stays fully transparent (without noise) N = mypaintlib.TILE_SIZE src = np.zeros((N, N, 4), 'uint16') dst = np.ones((N, N, 4), 'uint8') mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) assert not dst.any() # fully opaque tile stays fully opaque src[:, :, 3] = 1 << 15 src[:, :, :3] = np.randint(0, 1 << 15, (N, N, 3)) dst = np.zeros((N, N, 4), 'uint8') mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) assert (dst[:, :, 3] == 255).all()
def tileConversions(): # fully transparent tile stays fully transparent (without noise) N = mypaintlib.TILE_SIZE src = zeros((N, N, 4), 'uint16') dst = ones((N, N, 4), 'uint8') mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) assert not dst.any() # fully opaque tile stays fully opaque src[:,:,3] = 1<<15 src[:,:,:3] = randint(0, 1<<15, (N, N, 3)) dst = zeros((N, N, 4), 'uint8') mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) assert (dst[:,:,3] == 255).all()
def test_fix15_to_int8_transparent(self): """Fully transparent tile stays fully transparent, without noise""" src = np.zeros((N, N, 4), 'uint16') dst = np.ones((N, N, 4), 'uint8') mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) self.assertFalse(dst.any(), msg="Not fully transparent")