Use the default system interface to cut Images
If you call the system image interface:
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);//intent.addCategory(Intent.CATEGORY_OPENABLE);//intent.setType("image/*"); startActivityForResult(intent, REQUEST_CODE_SELECT_PHOTO);
@ Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {if (requestCode = REQUEST_CODE_SELECT_PHOTO) {try {// onPhotoSelected (data); final Uri originalUri = data. getData (); if (originalUri = null) {return;} startPhotoZoom (originalUri);} catch (Exception e) {if (LogSettings. MARKET) {MktLog. e (TAG, "onPhotoSelected ():" + e. getMessage () ;}} return ;}} public void startPhotoZoom (Uri uri) {// This is the Intent intent = new Intent ("com. android. camera. action. CROP "); intent. setDataAndType (uri, "image/*"); intent. putExtra ("crop", "true"); intent. putExtra ("aspectX", 1); intent. putExtra ("aspectY", 1); intent. putExtra ("outputX", 150); intent. putExtra ("outputY", 150); intent. putExtra ("return-data", true); startActivityForResult (intent, REQUEST_CODE_SELECT_CUT_PHOTO );}
After cropping, you can use the following in onActivityResult:
if(requestCode == REQUEST_CODE_SELECT_CUT_PHOTO) { try { Bitmap bm = data.getParcelableExtra("data"); } catch (Exception e) { if (LogSettings.MARKET) { MktLog.e(TAG, "onPhotoSelected() : " + e.getMessage()); } }
Image cropping interface: