0
A
回答
0
我想你在找什么是裁剪图像。
可以实现与Android默认裁剪功能:
private void performCrop(Uri picUri) {
try {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
// indicate image type and Uri
cropIntent.setDataAndType(picUri, "image/*");
// set crop properties
cropIntent.putExtra("crop", "true");
// indicate aspect of desired crop
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
// indicate output X and Y
cropIntent.putExtra("outputX", 128);
cropIntent.putExtra("outputY", 128);
// retrieve data on return
cropIntent.putExtra("return-data", true);
// start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, PIC_CROP);
}
// respond to users whose devices do not support the crop action
catch (ActivityNotFoundException anfe) {
// display an error message
String errorMessage = "Whoops - your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
恒声明:您的活动
final int PIC_CROP = 1;
覆盖onActivity结果的方法,令状下面的代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PIC_CROP) {
if (data != null) {
// get the returned data
Bundle extras = data.getExtras();
// get the cropped bitmap
Bitmap selectedBitmap = extras.getParcelable("data");
imgView.setImageBitmap(selectedBitmap);
}
}
}
相关问题
- 1. 图像缩放调整大小IMAGEVIEW android
- 2. 如何在Android中通过放大和缩小拖动图像并拖动
- 3. Android:高质量图像大小调整/缩放
- 4. Android:调整图像大小并缩放一部分
- 5. RMagick:为缩略图缩放和调整图像大小
- 6. 调整大小/缩放位图后图像质量不佳
- 7. 放大/缩小AbsoluteLayout上的图像Android
- 8. 放大和缩小android中的图像
- 9. 放大和缩小android中的图像
- 10. 如何在android中放大,缩小,拖放和旋转图像视图?
- 11. 多个图像大小vs浏览器图像大小调整/缩放
- 12. 调整MKAnnotationView图像当地图放大和缩小时?
- 13. 调整大小svg图像放入html5
- 14. 动力学JS拖放,调整大小和旋转图像
- 15. HTML5画布拖放,调整图像大小
- 16. 如何使用jQuery在图像上拖放和调整大小?
- 17. 调整大小/缩放图像会导致失真
- 18. 如何通过拖动边缘来移动和缩放图像?
- 19. 调整图像大小后放大图像内的图像
- 20. jQuery UI:通过CSS缩放内容时调整对象大小
- 21. 捏放大图像和缩小图像
- 22. 拖放大小拖放区
- 23. 在iframe中自动缩放(调整大小)图像
- 24. 如何在缩放后在imageView中调整图像大小?
- 25. jQuery的,缩放和调整图像大小
- 26. 在窗口大小调整时缩放SVG背景图像div
- 27. UIButton图像调整大小/缩放以适合
- 28. 如何修复调整大小和缩放背景图像?
- 29. 缩放比,没有jQuery的调整大小图像的SVG
- 30. 调整包含缩放图像的父div的大小