直接上实现代码代码
import com.adobe.images.PNGEncoder;
import flash.net.FileReference;
import flash.geom.Matrix;
import flash.display.BitmapData;
public function onCapture():*
{
var m:Matrix;
trace("onCapture-Width:"+this.video.width+",Height:"+this.video.height+",Video Width:"+this.video.videoWidth+",Video Height:"+this.video.videoHeight);
try
{
//固定了截图尺寸,不知道为什么无法根据this.video.videoWidth, this.video.videoHeight截图
//var bmpd:* = new BitmapData(352, 288);
//var bmpd:* = new BitmapData(704, 576);
var bmpd = new flash.display.BitmapData(this.video.videoWidth, this.video.videoHeight);
m = new Matrix(video.videoWidth/320,0,0,video.videoHeight/240);
bmpd.draw(this.video,m,null,null,null,true);
}
catch (e:Error)
{
//ExternalInterface.call("onVideoMsg", "" + 0 + "", "PicSave-error" + e.message);
return;
}
var imgByteArray:* = PNGEncoder.encode(bmpd);
var FileRefe:* = new FileReference();
var date:* = new Date();
var info:*;
var s:* = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + "-" + date.getMinutes() + "-" + date.getSeconds() + ".png";
FileRefe.save(imgByteArray, s);
return;
}