复制BitmapData从mx:Image [英] Copy BitmapData From mx:Image
问题描述
如何从mx:image组件复制或复制bitmapdata?
How can I copy or duplicate the bitmapdata from a mx:image component?
我需要在我的应用程序的多个屏幕中显示相同的图像,想要多次下载图片。
I need to display the same image in multiple screens of my application and don't want to have to download the image multiple times.
我可以使用urlrequest将图片下载为位图并复制,但我喜欢的方式,你可以只是设置图像组件的来源。
I could just use a urlrequest to download the image as a bitmap and copy that but I like the way you can can just set the source of the image component.
推荐答案
图像
c $ c> SWFLoader 其中包含内容属性,其将包含已加载的 Bitmap
对象。等待图片加载,将内容转换为Bitmap并读取其 bitmapData
Image
extends SWFLoader
which has a content property that will contain the Bitmap
object that was loaded. Wait for the image to load, cast the content to Bitmap and read its bitmapData
public function imageLoadCompleteHandler(e:Event):void
{
var bitmap:Bitmap = img.content as Bitmap;
if(bitmap == null) {
trace("loaded content is not an image");
return;
}
bmpData = bitmap.bitmapData;
//hurray..!
}
这篇关于复制BitmapData从mx:Image的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!