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; } } }