【发布时间】:2014-07-25 17:38:11
【问题描述】:
我正在尝试开发一个小型裁剪应用程序。我将在相机窗口上使用覆盖,就像我们通常在条形码扫描仪中使用的那样。但是我想在用户单击图片后裁剪图像的覆盖部分并只存储非覆盖部分。我尝试了原生裁剪功能,但它告诉用户选择裁剪部分。我想直接裁剪照片并将其保存在图库中。我怎样才能做到这一点??
现在我正在使用以下代码进行裁剪......
private void performCrop() {
// TODO Auto-generated method stub
//call the standard crop action intent (the user device may not support it)
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(picUri, "image/*");
//set crop properties
cropIntent.putExtra("crop", "true");
//indicate aspect of desired crop
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
//indicate output X and Y
cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);
//retrieve data on return
cropIntent.putExtra("return-data", true);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent,AppUtils.PIC_CROP);
}
【问题讨论】: