It was a while since I programmed AS3. Now I have a problem where I need to merge the two images where the upper image is a png that must retain its transparency. The upper image is an area that must pass through the lower image. A bit like a masked layer.
The result of this merge should result in a a display object. This object will later be sent to a method with the following signature:
public function addImage ( display_object:DisplayObject, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, image_format:String = "PNG", quality:Number = 100, alpha:Number = 1, resizeMode:String = "None", blendMode:String = "Normal", keep_transformation:Boolean = true, link:String = '' ):void
Any advice is of the utmost interest. Thanks!
After some struggling I've come up with this:
var bitmapDataBuffer:BitmapData = new BitmapData ( front.loader.width, front.loader.height, true ); bitmapDataBuffer.draw ( front.loader ); var bitmapOverlay:BitmapData = new BitmapData ( front.loader.width, front.loader.height, true ); bitmapOverlay.draw ( frontBanner.loader ); var rect:Rectangle = new Rectangle(0, 0, front.loader.width, front.loader.height); var pt:Point = new Point(0, 0); var mult:uint = 0x00; bitmapOverlay.merge(bitmapDataBuffer, rect, pt, mult, mult, mult, mult); var bmp:Bitmap = new Bitmap(bitmapOverlay); pdf.addImage(bmp,0,0,0,0,ImageFormat.PNG,100,1,ResizeMode.FIT_TO_PAGE);
The problem is that my background image (represented by bitmapDataBuffer) will be totally overwritten by my upper image (the one I call overlay).
The overlay image is a png image. This image has a part of it that is transparent. Through this transparency I want to see my background image.
Any more suggestions?