Android - Crop image taken from camera with resizable ,independant height and width of cropped area

落花浮王杯 提交于 2019-12-05 08:04:42

问题


I am developing app where i want to crop image taken from camera and upload to sftp server. I am using following code to crop image:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1; 
Bitmap bm = BitmapFactory.decodeFile(imagePath, opts);
Intent intent = new Intent("com.android.camera.action.CROP");              
intent .setDataAndType(outputFileUri, "image/*");
intent.putExtra("outputX",bm.getWidth());
intent.putExtra("outputY", bm.getHeight());
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", false); 
startActivityForResult(intent, 2);

With this I am getting a resizable rectangle. But while resizing cropped area width and height are changing proprtionally like this .

I want to change width and height of cropped area independently like in PhotoCrop app

I hope you have understand my problem.

EDIT: ****Also image cropping is not working on Samsung galaxy S3 and another thing is that when i resize cropping area, it is zooming the image too much and image is getting blur..****


回答1:


Try This :

 intent.putExtra("aspectX", 0);
 intent.putExtra("aspectY", 0);

Hope it helps you.

Thanks.



来源:https://stackoverflow.com/questions/13873994/android-crop-image-taken-from-camera-with-resizable-independant-height-and-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!