diff -r 3c2115660746 -r b8daa402967f Depth8Image.st --- a/Depth8Image.st Mon Jul 27 09:50:21 1998 +0200 +++ b/Depth8Image.st Mon Jul 27 10:11:08 1998 +0200 @@ -1458,7 +1458,7 @@ ! magnifyRowFrom:srcBytes offset:srcStart - into:dstBytes offset:dstStart factor:mX + into:dstBytes offset:dstStart factor:mX "magnify a single pixel row - can only magnify by integer factors. Specially tuned for factors 2,3 and 4." @@ -1466,6 +1466,7 @@ %{ REGISTER unsigned char *srcP, *dstP; REGISTER unsigned char _byte; + unsigned _word; int _mag; REGISTER int i; int _pixels; @@ -1474,54 +1475,85 @@ if (__bothSmallInteger(srcStart, dstStart) && __bothSmallInteger(w, mX) && __isByteArray(srcBytes) && __isByteArray(dstBytes)) { - _mag = __intVal(mX); - srcP = __ByteArrayInstPtr(srcBytes)->ba_element - 1 + __intVal(srcStart); - dstP = __ByteArrayInstPtr(dstBytes)->ba_element - 1 + __intVal(dstStart); - _pixels = __intVal(w); + _mag = __intVal(mX); + srcP = __ByteArrayInstPtr(srcBytes)->ba_element - 1 + __intVal(srcStart); + dstP = __ByteArrayInstPtr(dstBytes)->ba_element - 1 + __intVal(dstStart); + _pixels = __intVal(w); - switch (_mag) { - case 1: - break; + switch (_mag) { + case 1: + break; - case 2: - /* special code for common case */ - while (_pixels--) { - _byte = *srcP++; - *dstP++ = _byte; - *dstP++ = _byte; - } - break; + case 2: + /* special code for common case */ + if (((INT)dstP & 1) == 0) { + while (_pixels--) { + _byte = *srcP++; + _word = (_byte<<8) | _byte; + ((short *)dstP)[0] = _word; + dstP += 2; + } + } else { + while (_pixels--) { + _byte = *srcP++; + *dstP++ = _byte; + *dstP++ = _byte; + } + } + break; + + case 3: + /* special code for common case */ + while (_pixels--) { + _byte = *srcP++; + *dstP++ = _byte; + *dstP++ = _byte; + *dstP++ = _byte; + } + break; - case 3: - /* special code for common case */ - while (_pixels--) { - _byte = *srcP++; - *dstP++ = _byte; - *dstP++ = _byte; - *dstP++ = _byte; - } - break; + case 4: + /* special code for common case */ + if (((INT)dstP & 3) == 0) { + while (_pixels--) { + _byte = *srcP++; + _word = (_byte<<8) | _byte; + _word = (_word<<16) | _word; + ((int *)dstP)[0] = _word; + dstP += 4; + } + } else { + while (_pixels--) { + _byte = *srcP++; + *dstP++ = _byte; + *dstP++ = _byte; + *dstP++ = _byte; + *dstP++ = _byte; + } + } + break; - case 4: - /* special code for common case */ - while (_pixels--) { - _byte = *srcP++; - *dstP++ = _byte; - *dstP++ = _byte; - *dstP++ = _byte; - *dstP++ = _byte; - } - break; - - default: - while (_pixels--) { - _byte = *srcP++; - for (i=_mag; i>0; i--) - *dstP++ = _byte; - } - break; - } - RETURN (self); + default: + if ((((INT)dstP & 1) == 0) + && ((_mag & 1) == 0)) { + while (_pixels--) { + _byte = *srcP++; + _word = (_byte<<8) | _byte; + for (i=_mag; i>0; i-=2) { + ((short *)dstP)[0] = _word; + dstP += 2; + } + } + } else { + while (_pixels--) { + _byte = *srcP++; + for (i=_mag; i>0; i--) + *dstP++ = _byte; + } + } + break; + } + RETURN (self); } %} . @@ -1779,5 +1811,5 @@ !Depth8Image class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.82 1998-02-05 14:30:32 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.83 1998-07-27 08:11:08 cg Exp $' ! !