Depth1Image.st
changeset 798 31ed4a1d4b4a
parent 611 e0442439a3c6
child 805 5573c2078b73
--- a/Depth1Image.st	Fri Jun 07 19:29:05 1996 +0200
+++ b/Depth1Image.st	Fri Jun 07 19:32:55 1996 +0200
@@ -41,6 +41,8 @@
     image processing on bilevel images, you may want to add more
     specialized methods here.
 
+    #blackIs0 / #whiteIs0 and #palette formats are supported here.
+
     [author:]
         Claus Gittinger
 
@@ -109,33 +111,35 @@
     |clr0 clr1|
 
     photometric == #whiteIs0 ifTrue:[
-	clr0 := Color white.
-	clr1 := Color black.
+        clr0 := Color white.
+        clr1 := Color black.
     ] ifFalse:[
-	photometric == #blackIs0 ifTrue:[
-	    clr0 := Color black.
-	    clr1 := Color white.
-	] ifFalse:[
-	    photometric ~~ #palette ifTrue:[
-		self error:'format not supported'.
-		^ nil
-	    ].
-	    clr0 := colorMap at:1.
-	    clr1 := colorMap at:2.
-	]
+        photometric == #blackIs0 ifTrue:[
+            clr0 := Color black.
+            clr1 := Color white.
+        ] ifFalse:[
+            photometric ~~ #palette ifTrue:[
+                self error:'format not supported'.
+                ^ nil
+            ].
+            clr0 := colorMap at:1.
+            clr1 := colorMap at:2.
+        ]
     ].
     aColor = clr0 ifTrue:[
-	self atX:x y:y putValue:0.
-	^ self
+        self atX:x y:y putValue:0.
+        ^ self
     ].
     aColor = clr1 ifTrue:[
-	self atX:x y:y putValue:1.
-	^ self
+        self atX:x y:y putValue:1.
+        ^ self
     ].
     "
      the color to be stored is not in the images colormap
     "
-    self error:'invalid color'
+    self error:'invalid color - not in colorMap'
+
+    "Modified: 7.6.1996 / 19:17:08 / cg"
 !
 
 atX:x y:y putValue:aPixelValue
@@ -305,7 +309,7 @@
 
 !Depth1Image methodsFor:'enumerating'!
 
-atY:y from:xLow to:xHigh do:aBlock
+colorsAtY:y from:xLow to:xHigh do:aBlock
     "perform aBlock for each pixel from x1 to x2 in row y.
      The block is passed the color at each pixel.
      This method allows slighly faster processing of an
@@ -327,51 +331,56 @@
     "left pixel is in high bit"
 
     photometric == #whiteIs0 ifTrue:[
-	color0 := Color white.
-	color1 := Color black
+        color0 := Color white.
+        color1 := Color black
     ] ifFalse:[
-	photometric == #blackIs0 ifTrue:[
-	    color0 := Color black.
-	    color1 := Color white
-	] ifFalse:[
-	    photometric == #palette ifTrue:[
-		color0 := colorMap at:1.
-		color1 := colorMap at:2
-	    ] ifFalse:[
-		self error:'format not supported'.
-		^ nil
-	    ]
-	]
+        photometric == #blackIs0 ifTrue:[
+            color0 := Color black.
+            color1 := Color white
+        ] ifFalse:[
+            photometric == #palette ifTrue:[
+                color0 := colorMap at:1.
+                color1 := colorMap at:2
+            ] ifFalse:[
+                self error:'format not supported'.
+                ^ nil
+            ]
+        ]
     ].
 
     srcIndex := srcIndex + (x1 // 8).
     mask := #[2r10000000 
-	      2r01000000
-	      2r00100000
-	      2r00010000
-	      2r00001000
-	      2r00000100
-	      2r00000010
-	      2r00000001] at:((x1 \\ 8) + 1).
+              2r01000000
+              2r00100000
+              2r00010000
+              2r00001000
+              2r00000100
+              2r00000010
+              2r00000001] at:((x1 \\ 8) + 1).
 
+    byte := bytes at:srcIndex.
     x1 to:x2 do:[:x |
-	byte := bytes at:srcIndex.
-	(byte bitAnd:mask) == 0 ifTrue:[
-	    color := color0
-	] ifFalse:[
-	    color := color1
-	].
-	aBlock value:x value:color.
+        (byte bitAnd:mask) == 0 ifTrue:[
+            aBlock value:x value:color0
+        ] ifFalse:[
+            aBlock value:x value:color1
+        ].
 
-	mask := mask bitShift:-1.
-	mask == 0 ifTrue:[
-	    mask := 2r10000000.
-	    srcIndex := srcIndex + 1
-	]
+        mask := mask bitShift:-1.
+        mask == 0 ifTrue:[
+            mask := 2r10000000.
+            srcIndex := srcIndex + 1.
+            x <= x2 ifTrue:[
+                byte := bytes at:srcIndex.
+            ]
+        ]
     ]
+
+    "Modified: 7.6.1996 / 18:52:23 / cg"
+    "Created: 7.6.1996 / 19:12:26 / cg"
 !
 
-valueAtY:y from:xLow to:xHigh do:aBlock
+valuesAtY:y from:xLow to:xHigh do:aBlock
     "perform aBlock for each pixelValue from x1 to x2 in row y.
      The block is passed the color at each pixel.
      This method allows slighly faster processing of an
@@ -397,29 +406,34 @@
 
     srcIndex := srcIndex + (x1 // 8).
     mask := #[2r10000000 
-	      2r01000000
-	      2r00100000
-	      2r00010000
-	      2r00001000
-	      2r00000100
-	      2r00000010
-	      2r00000001] at:((x1 \\ 8) + 1).
+              2r01000000
+              2r00100000
+              2r00010000
+              2r00001000
+              2r00000100
+              2r00000010
+              2r00000001] at:((x1 \\ 8) + 1).
 
+    byte := bytes at:srcIndex.
     x1 to:x2 do:[:x |
-	byte := bytes at:srcIndex.
-	(byte bitAnd:mask) == 0 ifTrue:[
-	    pixelValue := 0
-	] ifFalse:[
-	    pixelValue := 1
-	].
-	aBlock value:x value:pixelValue.
+        (byte bitAnd:mask) == 0 ifTrue:[
+            aBlock value:x value:0
+        ] ifFalse:[
+            aBlock value:x value:1
+        ].
 
-	mask := mask bitShift:-1.
-	mask == 0 ifTrue:[
-	    mask := 2r10000000.
-	    srcIndex := srcIndex + 1
-	]
+        mask := mask bitShift:-1.
+        mask == 0 ifTrue:[
+            mask := 2r10000000.
+            srcIndex := srcIndex + 1.
+            x <= x2 ifTrue:[
+                byte := bytes at:srcIndex.
+            ]
+        ]
     ]
+
+    "Modified: 7.6.1996 / 18:51:34 / cg"
+    "Created: 7.6.1996 / 19:09:38 / cg"
 ! !
 
 !Depth1Image methodsFor:'magnification'!
@@ -594,5 +608,5 @@
 !Depth1Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.20 1996-04-25 16:21:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.21 1996-06-07 17:31:04 cg Exp $'
 ! !