当谈到 Flash 时,我几乎是最菜鸟的菜鸟。
这是动作脚本(3):
// Here's the dumb-dumb:
/*****************************************************************/
/*****************************************************************/
function captureImage(e:MouseEvent):void {
// The video still-image is captured and drawn...but at 320x240? Oh, and the real kicker is that it gets squeezed (resized), not cropped.
bitmapData.draw(video);
}
/*****************************************************************/
/*****************************************************************/
// Here's the other relevant code...
/*****************************************************************/
var bandwidth:int = 0;
var quality:int = 100;
var myWidth:int = 320; // the width for camera, video, and bitmaps.
var myHeight:int = 320; // the height for camera, video, and bitmaps.
var cam:Camera = Camera.getCamera();
cam.setQuality(bandwidth, quality);
cam.setMode(myWidth,myHeight,30,false); // (width, height, FPS, favorSize)
var video:Video = new Video();
video.attachCamera(cam);
video.x = 20;
video.y = 20;
// setting the video.width and video.height here makes the video appear in the desired aspect-ratio (1:1). If this is not set it defaults to 320x240.
video.width = myWidth;
video.height = myHeight;
addChild(video);
// 0xff0000 sets a red background just so I can see that the BitmapData "element" is 320x320 like it should be.
var bitmapData:BitmapData = new BitmapData(myWidth, myHeight, false, 0xff0000);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 360;
bitmap.y = 20;
bitmap.width=myWidth;
bitmap.height=myHeight;
addChild(bitmap);
// capture_mc is my take-a-picture button. :-)
capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
那么,我在这里缺少什么。我知道 Flash 的制造商并不坚持所有图像都应该以 4:3 的纵横比显示,对吧?:o)
无论如何,感谢您帮助“n00b”。
ps Flash 使用 Ctrl+Y 来“重做”而不是 Ctrl+Shift+Z(如 Photoshop)的事实让我想要flash.events.destroy(flash)
, 或其他东西。
更新:
我想出了如何将视频从 240 拉伸到 320。但是这样做会显着降低质量。这是带有BOLD更新部分的代码:
var bitmapData:BitmapData = new BitmapData(myWidth,
240
, false, 0xff0000);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 360;
bitmap.y = 20;
bitmap.width=myWidth;
bitmap.height=240;
bitmap.scaleY=1.333; // ADDED scaleY
addChild(bitmap);
所以我仍然想找到一个最大限度地提高质量的解决方案。