--- a/Depth1Image.st Tue Apr 08 14:32:24 2003 +0200
+++ b/Depth1Image.st Thu Apr 10 16:24:41 2003 +0200
@@ -156,8 +156,7 @@
Pixels start at 0@0 for upper left pixel, end at
(width-1)@(height-1) for lower right pixel"
- |bytesPerRow "{Class: SmallInteger}"
- index "{Class: SmallInteger}"
+ |index "{Class: SmallInteger}"
byte "{Class: SmallInteger}"
mask "{Class: SmallInteger}"|
@@ -166,40 +165,33 @@
OBJ b = _INST(bytes);
OBJ w = _INST(width);
- if (__isByteArray(b) && __bothSmallInteger(x, y) && __isSmallInteger(w) ) {
- int _w = __intVal(w);
- int _y = __intVal(y);
- int _x = __intVal(x);
- unsigned _byte;
- int _idx;
+ if (__bothSmallInteger(x, y) && __isSmallInteger(w)) {
+ if (__isByteArray(b)) {
+ int _w = __intVal(w);
+ int _y = __intVal(y);
+ int _x = __intVal(x);
+ unsigned _byte;
+ int _idx;
- _idx = ((_w + 7) >> 3) * _y + (_x >> 3);
- if ((unsigned)_idx < __byteArraySize(b)) {
- _byte = __ByteArrayInstPtr(b)->ba_element[_idx];
- RETURN( (_byte & (0x80 >> (_x & 7))) ? __MKSMALLINT(1) : __MKSMALLINT(0) );
+ _idx = ((_w + 7) >> 3) * _y + (_x >> 3);
+ if ((unsigned)_idx < __byteArraySize(b)) {
+ _byte = __ByteArrayInstPtr(b)->ba_element[_idx];
+ RETURN( (_byte & (0x80 >> (_x & 7))) ? __MKSMALLINT(1) : __MKSMALLINT(0) );
+ }
}
}
%}.
-"/ the above is equivalent to:
-"/ (notice that the code below is evaluated if the bytes-collection is
-"/ not a byteArray, or the arguments are not integers)
+ "/ the code below is only evaluated if the bytes-collection is
+ "/ not a ByteArray, or the arguments are not integers
+
+ index := (self bytesPerRow * y) + 1 + (x // 8).
-"/ bytesPerRow := width // 8.
-"/ ((width \\ 8) ~~ 0) ifTrue:[
-"/ bytesPerRow := bytesPerRow + 1
-"/ ].
-"/ index := (bytesPerRow * y) + 1 + (x // 8).
-"/
-"/ "left pixel is in high bit"
-"/ byte := bytes at:index.
-"/ mask := #(16r80 16r40 16r20 16r10 16r08 16r04 16r02 16r01) at:((x \\ 8) + 1).
-"/ (byte bitAnd:mask) == 0 ifTrue:[^ 0].
-"/ ^ 1
-
-"/ since that cannot happen, we faile here
- self primitiveFailed.
- ^ 0
+ "left pixel is in high bit"
+ byte := bytes at:index.
+ mask := 1 bitShift:(7 - (x \\ 8)).
+ (byte bitAnd:mask) == 0 ifTrue:[^ 0].
+ ^ 1
!
pixelAtX:x y:y put:aPixelValue
@@ -207,8 +199,7 @@
Pixels start at x=0 , y=0 for upper left pixel, end at
x = width-1, y=height-1 for lower right pixel"
- |bytesPerRow "{Class: SmallInteger}"
- index "{Class: SmallInteger}"
+ |index "{Class: SmallInteger}"
byte "{Class: SmallInteger}"
mask "{Class: SmallInteger}"|
@@ -236,11 +227,7 @@
%}.
"fall back code for nonByteArray or nonInteger arguments"
- bytesPerRow := width // 8.
- ((width \\ 8) ~~ 0) ifTrue:[
- bytesPerRow := bytesPerRow + 1
- ].
- index := (bytesPerRow * y) + 1 + (x // 8).
+ index := (self bytesPerRow * y) + 1 + (x // 8).
"left pixel is in high bit"
byte := bytes at:index.
@@ -580,24 +567,42 @@
case 2:
/* tuned for this common case */
+ while (_pixels > 4) {
+ _byte = *srcP++;
+ *dstP++ = mag1[ _byte >> 4 ];
+ *dstP++ = mag1[ _byte & 0x0F ];
+ _pixels -= 8;
+ }
while (_pixels > 0) {
_byte = *srcP++;
*dstP++ = mag1[ _byte >> 4 ];
- if (_pixels > 4) {
- *dstP++ = mag1[ _byte & 0x0F ];
- }
_pixels -= 8;
}
break;
case 4:
/* tuned for this common case */
+ while (_pixels > 6) {
+ _byte = *srcP++;
+ byte1 = mag1[_byte >> 4];
+ byte2 = mag1[byte1 & 0xF];
+ byte1 = mag1[byte1 >> 4];
+ byte3 = mag1[ _byte & 0x0F ];
+ byte4 = mag1[byte3 & 0xF];
+ byte3 = mag1[byte3 >> 4];
+
+ *dstP++ = byte1;
+ *dstP++ = byte2;
+ *dstP++ = byte3;
+ *dstP++ = byte4;
+ _pixels -= 8;
+ }
while (_pixels > 0) {
_byte = *srcP++;
byte1 = mag1[_byte >> 4];
byte2 = mag1[byte1 & 0xF];
byte1 = mag1[byte1 >> 4];
- byte3 = mag1[ _byte & 0x0F ];
+ byte3 = mag1[_byte & 0x0F ];
byte4 = mag1[byte3 & 0xF];
byte3 = mag1[byte3 >> 4];
@@ -651,7 +656,9 @@
RETURN (self);
}
%}.
- self primitiveFailed
+ super
+ magnifyRowFrom:srcBytes offset:srcStart
+ into:dstBytes offset:dstStart factor:mX
! !
!Depth1Image methodsFor:'private'!
@@ -746,5 +753,5 @@
!Depth1Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.47 2002-02-12 17:12:37 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.48 2003-04-10 14:24:32 cg Exp $'
! !