我想从相机获取图像捕获图像,并希望通过android gallery的裁剪裁剪它 活动到固定的宽高比和固定的大小。
此代码适用于图库,我想将它作为相机
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
photoPickerIntent.putExtra("crop", "true");
photoPickerIntent.putExtra("scale", "true");
photoPickerIntent.putExtra("aspectX", 1);
photoPickerIntent.putExtra("aspectY", 1);
photoPickerIntent.putExtra("outputX", 100);
photoPickerIntent.putExtra("outputY", 100);
startActivityForResult(photoPickerIntent, SELECT_PHOTO);
答案 0 :(得分:0)
public void cropCapturedImage(Uri picUri) { / Intent intent = new Intent(); intent.setType( “图像/ ”); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent,GALLERY); * /
// System.out.println("cropCapturedImage picUri=" + picUri);
// call the standard crop action intent
Intent cropIntent = new Intent("com.android.camera.action.CROP");
// indicate image type and Uri of image
cropIntent.setDataAndType(picUri, "image/*");
// set crop properties
cropIntent.putExtra("crop", "true");
// indicate aspect of desired crop
cropIntent.putExtra("aspectX", 2);
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, 2);
}
发送从相机中捕获的图像的uri