Size mismatch when getting BitmapData from Camera

Recently while trying to capture a frame from my webcam in Adobe Air, I realize the captured image is always smaller than the height or videoHeight from the Video object. The BitmapData documentation revealed that the BitmapData.draw() operation does not respect any matrix transformation applied on the Camera or Video object, so we need to do the scaling ourselves. A quick and dirty way would be:

 

//var video:Video; and a Camera object is already attached
var matrix:Matrix = new Matrix();
matrix.scale(video.width / 320, video.height / 240);
bitmapData.draw(video,matrix,null,null,null,true);

 

 

4 thoughts on “Size mismatch when getting BitmapData from Camera

  1. Tim J

    Thanks for this Ryan! I was bangin’ my head with a hammer. An alternate solution is to create the video object via code rather than dragging a video component on stage. This fixed this wacky scaling issue for me.

    Reply
  2. Pingback: AS3: BitmapData.draw with Video | put things down

Leave a Reply

Your email address will not be published. Required fields are marked *