.
--- a/Depth24Image.st Mon Oct 23 18:00:19 1995 +0100
+++ b/Depth24Image.st Tue Oct 24 18:09:00 1995 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.14 1995-06-06 04:05:15 claus Exp $
+$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.15 1995-10-24 17:08:27 cg Exp $
'!
!Depth24Image class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.14 1995-06-06 04:05:15 claus Exp $
+$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.15 1995-10-24 17:08:27 cg Exp $
"
!
@@ -1344,6 +1344,280 @@
x:0 y:0
into:(f id) x:0 y:0 width:width height:height with:(f gcId).
^ f
+!
+
+rgbImageAsTrueColorFormOn:aDevice
+ "return a truecolor form from the rgb-picture."
+
+ |bestFormat usedDeviceDepth usedDeviceBitsPerPixel depth
+ myDepth form imageBits destIndex srcIndex
+ rightShiftR rightShiftG rightShiftB shiftRed shiftGreen shiftBlue ok|
+
+ bestFormat := self bestSupportedImageFormatFor:aDevice.
+ usedDeviceDepth := bestFormat at:1.
+ usedDeviceBitsPerPixel := bestFormat at:2.
+
+ rightShiftR := (8 - aDevice bitsRed).
+ rightShiftG := (8 - aDevice bitsGreen).
+ rightShiftB := (8 - aDevice bitsBlue).
+
+ shiftRed := aDevice shiftRed.
+ shiftGreen := aDevice shiftGreen.
+ shiftBlue := aDevice shiftBlue.
+
+ "/
+ "/ for now, only a few formats are supported
+ "/
+ myDepth := self bitsPerPixel.
+ myDepth == usedDeviceBitsPerPixel ifTrue:[
+ "/
+ "/ first, the trivial case, where the depths match
+ "/ 24 bit/pixel
+ "/
+ imageBits := bytes.
+ ] ifFalse:[
+ "/
+ "/ 16 bit/pixel ...
+ "/
+ (usedDeviceBitsPerPixel == 16) ifTrue:[
+ imageBits := ByteArray uninitializedNew:(width * height * 2).
+
+ "/ now, walk over the image and compose 16bit values from the r/g/b triples
+
+ ok := false.
+
+%{ /* OPTIONAL */
+ if (__bothSmallInteger(_INST(height),_INST(width))
+ && __bothSmallInteger(rightShiftR, shiftRed)
+ && __bothSmallInteger(rightShiftG, shiftGreen)
+ && __bothSmallInteger(rightShiftB, shiftBlue)
+ && __isByteArray(_INST(bytes))
+ && __isByteArray(imageBits)) {
+ int rShRed = __intVal(rightShiftR),
+ rShGreen = __intVal(rightShiftG),
+ rShBlue = __intVal(rightShiftB),
+ lShRed = __intVal(shiftRed),
+ lShGreen = __intVal(shiftGreen),
+ lShBlue = __intVal(shiftBlue);
+ int x, y, w;
+
+ unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
+ 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--) {
+ for (x=w; x > 0; x--) {
+ unsigned v;
+
+ v = srcPtr[0] << lShRed;
+ v |= (srcPtr[1] << lShGreen);
+ v |= (srcPtr[2] << lShBlue);
+# ifdef MSBFIRST
+ ((short *)dstPtr)[0] = v;
+# else
+ dstPtr[0] = (v>>8) & 0xFF;
+ dstPtr[1] = (v) & 0xFF;
+# endif
+ dstPtr += 2;
+ 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);
+# ifdef MSBFIRST
+ ((short *)dstPtr)[0] = v;
+# else
+ dstPtr[0] = (v>>8) & 0xFF;
+ dstPtr[1] = (v) & 0xFF;
+# endif
+ dstPtr += 2;
+ srcPtr += 3;
+ }
+ }
+ }
+ ok = true;
+ }
+%}.
+ ok ifFalse:[
+ "/ this fallback is only executed if type is not
+ "/ what the primitive expects; for example, if the bytes-instvar
+ "/ is not a ByteArray
+
+ rightShiftR := rightShiftR negated.
+ rightShiftG := rightShiftG negated.
+ rightShiftB := rightShiftB negated.
+
+ destIndex := 1.
+ srcIndex := 1.
+
+ 0 to:height-1 do:[:y |
+ 0 to:width-1 do:[:x |
+ |r g b v|
+
+ r := bytes at:srcIndex.
+ g := bytes at:(srcIndex + 1).
+ b := bytes at:(srcIndex + 2).
+
+ r := r bitShift:rightShiftR.
+ g := g bitShift:rightShiftG.
+ b := b bitShift:rightShiftB.
+
+ v := r bitShift:shiftRed.
+ v := v bitOr:(g bitShift:shiftGreen).
+ v := v bitOr:(b bitShift:shiftBlue).
+
+ imageBits wordAt:destIndex put:v MSB:true.
+ destIndex := destIndex + 2.
+ srcIndex := srcIndex + 3.
+ ]
+ ]
+ ]
+ ] ifFalse:[
+ "/
+ "/ 32bit pixels
+ "/
+ (usedDeviceBitsPerPixel == 32) ifTrue:[
+ imageBits := ByteArray uninitializedNew:(width * height * 4).
+
+ "/ now, walk over the image and compose 32bit values from the r/g/b triples
+
+ ok := false.
+
+%{ /* OPTIONAL */
+ if (__bothSmallInteger(_INST(height), _INST(width))
+ && __bothSmallInteger(rightShiftR, shiftRed)
+ && __bothSmallInteger(rightShiftG, shiftGreen)
+ && __bothSmallInteger(rightShiftB, shiftBlue)
+ && __isByteArray(_INST(bytes))
+ && __isByteArray(imageBits)) {
+ int rShRed = __intVal(rightShiftR),
+ rShGreen = __intVal(rightShiftG),
+ rShBlue = __intVal(rightShiftB),
+ lShRed = __intVal(shiftRed),
+ lShGreen = __intVal(shiftGreen),
+ lShBlue = __intVal(shiftBlue);
+ int x, y, w;
+
+ unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
+ 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--) {
+ for (x=w; x > 0; x--) {
+ unsigned v;
+
+ v = srcPtr[0] << lShRed;
+ v |= (srcPtr[1] << lShGreen);
+ v |= (srcPtr[2] << lShBlue);
+# ifdef MSBFIRST
+ ((int *)dstPtr)[0] = v;
+# else
+ dstPtr[0] = (v>>24) & 0xFF;
+ dstPtr[1] = (v>>16) & 0xFF;
+ dstPtr[2] = (v>>8) & 0xFF;
+ dstPtr[3] = (v) & 0xFF;
+# endif
+ dstPtr += 4;
+ 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);
+# ifdef MSBFIRST
+ ((int *)dstPtr)[0] = v;
+# else
+ dstPtr[0] = (v>>24) & 0xFF;
+ dstPtr[1] = (v>>16) & 0xFF;
+ dstPtr[2] = (v>>8) & 0xFF;
+ dstPtr[3] = (v) & 0xFF;
+# endif
+ dstPtr += 4;
+ srcPtr += 3;
+ }
+ }
+ }
+ ok = true;
+ }
+%}.
+ ok ifFalse:[
+ "/ this fallback is only executed if type is not
+ "/ what the primitive expects; for example, if the bytes-instvar
+ "/ is not a ByteArray; or, if this class is autoload on non-compiling
+ "/ systems.
+
+ rightShiftR := rightShiftR negated.
+ rightShiftG := rightShiftG negated.
+ rightShiftB := rightShiftB negated.
+
+ destIndex := 1.
+ srcIndex := 1.
+
+ 0 to:height-1 do:[:y |
+ 0 to:width-1 do:[:x |
+ |r g b v|
+
+ r := bytes at:srcIndex.
+ g := bytes at:(srcIndex + 1).
+ b := bytes at:(srcIndex + 2).
+
+ r := r bitShift:rightShiftR.
+ g := g bitShift:rightShiftG.
+ b := b bitShift:rightShiftB.
+
+ v := r bitShift:shiftRed.
+ v := v bitOr:(g bitShift:shiftGreen).
+ v := v bitOr:(b bitShift:shiftBlue).
+
+ imageBits doubleWordAt:destIndex put:v MSB:true.
+ destIndex := destIndex + 4.
+ srcIndex := srcIndex + 3.
+ ]
+ ]
+ ]
+ ].
+ ]
+ ].
+
+ imageBits isNil ifTrue:[
+ 'IMAGE: unimplemented trueColor depth in rgbImageAsTrueColorFormOn:' errorPrintNL.
+ ^ self rgbImageAsMonoFormOn:aDevice
+ ].
+
+ form := Form width:width height:height depth:usedDeviceDepth on:aDevice.
+ form isNil ifTrue:[
+ 'IMAGE: display bitmap creation failed' errorPrintNL.
+ ^ nil
+ ].
+ form initGC.
+
+ form
+ copyBitsFrom:imageBits bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth
+ width:width height:height
+ x:0 y:0 toX:0 y:0.
+
+ ^ form
+
+ "Modified: 21.10.1995 / 19:30:11 / cg"
! !
!Depth24Image methodsFor:'magnification'!
--- a/Depth4Image.st Mon Oct 23 18:00:19 1995 +0100
+++ b/Depth4Image.st Tue Oct 24 18:09:00 1995 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.11 1995-03-18 05:10:32 claus Exp $
+$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.12 1995-10-24 17:08:30 cg Exp $
'!
!Depth4Image class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.11 1995-03-18 05:10:32 claus Exp $
+$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.12 1995-10-24 17:08:30 cg Exp $
"
!
@@ -61,6 +61,21 @@
^ 4
! !
+!Depth4Image ignoredMethodsFor:'queries'!
+
+bitsPerSample
+ "return the number of bits per sample.
+ The return value is an array of bits-per-plane."
+
+ ^ #(4)
+!
+
+samplesPerPixel
+ "return the number of samples per pixel in the image."
+
+ ^ 1
+! !
+
!Depth4Image methodsFor:'queries'!
bitsPerPixel
@@ -75,13 +90,6 @@
^ width * 4
!
-bitsPerSample
- "return the number of bits per sample.
- The return value is an array of bits-per-plane."
-
- ^ #(4)
-!
-
bytesPerRow
"return the number of bytes in one scanline of the image"
@@ -94,12 +102,6 @@
^ nbytes
!
-samplesPerPixel
- "return the number of samples per pixel in the image."
-
- ^ 1
-!
-
usedValues
"return a collection of color values used in the receiver."
--- a/Depth8Image.st Mon Oct 23 18:00:19 1995 +0100
+++ b/Depth8Image.st Tue Oct 24 18:09:00 1995 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.28 1995-09-07 12:29:01 claus Exp $
+$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.29 1995-10-24 17:08:33 cg Exp $
'!
!Depth8Image class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.28 1995-09-07 12:29:01 claus Exp $
+$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.29 1995-10-24 17:08:33 cg Exp $
"
!
@@ -60,6 +60,21 @@
^ 8
! !
+!Depth8Image ignoredMethodsFor:'queries'!
+
+bitsPerSample
+ "return the number of bits per sample.
+ The return value is an array of bits-per-plane."
+
+ ^ #(8)
+!
+
+samplesPerPixel
+ "return the number of samples per pixel in the image."
+
+ ^ 1
+! !
+
!Depth8Image methodsFor:'queries'!
bitsPerPixel
@@ -74,25 +89,12 @@
^ width * 8
!
-bitsPerSample
- "return the number of bits per sample.
- The return value is an array of bits-per-plane."
-
- ^ #(8)
-!
-
bytesPerRow
"return the number of bytes in one scanline of the image"
^ width
!
-samplesPerPixel
- "return the number of samples per pixel in the image."
-
- ^ 1
-!
-
usedValues
"return a collection of color values used in the receiver."
--- a/Image.st Mon Oct 23 18:00:19 1995 +0100
+++ b/Image.st Tue Oct 24 18:09:00 1995 +0100
@@ -29,7 +29,7 @@
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libview/Image.st,v 1.42 1995-10-23 16:59:09 cg Exp $
+$Header: /cvs/stx/stx/libview/Image.st,v 1.43 1995-10-24 17:09:00 cg Exp $
'!
!Image class methodsFor:'documentation'!
@@ -50,7 +50,7 @@
version
"
-$Header: /cvs/stx/stx/libview/Image.st,v 1.42 1995-10-23 16:59:09 cg Exp $
+$Header: /cvs/stx/stx/libview/Image.st,v 1.43 1995-10-24 17:09:00 cg Exp $
"
!
@@ -1864,237 +1864,18 @@
"return a truecolor form from the rgb-picture."
|bestFormat usedDeviceDepth usedDeviceBitsPerPixel depth
- myDepth form imageBits destIndex srcIndex
- rightShiftR rightShiftG rightShiftB shiftRed shiftGreen shiftBlue ok|
+ form|
bestFormat := self bestSupportedImageFormatFor:aDevice.
usedDeviceDepth := bestFormat at:1.
usedDeviceBitsPerPixel := bestFormat at:2.
- rightShiftR := (8 - aDevice bitsRed).
- rightShiftG := (8 - aDevice bitsGreen).
- rightShiftB := (8 - aDevice bitsBlue).
-
- shiftRed := aDevice shiftRed.
- shiftGreen := aDevice shiftGreen.
- shiftBlue := aDevice shiftBlue.
-
- myDepth := self bitsPerPixel.
- myDepth == usedDeviceBitsPerPixel ifTrue:[
- "/
- "/ first, the trivial case, where the depths match
- "/
- imageBits := bytes.
- ] ifFalse:[
- "/
- "/ for now, only a few formats are supported
- "/
- ((myDepth == 24) and:[usedDeviceBitsPerPixel == 16]) ifTrue:[
- imageBits := ByteArray uninitializedNew:(width * height * 2).
-
- "/ now, walk over the image and compose 16bit values from the r/g/b triples
-
- ok := false.
-%{
-#ifdef NOTDEF
- if (__isSmallInteger(_INST(height))
- && __isSmallInteger(_INST(width))
- && __isSmallInteger(rightShiftR)
- && __isSmallInteger(rightShiftG)
- && __isSmallInteger(rightShiftB)
- && __isSmallInteger(shiftRed)
- && __isSmallInteger(shiftGreen)
- && __isSmallInteger(shiftBlue)
- && __isByteArray(_INST(bytes))
- && __isByteArray(imageBits)) {
- int rShRed = __intVal(rightShiftR),
- rShGreen = __intVal(rightShiftG),
- rShBlue = __intVal(rightShiftB),
- lShRed = __intVal(shiftRed),
- lShGreen = __intVal(shiftGreen),
- lShBlue = __intVal(shiftBlue);
- int x, y;
-
- unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
- char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
-
- for (y=__intVal(_INST(height)); y > 0; y--) {
- for (x=__intVal(_INST(width)); 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
- ((short *)dstPtr)[0] = v;
-#else
- dstPtr[0] = (v>>8) & 0xFF;
- dstPtr[1] = (v) & 0xFF;
-#endif
- dstPtr += 2;
- srcPtr += 3;
- }
- }
- ok = true;
- }
-#endif
-%}.
- ok ifFalse:[
- "/ this fallback is only executed if type is not
- "/ what the primitive expects; for example, if the bytes-instvar
- "/ is not a ByteArray
-
- rightShiftR := rightShiftR negated.
- rightShiftG := rightShiftG negated.
- rightShiftB := rightShiftB negated.
-
- destIndex := 1.
- srcIndex := 1.
-
- 0 to:height-1 do:[:y |
- 0 to:width-1 do:[:x |
- |r g b v|
-
- r := bytes at:srcIndex.
- g := bytes at:(srcIndex + 1).
- b := bytes at:(srcIndex + 2).
-
- r := r bitShift:rightShiftR.
- g := g bitShift:rightShiftG.
- b := b bitShift:rightShiftB.
-
- v := r bitShift:shiftRed.
- v := v bitOr:(g bitShift:shiftGreen).
- v := v bitOr:(b bitShift:shiftBlue).
-
- imageBits wordAt:destIndex put:v MSB:true.
- destIndex := destIndex + 2.
- srcIndex := srcIndex + 3.
- ]
- ]
- ]
- ] ifFalse:[
- ((myDepth == 24) and:[usedDeviceBitsPerPixel == 32]) ifTrue:[
- imageBits := ByteArray uninitializedNew:(width * height * 4).
-
- "/ now, walk over the image and compose 32bit values from the r/g/b triples
-
- ok := false.
-%{
-#ifdef NOTDEF
- if (__isSmallInteger(_INST(height))
- && __isSmallInteger(_INST(width))
- && __isSmallInteger(rightShiftR)
- && __isSmallInteger(rightShiftG)
- && __isSmallInteger(rightShiftB)
- && __isSmallInteger(shiftRed)
- && __isSmallInteger(shiftGreen)
- && __isSmallInteger(shiftBlue)
- && __isByteArray(_INST(bytes))
- && __isByteArray(imageBits)) {
- int rShRed = __intVal(rightShiftR),
- rShGreen = __intVal(rightShiftG),
- rShBlue = __intVal(rightShiftB),
- lShRed = __intVal(shiftRed),
- lShGreen = __intVal(shiftGreen),
- lShBlue = __intVal(shiftBlue);
- int x, y;
-
- unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element;
- char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element;
-
- if ((rShRed == 0)
- && (rShGreen == 0)
- && (rShBlue == 0)) {
- for (y=__intVal(_INST(height)); y > 0; y--) {
- for (x=__intVal(_INST(width)); x > 0; x--) {
- unsigned v;
-
- v = srcPtr[0] << lShRed;
- v |= (srcPtr[1] << lShGreen);
- v |= (srcPtr[2] << lShBlue);
-#ifdef MSBFIRST
- ((int *)dstPtr)[0] = v;
-#else
- dstPtr[0] = (v>>24) & 0xFF;
- dstPtr[1] = (v>>16) & 0xFF;
- dstPtr[2] = (v>>8) & 0xFF;
- dstPtr[3] = (v) & 0xFF;
-#endif
- dstPtr += 4;
- srcPtr += 3;
- }
- }
- } else {
- for (y=__intVal(_INST(height)); y > 0; y--) {
- for (x=__intVal(_INST(width)); 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
- ((int *)dstPtr)[0] = v;
-#else
- dstPtr[0] = (v>>24) & 0xFF;
- dstPtr[1] = (v>>16) & 0xFF;
- dstPtr[2] = (v>>8) & 0xFF;
- dstPtr[3] = (v) & 0xFF;
-#endif
- dstPtr += 4;
- srcPtr += 3;
- }
- }
- }
- ok = true;
- }
-#endif
-%}.
- ok ifFalse:[
- "/ this fallback is only executed if type is not
- "/ what the primitive expects; for example, if the bytes-instvar
- "/ is not a ByteArray
-
- rightShiftR := rightShiftR negated.
- rightShiftG := rightShiftG negated.
- rightShiftB := rightShiftB negated.
-
- destIndex := 1.
- srcIndex := 1.
-
- 0 to:height-1 do:[:y |
- 0 to:width-1 do:[:x |
- |r g b v|
-
- r := bytes at:srcIndex.
- g := bytes at:(srcIndex + 1).
- b := bytes at:(srcIndex + 2).
-
- r := r bitShift:rightShiftR.
- g := g bitShift:rightShiftG.
- b := b bitShift:rightShiftB.
-
- v := r bitShift:shiftRed.
- v := v bitOr:(g bitShift:shiftGreen).
- v := v bitOr:(b bitShift:shiftBlue).
-
- imageBits doubleWordAt:destIndex put:v MSB:true.
- destIndex := destIndex + 4.
- srcIndex := srcIndex + 3.
- ]
- ]
- ]
- ].
- ]
- ].
-
- imageBits isNil ifTrue:[
+ "/
+ "/ only the trivial case, where the depths match
+ "/ is handled here; conversions are supposed to
+ "/ be done in concrete subclasses (see D24Image)
+ "/
+ self bitsPerPixel == usedDeviceBitsPerPixel ifFalse:[
'IMAGE: unimplemented trueColor depth in rgbImageAsTrueColorFormOn:' errorPrintNL.
^ self rgbImageAsMonoFormOn:aDevice
].
@@ -2107,13 +1888,12 @@
form initGC.
form
- copyBitsFrom:imageBits bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth
+ copyBitsFrom:bytes bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth
width:width height:height
x:0 y:0 toX:0 y:0.
^ form
- "Created: 21.10.1995 / 02:15:18 / cg"
"Modified: 21.10.1995 / 19:30:11 / cg"
! !
@@ -2204,7 +1984,8 @@
|depth myDepth nColors colorValues
scaleRed scaleGreen scaleBlue redShift greenShift blueShift
- form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel destIndex ok|
+ form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel
+ destIndex ok|
"/ this is a slow fallback method; this ought to be
"/ redefined in DepthxImage for more performance.
@@ -2265,26 +2046,26 @@
"/ colorMap indices by color values in the bits array
ok := false.
-%{
-#ifdef NOTDEF
- if (__isSmallInteger(_INST(height))
- && __isSmallInteger(_INST(width))
+
+%{ /* OPTIONAL */
+ if (__bothSmallInteger(_INST(height), _INST(width))
&& __isArray(colorValues)
&& __isByteArray(_INST(bytes))
&& (myDepth == __MKSMALLINT(8))
&& __isByteArray(imageBits)) {
- int x, y;
+ int x, y, w;
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=__intVal(_INST(width)); x > 0; x--) {
+ for (x=w; x > 0; x--) {
unsigned idx, v;
OBJ clr;
- idx = *srcPtr++;
+ idx = *srcPtr;
clr = ap[idx];
v = __intVal(clr);
#ifdef MSBFIRST
@@ -2294,16 +2075,16 @@
dstPtr[1] = (v) & 0xFF;
#endif
dstPtr += 2;
+ srcPtr += 1;
}
}
ok = true;
}
-#endif
%}.
ok ifFalse:[
"/ this fallback is only executed if type is not
- "/ what the primitive expects; for example, if the bytes-instvar
- "/ is not a ByteArray
+ "/ what the primitive expects (for example, if the bytes-instvar
+ "/ is not a ByteArray) or the source depth is not 8.
destIndex := 1.
0 to:height-1 do:[:y |
0 to:width-1 do:[:x |
@@ -2323,26 +2104,26 @@
"/ colorMap indices by color values in the bits array
ok := false.
-%{
-#ifdef NOTDEF
- if (__isSmallInteger(_INST(height))
- && __isSmallInteger(_INST(width))
+
+%{ /* OPTIONAL */
+ if (__bothSmallInteger(_INST(height), _INST(width))
&& __isArray(colorValues)
&& __isByteArray(_INST(bytes))
&& (myDepth == __MKSMALLINT(8))
&& __isByteArray(imageBits)) {
- int x, y;
+ int x, y, w;
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=__intVal(_INST(width)); x > 0; x--) {
+ for (x=w; x > 0; x--) {
unsigned idx, v;
OBJ clr;
- idx = *srcPtr++;
+ idx = *srcPtr;
clr = ap[idx];
v = __intVal(clr);
#ifdef MSBFIRST
@@ -2354,13 +2135,17 @@
dstPtr[3] = (v) & 0xFF;
#endif
dstPtr += 4;
+ srcPtr += 1;
}
}
ok = true;
}
-#endif
%}.
ok ifFalse:[
+ "/ this fallback is only executed if type is not
+ "/ what the primitive expects (for example, if the bytes-instvar
+ "/ is not a ByteArray) or the source depth is not 8.
+
destIndex := 1.
0 to:height-1 do:[:y |
0 to:width-1 do:[:x |