Android裁剪图片最简单方法(调用系统的)
2014-06-10 22:44
274 查看
转自:http://hi.baidu.com/android168/item/b97fcfc331940f3a0831c677
很多网友平时如果需要在Android平台下开发处理图片裁剪的应用,如果感觉实现的逻辑比较麻烦,比如说需要写类此Win32下的橡皮筋类CRectTracker来设置裁剪区域,这里Android开发网给大家一个最简单可靠的方法,通过下面的Intent调用系统的Camera程序的裁剪功能实现图片修剪。
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setClassName("com.android.camera", "com.android.camera.CropImage");
不过这里Android123提醒大家可能会出现无法找到Activity的android.content.ActivityNotFoundException异常,这是由于Android内部的gallery和camera都有处理,可以尝试另一种URI,com.android.gallery的com.android.camera.CropImage,在setClassName时,具体的代码为
final Intent intent = new Intent("com.android.camera.action.CROP");
intent.setClassName("com.android.camera", "com.android.camera.CropImage");
intent.setData(Uri.fromFile(mFile));
intent.putExtra("outputX", width);
intent.putExtra("outputY", height);
intent.putExtra("aspectX", width);
intent.putExtra("aspectY", height);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true);
intent.putExtra("output", Uri.parse("file:/" + mFile.getAbsolutePath()));
startActivityForResult(intent, REQUEST_CROP_IMAGE);
很多网友平时如果需要在Android平台下开发处理图片裁剪的应用,如果感觉实现的逻辑比较麻烦,比如说需要写类此Win32下的橡皮筋类CRectTracker来设置裁剪区域,这里Android开发网给大家一个最简单可靠的方法,通过下面的Intent调用系统的Camera程序的裁剪功能实现图片修剪。
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setClassName("com.android.camera", "com.android.camera.CropImage");
不过这里Android123提醒大家可能会出现无法找到Activity的android.content.ActivityNotFoundException异常,这是由于Android内部的gallery和camera都有处理,可以尝试另一种URI,com.android.gallery的com.android.camera.CropImage,在setClassName时,具体的代码为
final Intent intent = new Intent("com.android.camera.action.CROP");
intent.setClassName("com.android.camera", "com.android.camera.CropImage");
intent.setData(Uri.fromFile(mFile));
intent.putExtra("outputX", width);
intent.putExtra("outputY", height);
intent.putExtra("aspectX", width);
intent.putExtra("aspectY", height);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true);
intent.putExtra("output", Uri.parse("file:/" + mFile.getAbsolutePath()));
startActivityForResult(intent, REQUEST_CROP_IMAGE);
相关文章推荐
- Android裁剪图片最简单方法(调用系统的)
- Android [应用代码] 简单调用系统的图片裁剪功能
- Android——最简单的图片裁剪 调用系统原生裁剪图片(+保存不成功)
- Android最简单的图片裁剪方法,非使用系统裁切功能
- Android调用系统图片裁剪限定尺寸及7.0照相问题的解决方法
- Android调用系统拍照裁剪图片模糊的解决方法
- 调用Android系统相册并裁剪图片
- Android 调用系统图片裁剪(解决“无法加载。”问题)
- 区域实现Android实现图片的裁剪(不调用系统功能)
- android调用系统拍照程序和从图库选取图片,返回后调用系统裁剪工具
- android 调用系统裁剪图片,提示无法保存经过裁剪的图片
- [Android] 图片裁剪总结——调用系统裁剪
- Android实现图片的裁剪(不调用系统功能)
- Android实现图片的裁剪(不调用系统功能)
- [Android] 图片裁剪总结——调用系统裁剪
- Android修炼之道——调用系统图片裁剪,图片过小问题
- android调用系统图片,音频,视频和裁剪图片
- Android 调用系统的照相,浏览图片,转存并裁剪!
- Android:调用系统图库/裁剪图片
- android 4.4以上调用系统拍照与相册附带图片裁剪