Air保存图片示例

ContractedBlock.gif ExpandedBlockStart.gif as3
import flash.display.BitmapData;
import flash.utils.ByteArray;
import flash.filesystem.
*;

import com.adobe.images.JPGEncoder;


var bmpd:BitmapData 
= new BitmapData(mc.width,mc.height);
bmpd.draw(mc);


//create a new instance of the encoder, and set the jpeg compression level from 0 to 100
var jpgenc:JPGEncoder = new JPGEncoder(80);
//encode the bitmapdata object and keep the encoded ByteArray
var imgByteArray:ByteArray = jpgenc.encode(bmpd);

var file:File 
= File.desktopDirectory.resolvePath("snapshot.jpg");
//Use a FileStream to save the bytearray as bytes to the new file
var fs:FileStream = new FileStream();
try{
//open file in write mode
fs.open(file,FileMode.WRITE);
//write bytes from the byte array
fs.writeBytes(imgByteArray);
//close the file
fs.close();
}
catch(e:Error){
trace(e.message);
}

 

使用说明:

 此代码是用flash cs4开发的air的代码.mc 为舞台上的一个影片剪辑.

JPGEncoder是Adobe的一个as3工具类,用于将可视化元件编码为Jpg图像,可以在google或baidu中搜索下载到

windows下运行Air此图片自动保存到桌面

 

转载于:https://www.cnblogs.com/vilyLei/articles/1519207.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值