--- a/Depth32Image.st Mon Aug 01 23:30:02 2016 +0100
+++ b/Depth32Image.st Fri Sep 02 17:42:18 2016 +0100
@@ -207,6 +207,8 @@
pixelAtX:x y:y
"retrieve a pixel at x/y; return a pixelValue.
+ The interpretation of the returned value depends on the photometric
+ and the colormap. See also Image>>atX:y:)
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/a in msb order (i.e. r at high, a at low bits)"
@@ -249,6 +251,8 @@
pixelAtX:x y:y put:aPixelValue
"set the pixel 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"
@@ -286,6 +290,26 @@
!Depth32Image methodsFor:'converting rgb images'!
+computeAlphaValuesFromMask:aMaskImage
+ "convert a mask into alpha values;
+ masked pixels get an alpha value of 0,
+ unmasked of 255"
+
+ |alphaMask|
+
+ alphaMask := self alphaMaskForPixelValue.
+ self valuesFromX:0 y:0
+ toX:width-1 y:height-1
+ do:[:x :y :pixelValue |
+ (aMaskImage pixelAtX:x y:y) ~~ 0 ifTrue:[
+ self pixelAtX:x y:y put:(pixelValue bitOr:alphaMask).
+ ] ifFalse:[
+ self pixelAtX:x y:y put:(pixelValue bitClear:alphaMask).
+ ].
+ ].
+ photometric := #rgba
+!
+
rgbImageAsTrueColorFormOn:aDevice
"return a truecolor form from the rgba or argb-picture."
@@ -781,7 +805,7 @@
^ self asMonochromeFormOn:aDevice
].
- form := Form width:width height:height depth:usedDeviceDepth onDevice:aDevice.
+ form := Form imageForm width:width height:height depth:usedDeviceDepth onDevice:aDevice.
form isNil ifTrue:[
'Depth32Image [warning]: display bitmap creation failed' errorPrintCR.
^ nil