*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Wed, 06 Feb 2008 13:46:55 +0100
changeset 4904 653051844382
parent 4903 9bed66cb8c21
child 4905 a11132ada22c
*** empty log message ***
Depth4Image.st
--- a/Depth4Image.st	Tue Feb 05 21:02:33 2008 +0100
+++ b/Depth4Image.st	Wed Feb 06 13:46:55 2008 +0100
@@ -77,12 +77,17 @@
      x = width-1, y=height-1 for lower right pixel"
 
     |lineIndex "{ Class: SmallInteger }"
+     byteIndex "{ Class: SmallInteger }"
      byte      "{ Class: SmallInteger }" |
 
     lineIndex := (self bytesPerRow * y) + 1.
+    byteIndex := lineIndex + (x // 2).
 
     "left pixel in high bits"
-    byte := bytes at:(lineIndex + (x // 2)).
+    byteIndex > bytes size ifTrue:[
+        ^ 0
+    ].
+    byte := bytes at:byteIndex.
     x even ifTrue:[
         ^ (byte bitShift:-4) bitAnd:16rF.
     ].
@@ -792,9 +797,11 @@
      value    "{ Class: SmallInteger }"
      x1       "{ Class: SmallInteger }"
      x2       "{ Class: SmallInteger }"
+     byteSize "{ Class: SmallInteger }"
      colorArray bytes|
 
     bytes := self bits.
+    byteSize := bytes size.
     colorArray := ((0 to:15) collect:[:i | self colorFromValue:i]) asArray.
 
     x1 := xLow.
@@ -815,7 +822,11 @@
             shift := -4.
             srcIndex := srcIndex + 1.
         ] ifFalse:[
-            byte := bytes at:srcIndex.
+            srcIndex > byteSize ifTrue:[
+                byte := 0.
+            ] ifFalse:[
+                byte := bytes at:srcIndex.
+            ].
             value := (byte bitShift:-4) bitAnd:16rF.
             shift := 0
         ].
@@ -1036,5 +1047,5 @@
 !Depth4Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.49 2007-05-29 17:20:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.50 2008-02-06 12:46:55 cg Exp $'
 ! !