小编ato*_*oid的帖子

AS3/AIR/Mobile - 将位图保存到文件

我认真地到处寻找,但找不到解决方案.我的应用程序可以轻松地将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)

image bitmap actionscript-3 bitmapdata

5
推荐指数
1
解决办法
6384
查看次数

标签 统计

actionscript-3 ×1

bitmap ×1

bitmapdata ×1

image ×1