Android的code相机意向+ Croping图片说明 [英] Explanation of Android Code Camera Intent + Croping Images

查看:142
本文介绍了Android的code相机意向+ Croping图片说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在想拍照,裁剪并保存图像中的Andr​​oid应用程序,我用下面的意图在我的Java ...

When wanting to take a photo, crop and save the image in an Android application, I use the following intent in my Java...

            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", 1);
            camera.putExtra("aspectY", 1);
            camera.putExtra("scale", true);
            camera.putExtra("return-data", false); 

以上意向的伟大工程,但是我的Y和X总是相等的。我期待打破code找出指定,这样我可以定制的 - 最重要的独立 - X和我所拍摄的图像Y值和要剪裁...

The above intent works great, however my Y and X are always equal. I am looking to break down the code to find out what specifies this so that I can make customisable - and most importantly independent - X and Y values for the image which I have taken and wish to crop...

推荐答案

注:由于使用camera.putExtra(裁剪,真); 不建议... 查看评论上面的内容......纵横部分然而没有解决我的问题!

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); 

这样的方面设置为0而不是1,

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

它们成为彼此独立...

They become independent of each other...

问题解决了!

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); 

这篇关于Android的code相机意向+ Croping图片说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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