Depth24Image.st
changeset 813 8bc17dba7a02
parent 810 9789d836dbc4
child 816 6576c8242e5d
--- a/Depth24Image.st	Mon Jun 10 17:16:51 1996 +0200
+++ b/Depth24Image.st	Mon Jun 10 19:25:04 1996 +0200
@@ -52,6 +52,14 @@
 
 !Depth24Image class methodsFor:'queries'!
 
+defaultPhotometric
+    "return the default photometric pixel interpretation"
+
+    ^ #rgb
+
+    "Created: 10.6.1996 / 18:08:25 / cg"
+!
+
 imageDepth
     "return the depth of images represented by instances of
      this class - here we return 24"
@@ -139,168 +147,68 @@
 
 !Depth24Image methodsFor:'converting rgb images'!
 
-rgbImageAs2PlaneFormOn:aDevice
-    "return a 2-bit device form for aDevice from the rgb picture,
-     using a threshold algorithm. 
-     (i.e. grey value < 0.25 -> black // 0.25..0.5 -> darkgrey //
-      0.5 .. 0.75 -> lightgrey // > 0.75 -> white)."
-
-    |twoPlaneBits f
-     map rMap gMap bMap 
-     failed
-     r        "{ Class: SmallInteger }"
-     g        "{ Class: SmallInteger }"
-     b        "{ Class: SmallInteger }"
-     v        "{ Class: SmallInteger }"
-     w        "{ Class: SmallInteger }"
-     h        "{ Class: SmallInteger }"
-     srcIndex "{ Class: SmallInteger }"
-     dstIndex "{ Class: SmallInteger }"
-     bits     "{ Class: SmallInteger }"
-     bitCount "{ Class: SmallInteger }" |
-
-    w := width.
-    h := height.
-    twoPlaneBits := ByteArray uninitializedNew:(((w * 2 + 7) // 8) * h).
-
-    failed := true.
-%{
-    register unsigned char *srcPtr, *dstPtr;
-    register _v, _bits, _bitCount;
-    register j;
-    register i;
+asGrayFormOn:aDevice
+    "return a grey form from the receiver.
+     Redefined to use special code when converting to 8-bit
+     greyScale displays."
 
-    if ((__Class(_INST(bytes)) == ByteArray)
-     && (__Class(twoPlaneBits) == ByteArray)) {
-	failed = false;
-	srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
-	dstPtr = _ByteArrayInstPtr(twoPlaneBits)->ba_element;
-	for (i=_intVal(h); i>0; i--) {
-	    _bitCount = 0;
-	    _bits = 0;
-	    for (j=_intVal(w); j>0; j--) {
-		_v = (*srcPtr++ * 3);   /* 0.3*r + 0.6*g + b */
-		_v += (*srcPtr++ * 6);
-		_v += *srcPtr++;
-		_v /= 10;
-		_bits <<= 2; 
-		_bits |= (_v >> 6); /* take top 2 bits */
-		_bitCount++;
-		if (_bitCount == 4) {
-		    *dstPtr++ = _bits;
-		    _bits = 0;
-		    _bitCount = 0;
-		}
-	    }
-	    if (_bitCount != 0) {
-		while (_bitCount++ != 4) _bits <<= 2;
-		*dstPtr++ = _bits;
-	    }
-	}
-    }
-%}.
-    failed ifTrue:[
-"/ the above is equivalent to:
-"/
-"/        srcIndex := 1.
-"/        dstIndex := 1.
-"/        1 to:h do:[:row |
-"/            bitCount := 0.
-"/            bits := 0.
-"/            1 to:w do:[:col |
-"/                r := bytes at:srcIndex.
-"/                srcIndex := srcIndex + 1.
-"/                g := bytes at:srcIndex.
-"/                srcIndex := srcIndex + 1.
-"/                b := bytes at:srcIndex.
-"/                srcIndex := srcIndex + 1.
-"/                v := ((3 * r) + (6 * g) + (1 * b)) // 10.
-"/                v := v bitShift:-6. "take 2 hi bits"
-"/                bits := (bits bitShift:2) bitOr:v.
-"/                bitCount := bitCount + 1.
-"/                (bitCount == 4) ifTrue:[
-"/                    twoPlaneBits at:dstIndex put:bits.
-"/                    dstIndex := dstIndex + 1.
-"/                    bits := 0.
-"/                    bitCount := 0
-"/                ]
-"/            ].
-"/            (bitCount ~~ 0) ifTrue:[
-"/                [bitCount == 4] whileFalse:[
-"/                    bitCount := bitCount + 1.
-"/                    bits := bits bitShift:2.
-"/                ].
-"/                twoPlaneBits at:dstIndex put:bits.
-"/                dstIndex := dstIndex + 1
-"/            ]
-"/        ]
-	self primitiveFailed.
-	^ nil
+    (aDevice visualType == #StaticGray) ifTrue:[
+        aDevice depth == 8 ifTrue:[
+            ^ self makeDevicePixmapOn:aDevice depth:aDevice depth fromArray:(self threshold8BitGrayBits)
+        ].
     ].
+    ^ super asGrayFormOn:aDevice
 
-    f := Form width:width height:height depth:2 on:aDevice.
-    f isNil ifTrue:[^ nil].
-    f initGC.
-    (aDevice blackpixel == 0) ifFalse:[
-	"have to invert bits"
-	f function:#copyInverted
-    ].
-    aDevice drawBits:twoPlaneBits depth:2 width:width height:height
-		   x:0 y:0
-		into:(f id) x:0 y:0 width:width height:height with:(f gcId).
-    ^ f
+    "Created: 10.6.1996 / 19:00:45 / cg"
 !
 
-rgbImageAs8BitGreyFormOn:aDevice
-    "return an 8-bit greyForm from the rgb picture"
-
-    ^ Form
-        width:width
-        height:height
-        fromArray:(self threshold8BitGrayBits)
-
-    "Modified: 10.6.1996 / 14:39:55 / cg"
-!
-
-rgbImageAs8BitGreyImage
+asThresholdGrayImageDepth:depth
     "return an 8-bit grey image from the rgb picture.
      Pixel values are reduced to a 0..255 grey level."
 
-    ^ Depth8Image
-        width:width
-        height:height
-        fromArray:(self threshold8BitGrayBits)
+    depth == 8 ifTrue:[
+        photometric == #rgb ifTrue:[
+            ^ Depth8Image
+                width:width
+                height:height
+                fromArray:(self threshold8BitGrayBits)
+        ]
+    ].
+    ^ super asThresholdGrayImageDepth:depth
 
     "
      |i|
 
      i := Image fromFile:'bitmaps/granite.tiff'.
-     i rgbImageAs8BitGreyImage inspect
+     (i asThresholdGrayImageDepth:8) inspect.
+     (i asThresholdGrayImageDepth:4) inspect.
+     (i asThresholdGrayImageDepth:2) inspect.
+     (i asThresholdGrayImageDepth:1) inspect.
     "
 
     "
      |i|
 
      i := Image fromFile:'bitmaps/granite.tiff'.
-     (i rgbImageAs8BitGreyImage asOrderedDitheredGrayImageDepth:2) inspect
+     ((i asThresholdGrayImageDepth:8) asOrderedDitheredGrayImageDepth:2) inspect
     "
 
     "
      |i|
 
      i := Image fromFile:'bitmaps/granite.tiff'.
-     (i rgbImageAs8BitGreyImage asOrderedDitheredGrayImageDepth:4) inspect
+     ((i asThresholdGrayImageDepth:8) asOrderedDitheredGrayImageDepth:4) inspect
     "
 
     "
      |i|
 
      i := Image fromFile:'bitmaps/granite.tiff'.
-     i rgbImageAs8BitGreyImage asOrderedDitheredMonochromeImage inspect
+     (i asThresholdGrayImageDepth:8) asOrderedDitheredMonochromeImage inspect
     "
 
     "Created: 8.6.1996 / 13:58:46 / cg"
-    "Modified: 10.6.1996 / 14:39:52 / cg"
+    "Modified: 10.6.1996 / 19:11:18 / cg"
 !
 
 rgbImageAsDitheredPseudoFormOn:aDevice
@@ -515,52 +423,6 @@
     ^ f
 !
 
-rgbImageAsGreyFormOn:aDevice
-    "convert an rgb image to a grey image for greyscale displays"
-
-    |deviceDepth|
-
-    deviceDepth := aDevice depth.
-
-    "I have specially tuned methods for monochrome"
-    (deviceDepth == 1) ifTrue:[
-        DitherAlgorithm == #error ifTrue:[
-            ^ self rgbImageAsErrorDitheredGrayFormOn:aDevice
-        ].
-        DitherAlgorithm == #pattern ifTrue:[
-            ^ self rgbImageAsPatternDitheredGrayFormOn:aDevice
-        ].
-        ^ self rgbImageAsMonoFormOn:aDevice
-    ].
-
-    "and for 2plane greyscale (i.e. NeXTs)"
-    (deviceDepth == 2) ifTrue:[
-        DitherAlgorithm == #error  ifTrue:[
-            ^ self rgbImageAsErrorDitheredGrayFormOn:aDevice
-        ].
-        DitherAlgorithm == #pattern  ifTrue:[
-            ^ self rgbImageAsPatternDitheredGrayFormOn:aDevice
-        ].
-        ^ self rgbImageAs2PlaneFormOn:aDevice
-    ].
-
-    (deviceDepth == 8) ifTrue:[
-        ^ self rgbImageAs8BitGrayFormOn:aDevice
-    ].
-
-    "mhmh need another converter ...
-     till then we do:"
-    DitherAlgorithm == #error  ifTrue:[
-        ^ self rgbImageAsErrorDitheredGrayFormOn:aDevice
-    ].
-    DitherAlgorithm == #pattern  ifTrue:[
-        ^ self rgbImageAsPatternDitheredGrayFormOn:aDevice
-    ].
-    ^ self rgbImageAsMonoFormOn:aDevice
-
-    "Modified: 10.6.1996 / 14:44:41 / cg"
-!
-
 rgbImageAsPseudoFormOn:aDevice
     "return a pseudocolor form from the rgb-picture"
 
@@ -834,250 +696,250 @@
     "/
     myDepth := self bitsPerPixel.
     myDepth == usedDeviceBitsPerPixel ifTrue:[
-	"/
-	"/ first, the trivial case, where the depths match
-	"/ 24 bit/pixel
-	"/
-	imageBits := bytes.
+        "/
+        "/ first, the trivial case, where the depths match
+        "/ 24 bit/pixel
+        "/
+        imageBits := bytes.
     ] ifFalse:[
-	"/
-	"/ 16 bit/pixel ...
-	"/
-	(usedDeviceBitsPerPixel == 16) ifTrue:[
-	    imageBits := ByteArray uninitializedNew:(width * height * 2).
+        "/
+        "/ 16 bit/pixel ...
+        "/
+        (usedDeviceBitsPerPixel == 16) ifTrue:[
+            imageBits := ByteArray uninitializedNew:(width * height * 2).
 
-	    "/ now, walk over the image and compose 16bit values from the r/g/b triples
+            "/ now, walk over the image and compose 16bit values from the r/g/b triples
 
-	    ok := false.
+            ok := false.
 
 %{          /* OPTIONAL */
-	    if (__bothSmallInteger(_INST(height),_INST(width))
-	     && __bothSmallInteger(rightShiftR, shiftRed)
-	     && __bothSmallInteger(rightShiftG, shiftGreen)
-	     && __bothSmallInteger(rightShiftB, shiftBlue)
-	     && __isByteArray(_INST(bytes))
-	     && __isByteArray(imageBits)) {
-		int rShRed = __intVal(rightShiftR),
-		    rShGreen = __intVal(rightShiftG),
-		    rShBlue = __intVal(rightShiftB),
-		    lShRed = __intVal(shiftRed),
-		    lShGreen = __intVal(shiftGreen),
-		    lShBlue = __intVal(shiftBlue);
-		int x, y, w;
+            if (__bothSmallInteger(_INST(height),_INST(width))
+             && __bothSmallInteger(rightShiftR, shiftRed)
+             && __bothSmallInteger(rightShiftG, shiftGreen)
+             && __bothSmallInteger(rightShiftB, shiftBlue)
+             && __isByteArray(_INST(bytes))
+             && __isByteArray(imageBits)) {
+                int rShRed = __intVal(rightShiftR),
+                    rShGreen = __intVal(rightShiftG),
+                    rShBlue = __intVal(rightShiftB),
+                    lShRed = __intVal(shiftRed),
+                    lShGreen = __intVal(shiftGreen),
+                    lShBlue = __intVal(shiftBlue);
+                int x, y, w;
 
-		unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
-		char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
+                unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
+                char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
 
-		w = __intVal(_INST(width));
-		if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
-		    for (y=__intVal(_INST(height)); y > 0; y--) {
-			for (x=w; x > 0; x--) {
-			    unsigned v;
+                w = __intVal(_INST(width));
+                if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
+                    for (y=__intVal(_INST(height)); y > 0; y--) {
+                        for (x=w; x > 0; x--) {
+                            unsigned v;
 
-			    v = srcPtr[0] << lShRed;
-			    v |= (srcPtr[1] << lShGreen);
-			    v |= (srcPtr[2] << lShBlue);
+                            v = srcPtr[0] << lShRed;
+                            v |= (srcPtr[1] << lShGreen);
+                            v |= (srcPtr[2] << lShBlue);
 # ifdef MSBFIRST
-			    ((short *)dstPtr)[0] = v;
+                            ((short *)dstPtr)[0] = v;
 # else
-			    dstPtr[0] = (v>>8) & 0xFF;
-			    dstPtr[1] = (v) & 0xFF;
+                            dstPtr[0] = (v>>8) & 0xFF;
+                            dstPtr[1] = (v) & 0xFF;
 # endif
-			    dstPtr += 2;
-			    srcPtr += 3;
-			}
-		    }
-		} else {
-		    for (y=__intVal(_INST(height)); y > 0; y--) {
-			for (x=w; x > 0; x--) {
-			    unsigned r, g, b, v;
+                            dstPtr += 2;
+                            srcPtr += 3;
+                        }
+                    }
+                } else {
+                    for (y=__intVal(_INST(height)); y > 0; y--) {
+                        for (x=w; x > 0; x--) {
+                            unsigned r, g, b, v;
 
-			    r = srcPtr[0] >> rShRed;
-			    g = srcPtr[1] >> rShGreen;
-			    b = srcPtr[2] >> rShBlue;
-			    v = r << lShRed;
-			    v |= (g << lShGreen);
-			    v |= (b << lShBlue);
+                            r = srcPtr[0] >> rShRed;
+                            g = srcPtr[1] >> rShGreen;
+                            b = srcPtr[2] >> rShBlue;
+                            v = r << lShRed;
+                            v |= (g << lShGreen);
+                            v |= (b << lShBlue);
 # ifdef MSBFIRST
-			    ((short *)dstPtr)[0] = v;
+                            ((short *)dstPtr)[0] = v;
 # else
-			    dstPtr[0] = (v>>8) & 0xFF;
-			    dstPtr[1] = (v) & 0xFF;
+                            dstPtr[0] = (v>>8) & 0xFF;
+                            dstPtr[1] = (v) & 0xFF;
 # endif
-			    dstPtr += 2;
-			    srcPtr += 3;
-			}
-		    }
-		}
-		ok = true;
-	    }
+                            dstPtr += 2;
+                            srcPtr += 3;
+                        }
+                    }
+                }
+                ok = true;
+            }
 %}.
-	    ok ifFalse:[
-		"/ this fallback is only executed if type is not
-		"/ what the primitive expects; for example, if the bytes-instvar
-		"/ is not a ByteArray
+            ok ifFalse:[
+                "/ this fallback is only executed if type is not
+                "/ what the primitive expects; for example, if the bytes-instvar
+                "/ is not a ByteArray
 
-		rightShiftR := rightShiftR negated.
-		rightShiftG := rightShiftG negated.
-		rightShiftB := rightShiftB negated.
+                rightShiftR := rightShiftR negated.
+                rightShiftG := rightShiftG negated.
+                rightShiftB := rightShiftB negated.
 
-		destIndex := 1.
-		srcIndex := 1.
+                destIndex := 1.
+                srcIndex := 1.
 
-		0 to:height-1 do:[:y |
-		    0 to:width-1 do:[:x |
-			|r g b v|
+                0 to:height-1 do:[:y |
+                    0 to:width-1 do:[:x |
+                        |r g b v|
 
-			r := bytes at:srcIndex.
-			g := bytes at:(srcIndex + 1).
-			b := bytes at:(srcIndex + 2).
+                        r := bytes at:srcIndex.
+                        g := bytes at:(srcIndex + 1).
+                        b := bytes at:(srcIndex + 2).
 
-			r := r bitShift:rightShiftR.
-			g := g bitShift:rightShiftG.
-			b := b bitShift:rightShiftB.
+                        r := r bitShift:rightShiftR.
+                        g := g bitShift:rightShiftG.
+                        b := b bitShift:rightShiftB.
 
-			v := r bitShift:shiftRed.
-			v := v bitOr:(g bitShift:shiftGreen).
-			v := v bitOr:(b bitShift:shiftBlue).
+                        v := r bitShift:shiftRed.
+                        v := v bitOr:(g bitShift:shiftGreen).
+                        v := v bitOr:(b bitShift:shiftBlue).
 
-			imageBits wordAt:destIndex put:v MSB:true.
-			destIndex := destIndex + 2.
-			srcIndex := srcIndex + 3.
-		    ]
-		]
-	    ]
-	] ifFalse:[
-	    "/
-	    "/ 32bit pixels
-	    "/
-	    (usedDeviceBitsPerPixel == 32) ifTrue:[
-		imageBits := ByteArray uninitializedNew:(width * height * 4).
+                        imageBits wordAt:destIndex put:v MSB:true.
+                        destIndex := destIndex + 2.
+                        srcIndex := srcIndex + 3.
+                    ]
+                ]
+            ]
+        ] ifFalse:[
+            "/
+            "/ 32bit pixels
+            "/
+            (usedDeviceBitsPerPixel == 32) ifTrue:[
+                imageBits := ByteArray uninitializedNew:(width * height * 4).
 
-		"/ now, walk over the image and compose 32bit values from the r/g/b triples
+                "/ now, walk over the image and compose 32bit values from the r/g/b triples
 
-		ok := false.
+                ok := false.
 
 %{              /* OPTIONAL */
-		if (__bothSmallInteger(_INST(height), _INST(width))
-		 && __bothSmallInteger(rightShiftR, shiftRed)
-		 && __bothSmallInteger(rightShiftG, shiftGreen)
-		 && __bothSmallInteger(rightShiftB, shiftBlue)
-		 && __isByteArray(_INST(bytes))
-		 && __isByteArray(imageBits)) {
-		    int rShRed = __intVal(rightShiftR),
-			rShGreen = __intVal(rightShiftG),
-			rShBlue = __intVal(rightShiftB),
-			lShRed = __intVal(shiftRed),
-			lShGreen = __intVal(shiftGreen),
-			lShBlue = __intVal(shiftBlue);
-		    int x, y, w;
+                if (__bothSmallInteger(_INST(height), _INST(width))
+                 && __bothSmallInteger(rightShiftR, shiftRed)
+                 && __bothSmallInteger(rightShiftG, shiftGreen)
+                 && __bothSmallInteger(rightShiftB, shiftBlue)
+                 && __isByteArray(_INST(bytes))
+                 && __isByteArray(imageBits)) {
+                    int rShRed = __intVal(rightShiftR),
+                        rShGreen = __intVal(rightShiftG),
+                        rShBlue = __intVal(rightShiftB),
+                        lShRed = __intVal(shiftRed),
+                        lShGreen = __intVal(shiftGreen),
+                        lShBlue = __intVal(shiftBlue);
+                    int x, y, w;
 
-		    unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
-		    char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
+                    unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
+                    char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
 
-		    w = __intVal(_INST(width));
-		    if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
-			for (y=__intVal(_INST(height)); y > 0; y--) {
-			    for (x=w; x > 0; x--) {
-				unsigned v;
+                    w = __intVal(_INST(width));
+                    if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
+                        for (y=__intVal(_INST(height)); y > 0; y--) {
+                            for (x=w; x > 0; x--) {
+                                unsigned v;
 
-				v = srcPtr[0] << lShRed;
-				v |= (srcPtr[1] << lShGreen);
-				v |= (srcPtr[2] << lShBlue);
+                                v = srcPtr[0] << lShRed;
+                                v |= (srcPtr[1] << lShGreen);
+                                v |= (srcPtr[2] << lShBlue);
 # ifdef MSBFIRST
-				((int *)dstPtr)[0] = v;
+                                ((int *)dstPtr)[0] = v;
 # else
-				dstPtr[0] = (v>>24) & 0xFF;
-				dstPtr[1] = (v>>16) & 0xFF;
-				dstPtr[2] = (v>>8) & 0xFF;
-				dstPtr[3] = (v) & 0xFF;
+                                dstPtr[0] = (v>>24) & 0xFF;
+                                dstPtr[1] = (v>>16) & 0xFF;
+                                dstPtr[2] = (v>>8) & 0xFF;
+                                dstPtr[3] = (v) & 0xFF;
 # endif
-				dstPtr += 4;
-				srcPtr += 3;
-			    }
-			}
-		    } else {
-			for (y=__intVal(_INST(height)); y > 0; y--) {
-			    for (x=w; x > 0; x--) {
-				unsigned r, g, b, v;
+                                dstPtr += 4;
+                                srcPtr += 3;
+                            }
+                        }
+                    } else {
+                        for (y=__intVal(_INST(height)); y > 0; y--) {
+                            for (x=w; x > 0; x--) {
+                                unsigned r, g, b, v;
 
-				r = srcPtr[0] >> rShRed;
-				g = srcPtr[1] >> rShGreen;
-				b = srcPtr[2] >> rShBlue;
-				v = r << lShRed;
-				v |= (g << lShGreen);
-				v |= (b << lShBlue);
+                                r = srcPtr[0] >> rShRed;
+                                g = srcPtr[1] >> rShGreen;
+                                b = srcPtr[2] >> rShBlue;
+                                v = r << lShRed;
+                                v |= (g << lShGreen);
+                                v |= (b << lShBlue);
 # ifdef MSBFIRST
-				((int *)dstPtr)[0] = v;
+                                ((int *)dstPtr)[0] = v;
 # else
-				dstPtr[0] = (v>>24) & 0xFF;
-				dstPtr[1] = (v>>16) & 0xFF;
-				dstPtr[2] = (v>>8) & 0xFF;
-				dstPtr[3] = (v) & 0xFF;
+                                dstPtr[0] = (v>>24) & 0xFF;
+                                dstPtr[1] = (v>>16) & 0xFF;
+                                dstPtr[2] = (v>>8) & 0xFF;
+                                dstPtr[3] = (v) & 0xFF;
 # endif
-				dstPtr += 4;
-				srcPtr += 3;
-			    }
-			}
-		    }
-		    ok = true;
-		}
+                                dstPtr += 4;
+                                srcPtr += 3;
+                            }
+                        }
+                    }
+                    ok = true;
+                }
 %}.
-		ok ifFalse:[
-		    "/ this fallback is only executed if type is not
-		    "/ what the primitive expects; for example, if the bytes-instvar
-		    "/ is not a ByteArray; or, if this class is autoload on non-compiling
-		    "/ systems.
+                ok ifFalse:[
+                    "/ this fallback is only executed if type is not
+                    "/ what the primitive expects; for example, if the bytes-instvar
+                    "/ is not a ByteArray; or, if this class is autoload on non-compiling
+                    "/ systems.
 
-		    rightShiftR := rightShiftR negated.
-		    rightShiftG := rightShiftG negated.
-		    rightShiftB := rightShiftB negated.
+                    rightShiftR := rightShiftR negated.
+                    rightShiftG := rightShiftG negated.
+                    rightShiftB := rightShiftB negated.
 
-		    destIndex := 1.
-		    srcIndex := 1.
+                    destIndex := 1.
+                    srcIndex := 1.
 
-		    0 to:height-1 do:[:y |
-			0 to:width-1 do:[:x |
-			    |r g b v|
+                    0 to:height-1 do:[:y |
+                        0 to:width-1 do:[:x |
+                            |r g b v|
 
-			    r := bytes at:srcIndex.
-			    g := bytes at:(srcIndex + 1).
-			    b := bytes at:(srcIndex + 2).
+                            r := bytes at:srcIndex.
+                            g := bytes at:(srcIndex + 1).
+                            b := bytes at:(srcIndex + 2).
 
-			    r := r bitShift:rightShiftR.
-			    g := g bitShift:rightShiftG.
-			    b := b bitShift:rightShiftB.
+                            r := r bitShift:rightShiftR.
+                            g := g bitShift:rightShiftG.
+                            b := b bitShift:rightShiftB.
 
-			    v := r bitShift:shiftRed.
-			    v := v bitOr:(g bitShift:shiftGreen).
-			    v := v bitOr:(b bitShift:shiftBlue).
+                            v := r bitShift:shiftRed.
+                            v := v bitOr:(g bitShift:shiftGreen).
+                            v := v bitOr:(b bitShift:shiftBlue).
 
-			    imageBits doubleWordAt:destIndex put:v MSB:true.
-			    destIndex := destIndex + 4.
-			    srcIndex := srcIndex + 3.
-			]
-		    ]
-		]
-	    ].
-	]
+                            imageBits doubleWordAt:destIndex put:v MSB:true.
+                            destIndex := destIndex + 4.
+                            srcIndex := srcIndex + 3.
+                        ]
+                    ]
+                ]
+            ].
+        ]
     ].
 
     imageBits isNil ifTrue:[            
-	'IMAGE: unimplemented trueColor depth in rgbImageAsTrueColorFormOn:' errorPrintNL.
-	^ self rgbImageAsMonoFormOn:aDevice
+        'IMAGE: unimplemented trueColor depth in rgbImageAsTrueColorFormOn:' errorPrintNL.
+        ^ self asMonochromeFormOn:aDevice
     ].
 
     form := Form width:width height:height depth:usedDeviceDepth on:aDevice.
     form isNil ifTrue:[
-	'IMAGE: display bitmap creation failed' errorPrintNL.
-	^ nil
+        'IMAGE: display bitmap creation failed' errorPrintNL.
+        ^ nil
     ].
     form initGC.
 
     form 
-	copyBitsFrom:imageBits bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth 
-	       width:width height:height 
-		   x:0 y:0 toX:0 y:0. 
+        copyBitsFrom:imageBits bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth 
+               width:width height:height 
+                   x:0 y:0 toX:0 y:0. 
 
     ^ form
 
@@ -1617,7 +1479,10 @@
     "return the number of bits per sample.
      The return value is an array of bits-per-plane."
 
+    bitsPerSample notNil ifTrue:[^ bitsPerSample].
     ^ #(8 8 8)
+
+    "Modified: 10.6.1996 / 18:02:33 / cg"
 !
 
 blueBitsOf:pixel
@@ -1670,11 +1535,14 @@
 samplesPerPixel
     "return the number of samples per pixel in the image."
 
+    samplesPerPixel notNil ifTrue:[^ samplesPerPixel].
     ^ 3
+
+    "Modified: 10.6.1996 / 18:03:09 / cg"
 ! !
 
 !Depth24Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.30 1996-06-10 13:24:13 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.31 1996-06-10 17:24:31 cg Exp $'
 ! !