Depth24Image.st
changeset 4760 075322ae4864
parent 4721 ece6b3ce6b99
child 4778 799620f24088
--- a/Depth24Image.st	Tue May 29 12:13:10 2007 +0200
+++ b/Depth24Image.st	Tue May 29 12:13:23 2007 +0200
@@ -9,7 +9,6 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
-
 "{ Package: 'stx:libview' }"
 
 Image subclass:#Depth24Image
@@ -1077,448 +1076,448 @@
     "/
     myDepth := self bitsPerPixel.
     myDepth == usedDeviceBitsPerPixel ifTrue:[
-	"/
-	"/ first, the trivial case, where the depths match
-	"/ 24 bit/pixel
-	"/
-	imageBits := bytes.
-	"/
-	"/ however, the rgb-order could still be different
-	"/
-	(shiftBlue == 0) ifFalse:[
-	    imageBits := ByteArray uninitializedNew:(width * height * 3).
-	    usedDevicePadding := 8.
-
-	    "/ now, walk over the image and compose 24bit values from the r/g/b triples
+        "/
+        "/ first, the trivial case, where the depths match
+        "/ 24 bit/pixel
+        "/
+        imageBits := bytes.
+        "/
+        "/ however, the rgb-order could still be different
+        "/
+        ((shiftBlue == 0) and:[(shiftGreen == 8) and:[shiftRed == 16]]) ifFalse:[
+            imageBits := ByteArray uninitializedNew:(width * height * 3).
+            usedDevicePadding := 8.
+
+            "/ now, walk over the image and compose 24bit values from the r/g/b triples
 %{
-	    unsigned char *srcPtr = 0;
-	    unsigned char *dstPtr = 0;
-
-	    if (__isByteArray(bytes)) {
-		srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
-	    } else {
-		if (__isExternalBytesLike(bytes)) {
-		    srcPtr = __externalBytesAddress(bytes);
-		}
-	    }
-	    if (__isByteArray(imageBits)) {
-		dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
-	    } else {
-		if (__isExternalBytesLike(imageBits)) {
-		    dstPtr = __externalBytesAddress(imageBits);
-		}
-	    }
-
-	    if (__bothSmallInteger(_INST(height), _INST(width))
-	     && __bothSmallInteger(rightShiftR, shiftRed)
-	     && __bothSmallInteger(rightShiftG, shiftGreen)
-	     && __bothSmallInteger(rightShiftB, shiftBlue)
-	     && srcPtr
-	     && dstPtr) {
-		int rShRed = __intVal(rightShiftR),
-		    rShGreen = __intVal(rightShiftG),
-		    rShBlue = __intVal(rightShiftB),
-		    lShRed = __intVal(shiftRed),
-		    lShGreen = __intVal(shiftGreen),
-		    lShBlue = __intVal(shiftBlue);
-		int x, y, w;
-
-		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);
+            unsigned char *srcPtr = 0;
+            unsigned char *dstPtr = 0;
+
+            if (__isByteArray(bytes)) {
+                srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
+            } else {
+                if (__isExternalBytesLike(bytes)) {
+                    srcPtr = __externalBytesAddress(bytes);
+                }
+            }
+            if (__isByteArray(imageBits)) {
+                dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
+            } else {
+                if (__isExternalBytesLike(imageBits)) {
+                    dstPtr = __externalBytesAddress(imageBits);
+                }
+            }
+
+            if (__bothSmallInteger(_INST(height), _INST(width))
+             && __bothSmallInteger(rightShiftR, shiftRed)
+             && __bothSmallInteger(rightShiftG, shiftGreen)
+             && __bothSmallInteger(rightShiftB, shiftBlue)
+             && srcPtr
+             && dstPtr) {
+                int rShRed = __intVal(rightShiftR),
+                    rShGreen = __intVal(rightShiftG),
+                    rShBlue = __intVal(rightShiftB),
+                    lShRed = __intVal(shiftRed),
+                    lShGreen = __intVal(shiftGreen),
+                    lShBlue = __intVal(shiftBlue);
+                int x, y, w;
+
+                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);
 # ifdef __MSBFIRST
-			    dstPtr[0] = (v) & 0xFF;
-			    dstPtr[1] = (v>>8) & 0xFF;
-			    dstPtr[2] = (v>>16) & 0xFF;
+                            dstPtr[0] = (v) & 0xFF;
+                            dstPtr[1] = (v>>8) & 0xFF;
+                            dstPtr[2] = (v>>16) & 0xFF;
 # else /* not MSB */
-			    dstPtr[0] = (v>>16) & 0xFF;
-			    dstPtr[1] = (v>>8) & 0xFF;
-			    dstPtr[2] = (v) & 0xFF;
+                            dstPtr[0] = (v>>16) & 0xFF;
+                            dstPtr[1] = (v>>8) & 0xFF;
+                            dstPtr[2] = (v) & 0xFF;
 # endif /* not MSB */
-			    dstPtr += 3;
-			    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);
+                            dstPtr += 3;
+                            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);
 # ifdef __MSBFIRST
-			    dstPtr[0] = (v) & 0xFF;
-			    dstPtr[1] = (v>>8) & 0xFF;
-			    dstPtr[2] = (v>>16) & 0xFF;
+                            dstPtr[0] = (v) & 0xFF;
+                            dstPtr[1] = (v>>8) & 0xFF;
+                            dstPtr[2] = (v>>16) & 0xFF;
 # else /* not MSB */
-			    dstPtr[0] = (v>>16) & 0xFF;
-			    dstPtr[1] = (v>>8) & 0xFF;
-			    dstPtr[2] = (v) & 0xFF;
+                            dstPtr[0] = (v>>16) & 0xFF;
+                            dstPtr[1] = (v>>8) & 0xFF;
+                            dstPtr[2] = (v) & 0xFF;
 # endif /* not MSB */
-			    dstPtr += 3;
-			    srcPtr += 3;
-			}
-		    }
-		}
-	    }
+                            dstPtr += 3;
+                            srcPtr += 3;
+                        }
+                    }
+                }
+            }
 %}.
-	]
+        ]
     ] ifFalse:[
-	"/
-	"/ 16 bit/pixel ...
-	"/
-	(usedDeviceBitsPerPixel == 16) ifTrue:[
-	    padd := width \\ (usedDevicePadding // 16).
-	    imageBits := ByteArray uninitializedNew:((width + padd) * height * 2).
-
-	    "/ now, walk over the image and compose 16bit values from the r/g/b triples
+        "/
+        "/ 16 bit/pixel ...
+        "/
+        (usedDeviceBitsPerPixel == 16) ifTrue:[
+            padd := width \\ (usedDevicePadding // 16).
+            imageBits := ByteArray uninitializedNew:((width + padd) * height * 2).
+
+            "/ now, walk over the image and compose 16bit values from the r/g/b triples
 
 %{
-	    unsigned char *srcPtr = 0;
-	    unsigned char *dstPtr = 0;
-
-	    if (__isByteArray(bytes)) {
-		srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
-	    } else {
-		if (__isExternalBytesLike(bytes)) {
-		    srcPtr = __externalBytesAddress(bytes);
-		}
-	    }
-	    if (__isByteArray(imageBits)) {
-		dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
-	    } else {
-		if (__isExternalBytesLike(imageBits)) {
-		    dstPtr = __externalBytesAddress(imageBits);
-		}
-	    }
-
-	    if (__bothSmallInteger(_INST(height),_INST(width))
-	     && __bothSmallInteger(rightShiftR, shiftRed)
-	     && __bothSmallInteger(rightShiftG, shiftGreen)
-	     && __bothSmallInteger(rightShiftB, shiftBlue)
-	     && srcPtr
-	     && dstPtr) {
-		int rShRed = __intVal(rightShiftR),
-		    rShGreen = __intVal(rightShiftG),
-		    rShBlue = __intVal(rightShiftB),
-		    lShRed = __intVal(shiftRed),
-		    lShGreen = __intVal(shiftGreen),
-		    lShBlue = __intVal(shiftBlue);
-		int x, y, w;
-		int p;
-
-		w = __intVal(_INST(width));
-		p = __intVal(padd) * 2;
-
-		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);
+            unsigned char *srcPtr = 0;
+            unsigned char *dstPtr = 0;
+
+            if (__isByteArray(bytes)) {
+                srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
+            } else {
+                if (__isExternalBytesLike(bytes)) {
+                    srcPtr = __externalBytesAddress(bytes);
+                }
+            }
+            if (__isByteArray(imageBits)) {
+                dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
+            } else {
+                if (__isExternalBytesLike(imageBits)) {
+                    dstPtr = __externalBytesAddress(imageBits);
+                }
+            }
+
+            if (__bothSmallInteger(_INST(height),_INST(width))
+             && __bothSmallInteger(rightShiftR, shiftRed)
+             && __bothSmallInteger(rightShiftG, shiftGreen)
+             && __bothSmallInteger(rightShiftB, shiftBlue)
+             && srcPtr
+             && dstPtr) {
+                int rShRed = __intVal(rightShiftR),
+                    rShGreen = __intVal(rightShiftG),
+                    rShBlue = __intVal(rightShiftB),
+                    lShRed = __intVal(shiftRed),
+                    lShGreen = __intVal(shiftGreen),
+                    lShBlue = __intVal(shiftBlue);
+                int x, y, w;
+                int p;
+
+                w = __intVal(_INST(width));
+                p = __intVal(padd) * 2;
+
+                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);
 # ifdef __MSBFIRST
-			    ((short *)dstPtr)[0] = v;
+                            ((short *)dstPtr)[0] = v;
 # else /* not MSB */
-			    dstPtr[0] = (v>>8) & 0xFF;
-			    dstPtr[1] = (v) & 0xFF;
+                            dstPtr[0] = (v>>8) & 0xFF;
+                            dstPtr[1] = (v) & 0xFF;
 # endif /* not MSB */
-			    dstPtr += 2;
-			    srcPtr += 3;
-			}
-			dstPtr += p;
-		    }
-		} else {
-		    if (p == 0) {
-			int n = __intVal(__INST(height)) * w;
-
-			while (n >= 2) {
-			    unsigned w, r, g, b, v;
-
-			    n -= 2;
-
-			    r = srcPtr[0];
-			    g = srcPtr[1];
-			    b = srcPtr[2];
-			    v = (r >> rShRed) << lShRed;
-			    v |= ((g >> rShGreen) << lShGreen);
-			    v |= ((b >> rShBlue) << lShBlue);
+                            dstPtr += 2;
+                            srcPtr += 3;
+                        }
+                        dstPtr += p;
+                    }
+                } else {
+                    if (p == 0) {
+                        int n = __intVal(__INST(height)) * w;
+
+                        while (n >= 2) {
+                            unsigned w, r, g, b, v;
+
+                            n -= 2;
+
+                            r = srcPtr[0];
+                            g = srcPtr[1];
+                            b = srcPtr[2];
+                            v = (r >> rShRed) << lShRed;
+                            v |= ((g >> rShGreen) << lShGreen);
+                            v |= ((b >> rShBlue) << 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 /* not MSB */
 
-			    r = srcPtr[3];
-			    g = srcPtr[4];
-			    b = srcPtr[5];
-			    v = (r >> rShRed) << lShRed;
-			    v |= ((g >> rShGreen) << lShGreen);
-			    v |= ((b >> rShBlue) << lShBlue);
+                            r = srcPtr[3];
+                            g = srcPtr[4];
+                            b = srcPtr[5];
+                            v = (r >> rShRed) << lShRed;
+                            v |= ((g >> rShGreen) << lShGreen);
+                            v |= ((b >> rShBlue) << lShBlue);
 # ifdef __MSBFIRST
-			    ((short *)dstPtr)[1] = v;
+                            ((short *)dstPtr)[1] = v;
 # else
-			    dstPtr[2] = (v>>8) & 0xFF;
-			    dstPtr[3] = (v) & 0xFF;
+                            dstPtr[2] = (v>>8) & 0xFF;
+                            dstPtr[3] = (v) & 0xFF;
 # endif /* not MSB */
-			    dstPtr += 4;
-			    srcPtr += 6;
-			}
-
-			while (n--) {
-			    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);
+                            dstPtr += 4;
+                            srcPtr += 6;
+                        }
+
+                        while (n--) {
+                            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);
 # ifdef __MSBFIRST
-			    ((short *)dstPtr)[0] = v;
+                            ((short *)dstPtr)[0] = v;
 # else /* not MSB */
-			    dstPtr[0] = (v>>8) & 0xFF;
-			    dstPtr[1] = (v) & 0xFF;
+                            dstPtr[0] = (v>>8) & 0xFF;
+                            dstPtr[1] = (v) & 0xFF;
 # endif /* not MSB */
-			    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);
+                            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);
 # ifdef __MSBFIRST
-				((short *)dstPtr)[0] = v;
+                                ((short *)dstPtr)[0] = v;
 # else /* not MSB */
-				dstPtr[0] = (v>>8) & 0xFF;
-				dstPtr[1] = (v) & 0xFF;
+                                dstPtr[0] = (v>>8) & 0xFF;
+                                dstPtr[1] = (v) & 0xFF;
 # endif /* not MSB */
-				dstPtr += 2;
-				srcPtr += 3;
-			    }
-			    dstPtr += p;
-			}
-		    }
-		}
-	    }
+                                dstPtr += 2;
+                                srcPtr += 3;
+                            }
+                            dstPtr += p;
+                        }
+                    }
+                }
+            }
 %}.
-	] ifFalse:[
-	    "/
-	    "/ 32 bits/pixel ...
-	    "/
-	    (usedDeviceBitsPerPixel == 32) ifTrue:[
-		usedDevicePadding := 8.
-		imageBits := ByteArray uninitializedNew:(width * height * 4).
-
-		"/ now, walk over the image and compose 32bit values from the r/g/b triples
+        ] ifFalse:[
+            "/
+            "/ 32 bits/pixel ...
+            "/
+            (usedDeviceBitsPerPixel == 32) ifTrue:[
+                usedDevicePadding := 8.
+                imageBits := ByteArray uninitializedNew:(width * height * 4).
+
+                "/ now, walk over the image and compose 32bit values from the r/g/b triples
 
 %{
-		unsigned char *srcPtr = 0;
-		unsigned char *dstPtr = 0;
-
-		if (__isByteArray(bytes)) {
-		    srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
-		} else {
-		    if (__isExternalBytesLike(bytes)) {
-			srcPtr = __externalBytesAddress(bytes);
-		    }
-		}
-		if (__isByteArray(imageBits)) {
-		    dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
-		} else {
-		    if (__isExternalBytesLike(imageBits)) {
-			dstPtr = __externalBytesAddress(imageBits);
-		    }
-		}
-
-		if (__bothSmallInteger(_INST(height), _INST(width))
-		 && __bothSmallInteger(rightShiftR, shiftRed)
-		 && __bothSmallInteger(rightShiftG, shiftGreen)
-		 && __bothSmallInteger(rightShiftB, shiftBlue)
-		 && srcPtr
-		 && dstPtr) {
-		    int rShRed = __intVal(rightShiftR),
-			rShGreen = __intVal(rightShiftG),
-			rShBlue = __intVal(rightShiftB),
-			lShRed = __intVal(shiftRed),
-			lShGreen = __intVal(shiftGreen),
-			lShBlue = __intVal(shiftBlue);
-		    int x, y, w;
-
-		    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);
+                unsigned char *srcPtr = 0;
+                unsigned char *dstPtr = 0;
+
+                if (__isByteArray(bytes)) {
+                    srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
+                } else {
+                    if (__isExternalBytesLike(bytes)) {
+                        srcPtr = __externalBytesAddress(bytes);
+                    }
+                }
+                if (__isByteArray(imageBits)) {
+                    dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
+                } else {
+                    if (__isExternalBytesLike(imageBits)) {
+                        dstPtr = __externalBytesAddress(imageBits);
+                    }
+                }
+
+                if (__bothSmallInteger(_INST(height), _INST(width))
+                 && __bothSmallInteger(rightShiftR, shiftRed)
+                 && __bothSmallInteger(rightShiftG, shiftGreen)
+                 && __bothSmallInteger(rightShiftB, shiftBlue)
+                 && srcPtr
+                 && dstPtr) {
+                    int rShRed = __intVal(rightShiftR),
+                        rShGreen = __intVal(rightShiftG),
+                        rShBlue = __intVal(rightShiftB),
+                        lShRed = __intVal(shiftRed),
+                        lShGreen = __intVal(shiftGreen),
+                        lShBlue = __intVal(shiftBlue);
+                    int x, y, w;
+
+                    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);
 # ifdef __MSBFIRST
-				((int *)dstPtr)[0] = v;
+                                ((int *)dstPtr)[0] = v;
 # else /* not MSB */
-				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 /* not MSB */
-				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);
+                                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);
 # ifdef __MSBFIRST
-				((int *)dstPtr)[0] = v;
+                                ((int *)dstPtr)[0] = v;
 # else /* not MSB */
-				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 /* not MSB */
-				dstPtr += 4;
-				srcPtr += 3;
-			    }
-			}
-		    }
-		}
+                                dstPtr += 4;
+                                srcPtr += 3;
+                            }
+                        }
+                    }
+                }
 %}.
-	    ] ifFalse:[
-		"/
-		"/ 8 bits/pixel ...
-		"/
-		(usedDeviceBitsPerPixel == 8) ifTrue:[
-		    usedDevicePadding := 8.
-		    imageBits := ByteArray uninitializedNew:(width * height).
-
-		    "/ now, walk over the image and compose 8bit values from the r/g/b triples
+            ] ifFalse:[
+                "/
+                "/ 8 bits/pixel ...
+                "/
+                (usedDeviceBitsPerPixel == 8) ifTrue:[
+                    usedDevicePadding := 8.
+                    imageBits := ByteArray uninitializedNew:(width * height).
+
+                    "/ now, walk over the image and compose 8bit values from the r/g/b triples
 
 %{
-		    unsigned char *srcPtr = 0;
-		    unsigned char *dstPtr = 0;
-
-		    if (__isByteArray(bytes)) {
-			srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
-		    } else {
-			if (__isExternalBytesLike(bytes)) {
-			    srcPtr = __externalBytesAddress(bytes);
-			}
-		    }
-		    if (__isByteArray(imageBits)) {
-			dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
-		    } else {
-			if (__isExternalBytesLike(imageBits)) {
-			    dstPtr = __externalBytesAddress(imageBits);
-			}
-		    }
-
-		    if (__bothSmallInteger(_INST(height), _INST(width))
-		     && __bothSmallInteger(rightShiftR, shiftRed)
-		     && __bothSmallInteger(rightShiftG, shiftGreen)
-		     && __bothSmallInteger(rightShiftB, shiftBlue)
-		     && srcPtr
-		     && dstPtr) {
-			int rShRed = __intVal(rightShiftR),
-			    rShGreen = __intVal(rightShiftG),
-			    rShBlue = __intVal(rightShiftB),
-			    lShRed = __intVal(shiftRed),
-			    lShGreen = __intVal(shiftGreen),
-			    lShBlue = __intVal(shiftBlue);
-			int x, y, w;
-
-			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);
-				    dstPtr[0] = v;
-
-				    dstPtr += 1;
-				    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);
-
-				    dstPtr[0] = v;
-
-				    dstPtr += 1;
-				    srcPtr += 3;
-				}
-			    }
-			}
-		    }
+                    unsigned char *srcPtr = 0;
+                    unsigned char *dstPtr = 0;
+
+                    if (__isByteArray(bytes)) {
+                        srcPtr = _ByteArrayInstPtr(bytes)->ba_element;
+                    } else {
+                        if (__isExternalBytesLike(bytes)) {
+                            srcPtr = __externalBytesAddress(bytes);
+                        }
+                    }
+                    if (__isByteArray(imageBits)) {
+                        dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
+                    } else {
+                        if (__isExternalBytesLike(imageBits)) {
+                            dstPtr = __externalBytesAddress(imageBits);
+                        }
+                    }
+
+                    if (__bothSmallInteger(_INST(height), _INST(width))
+                     && __bothSmallInteger(rightShiftR, shiftRed)
+                     && __bothSmallInteger(rightShiftG, shiftGreen)
+                     && __bothSmallInteger(rightShiftB, shiftBlue)
+                     && srcPtr
+                     && dstPtr) {
+                        int rShRed = __intVal(rightShiftR),
+                            rShGreen = __intVal(rightShiftG),
+                            rShBlue = __intVal(rightShiftB),
+                            lShRed = __intVal(shiftRed),
+                            lShGreen = __intVal(shiftGreen),
+                            lShBlue = __intVal(shiftBlue);
+                        int x, y, w;
+
+                        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);
+                                    dstPtr[0] = v;
+
+                                    dstPtr += 1;
+                                    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);
+
+                                    dstPtr[0] = v;
+
+                                    dstPtr += 1;
+                                    srcPtr += 3;
+                                }
+                            }
+                        }
+                    }
 %}.
-		]
-	    ].
-	]
+                ]
+            ].
+        ]
     ].
 
     imageBits isNil ifTrue:[
-	'IMAGE: unimplemented trueColor depth in #rgbImageAsTrueColorFormOn: ' errorPrint.
-	usedDeviceBitsPerPixel errorPrintCR.
-	^ self asMonochromeFormOn:aDevice
+        'IMAGE: unimplemented trueColor depth in #rgbImageAsTrueColorFormOn: ' errorPrint.
+        usedDeviceBitsPerPixel errorPrintCR.
+        ^ self asMonochromeFormOn:aDevice
     ].
 
-    form := Form width:width height:height depth:usedDeviceDepth on:aDevice.
+    form := Form width:width height:height depth:usedDeviceDepth onDevice:aDevice.
     form isNil ifTrue:[
-	'Depth24Image [warning]: display bitmap creation failed' errorPrintCR.
-	^ nil
+        'Depth24Image [warning]: display bitmap creation failed' errorPrintCR.
+        ^ nil
     ].
     form initGC.
 
     form
-	copyBitsFrom:imageBits
-	bitsPerPixel:usedDeviceBitsPerPixel
-	depth:usedDeviceDepth
-	padding:usedDevicePadding
-	width:width height:height
-	x:0 y:0 toX:0 y:0.
+        copyBitsFrom:imageBits
+        bitsPerPixel:usedDeviceBitsPerPixel
+        depth:usedDeviceDepth
+        padding:usedDevicePadding
+        width:width height:height
+        x:0 y:0 toX:0 y:0.
 
     ^ form
 
-    "Modified: 21.10.1995 / 19:30:11 / cg"
+    "Modified: / 27-05-2007 / 16:48:16 / cg"
 ! !
 
 !Depth24Image methodsFor:'dither helpers'!
@@ -2588,6 +2587,16 @@
     "Modified: 23.6.1997 / 09:57:19 / cg"
 ! !
 
+!Depth24Image methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    samplesPerPixel := 3. 
+    bitsPerSample := #(8 8 8).
+
+    "Created: / 27-05-2007 / 14:09:34 / cg"
+! !
+
 !Depth24Image methodsFor:'magnification'!
 
 hardAntiAliasedMagnifiedBy:scalePoint
@@ -3025,5 +3034,5 @@
 !Depth24Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.85 2007-02-22 15:11:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.86 2007-05-29 10:13:23 cg Exp $'
 ! !