--- a/Image.st Fri Nov 03 13:33:08 1995 +0100
+++ b/Image.st Sat Nov 04 11:40:32 1995 +0100
@@ -29,7 +29,7 @@
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libview/Image.st,v 1.43 1995-10-24 17:09:00 cg Exp $
+$Header: /cvs/stx/stx/libview/Image.st,v 1.44 1995-11-04 10:40:32 cg Exp $
'!
!Image class methodsFor:'documentation'!
@@ -50,7 +50,7 @@
version
"
-$Header: /cvs/stx/stx/libview/Image.st,v 1.43 1995-10-24 17:09:00 cg Exp $
+$Header: /cvs/stx/stx/libview/Image.st,v 1.44 1995-11-04 10:40:32 cg Exp $
"
!
@@ -1982,7 +1982,10 @@
paletteImageAsTrueColorFormOn:aDevice
"return a true-color device-form for the palette-image receiver."
- |depth myDepth nColors colorValues
+ |depth
+ myDepth "{ Class: SmallInteger }"
+ nColors "{ Class: SmallInteger }"
+ colorValues
scaleRed scaleGreen scaleBlue redShift greenShift blueShift
form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel
destIndex ok|
@@ -2014,7 +2017,7 @@
colorValues := Array uninitializedNew:nColors.
1 to:nColors do:[:index |
- |clr rv gv bv v|
+ |clr rv gv bv v "{ Class: SmallInteger }" |
clr := colorMap at:index.
clr notNil ifTrue:[
@@ -2053,38 +2056,42 @@
&& __isByteArray(_INST(bytes))
&& (myDepth == __MKSMALLINT(8))
&& __isByteArray(imageBits)) {
- int x, y, w;
+ int x, y, w, h, nPix;
unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
w = __intVal(_INST(width));
- for (y=__intVal(_INST(height)); y > 0; y--) {
- for (x=w; x > 0; x--) {
- unsigned idx, v;
- OBJ clr;
-
- idx = *srcPtr;
- clr = ap[idx];
- v = __intVal(clr);
+ h = __intVal(_INST(height));
+ nPix = w * h;
+ while (nPix > 0) {
+ unsigned idx, v;
+ OBJ clr;
+
+ idx = *srcPtr;
+ clr = ap[idx];
+ v = __intVal(clr);
#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 += 1;
- }
+ dstPtr += 2;
+ srcPtr += 1;
+ nPix--;
}
ok = true;
}
%}.
ok ifFalse:[
- "/ this fallback is only executed if type is not
+ "/ this fallback is only executed if some type is not
"/ what the primitive expects (for example, if the bytes-instvar
- "/ is not a ByteArray) or the source depth is not 8.
+ "/ is not a ByteArray)
+ "/ or (more important) the source depth is not 8.
+ "/ The code below uses the (depth independent) but slower
+ "/ #valueAtX:y: to fetch pixel values.
destIndex := 1.
0 to:height-1 do:[:y |
0 to:width-1 do:[:x |
@@ -2111,40 +2118,44 @@
&& __isByteArray(_INST(bytes))
&& (myDepth == __MKSMALLINT(8))
&& __isByteArray(imageBits)) {
- int x, y, w;
+ int x, y, w, h, nPix;
unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
OBJ *ap = __ArrayInstPtr(colorValues)->a_element;
w = __intVal(_INST(width));
- for (y=__intVal(_INST(height)); y > 0; y--) {
- for (x=w; x > 0; x--) {
- unsigned idx, v;
- OBJ clr;
-
- idx = *srcPtr;
- clr = ap[idx];
- v = __intVal(clr);
+ h = __intVal(_INST(height));
+ nPix = w * h;
+ while (nPix > 0) {
+ unsigned idx, v;
+ OBJ clr;
+
+ idx = *srcPtr;
+ clr = ap[idx];
+ v = __intVal(clr);
#ifdef MSBFIRST
- ((short *)dstPtr)[0] = v;
+ ((long *)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 += 1;
- }
+ dstPtr += 4;
+ srcPtr += 1;
+ nPix--;
}
ok = true;
}
%}.
ok ifFalse:[
- "/ this fallback is only executed if type is not
+ "/ this fallback is only executed if some type is not
"/ what the primitive expects (for example, if the bytes-instvar
- "/ is not a ByteArray) or the source depth is not 8.
+ "/ is not a ByteArray)
+ "/ or (more important) the source depth is not 8.
+ "/ The code below uses the (depth independent) but slower
+ "/ #valueAtX:y: to fetch pixel values.
destIndex := 1.
0 to:height-1 do:[:y |
@@ -2472,10 +2483,14 @@
"return a true-color device-form for the grey-image receiver.
TODO: the pixel loops ought to be implemented as inline primitive code ..."
- |depth myDepth nColors colorValues
+ |depth
+ myDepth "{ Class: SmallInteger }"
+ nColors "{ Class: SmallInteger }"
+ colorValues
scaleDown scaleRed scaleGreen scaleBlue redShift blueShift greenShift
form imageBitsdestIndex
- bestFormat usedDeviceDepth usedDeviceBitsPerPixel imageBits destIndex|
+ bestFormat usedDeviceDepth usedDeviceBitsPerPixel imageBits destIndex
+ nPixels|
"/ this is a slow fallback method; this ought to be
"/ redefined in DepthxImage for more performance.