--- a/Depth1Image.st Tue Aug 30 16:07:42 2016 +0200
+++ b/Depth1Image.st Tue Aug 30 16:08:07 2016 +0200
@@ -69,7 +69,7 @@
!Depth1Image methodsFor:'accessing-pixels'!
pixelAtX:x y:y
- "retrieve a pixelValue at x/y; return a number.
+ "retrieve a pixelValue at x/y; return a pixel value.
The interpretation of the returned value depends on the photometric
and the colormap. See also Image>>atX:y:)
Pixels start at 0@0 for upper left pixel, end at
@@ -118,6 +118,8 @@
pixelAtX:x y:y put:aPixelValue
"set a pixels value at x/y to aPixelValue.
+ The interpretation of the pixelValue depends on the photometric
+ and the colormap. (see also: Image>>atX:y:put:)
Pixels start at x=0 , y=0 for upper left pixel, end at
x = width-1, y=height-1 for lower right pixel"
@@ -131,20 +133,20 @@
OBJ w = __INST(width);
if (__isByteArray(b) && __bothSmallInteger(x, y) && __isSmallInteger(w) ) {
- int _w = __intVal(w);
- int _y = __intVal(y);
- int _x = __intVal(x);
- int _idx;
+ int _w = __intVal(w);
+ int _y = __intVal(y);
+ int _x = __intVal(x);
+ int _idx;
- _idx = ((_w + 7) >> 3) * _y + (_x >> 3);
- if ((unsigned)_idx < __byteArraySize(b)) {
- if (aPixelValue == __MKSMALLINT(0)) {
- __ByteArrayInstPtr(b)->ba_element[_idx] &= ~(0x80 >> (_x & 7));
- } else {
- __ByteArrayInstPtr(b)->ba_element[_idx] |= (0x80 >> (_x & 7));
- }
- RETURN( self );
- }
+ _idx = ((_w + 7) >> 3) * _y + (_x >> 3);
+ if ((unsigned)_idx < __byteArraySize(b)) {
+ if (aPixelValue == __MKSMALLINT(0)) {
+ __ByteArrayInstPtr(b)->ba_element[_idx] &= ~(0x80 >> (_x & 7));
+ } else {
+ __ByteArrayInstPtr(b)->ba_element[_idx] |= (0x80 >> (_x & 7));
+ }
+ RETURN( self );
+ }
}
%}.
"fall back code for nonByteArray or nonInteger arguments"
@@ -155,9 +157,9 @@
byte := bytes at:index.
mask := #(16r80 16r40 16r20 16r10 16r08 16r04 16r02 16r01) at:((x \\ 8) + 1).
aPixelValue == 0 ifTrue:[
- byte := byte bitAnd:(mask bitInvert)
+ byte := byte bitAnd:(mask bitInvert)
] ifFalse:[
- byte := byte bitOr:mask
+ byte := byte bitOr:mask
].
bytes at:index put:byte
! !