care for invalid pixel values in image
authorClaus Gittinger <cg@exept.de>
Mon, 17 Aug 1998 10:18:15 +0200
changeset 2248 20fc22184ef5
parent 2247 50650fdc8c72
child 2249 61b9cc611488
care for invalid pixel values in image
Depth8Image.st
--- a/Depth8Image.st	Fri Aug 14 19:35:48 1998 +0200
+++ b/Depth8Image.st	Mon Aug 17 10:18:15 1998 +0200
@@ -1328,7 +1328,8 @@
      x2       "{ Class: SmallInteger }"
      y1       "{ Class: SmallInteger }"
      y2       "{ Class: SmallInteger }"
-     colorArray|
+     colorArray
+     maxColor|
 
     x1 := xStart.
     x2 := xEnd.
@@ -1339,6 +1340,7 @@
     bytesPerRow := self bytesPerRow.
 
     colorArray := self realColorMap.
+    maxColor := colorArray size.
 
     y1 to:y2 do:[:y |
         srcNext := srcIndex + bytesPerRow.
@@ -1346,14 +1348,17 @@
             value := bytes at:srcIndex.
             srcIndex := srcIndex + 1.
 
+            value >= maxColor ifTrue:[
+                value := 0.
+            ].
             aBlock value:x value:y value:(colorArray at:value+1)
         ].
         srcIndex := srcNext.
     ].
     ^ self
 
-    "Created: 7.6.1996 / 19:12:35 / cg"
-    "Modified: 11.7.1996 / 20:20:55 / cg"
+    "Created: / 7.6.1996 / 19:12:35 / cg"
+    "Modified: / 17.8.1998 / 10:17:45 / cg"
 !
 
 valuesAtY:y from:xLow to:xHigh do:aBlock
@@ -1864,5 +1869,5 @@
 !Depth8Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.84 1998-07-29 11:17:25 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.85 1998-08-17 08:18:15 cg Exp $'
 ! !