开发者

Fail to crop for large images

开发者 https://www.devze.com 2023-01-31 18:15 出处:网络
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 cro

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.


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


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".


Re the wallpaper problem, try setting explicitly:

your_intent.putExtra("setWallpaper", false);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号