FlashのWebCamからキャプチャした静止画を保存します
質問
フラッシュのWebカメラのビデオをプレビューするのに十分なコードを書きました。
今、私は10秒間隔で画像を撮りたいです。
これが私のコードです:
import flash.display.BitmapData
import flash.geom.Matrix
import com.adobe.images.JPGEncoder;
import flash.net.FileReference;
//get the default camera
//change your Default camera using the Flash Player Settings.
cam=Camera.get()
//this event is called whenever permission to access the local camera, is accepted or denied by the user
cam.onStatus=function(e)
{
//if we are given permission
if(e.code == "Camera.Unmuted")
{
//start the application
initialize()
}
else
{
System.showSettings(3)
}
}
var snapshot:BitmapData=new BitmapData(cam._width,cam._height);
function takeSnapshot()
{
snapshot.draw(cam,new Matrix());
}
//if there are no Cameras
if(cam == null)
{
System.showSettings(3)
}
else
{
cam.setMode(1024, 768, 30);
cam.setQuality(10000,0);
output.attachVideo(cam);
setInterval(this,"takeSnapshot",1000);
}
.
助けをお願いしますか?
私はトータルフラッシュニュービーです。
ありがとう、 Rishi。
解決
セキュリティ上の理由から、ファイルを自動的に行うことができない場合は、セキュリティ上の理由から、特定のユーザーアクションの後にのみ使用できます。ムーズタウンと私はキープレスを推測します)。BitMapDataが入ったら、 http://code.google.com/からJPEGエンコーダが必要です。P / AS3CORELIB / IMGをエンコードしてディスクに保存します。このようなもの:
var fileBrowser:FileReference = new FileReference();
var bd:BitmapData = new BitmapData(imageContainer.width, imageContainer.height, false, 0xFFFFFF);
bd.draw(imageContainer);
var encoder:JPGEncoder = new JPGEncoder(35);
var bytes:ByteArray = encoder.encode(bd);
fileBrowser.save(bytes);
.
ここでのFileReference Docを見てみましょう http://help.adobe.com/en_us/as3lcr/flash_10.0/flash/net/fileReference.html あなたはそれを使って他にできることを見ます。
所属していません StackOverflow