Android:以低画质拍照 [英] Android: Taking picture with low quality

查看:189
本文介绍了Android:以低画质拍照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个项目,允许用户拍照并查看.拍摄,查看,保存和检索照片时,我没有任何问题.但是我的问题是相机拍摄的图像质量不好,我不知道如何设置相机Intent的质量.这是我的代码.

I created a project that allow user to take a picture and view it. I have no face any issue while taking, view, save and retrieve the photo. But my problem is the image that camera took is in bad quality, I don't know how to set the quality of the camera Intent. Here is my code looks like.

....
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(cameraIntent, CAMERA_REQUEST);
....

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
            Bitmap userPhoto = (Bitmap) data.getExtras().get("data");
            iv_user.setImageBitmap(userPhoto);
        }
    }

这是相机开机时的屏幕截图.

Here is a screenshot of while camera is on.

在捕获图像之后,这里处于预览相机模式.

And here is in preview camera mode after the image is captured.

如果比较这两张照片,我们可以看到预览模式下的图像是模糊的.

If we compare these two photos, we can see the image in preview mode is blur.

推荐答案

Android相机应用程序将照片编码在传递给onActivityResult()的返回Intent中,作为附加项中的小位图(我们称为缩略图),在键下数据".

The Android Camera application encodes the photo in the return Intent delivered to onActivityResult() as a small Bitmap (we call it thumbnail) in the extras, under the key "data".

如果要检索完整尺寸的图像,则您的应用程序首先需要将图像存储到外部存储中,然后再读回.您可以通过

If you want to retrive full size image your app first need to store image to external storage and then read it back. You can access full code at

https://developer.android.com/training/camera/photobasics

这篇关于Android:以低画质拍照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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