--- a/Depth24Image.st Tue Aug 30 15:22:46 2016 +0200
+++ b/Depth24Image.st Tue Aug 30 16:05:29 2016 +0200
@@ -111,7 +111,7 @@
!
pixelAtX:x y:y
- "retrieve a pixel at x/y; return a color.
+ "retrieve a pixel at x/y; return a pixel value.
Pixels start at x=0 , y=0 for upper left pixel, end at
x = width-1, y=height-1 for lower right pixel.
The pixel value contains r/g/b in msb order (i.e. r at high, b at low bits)"
@@ -153,12 +153,35 @@
pixelAtX:x y:y put:aPixelValue
"set a pixel at x/y to aPixelValue, which is 24 bits RGB.
+ 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"
|index "{ Class: SmallInteger }"
- val "{ Class: SmallInteger }" |
-
+ val "{ Class: SmallInteger }"|
+
+%{ /* NOCONTEXT */
+ OBJ b = __INST(bytes);
+ OBJ w = __INST(width);
+
+ if (__isByteArrayLike(b)
+ && __bothSmallInteger(x, y)
+ && __bothSmallInteger(w, aPixelValue)
+ && (__INST(pixelFunction)==nil) ) {
+ int _idx;
+
+ _idx = ((__intVal(w) * __intVal(y)) + __intVal(x))*3;
+ if (((unsigned)(_idx+2)) < __byteArraySize(b)) {
+ unsigned char *pPix = &(__ByteArrayInstPtr(b)->ba_element[_idx]);
+ unsigned int _pix = __intVal(aPixelValue);
+ pPix[0] = (_pix>>16) & 0xFF;
+ pPix[1] = (_pix>>8) & 0xFF;
+ pPix[2] = (_pix) & 0xFF;
+ RETURN( self );
+ }
+ }
+%}.
index := 1 + (((width * y) + x) * 3).
val := aPixelValue.
bytes at:(index + 2) put:(val bitAnd:16rFF).
@@ -166,8 +189,6 @@
bytes at:(index + 1) put:(val bitAnd:16rFF).
val := val bitShift:-8.
bytes at:(index) put:val.
-
- "Created: 24.4.1997 / 17:06:33 / cg"
!
rgbValueAtX:x y:y