cel*_*orb 9 parameters camera android image
目前我正在尝试将我的相机设置在我的摩托罗拉Droid手机上以拍摄与我的屏幕尺寸相匹配的图像(854 x 480像素),并且我试图通过相机的参数来完成:
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);
Run Code Online (Sandbox Code Playgroud)
我的活动实现了onPictureTaken的Camera.PictureCallback方法(不包括日志调用),因此当调用takePicture方法时,它运行此方法:
@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));
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我的相机正在拍摄1280 x 960的照片.这是相机可以拍摄图像的某种最小尺寸吗?从日志调用我可以看到相机的参数仍然设置为854 x 480的图片大小,但图像保持为1280 x 960.我是否正确解码图像,我是否正确设置了相机的参数,或者我我做错了什么?
在此先感谢您提供任何帮助!
此致,celestialorb.
naw*_*wab 20
是的,提供了一些方法来获取相机支持的图片尺寸.通过摄像机提供支持的图像大小的参数类型的方法是getSupportedPictureSizes(); 使用此方法,您可以通过相机获得支持的大小.代码段如下所示: -
Camera camera = Camera.open();
Parameters params = camera.getParameters();
List<Camera.Size> sizes = params.getSupportedPictureSizes();
Run Code Online (Sandbox Code Playgroud)
我希望这能帮到您.
谢谢Nawab
| 归档时间: |
|
| 查看次数: |
25879 次 |
| 最近记录: |