Bitmapdata blendmode和alpha

时间:2012-11-08 19:46:17

标签: actionscript-3 flash

在使用bitmapdata绘图时,是否仍然应用alpha和BlendMode.HardLight?

var processImageBmd:BitmapData=new BitmapData(900,900);
processImageBmd.draw(backgroundImage);  //backgroundImage is a sprite                               

processImageBmd.draw(frontImage,null,null,BlendMode.HARDLIGHT);//frontImage is a sprite

基本上我需要将alpha(假设alpha = 0.4)和BlendMode.HardLight应用于frontImage。我成功地将blendmode hardlight应用于正面图像,但无法弄清楚如何使其成为alpha。

2 个答案:

答案 0 :(得分:1)

是的,这是可能的。您必须传递ColorTransform,其中包含alphaMultiplier参数。

BitmapData.draw(IDrawable, Matrix, ColorTransform, BlendMode, ClipRect, smoothing)

答案 1 :(得分:1)

你应该能够通过传递给draw函数的colorTransfrom来做到这一点。

因此,对于您的场景,这应该可以解决问题:

var ct:ColorTransform = frontImage.transform.colorTransform; //copy the current colorTransform so you don't have to mess with colors
ct.alphaMultiplier = .4; //set it's alpha to .4;
processImageBmd.draw(frontImage,null,ct,BlendMode.HARDLIGHT); //pass your color transform to the draw command