设置摄像头图像的大小,机器人 [英] Setting camera image size in Android

查看:297
本文介绍了设置摄像头图像的大小,机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我试图在我的摩托罗拉Droid手机设置我的相机采取符合我的屏幕(854×480像素)的规模形象,我试图通过参数来完成相机本身

At the moment I am attempting to set my camera on my Motorola Droid phone to take an image that matches the size of my screen (854 x 480 pixels), and I am attempting to accomplish via the parameters for the camera as such:

Camera.Parameters parameters = this.mCamera.getParameters();
Log.i(TAG, "CAMERA SIZE: (" + this.mCameraView.getWidth() + ", " + this.mCameraView.getHeight() + ")");
parameters.setPictureSize(this.mCameraView.getWidth(), this.mCameraView.getHeight());
this.mCamera.setParameters(parameters);
this.mCamera.takePicture(null, null, this);

我有我的活动实施onPictureTaken的Camera.PictureCallback方法(不包括日志调用),所以当takePicture方法被调用运行这个方法:

I have my activity implement the Camera.PictureCallback method of onPictureTaken (excluding log calls), so when the takePicture method is called it runs this method:

@Override
public void onPictureTaken(byte[] data, Camera camera) {
    Bitmap image = BitmapFactory.decodeByteArray(data, 0, data.length);
    //Size imageSize = camera.getParameters().getPictureSize();
    //image = Bitmap.createBitmap(image, 0, 0, imageSize.width, imageSize.height);
    this.mCameraView.setBackgroundDrawable(new BitmapDrawable(image));
}

由于种种原因,虽然,我的相机拍照,在1280 * 960这是某种形式的最小尺寸的相机可以捕捉图像?从日志调用我可以看到摄像头的参数仍然设定为具有854×480图像尺寸,但图像保持现身为1280 * 960。上午我的形象不正确解码,我会设置相机的参数不正确,或者是我做其他事情了?

For some reason though, my camera is taking pictures in 1280 x 960. Is this some sort of minimum size the camera can capture an image in? From log calls I can see that the Camera's parameters are still set to have a picture size of 854 x 480, but image keeps coming out as 1280 x 960. Am I decoding the image incorrectly, am I setting the camera's parameters incorrectly, or am I doing something else wrong?

在此先感谢您的帮助,你可以给!

Thanks in advance for any help you can give!

问候,celestialorb。

Regards, celestialorb.

推荐答案

是有大小不一的摄像头所提供的支持来获得图像的方法。 在paramters类相机,它提供了支持的图片大小的方法,通过相机getSupportedPictureSizes(); 使用这种方法,您可以通过相机获得支持的大小。 在code段是这样的: -

Yes there are methods provided to get the picture sizes supported by camera. The method the paramters class of camera which provides the supported picture sizes by camera is getSupportedPictureSizes(); Using this method, you can get the supported size by camera. The code snippet would look like this:-

Camera camera = Camera.open();
Parameters params = camera.getParameters();
List<Camera.Size> sizes = params.getSupportedPictureSizes();

我希望这会帮助你。

I hope this will help you.

谢谢 纳瓦布

这篇关于设置摄像头图像的大小,机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆