Flex : Translate Embed Image 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;
精彩评论