Merge 2 transparent BitmapDatas
Sunday, September 2nd, 2007Maybe it’s just me, but I don’t know how to merge 2 transparent BitmapDatas. I know solution with draw() function, but I think, it should be possible with merge as well
Here is code:
import flash.geom.*;
var bd1:BitmapData = new BitmapData(100,100,true,0×00ff0000);
var bd2:BitmapData = new BitmapData(100,100,true,0×00ff0000);
bd1.fillRect(new Rectangle(30,30,30,30),0xffff0000)
bd2.fillRect(new Rectangle(60,60,30,30),0xff00ff00)
//this is not working
//bd1.merge(bd2, new Rectangle(0,0,100,100),new Point(0,0),0×00,0×00,0×00,0xff);
var b2:Bitmap = new Bitmap(bd2);
//this is working
bd1.draw(b2);
var b1:Bitmap = new Bitmap(bd1);
this.addChild(b1);
I think solution is correctly set up multipliers, I’ve tried few combinations, but I didn’t find combination to merge 2 transparent BitmapDatas.
tagged under:





1 Comments
Mario Klingemann
• Visit Site
September 3rd, 2007
The problem with merge is that you can just get a mix between the two maps but not their sum. When you mix both maps 50/50 you could boost the channels afterwards by 200% with a colorTransform:
bd1.merge(bd2, bd1.rect,new Point(0,0),0×80,0×80,0×80,0×80);
bd1.colorTransform( bd1.rect,new ColorTransform(2,2,2,2));
But I’m not sure if this will always give the same results like the draw() method.
Live Preview
Leave a comment