Android裁剪图片最简单方法 Android开发技术

   很多网友平时如果需要在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); 
 

本人擅长Ai、Fw、Fl、Br、Ae、Pr、Id、Ps等软件的安装与卸载,精通CSS、JavaScript、PHP、ASP、C、C++、C#、Java、Ruby、Perl、Lisp、Python、Objective-C、ActionScript、Pascal等单词的拼写,熟悉Windows、Linux、OS X、Android、iOS、WP8等系统的开关机。

通过下面的方式来联系我们:

电邮:138762189@qq.com

联系QQ:点击这里给我发消息

官方站:www.tadke.com

※ ※ 联系请加我的企鹅号 ※※

※ ※技术支持请微信联系站长 ※※

Copyright © 2023 Tadke.com. 琼ICP备20000547号