答案 0 :(得分:0)
当您完成捕获图像后,您将获得onActivityResult()
中获取的用于捕获的受影响图像或存储位图的路径。
现在使用下面的代码来执行裁剪图像:
public void performCrop(){
//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(Intent.createChooser(cropIntent,"Cropping"), PIC_CROP);
}
现在再次在onActivityResult()
内匹配您的PIC_CROP
请求代码,并获得如下结果图片:
//get the returned data
Bundle extras = data.getExtras();
//get the cropped bitmap
Bitmap thePic = extras.getParcelable("data");