如何将位图文件加载到 BitmapData 对象中? [英] How do you load a bitmap file into a BitmapData object?
本文介绍了如何将位图文件加载到 BitmapData 对象中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Flash 中,BitmapData 对象可用于在 RAM 中存储位图,稍后您可以使用 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 代码也会有帮助.
Even AS3 code would be helpful.
推荐答案
加载 PNG 并获取"其位图数据的 AS3 代码
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屋!
查看全文