How to capture low resolution picture using android camera

大兔子大兔子 提交于 2020-01-02 07:25:23

问题


I want to capture photo and also save it to my sdcard using android camera.I know its easy but I want to store image in low resolution without telling user go to setting and set low resolution manually.


回答1:


What i am gonna write is not good practice to do code but it may full-fill your requirement

  • capture image as you do with normally using android default camera .
  • check the path of that image which just now captured .
  • reduce quality of that image as per requirement using BitmapFactory.Options calss and store in bitmap object
  • delete that original image which captured by default camera
  • save that bitmap object to SD Card where old image was located with same file name and path



回答2:


I know this is very late but this is for the people who might read this question now , you can use this following code :

 Camera.Parameters parameters = mcamera.getParameters();
        List<Camera.Size> sizes = parameters.getSupportedPictureSizes();
        Camera.Size size = sizes.get(sizes.size()-1);
        Log.d("Parth","Size : "+size.height+","+size.width);
        Log.d("Parth","Sizes:"+sizes.toString());
        parameters.setPictureSize(size.width,size.height);
        mcamera.setParameters(parameters);



回答3:


Implement a camera app by yourself. Use BitmapFactory to decode raw data. Via BitmapFactory.Options, you can set any resolution you want.




回答4:


Use this to capture image :

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.ACTION_IMAGE_CAPTURE, preinsertedUri);

Don't use MediaStore.EXTRA_OUTPUT because the image will be big size if you use EXTRA_OUTPUT



来源:https://stackoverflow.com/questions/18228365/how-to-capture-low-resolution-picture-using-android-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!