复制的BitmapData从MX:图片 [英] Copy BitmapData From mx:Image

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

问题描述

我如何复制或从MX复制的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.

推荐答案

图片扩展的SWFLoader 具有< A HREF =htt​​p://livedocs.adobe.com/flex/3/langref/mx/controls/SWFLoader.html#content>内容属性将包含位图对象加载。等待图像加载,铸就内容为位图,并阅读其的位图数据

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:图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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