diff --git a/Tests/test_imagechops.py b/Tests/test_imagechops.py index 400ec54fb4e..09e83ed7ee7 100644 --- a/Tests/test_imagechops.py +++ b/Tests/test_imagechops.py @@ -40,8 +40,8 @@ def test_sanity(self): ImageChops.blend(im, im, 0.5) ImageChops.composite(im, im, im) - ImageChops.softlight(im, im) - ImageChops.hardlight(im, im) + ImageChops.soft_light(im, im) + ImageChops.hard_light(im, im) ImageChops.overlay(im, im) ImageChops.offset(im, 10) @@ -345,25 +345,25 @@ def test_subtract_modulo_no_clip(self): # Assert self.assertEqual(new.getpixel((50, 50)), (241, 167, 127)) - def test_softlight(self): + def test_soft_light(self): # Arrange im1 = Image.open("Tests/images/hopper.png") im2 = Image.open("Tests/images/hopper-XYZ.png") # Act - new = ImageChops.softlight(im1, im2) + new = ImageChops.soft_light(im1, im2) # Assert self.assertEqual(new.getpixel((64, 64)), (163, 54, 32)) self.assertEqual(new.getpixel((15, 100)), (1, 1, 3)) - def test_hardlight(self): + def test_hard_light(self): # Arrange im1 = Image.open("Tests/images/hopper.png") im2 = Image.open("Tests/images/hopper-XYZ.png") # Act - new = ImageChops.hardlight(im1, im2) + new = ImageChops.hard_light(im1, im2) # Assert self.assertEqual(new.getpixel((64, 64)), (144, 50, 27)) diff --git a/src/PIL/ImageChops.py b/src/PIL/ImageChops.py index 1dc456156c8..fa6fbbcbb90 100644 --- a/src/PIL/ImageChops.py +++ b/src/PIL/ImageChops.py @@ -139,7 +139,7 @@ def screen(image1, image2): return image1._new(image1.im.chop_screen(image2.im)) -def softlight(image1, image2): +def soft_light(image1, image2): """ Superimposes two images on top of each other using the Soft Light algorithm @@ -151,7 +151,7 @@ def softlight(image1, image2): return image1._new(image1.im.chop_softlight(image2.im)) -def hardlight(image1, image2): +def hard_light(image1, image2): """ Superimposes two images on top of each other using the Hard Light algorithm diff --git a/src/libImaging/Chops.c b/src/libImaging/Chops.c index cbd65b19649..a1673dff6c5 100644 --- a/src/libImaging/Chops.c +++ b/src/libImaging/Chops.c @@ -148,27 +148,25 @@ ImagingChopSubtractModulo(Imaging imIn1, Imaging imIn2) } Imaging -ImagingChopSoftLight(Imaging imIn1, Imaging imIn2) +ImagingChopSoftLight(Imaging imIn1, Imaging imIn2) { - // CHOP2( ( ( (255-in1[x]) * (in1[x]*in2[x]) ) / 65536) + - // ((in1[x] * (255 - ((255 - in1[1]) * (255 - in2[x]) / 255 ) )) / 255), NULL ); - CHOP2( (((255-in1[x]) * (in1[x]*in2[x]) ) / 65536) + + CHOP2( (((255-in1[x]) * (in1[x]*in2[x]) ) / 65536) + (in1[x] * ( 255 - ( (255 - in1[x]) * (255 - in2[x] ) / 255) )) / 255 , NULL ); } Imaging -ImagingChopHardLight(Imaging imIn1, Imaging imIn2) +ImagingChopHardLight(Imaging imIn1, Imaging imIn2) { - CHOP2( (in2[x]<128) ? ( (in1[x]*in2[x])/127) - : 255 - ( ((255-in2[x]) * (255-in1[x])) / 127) + CHOP2( (in2[x]<128) ? ( (in1[x]*in2[x])/127) + : 255 - ( ((255-in2[x]) * (255-in1[x])) / 127) , NULL); } Imaging -ImagingOverlay(Imaging imIn1, Imaging imIn2) +ImagingOverlay(Imaging imIn1, Imaging imIn2) { - CHOP2( (in1[x]<128) ? ( (in1[x]*in2[x])/127) - : 255 - ( ((255-in1[x]) * (255-in2[x])) / 127) + CHOP2( (in1[x]<128) ? ( (in1[x]*in2[x])/127) + : 255 - ( ((255-in1[x]) * (255-in2[x])) / 127) , NULL); -} \ No newline at end of file +}