从 mx:Image 复制 BitmapData [英] Copy BitmapData From mx:Image

查看:24
本文介绍了从 mx:Image 复制 BitmapData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 mx:image 组件复制或复制位图数据?

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.

推荐答案

Image 扩展了 SWFLoader,其中包含一个 content 属性,它将包含加载的 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..!
}

这篇关于从 mx:Image 复制 BitmapData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆