标签:剪切图片
如果调用系统的图片接口:
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) { //这个是调用裁剪图片的接口 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); }
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()); } }
标签:剪切图片
原文地址:http://blog.csdn.net/baidu_nod/article/details/40296547