在ActionScript 3调整大小的BitmapData大小、ActionScript、BitmapData

2023-09-09 21:55:14 作者:﹏嘴唇゛愛上煙

我使用的ActionScript 3.0 来捕捉图像,从用户的摄像头,它工作正常,但问题是,图像的大小是太大了,我喜欢。我可以把它小,我试过的位图数据的不断变化的坐标。 任何人都可以给我建议的解决方案。 谢谢

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

推荐答案

当你捕捉你必须提供一个矩阵的网络摄像头。这个矩阵可以处理重缩放。

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如果你是没事的平滑第一种方法。

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