Yordan Yanakiev
Yordan Yanakiev

Reputation: 2604

Flex : Translate Embed Image into BitmapData?

Upvotes: 1

Views: 6252

Answers (3)

Rajkamal
Rajkamal

Reputation: 425

just like this.

 var imgBitmap:BitmapAsset = new EmbedImage();
 var bitmapData:BitmapData = imgBitmap.bitmapData;

(or)

var bmd1:BitmapData = new EmbedImage().bitmapData;

Upvotes: 1

alxx
alxx

Reputation: 9897

Is your embedded image raster or vector? Raster becomes BitmapAsset, just instantiate and get bitmapData from it. If vector movieclip, instantiate it, then render with BitmapData.draw.

Upvotes: 2

Mattias
Mattias

Reputation: 3907

If you embedded the image you could use the reference to Bitmap.bitmapdata.

package
{
    import flash.display.Bitmap;
    import flash.display.Sprite;

    public class Main extends Sprite
    {

        [Embed(source="assets/image.png")]
        private var embeddedImage : Class;


        public function Main()
        {
            var image : Bitmap = new embeddedImage();
            //addChild(image);

            // reference
            var bitmapData : BitmapData = image.bitmapData.clone();
        }
    }
}

Upvotes: 4

Related Questions