gpt4 book ai didi

java - 使用 ACTION_IMAGE_CAPTURE 时返回什么数据?

转载 作者:太空宇宙 更新时间:2023-11-03 12:57:15 25 4
gpt4 key购买 nike

我对这个描述有点困惑:

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. This is useful for applications that only need a small image. If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT.

如果没有 EXTRA_OUTPUT,它会返回一个“小尺寸图像”吗?

使用 EXTRA_OUTPUT,它会返回全尺寸图像吗?

“在额外字段中作为位图对象返回”...

在我的 onActivityResult 上,我只是使用 Intent data 作为实际数据。我应该使用 data.getExtra 还是什么?

最佳答案

如果您提供一个 Uri:

Intent action = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
action.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, myUri);
startActivityForResult(action, CAMERA_RESULT);

然后您使用(在对 requestCode 和 resultCode 进行测试之后)检索它:

Bitmap bitmap = BitmapFactory.decodeFile(myUri, options); 

另一种情况:

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(intent, CAMERA_RESULT);

然后用以下方法检索它:

Bundle bundle = intent.getExtras(); 
Bitmap bitmap = (Bitmap) extras.get("data");

关于java - 使用 ACTION_IMAGE_CAPTURE 时返回什么数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17768145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com