我认真地到处寻找,但找不到解决方案.我的应用程序可以轻松地将UTF字节作为XML文件保存在iOS和Android的允许缓存位置中.
但我无法弄清楚如何将Bitmap/BitmapData保存到同一缓存文件夹中的文件.创建文件很好....
_fs.open(_f, FileMode.WRITE);
//What goes in here to save the Bitmap?
_fs.close();
Run Code Online (Sandbox Code Playgroud)
任何有关这方面的帮助将不胜感激.
谢谢
更新:代码如下......
_smallLogo = Bitmap(_loader.content);
//this.addChild(_smallLogo);
var jpg:JPGEncoder = new JPGEncoder(100);
var bd:BitmapData = new BitmapData(_smallLogo.width, _smallLogo.height);
bd.draw(_smallLogo);
var ba:ByteArray = jpg.encode(bd);
//3
_fs.open(_f, FileMode.WRITE);
_fs.writeBytes( ba, 0, ba.length );
_fs.close();
Run Code Online (Sandbox Code Playgroud)
更新 - 答案
//SAVE
_smallLogo = Bitmap(_loader.content);
var jpg:JPGEncoder = new JPGEncoder(100);
var ba:ByteArray = jpg.encode(_smallLogo.bitmapData);
_fs.open(_f, FileMode.WRITE);
_fs.writeBytes( ba, 0, ba.length );
_fs.close();
Run Code Online (Sandbox Code Playgroud)
//OPEN
private function getLogo():void {
var ba:ByteArray = new ByteArray();
_fs.open(_f, …Run Code Online (Sandbox Code Playgroud)