Explanation of Android Code Camera Intent + Cropping Images

江枫思渺然 提交于 2019-11-29 08:42:32

NOTE : THE USE OF camera.putExtra("crop", "true"); IS NOT ADVISED... See Comments above for details... The aspect parts did however fix my issues !

            Intent camera=new Intent();

            /** This specifies the action for this intent when it is called. */
            camera.setAction(MediaStore.ACTION_IMAGE_CAPTURE);

            /** This says yes we can crop the image. */
            camera.putExtra("crop", "true");


            /** These provide the initial dimensions for X and Y. */
            camera.putExtra("outputX",600);
            camera.putExtra("outputY", 600);

            /** These provide the relative aspects. */
            camera.putExtra("aspectX", 1);
            camera.putExtra("aspectY", 1);


            /** These I am unsure about. */
            camera.putExtra("scale", true);
            camera.putExtra("return-data", false); 

so by setting the aspects to 0 instead of 1,

            /** These provide the relative aspects. */
            camera.putExtra("aspectX", 0);
            camera.putExtra("aspectY", 0);

They become independent of each other...

Problem solved !

FINAL CODE

            Intent camera=new Intent();
            camera.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
            camera.putExtra("crop", "true");
            camera.putExtra("outputX",600);
            camera.putExtra("outputY", 600);
            camera.putExtra("aspectX", 0);
            camera.putExtra("aspectY", 0);
            camera.putExtra("scale", true);
            camera.putExtra("return-data", false); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!