简体   繁体   English

Android-通过可调整大小的,独立于裁剪区域的高度和宽度的相机拍摄的裁剪图像

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

I am developing app where i want to crop image taken from camera and upload to sftp server. 我正在开发应用程序,我想裁剪从相机拍摄的图像并上传到sftp服务器。 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 我想像在PhotoCrop应用中一样单独更改裁剪区域的宽度和高度

在此处输入图片说明

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..**** 编辑: ****图像裁剪也无法在三星银河S3上进行,另一件事是,当我调整裁剪区域的大小时,图像缩放过多,图像变得模糊。

Try This : 尝试这个 :

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

Hope it helps you. 希望对您有帮助。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM