From db9a8eae50b89780b98263d3f86b03f13bd752d8 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 28 Aug 2008 17:19:38 +0000 Subject: [PATCH] * convolution_template.h: clamp output values after a convolution. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2791 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/filter/convolution_template.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pipi/filter/convolution_template.h b/pipi/filter/convolution_template.h index 595d1e7..1267ee3 100644 --- a/pipi/filter/convolution_template.h +++ b/pipi/filter/convolution_template.h @@ -70,7 +70,7 @@ static pipi_image_t *FUNC1(pipi_image_t *src, int m, int n, double mat[]) } } - dstdata[y * w + x] = Y; + dstdata[y * w + x] = Y < 0.0 ? 0.0 : Y > 1.0 ? 1.0 : Y; } else { @@ -97,9 +97,9 @@ static pipi_image_t *FUNC1(pipi_image_t *src, int m, int n, double mat[]) } } - dstdata[off] = R; - dstdata[off + 1] = G; - dstdata[off + 2] = B; + dstdata[off] = R < 0.0 ? 0.0 : R > 1.0 ? 1.0 : R; + dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G; + dstdata[off + 2] = B < 0.0 ? 0.0 : B > 1.0 ? 1.0 : B; } } } @@ -193,7 +193,7 @@ static pipi_image_t *FUNC2(pipi_image_t *src, Y += vvec[j] * buffer[y2 * w + x]; } - dstdata[y * w + x] = Y; + dstdata[y * w + x] = Y < 0.0 ? 0.0 : Y > 1.0 ? 1.0 : Y; } else { @@ -213,9 +213,9 @@ static pipi_image_t *FUNC2(pipi_image_t *src, B += f * buffer[(y2 * w + x) * 4 + 2]; } - dstdata[off] = R; - dstdata[off + 1] = G; - dstdata[off + 2] = B; + dstdata[off] = R < 0.0 ? 0.0 : R > 1.0 ? 1.0 : R; + dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G; + dstdata[off + 2] = B < 0.0 ? 0.0 : B > 1.0 ? 1.0 : B; } } }