com.android.camera.action.CROP
您可以使用as裁剪图像
File tempFile = new File("mnt/sdcard/Images/beijingtesttemp.jpeg");//Image path which u want to crop
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(Uri.fromFile(tempFile), "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 96);
intent.putExtra("outputY", 96);
intent.putExtra("output", Uri.fromFile(tempFile));
intent.putExtra("outputFormat", "JPEG");
startActivityForResult(intent,PHOTOR);
并onActivityResult
使用data.getExtras()
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == NONE)
return;
if (requestCode == PHOTOR) {
Bundle extras = data.getExtras();
if (extras != null) {
// get cropped image as bitmap here
Bitmap photo = extras.getParcelable("data");
}
}
super.onActivityResult(requestCode, resultCode, data);
}