From caba836e5d86eedf7fe80e2e7b72f53c3253bea9 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 31 Jul 2008 22:02:34 +0000 Subject: [PATCH] * pixels.c: clamp pixels in the float32 -> rgba32 conversion to avoid artifacts. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2620 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/pixels.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pipi/pixels.c b/pipi/pixels.c index 9f0b253..fd10ff4 100644 --- a/pipi/pixels.c +++ b/pipi/pixels.c @@ -97,7 +97,11 @@ pipi_pixels_t *pipi_getpixels(pipi_image_t *img, pipi_format_t type) uint8_t d; p = src[4 * (y * img->w + x) + i]; - d = (int)(255.999 * pow(p, 1. / GAMMA)); + + if(p < 0.) d = 0.; + else if(p > 1.) d = 255; + else d = (int)(255.999 * pow(p, 1. / GAMMA)); + dest[4 * (y * img->w + x) + i] = d; e = p - u8tof32(d);