Android Code Camera意图+裁剪图像的说明 [英] Explanation of Android Code Camera Intent + Cropping Images
问题描述
当想要拍照,裁剪并将图像保存在Android应用程序中时,我在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始终相等.我希望对代码进行分解,以找出指定此内容的内容,以便我可以为自己拍摄并希望裁剪的图像设置可自定义的-最重要的是独立的-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("crop", "true");
... 有关详细信息,请参见上面的注释...方面部分做了但是解决我的问题!
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...
问题解决了!
最终代码
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 Camera意图+裁剪图像的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!