From 9d359473638eb51b5047b0a0cff45c21e67f1a55 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 19 Dec 2012 14:25:18 +0100 Subject: [PATCH] Avoid rounding error in Image.alpha_composite --- libImaging/AlphaComposite.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libImaging/AlphaComposite.c b/libImaging/AlphaComposite.c index 28404fd53..c5801b779 100644 --- a/libImaging/AlphaComposite.c +++ b/libImaging/AlphaComposite.c @@ -81,10 +81,10 @@ ImagingAlphaComposite(Imaging imDst, Imaging imSrc) } } - out[x + 0] = (UINT8) (255.0 * outR); - out[x + 1] = (UINT8) (255.0 * outG); - out[x + 2] = (UINT8) (255.0 * outB); - out[x + 3] = (UINT8) (255.0 * outA); + out[x + 0] = (UINT8) (255.0 * outR + 0.5); + out[x + 1] = (UINT8) (255.0 * outG + 0.5); + out[x + 2] = (UINT8) (255.0 * outB + 0.5); + out[x + 3] = (UINT8) (255.0 * outA + 0.5); }