# HG changeset patch # User Claus Gittinger # Date 1470657995 -7200 # Node ID 34cfdad0060348e2c43e03c424b74822699955bc # Parent 72af47b8a56a78d2d73ba1411cb2649285eb0c01 #FEATURE by cg class: Depth32Image added: #computeAlphaValuesFromMask: converting masks to an alpha value diff -r 72af47b8a56a -r 34cfdad00603 Depth32Image.st --- 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."