#FEATURE by cg
class: Depth32Image
added: #computeAlphaValuesFromMask:
converting masks to an alpha value
--- a/Depth32Image.st Tue Aug 02 10:23:14 2016 +0200
+++ b/Depth32Image.st Mon Aug 08 14:06:35 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
@@ -218,6 +220,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."