From acab26a2408cd07024376f84ed566ae1ba7ee52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Wed, 3 Feb 2010 06:20:52 +0100 Subject: [PATCH] add safeguard in gray normalization --- backend/genesys_conv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/genesys_conv.c b/backend/genesys_conv.c index 7a4873f80..779355f5c 100644 --- a/backend/genesys_conv.c +++ b/backend/genesys_conv.c @@ -122,6 +122,11 @@ binarize_line(Genesys_Device * dev, uint8_t *src, uint8_t *dst, int width) min = src[x]; } } + /* safeguard againt dark of white areas */ + if(min>80) + min=0; + if(max<80) + max=255; for (x = 0; x < width; x++) { src[x] = ((src[x] - min) * 255) / (max - min);