Index: trunk/MagicSoft/Cosy/videodev/Filter.cc
===================================================================
--- trunk/MagicSoft/Cosy/videodev/Filter.cc	(revision 1959)
+++ trunk/MagicSoft/Cosy/videodev/Filter.cc	(revision 2019)
@@ -205,5 +205,5 @@
 void Filter::Stretch(byte *img)
 {
-    const int offset = 10;
+    const int offset = 25;
 
     int max;
@@ -212,9 +212,23 @@
     /*const float mean =*/Mean(img, offset, &min, &max);
 
+    const byte diff = max-min;
+
     for (int x=0; x<768; x++)
         for (int y=0; y<576; y++)
         {
-            img[y*768+x] -= min;
-            img[y*768+x] *= 255/(max-min);
-        }
-}
+            byte &b = img[y*768+x];
+
+            if (b<min)
+            {
+                b=0;
+                continue;
+            }
+            if (b>max)
+            {
+                b=max;
+                continue;
+            }
+            b -= min;
+            b *= 255/diff;
+        }
+}
