【问题标题】:Android - Crop image taken from camera with resizable ,independant height and width of cropped areaAndroid - 从相机拍摄的裁剪图像可调整大小,裁剪区域的独立高度和宽度
【发布时间】:2012-12-14 06:48:33
【问题描述】:

我正在开发应用程序,我想裁剪从相机拍摄的图像并上传到 sftp 服务器。 我正在使用以下代码来裁剪图像:

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

有了这个,我得到了一个可调整大小的矩形。但是,在调整裁剪区域宽度和高度的大小时,会像这样按比例变化。

我想像PhotoCrop app一样独立更改裁剪区域的宽度和高度

希望你能理解我的问题。

编辑: ****此外,图像裁剪在三星 Galaxy S3 上不起作用,另一件事是,当我调整裁剪区域的大小时,它会过度缩放图像并且图像变得模糊..****

【问题讨论】:

  • 不定义方面?通常这不是公共 API,您应该将代码集成到您的项目中。否则,您的应用可能无法在替换默认相机和图库应用(承载裁剪意图)的手机上运行。
  • 是的。当我们不定义方面时,它会独立改变裁剪区域的高度和宽度。
  • 然后您接受其他答案 :) 确实,如果您想确保它适用于所有设备,请将其集成到您的应用中。

标签: android image android-camera crop


【解决方案1】:

试试这个:

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

希望对你有帮助。

谢谢。

【讨论】:

  • 嗨,你能给我一些建议吗?............图像裁剪不起作用三星 Galaxy S3 当我调整裁剪区域大小时,它会过度缩放图像并且图像越来越模糊..请指教..
  • @Umesh 发布另一个问题,如果在我调整裁剪区域大小时不能使用三星 Galaxy S3 和更多东西,它会过度缩放图像并且图像变得模糊。并保持此答案为已接受,因为您提出的问题已通过此解决方案解决。
  • 对不起,这是我的错。我已经接受了你的回答,我已经提出了新的问题stackoverflow.com/questions/13910842/…给一些建议。
猜你喜欢
  • 1970-01-01
  • 2018-11-02
  • 2013-07-30
  • 1970-01-01
  • 1970-01-01
  • 2014-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多