當談到Flash時,我幾乎是最出色的菜鳥。Flash:BitmapData.draw(視頻)忽略視頻高度
這裏的動作(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」。
p.s. Flash使用Ctrl + Y「重做」而不是Ctrl + Shift + Z(如Photoshop)這一事實讓我想要flash.events.destroy(flash)
,或者其他東西。
UPDATE:
我想通了,如何從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);
所以我還是想找到最大化質量的解決方案。
感謝。它看起來像'videoHeight'和'videoWidth'是隻讀的。此外,視頻DisplayObject以正確的寬高比(320x320或1:1)顯示實況網絡攝像頭視頻。它只是當我捕捉它仍然擠壓圖像到320x240。 – 2010-03-04 16:29:43
從技術上講,Ctrl + Shift + Z撤銷撤銷。 :-) – 2010-03-04 16:30:02