Resizing BitmapData in ActionScript 3

吃可爱长大的小学妹 提交于 2019-12-25 08:09:33

问题


I am using ActionScript 3.0 to capture image from users webcam ,It is working fine , however the problem is that the size of image is too big for my liking . Can I make it small , I tried changing coordinates of Bitmap Data. Can anybody suggest me the solution. Thanks


回答1:


When you capture the webcam you have to provide a matrix. This matrix can handle a rescaling.

var output:BitmapData = new BitmapData(camera.width * scaleFactor, camera.height * scaleFactor, false);
var matrix:Matrix = new Matrix();
matrix.scale(scaleFactor, scaleFactor);
output.draw(camera, matrix, null, null, null, true);

Sometimes the smoothing of this method is not really satisfying. A solution would be to use an intermediate:

var capture:BitmapData = new BitmapData(camera.width, camera.height, false);
capture.draw(camera);
//or with a newer compiler
//camera.drawToBitmapData(capture);
var intermediate:Bitmap = new Bitmap(capture);
intermediate.scaleX = intermediate.scaleY = scaleFactor;
output.draw(intermediate);
capture.dispose();

Prefer the first method if you are okay with the smoothing.



来源:https://stackoverflow.com/questions/9888799/resizing-bitmapdata-in-actionscript-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!