AS3的BitmapData到的字节数组 [英] AS3 BitmapData to byteArray

查看:133
本文介绍了AS3的BitmapData到的字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想序列化的位图存储在XML文件中。我的计划是把的BitmapData成字节数组,但我一直没能罚这样的一个例子。

I am trying to serialize a Bitmap to store in an XML file. My plan is to turn the BitmapData into a byteArray, but I haven't been able to fine an example of this.

其他建议也欢迎。

推荐答案

这个过程应该是:的BitmapData>的ByteArray>的Base64> XML

The process should be: BitmapData > ByteArray > Base64 > XML

使用BitmapData的getPixels()方法来获得像素的ByteArray。

Use the BitmapData getPixels() method to get a ByteArray of the pixels.

然后你可以使用像<一个href="http://$c$c.google.com/p/as3crypto/source/browse/trunk/as3crypto/src/com/hurlant/util/Base64.as"相对=nofollow> Hurlant的Base64的 EN codeR将其转换为基础64。

Then you can use something like Hurlant's Base64 encoder to convert it to base 64.

然后走另一条路,unbase64,然后使用的BitmapData的的setPixels加载它。

Then going the other way, "unbase64" it, then use BitmapData's setPixels to load it.

这篇关于AS3的BitmapData到的字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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