also handle subclasses of ExternalBytes (Mapped..)
authorClaus Gittinger <cg@exept.de>
Fri, 11 Apr 2003 02:09:05 +0200
changeset 3851 34637f468b2a
parent 3850 6d3def73ffce
child 3852 fc190ad74774
also handle subclasses of ExternalBytes (Mapped..) as image data
Depth24Image.st
Depth2Image.st
Depth4Image.st
Depth8Image.st
ImageMask.st
--- a/Depth24Image.st	Fri Apr 11 01:41:12 2003 +0200
+++ b/Depth24Image.st	Fri Apr 11 02:09:05 2003 +0200
@@ -1064,8 +1064,8 @@
 rgbImageAsTrueColorFormOn:aDevice
     "return a truecolor form from the rgb-picture."
 
-    |bestFormat usedDeviceDepth usedDeviceBitsPerPixel usedDevicePadding depth
-     myDepth form imageBits destIndex srcIndex padd
+    |bestFormat usedDeviceDepth usedDeviceBitsPerPixel usedDevicePadding 
+     myDepth form imageBits padd
      rightShiftR rightShiftG rightShiftB shiftRed shiftGreen shiftBlue|
 
     bestFormat := self bestSupportedImageFormatFor:aDevice.
@@ -1100,86 +1100,87 @@
 
             "/ 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(__INST(bytes))) {
-                    srcPtr = _ByteArrayInstPtr(__INST(bytes))->ba_element;
-                } else {
-                    if (__isExternalBytesLike(__INST(bytes))) {
-                        srcPtr = __externalBytesAddress(__INST(bytes));
-                    }
+            unsigned char *srcPtr = 0;
+            unsigned char *dstPtr = 0;
+            OBJ _bytes = __INST(bytes);
+
+            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 (__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);
+            }
+
+            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;
-                            }
+                            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);
+                    }
+                } 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:[
@@ -1193,12 +1194,31 @@
             "/ now, walk over the image and compose 16bit values from the r/g/b triples
 
 %{
+            unsigned char *srcPtr = 0;
+            unsigned char *dstPtr = 0;
+            OBJ _bytes = __INST(bytes);
+
+            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)
-             && __isByteArray(_INST(bytes))
-             && __isByteArray(imageBits)) {
+             && srcPtr
+             && dstPtr) {
                 int rShRed = __intVal(rightShiftR),
                     rShGreen = __intVal(rightShiftG),
                     rShBlue = __intVal(rightShiftB),
@@ -1208,9 +1228,6 @@
                 int x, y, w;
                 int p;
 
-                unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
-
                 w = __intVal(_INST(width));
                 p = __intVal(padd) * 2;
 
@@ -1326,12 +1343,31 @@
                 "/ now, walk over the image and compose 32bit values from the r/g/b triples
 
 %{       
+                unsigned char *srcPtr = 0;
+                unsigned char *dstPtr = 0;
+                OBJ _bytes = __INST(bytes);
+
+                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)
-                 && __isByteArray(_INST(bytes))
-                 && __isByteArray(imageBits)) {
+                 && srcPtr
+                 && dstPtr) {
                     int rShRed = __intVal(rightShiftR),
                         rShGreen = __intVal(rightShiftG),
                         rShBlue = __intVal(rightShiftB),
@@ -1340,9 +1376,6 @@
                         lShBlue = __intVal(shiftBlue);
                     int x, y, w;
 
-                    unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                    unsigned 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--) {
@@ -1401,12 +1434,31 @@
                     "/ now, walk over the image and compose 8bit values from the r/g/b triples
 
 %{              
+                    unsigned char *srcPtr = 0;
+                    unsigned char *dstPtr = 0;
+                    OBJ _bytes = __INST(bytes);
+
+                    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)
-                     && __isByteArray(_INST(bytes))
-                     && __isByteArray(imageBits)) {
+                     && srcPtr
+                     && dstPtr) {
                         int rShRed = __intVal(rightShiftR),
                             rShGreen = __intVal(rightShiftG),
                             rShBlue = __intVal(rightShiftB),
@@ -1415,9 +1467,6 @@
                             lShBlue = __intVal(shiftBlue);
                         int x, y, w;
 
-                        unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                        unsigned 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--) {
@@ -2520,5 +2569,5 @@
 !Depth24Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.76 2003-04-10 23:40:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.77 2003-04-11 00:09:00 cg Exp $'
 ! !
--- a/Depth2Image.st	Fri Apr 11 01:41:12 2003 +0200
+++ b/Depth2Image.st	Fri Apr 11 02:09:05 2003 +0200
@@ -163,7 +163,7 @@
     |depth 
      colorValues 
      form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel 
-     usedDevicePadding usedDeviceBytesPerRow padd n|
+     usedDevicePadding usedDeviceBytesPerRow padd|
 
     depth := aDevice depth.
 
@@ -192,16 +192,33 @@
         "/ colorMap indices by color values in the bits array
 
 %{  
+        unsigned char *srcPtr = 0;
+        unsigned char *dstPtr = 0;
+        OBJ _bytes = __INST(bytes);
+
+        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))
          && __isArray(colorValues)
-         && __isByteArray(_INST(bytes))
-         && __isByteArray(imageBits)) {
+         && srcPtr
+         && dstPtr) {
             int r,p;
             int x, y, w, h, nPix;
             int byte, shift;
 
-            unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-            unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
             OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
             w = __intVal(_INST(width));
@@ -253,16 +270,33 @@
             "/ colorMap indices by color values in the bits array
 
 %{       
+            unsigned char *srcPtr = 0;
+            unsigned char *dstPtr = 0;
+            OBJ _bytes = __INST(bytes);
+
+            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))
              && __isArray(colorValues)
-             && __isByteArray(_INST(bytes))
-             && __isByteArray(imageBits)) {
+             && srcPtr
+             && dstPtr) {
                 int x, y, w, h, nPix;
                 int r,p;
                 int byte, shift;
 
-                unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                 OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                 w = __intVal(_INST(width));
@@ -312,15 +346,32 @@
                 "/ colorMap indices by color values in the bits array
 
 %{       
+                unsigned char *srcPtr = 0;
+                unsigned char *dstPtr = 0;
+                OBJ _bytes = __INST(bytes);
+
+                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))
                  && __isArray(colorValues)
-                 && __isByteArray(_INST(bytes))
-                 && __isByteArray(imageBits)) {
+                 && srcPtr
+                 && dstPtr) {
                     int x, y, w, h, nPix;
                     int r,p, byte, shift;
 
-                    unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                    unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                     OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                     w = __intVal(_INST(width));
@@ -365,15 +416,32 @@
                     "/ colorMap indices by color values in the bits array
 
 %{       
+                    unsigned char *srcPtr = 0;
+                    unsigned char *dstPtr = 0;
+                    OBJ _bytes = __INST(bytes);
+
+                    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))
                      && __isArray(colorValues)
-                     && __isByteArray(_INST(bytes))
-                     && __isByteArray(imageBits)) {
+                     && srcPtr
+                     && dstPtr) {
                         int x, y, w, h, nPix;
                         int r, p, byte, shift;
 
-                        unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                        unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                         OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                         w = __intVal(_INST(width));
@@ -441,10 +509,6 @@
 
     "Created: 20.10.1995 / 22:05:10 / cg"
     "Modified: 21.10.1995 / 19:30:26 / cg"
-
-
-
-
 !
 
 greyImageAsTrueColorFormOn:aDevice
@@ -942,5 +1006,5 @@
 !Depth2Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth2Image.st,v 1.42 2003-04-10 14:24:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth2Image.st,v 1.43 2003-04-11 00:08:58 cg Exp $'
 ! !
--- a/Depth4Image.st	Fri Apr 11 01:41:12 2003 +0200
+++ b/Depth4Image.st	Fri Apr 11 02:09:05 2003 +0200
@@ -178,7 +178,7 @@
     |depth 
      colorValues 
      form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel 
-     usedDevicePadding usedDeviceBytesPerRow padd n|
+     usedDevicePadding usedDeviceBytesPerRow padd|
 
     depth := aDevice depth.
 
@@ -207,16 +207,33 @@
         "/ colorMap indices by color values in the bits array
 
 %{  
+        unsigned char *srcPtr = 0;
+        unsigned char *dstPtr = 0;
+        OBJ _bytes = __INST(bytes);
+
+        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))
          && __isArray(colorValues)
-         && __isByteArray(_INST(bytes))
-         && __isByteArray(imageBits)) {
+         && srcPtr
+         && dstPtr) {
             int r,p;
             int x, y, w, h, nPix;
             int byte;
 
-            unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-            unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
             OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
             w = __intVal(_INST(width));
@@ -264,16 +281,33 @@
             "/ colorMap indices by color values in the bits array
 
 %{       
+            unsigned char *srcPtr = 0;
+            unsigned char *dstPtr = 0;
+            OBJ _bytes = __INST(bytes);
+
+            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))
              && __isArray(colorValues)
-             && __isByteArray(_INST(bytes))
-             && __isByteArray(imageBits)) {
+             && srcPtr
+             && dstPtr) {
                 int x, y, w, h, nPix;
                 int r,p;
                 int byte;
 
-                unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                 OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                 w = __intVal(_INST(width));
@@ -319,15 +353,32 @@
                 "/ colorMap indices by color values in the bits array
 
 %{       
+                unsigned char *srcPtr = 0;
+                unsigned char *dstPtr = 0;
+                OBJ _bytes = __INST(bytes);
+
+                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))
                  && __isArray(colorValues)
-                 && __isByteArray(_INST(bytes))
-                 && __isByteArray(imageBits)) {
+                 && srcPtr
+                 && dstPtr) {
                     int x, y, w, h, nPix;
                     int r,p, byte;
 
-                    unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                    unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                     OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                     w = __intVal(_INST(width));
@@ -369,15 +420,32 @@
                     "/ colorMap indices by color values in the bits array
 
 %{       
+                    unsigned char *srcPtr = 0;
+                    unsigned char *dstPtr = 0;
+                    OBJ _bytes = __INST(bytes);
+
+                    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))
                      && __isArray(colorValues)
-                     && __isByteArray(_INST(bytes))
-                     && __isByteArray(imageBits)) {
+                     && srcPtr
+                     && dstPtr) {
                         int x, y, w, h, nPix;
                         int r, p, byte;
 
-                        unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                        unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                         OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                         w = __intVal(_INST(width));
@@ -442,8 +510,6 @@
 
     "Created: 20.10.1995 / 22:05:10 / cg"
     "Modified: 21.10.1995 / 19:30:26 / cg"
-
-
 !
 
 greyImageAsTrueColorFormOn:aDevice
@@ -973,5 +1039,5 @@
 !Depth4Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.41 2003-04-10 14:24:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.42 2003-04-11 00:09:05 cg Exp $'
 ! !
--- a/Depth8Image.st	Fri Apr 11 01:41:12 2003 +0200
+++ b/Depth8Image.st	Fri Apr 11 02:09:05 2003 +0200
@@ -623,7 +623,7 @@
     |depth 
      colorValues 
      form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel 
-     usedDevicePadding usedDeviceBytesPerRow padd n|
+     usedDevicePadding usedDeviceBytesPerRow padd|
 
     depth := aDevice depth.
 
@@ -652,16 +652,33 @@
         "/ colorMap indices by color values in the bits array
 
 %{  
+        unsigned char *srcPtr = 0;
+        unsigned char *dstPtr = 0;
+        OBJ _bytes = __INST(bytes);
+
+        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))
          && __isArray(colorValues)
-         && __isByteArray(_INST(bytes))
-         && __isByteArray(imageBits)) {
+         && srcPtr
+         && dstPtr) {
             int r,p;
             int x, y, w, h, nPix;
             unsigned short pixels[256];
 
-            unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-            unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
             OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
             nPix = __arraySize(colorValues);
@@ -766,14 +783,31 @@
             "/ colorMap indices by color values in the bits array
 
 %{       
+            unsigned char *srcPtr = 0;
+            unsigned char *dstPtr = 0;
+            OBJ _bytes = __INST(bytes);
+
+            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))
              && __isArray(colorValues)
-             && __isByteArray(_INST(bytes))
-             && __isByteArray(imageBits)) {
+             && srcPtr
+             && dstPtr) {
                 int x, y, w, h, nPix;
 
-                unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                 OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                 w = __intVal(_INST(width));
@@ -808,15 +842,32 @@
                 "/ colorMap indices by color values in the bits array
 
 %{       
+                unsigned char *srcPtr = 0;
+                unsigned char *dstPtr = 0;
+                OBJ _bytes = __INST(bytes);
+
+                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))
                  && __isArray(colorValues)
-                 && __isByteArray(_INST(bytes))
-                 && __isByteArray(imageBits)) {
+                 && srcPtr
+                 && dstPtr) {
                     int x, y, w, h, nPix;
                     int r,p;
 
-                    unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                    unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                     OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                     w = __intVal(_INST(width));
@@ -855,15 +906,32 @@
                     "/ colorMap indices by color values in the bits array
 
 %{       
+                    unsigned char *srcPtr = 0;
+                    unsigned char *dstPtr = 0;
+                    OBJ _bytes = __INST(bytes);
+
+                    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))
                      && __isArray(colorValues)
-                     && __isByteArray(_INST(bytes))
-                     && __isByteArray(imageBits)) {
+                     && srcPtr
+                     && dstPtr) {
                         int x, y, w, h, nPix;
                         int r,p;
 
-                        unsigned char *srcPtr = __ByteArrayInstPtr(_INST(bytes))->ba_element;
-                        unsigned char *dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
                         OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
 
                         w = __intVal(_INST(width));
@@ -934,14 +1002,15 @@
     map := ByteArray uninitializedNew:256.
 
     1 to:256 do:[:i |
-	map at:i put:((self colorFromValue:(i-1)) brightness * 255) rounded
+        map at:i put:((self colorFromValue:(i-1)) brightness * 255) rounded
     ].
 
-    bytes expandPixels:8         "xlate only"
-		width:width 
-	       height:height
-		 into:greyBits
-	      mapping:map.
+    bytes 
+        expandPixels:8         "xlate only"
+        width:width 
+        height:height
+        into:greyBits
+        mapping:map.
 
     ^ self makeDeviceGrayPixmapOn:aDevice depth:8 fromArray:greyBits
 
@@ -1890,5 +1959,5 @@
 !Depth8Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.98 2003-04-10 14:24:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.99 2003-04-11 00:08:45 cg Exp $'
 ! !
--- a/ImageMask.st	Fri Apr 11 01:41:12 2003 +0200
+++ b/ImageMask.st	Fri Apr 11 02:09:05 2003 +0200
@@ -11,6 +11,8 @@
 "
 
 
+"{ Package: 'stx:libview' }"
+
 Depth1Image subclass:#ImageMask
 	instanceVariableNames:''
 	classVariableNames:''
@@ -74,5 +76,5 @@
 !ImageMask class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ImageMask.st,v 1.2 1999-05-18 19:16:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ImageMask.st,v 1.3 2003-04-11 00:08:56 cg Exp $'
 ! !