i want to get image capture image from camera and want to crop it by android gallery's crop activity to a fixed aspect ratio and a fixed size.
this code is for gallery and i want as it for camera
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);
public void cropCapturedImage(Uri picUri) { / Intent intent = new Intent(); intent.setType("image/ "); 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);
}
send the uri of the image captured from camera
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.