[英]how to crop image after capturing from camera through intent : Android
我想從相機獲取圖像捕獲圖像,並想通過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);
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);
}
發送從相機捕獲的圖像的uri
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.