start to support externalBytes as pixel storage
authorClaus Gittinger <cg@exept.de>
Fri, 18 Sep 1998 13:44:03 +0200
changeset 2346 7d018cf65a14
parent 2345 2a39ca8e8b77
child 2347 c276691fdd72
start to support externalBytes as pixel storage
Depth24Image.st
--- a/Depth24Image.st	Tue Sep 15 19:10:04 1998 +0200
+++ b/Depth24Image.st	Fri Sep 18 13:44:03 1998 +0200
@@ -1100,12 +1100,30 @@
 
 	    "/ 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 (__isExternalBytes(__INST(bytes))) {
+			srcPtr = __externalBytesAddress(__INST(bytes));
+		    }
+		}
+		if (__isByteArray(imageBits)) {
+		    dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
+		} else {
+		    if (__isExternalBytes(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),
@@ -1114,9 +1132,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--) {
@@ -2407,5 +2422,5 @@
 !Depth24Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.65 1998-09-08 10:00:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.66 1998-09-18 11:44:03 cg Exp $'
 ! !