more tests and fixed bug for interpolate4

This commit is contained in:
Alexander 2018-03-26 23:17:17 +03:00
parent 5227c30561
commit 838a5cffe7
2 changed files with 22 additions and 1 deletions

View File

@ -146,6 +146,27 @@ class TestColorLut3DCoreAPI(PillowTestCase):
im.im.color_lut_3d('RGB', Image.LINEAR,
*self.generate_unit_table(3, (2, 2, 65)))))
def test_units_4channels(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180)])
# Red channel copied to alpha
self.assert_image_equal(
Image.merge('RGBA', (im.split()*2)[:4]),
im._new(im.im.color_lut_3d('RGBA', Image.LINEAR,
*self.generate_unit_table(4, 17))))
def test_copy_alpha_channel(self):
g = Image.linear_gradient('L')
im = Image.merge('RGBA', [g, g.transpose(Image.ROTATE_90),
g.transpose(Image.ROTATE_180),
g.transpose(Image.ROTATE_270)])
self.assert_image_equal(im, im._new(
im.im.color_lut_3d('RGBA', Image.LINEAR,
*self.generate_unit_table(3, 17))))
def test_channels_order(self):
g = Image.linear_gradient('L')
im = Image.merge('RGB', [g, g.transpose(Image.ROTATE_90),

View File

@ -111,7 +111,7 @@ ImagingColorLUT3D_linear(Imaging imOut, Imaging imIn, int table_channels,
INT16 shift1D = (SCALE_MASK & index1D) >> (SCALE_BITS - SHIFT_BITS);
INT16 shift2D = (SCALE_MASK & index2D) >> (SCALE_BITS - SHIFT_BITS);
INT16 shift3D = (SCALE_MASK & index3D) >> (SCALE_BITS - SHIFT_BITS);
int idx = 3 * table_index3D(
int idx = table_channels * table_index3D(
index1D >> SCALE_BITS, index2D >> SCALE_BITS,
index3D >> SCALE_BITS, size1D, size1D_2D);
INT16 result[4], left[4], right[4];