首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >com.android.camera.action.CROP stucks

com.android.camera.action.CROP stucks
EN

Stack Overflow用户
提问于 2014-09-27 20:37:23
回答 1查看 796关注 0票数 1

我开始遵循以下意图:

代码语言:javascript
复制
            Intent cropIntent = new Intent("com.android.camera.action.CROP");
            cropIntent.setDataAndType(data.getData(), "image/*");
            cropIntent.putExtra("crop", "true");
            cropIntent.putExtra("outputX", wallWidth);
            cropIntent.putExtra("outputY", wallHeight);
            cropIntent.putExtra("aspectX", wallWidth);
            cropIntent.putExtra("aspectY", wallHeight);
            cropIntent.putExtra("scale", true);
            cropIntent.putExtra("scaleUpIfNeeded", true);
            cropIntent.putExtra("return-data", true);
            cropIntent.putExtra("noFaceDetection", true);

在我的例子中,wallWidth和wallHeight是960/800,然后这个意图在裁剪时受阻(这个加载循环整个时间都在旋转)。如果我在那里输入大约400或更小的值作为输出,它就能完美地工作。我该如何解决这个问题呢?因为我想有一个更高分辨率的位图作为输出。

EN

回答 1

Stack Overflow用户

发布于 2016-06-22 21:09:03

大图片使用Uri,小图片使用Bitmap.Here你需要使用Uri。

关键代码如下:

代码语言:javascript
复制
private static final String IMAGE_FILE_LOCATION = "file:///sdcard/temp.jpg";//temp file
private Uri imageUri = Uri.parse(IMAGE_FILE_LOCATION);//The Uri to store the big bitmap

startPhotoZoom(data.getData());

public void startPhotoZoom(Uri uri) {
	Intent intent = new Intent("com.android.camera.action.CROP");
	intent.setDataAndType(uri, "image/*");
	intent.putExtra("crop", "true");
	intent.putExtra("aspectX", 1);
	intent.putExtra("aspectY", 1);
	intent.putExtra("scale", true);
	intent.putExtra("outputX", 500);
	intent.putExtra("outputY", 500);
	intent.putExtra("noFaceDetection", true);
	intent.putExtra("return-data", false);
	intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
	intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
	startActivityForResult(intent, Constant.CROP_IMAGE);
}

Bitmap bitmap = decodeUriAsBitmap(imageUri);

//decode bitmap
private Bitmap decodeUriAsBitmap(Uri uri){
	Bitmap bitmap = null;
	try {
		bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
	} catch (FileNotFoundException e) {
		e.printStackTrace();
		return null;
	}
	return bitmap;
}

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26074741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档