在android中以编程方式更改相机分辨率设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11009347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change camera resolution setting programmatically in android
提问by SANDHYA
I'm using the below code to open the camera. Is it possible to set the camera resolution to high programmatically?
我正在使用以下代码打开相机。是否可以以编程方式将相机分辨率设置为高?
private void openDefaultCameraApp() {
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, CAPTURE_PHOTO_CONSTANT);
}
采纳答案by Zaid Daghestani
You must add an MediaStore.EXTRA_OUTPUT
to the intent. In the extra, you have to specify a Uri for the picture to be saved to. This will save the full resolution image, otherwise, it will just snap a small image.
您必须MediaStore.EXTRA_OUTPUT
向意图添加。此外,您必须为要保存的图片指定一个 Uri。这将保存全分辨率图像,否则,它只会捕捉一个小图像。
Refer to the Android docs: ACTION_IMAGE_CAPTURE
请参阅 Android 文档:ACTION_IMAGE_CAPTURE
Standard Intent action that can be sent to have the camera application capture an image and return it.
The caller may pass an extra EXTRA_OUTPUT
to control where this image will be written. If the EXTRA_OUTPUT
is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT
is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT
可以发送的标准意图操作让相机应用程序捕获图像并返回它。调用者可以传递一个额外的参数EXTRA_OUTPUT
来控制这个图像的写入位置。如果EXTRA_OUTPUT
不存在,则在额外字段中将小尺寸图像作为位图对象返回。这对于只需要小图像的应用程序很有用。如果EXTRA_OUTPUT
存在,则全尺寸图像将被写入到的 Uri 值EXTRA_OUTPUT
回答by Vipul Purohit
I think its not possible see the link below :
我认为这是不可能的,请参阅下面的链接:
Open Android Camera in lower resolution with ACTION_IMAGE_CAPTURE
使用 ACTION_IMAGE_CAPTURE 以较低分辨率打开 Android 相机
You have to manually set the resolution from camera preview screen.
您必须从相机预览屏幕手动设置分辨率。
If you are getting small snap even if your camera resolution is set to high then use Zed Scio's approach.
如果即使您的相机分辨率设置为高,您的照片也会变小,那么请使用 Zed Scio 的方法。
回答by Kazekage Gaara
You can use thismethod to get all supported sizes of pictures.
您可以使用此方法获取所有支持的图片尺寸。
public List<Camera.Size> getSupportedPictureSizes ()
You will get a List
of supported Picture Sizes. And then from this, you can set whichever size you want to using thismethod.
您将获得List
支持的图片尺寸。然后从中,您可以使用此方法设置您想要的任何大小。
public void setPictureSize (int width, int height)