private class SaveOutput implements Job<Intent> {
private final RectF mCropRect; public SaveOutput(RectF cropRect) {
mCropRect = cropRect;
} public Intent run(JobContext jc) {
RectF cropRect = mCropRect;
Bundle extra = getIntent().getExtras(); Rect rect = new Rect(
Math.round(cropRect.left), Math.round(cropRect.top),
Math.round(cropRect.right), Math.round(cropRect.bottom)); Intent result = new Intent();
result.putExtra(KEY_CROPPED_RECT, rect);
Bitmap cropped = null;
boolean outputted = false;
if (extra != null) {
Uri uri = (Uri) extra.getParcelable(MediaStore.EXTRA_OUTPUT);
if (uri != null) {
if (jc.isCancelled()) return null;
outputted = true;
cropped = getCroppedImage(rect);
if (!saveBitmapToUri(jc, cropped, uri)) return null;
}
if (extra.getBoolean(KEY_RETURN_DATA, false)) {
if (jc.isCancelled()) return null;
outputted = true;
if (cropped == null) cropped = getCroppedImage(rect);
result.putExtra(KEY_DATA, cropped);
}
if (extra.getBoolean(KEY_SET_AS_WALLPAPER, false)) {
if (jc.isCancelled()) return null;
outputted = true;
if (cropped == null) cropped = getCroppedImage(rect);
if (!setAsWallpaper(jc, cropped)) return null;
}
}
if (!outputted) {
if (jc.isCancelled()) return null;
if (cropped == null) cropped = getCroppedImage(rect);
Uri data = saveToMediaProvider(jc, cropped);
if (data != null) result.setData(data);
}
return result;
}
}
看到了么?
根据你发起的时候的参数,会返回不同的值,默认返回下面:
Uri data = saveToMediaProvider(jc, cropped);
if (data != null) result.setData(data);你可以上android源码里面的CropImage.java这个类里面看看
private final RectF mCropRect; public SaveOutput(RectF cropRect) {
mCropRect = cropRect;
} public Intent run(JobContext jc) {
RectF cropRect = mCropRect;
Bundle extra = getIntent().getExtras(); Rect rect = new Rect(
Math.round(cropRect.left), Math.round(cropRect.top),
Math.round(cropRect.right), Math.round(cropRect.bottom)); Intent result = new Intent();
result.putExtra(KEY_CROPPED_RECT, rect);
Bitmap cropped = null;
boolean outputted = false;
if (extra != null) {
Uri uri = (Uri) extra.getParcelable(MediaStore.EXTRA_OUTPUT);
if (uri != null) {
if (jc.isCancelled()) return null;
outputted = true;
cropped = getCroppedImage(rect);
if (!saveBitmapToUri(jc, cropped, uri)) return null;
}
if (extra.getBoolean(KEY_RETURN_DATA, false)) {
if (jc.isCancelled()) return null;
outputted = true;
if (cropped == null) cropped = getCroppedImage(rect);
result.putExtra(KEY_DATA, cropped);
}
if (extra.getBoolean(KEY_SET_AS_WALLPAPER, false)) {
if (jc.isCancelled()) return null;
outputted = true;
if (cropped == null) cropped = getCroppedImage(rect);
if (!setAsWallpaper(jc, cropped)) return null;
}
}
if (!outputted) {
if (jc.isCancelled()) return null;
if (cropped == null) cropped = getCroppedImage(rect);
Uri data = saveToMediaProvider(jc, cropped);
if (data != null) result.setData(data);
}
return result;
}
}
看到了么?
根据你发起的时候的参数,会返回不同的值,默认返回下面:
Uri data = saveToMediaProvider(jc, cropped);
if (data != null) result.setData(data);你可以上android源码里面的CropImage.java这个类里面看看
解决方案 »
- 100分 Android下GPIO模拟串口
- 安卓音频混音
- 对于安装Android sd卡和没装sd卡的模拟器的根目录路径是什么啊,项目急用!
- android2.3.3平板,DNS失效问题如何解决?
- 这两个是android内置的样式吗??
- 这个query语句有什么问题?
- 怎么样在ContentResolver中把扫描Video和Audio文件的语句结合为一句话?
- android root权限后隐藏第三方应用程序
- 寻找思路,指点一下别人这效果怎么实现的
- 小米note 顶配,死机无法开机并忘记开机数字密码,恳求大神如何导出内存照片?因为刚注册只有这点积分,请见谅
- 有什么方法使webview加载的网页拉伸至webview控件大小
- RelativeLayout不能绑pressed="true"?
http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android/2.0_r1/
http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/
我看这个例子里面也是把返回的作为bitmap,http://www.apkbus.com/android-52710-1-1.html
比如你想把裁剪后的图片存到/mnt/sdcard/test/crop_xxx.jpg
那么
File file = new File("/mnt/sdcard/test/crop_xxx.jpg");
Uri uri = Uri.fromFile(file);启动crop程序的时候,你再把这个uri作为参数传过去
key为MediaStore.EXTRA_OUTPUT