【发布时间】:2016-02-23 05:24:04
【问题描述】:
我跟着this 捕获或从 Web 视图中选择文件并上传...这是完美的,适用于所有 android 版本..
所以我想在那里添加裁剪意图...在相机捕获/图库后裁剪然后上传所有这些从 Webview 发生
我收到 this 意图添加裁剪图像。我想在 MainActivity 中添加它。在捕获表单相机和图库中..
Intent cropIntent = new Intent("com.android.camera.action.CROP");
// indicate image type and Uri
cropIntent.setDataAndType(data.getData(), "image/*");
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
cropIntent.putExtra("outputFormat",
Bitmap.CompressFormat.JPEG.toString());
// 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", 256);
cropIntent.putExtra("outputY", 256);
// retrieve data on return
cropIntent.putExtra("return-data", true);
// start the activity - we handle returning in
// onActivityResult
startActivityForResult(cropIntent, 3);
所以我想裁剪和上传的可能是相机或画廊..
任何人都可以建议我如何将作物意图添加到主要活动..
更新 1
我有捕捉相机和查看画廊的意图。以类似的方式,我可以选择裁剪意图……但我想将此裁剪应用于相机意图和画廊,但所有这些都需要在 webview 中发生(主要活动)...
请在回答之前检查我的Mainactivity...。
我想从相机意图和画廊意图添加裁剪意图..它应该能够上传......最小分辨率......不超过 2 兆像素..如果小于也没有问题......就像@987654324 @位图...
在更新中我再次添加了相同的链接不要混淆......
这里都需要在webview中裁剪上传...
更新 2
是否可以在我的 MainActivity 中使用 this 库...如果从网络视图裁剪相机捕获并在同一网络视图中上传...
【问题讨论】:
-
您遇到了什么问题?上面的代码不行吗?
-
先生..我想在主要活动中添加 CROP 意图,您能建议我在哪里添加.. 如果可能,添加和更新答案...
-
这意味着您可以裁剪图像但无法将其设置为 webview,对吧?
-
不,先生..我可以在单独的应用程序中裁剪..但不能在 webview mainactivity 中......有意图
-
Android does not have a
CROPIntent。有很多image cropping libraries for Android。请使用一个。或者,在您的情况下,找到一些基于 JavaScript 的图像裁剪库,并从您的 Web 内容中使用它。
标签: android android-intent webview android-camera crop