开发者

Flex : Translate Embed Image into BitmapData?

开发者 https://www.devze.com 2023-03-14 05:45 出处:网络
I am looking for good, and hopefully for fast methood to turn an Embed Imag开发者_开发技巧e into BitmapData.
  • I am looking for good, and hopefully for fast methood to turn an Embed Imag开发者_开发技巧e into BitmapData.


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();
        }
    }
}


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.


just like this.

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

(or)

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

精彩评论

暂无评论...
验证码 换一张
取 消