我正在使用以下代码从网络摄像头获取图像。我面临的问题是我需要将“位图”适合 mcVideo。我不能只做 mcVideo.addChild(bitmap),因为位图比 mcVideo 大。如何将位图放入 mcVideo 以进行预览?
谢谢!
var bandwidth:int = 0;
var quality:int = 100;
var cam:Camera;
var video:Video;
var captureVideo:Video;
var bitmapData:BitmapData;
var bitmap:Bitmap;
public function Main() {
mcCapture.addEventListener(MouseEvent.CLICK, mcCapture_Click);
cam = Camera.getCamera();
cam.setQuality(bandwidth, quality);
cam.setMode(640,480,30,false);
// The display object:
video = new Video();
video.attachCamera(cam);
video.width = mcVideo.width;
video.height = mcVideo.height;
mcVideo.addChild(video);
// Bitmap to capture full 640x480
bitmapData = new BitmapData(cam.width, cam.height);
bitmap = new Bitmap(bitmapData);
bitmap.width = cam.width;
bitmap.height = cam.height;
trace("Set bitmap width: " + bitmap.width + " Height: " + bitmap.height);
}
public function mcCapture_Click(e:Event):void {
bitmapData.draw(video);
// Code to display preview
trace("done");
}