Reputation: 47
I just implemented an image crop activity in my app according to this example http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/.
What I want to achieve is an image that is cropped to a square with the dimensions of the smaller dimension of the orginial image, e.g. an image 400 x 600 results in an cropped image 400 x 400.
Unfortunately, the rectangle that determines the cropped image size does not fill the image and stays unchanged regardless of the imput I set to Intent("com.android.camera.action.CROP")
.
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");
intent.setData(mImageCaptureUri);
intent.putExtra("outputX", widthHeight);
intent.putExtra("outputY", widthHeight);
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("noFaceDetection", true);
intent.putExtra("return-data", true);
I this due to the android emulator I use or how can I change that?
An a second question: Can anyone tell me if it is possible to style this Intent in some way?
Thanks a lot!!
Upvotes: 1
Views: 6901
Reputation: 19
cropIntent.putExtra("aspectX", 0); cropIntent.putExtra("aspectY", 1);
Upvotes: 0
Reputation: 156
You have to delete 4 lines only
(1)
intent.putExtra("outputX", widthHeight);
intent.putExtra("outputY", widthHeight);
(2)
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
it will crop rectangle
Upvotes: 1
Reputation: 133
aspect values are defining the dimensions scale(x/y). if you want free dimensions you should delete
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
values. or if you want new aspect sizes you can assign them new integers.
Upvotes: 6