Henry Sou
Henry Sou

Reputation: 882

Fail to crop for large images

My application needs to open the gallery and pick an image to crop. I set the target size as a value(87%*screenWide). Now, problems occur. In large screen devices, the gallery failed to return the cropped image and the log said "!!! FAILED BINDER TRANSACTION !!!". In most of the devices, it is OK.

Can any one help me for this? Thanks!

I use Intent.ACTION_GET_CONTENT to crop, and set the outputX, outputY etc. It's routine to crop images.

Upvotes: 4

Views: 3971

Answers (3)

Arik Halperin
Arik Halperin

Reputation: 458

Try sending the intent as below:

mSavedUri = Uri.fromFile(new File("/sdcard/cropped.jpg"));

mImageSelectIntent = new Intent(Intent.ACTION_GET_CONTENT, null);
mImageSelectIntent.setType("image/*");
mImageSelectIntent.putExtra("crop", "true");
mImageSelectIntent.putExtra("aspectX", 4);
mImageSelectIntent.putExtra("aspectY", 3);
mImageSelectIntent.putExtra("outputX", mImageWidth);
mImageSelectIntent.putExtra("outputY", mImageHeight);
mImageSelectIntent.putExtra("output", mSavedUri);

The cropped image will be saved as a cropped JPG and not returned to you via "data".

Upvotes: 6

colinwong
colinwong

Reputation: 382

I ran into a similar problem. If you're using Android's default cropping tool, it has a 256x256 max crop size limitation. Set the size of your crop to smaller or equal to that and you'll be fine.

intent.putExtra("outputX", 256);
intent.putExtra("outputY", 256);

Upvotes: 7

Giulio Prisco
Giulio Prisco

Reputation: 941

Re the wallpaper problem, try setting explicitly:

your_intent.putExtra("setWallpaper", false);

Upvotes: 1

Related Questions