你如何加载位图文件到BitmapData对象? [英] How do you load a bitmap file into a BitmapData object?

查看:220
本文介绍了你如何加载位图文件到BitmapData对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在闪存中,<一个href="http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001944.html"相对=nofollow>的BitmapData 对象可以用来存储在RAM中的位图,则可以在以后使用它们画到MovieClip的<一个href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001895.html"相对=nofollow> beginBitmapFill()方法。

In Flash, the BitmapData object can be used to store bitmaps in RAM, you can later draw them to a MovieClip using the beginBitmapFill() method.

你如何加载外部的位图文件(.JPG)到BitmapData对象?

How do you load an external bitmap file (.jpg) into a BitmapData object?

即使AS3 code将是有益的。

Even AS3 code would be helpful.

推荐答案

AS3 code加载PNG和搞定它的位图数据。

AS3 code to load a PNG and "get" its bitmapData

var bitmapData:BitmapData;

var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    loader.load(new URLRequest("../lib/img.png"));

function onComplete (event:Event):void
{
    bitmapData = Bitmap(LoaderInfo(event.target).content).bitmapData;
}

这篇关于你如何加载位图文件到BitmapData对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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