didhavn
didhavn

Reputation: 47

com.android.camera.action.CROP resize crop-rectangle

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

Example of the cropping rectangle that is NOT scaled to the maximum height

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

Answers (3)

prashant pol
prashant pol

Reputation: 19

cropIntent.putExtra("aspectX", 0); cropIntent.putExtra("aspectY", 1);

Upvotes: 0

Robokishan
Robokishan

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

KaanB
KaanB

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

Related Questions