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); 我是看android123上说的。用来裁剪图片。通过Intent ,去调用Camera里的图片剪裁功能
可我对这段代码, 一点点都不懂。
热心的好人:用这代码给个小例子。 文件路径有什么需要注意的吗,在操作的时候。
麻烦,给代码来点注释,实在是头疼。
PS:
本人绝对的菜鸟,还是没长大的菜鸟
intent.setClassName("com.android.camera", "com.android.camera.CropImage"); //类名是死的,android系统自带的,不用管
intent.setData(Uri.fromFile(mFile)); //将文件路径的uri传给camera,你总得让它知道要对哪个图片文件操作吧?
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);
具体参数自己看吧:
SetExtra DataType Description
crop String Signals the crop feature
aspectX int Aspect Ratio
aspectY int Aspect Ratio
outputX int width of output created from this Intent
outputY int width of output created from this Intent
scale boolean should it scale
return-data boolean Return the bitmap with Action=inline-data by using the data
data Parcelable Bitmap to process, you may provide it a bitmap (not tested)
circleCrop String if this string is not null, it will provide some circular cr
MediaStore.EXTRA_OUTPUT ("output") URI Set this URi to a File:///, see example code