尽管在 2.X 中指定了 MediaStore.EXTRA_OUTPUT,但从相机检索到小图片

发布于 2024-08-31 15:22:08 字数 1124 浏览 8 评论 0原文

我只是不明白:当我有意使用相机并指定输出文件时,在许多设备上返回的图像总是很小(例如 Motorola Milestone 2.1、HTC Desire 2.1、Emulator 2.1、Emulator 2.0.1 )但并非全部(例如 Nexus One)。这是我打开相机应用程序的方法:

private final static String TEMP_PHOTO_FILE = Environment.getExternalStorageDirectory() + "/TEMP_PHOTO.JPG";  
private final static int REQUEST_CAMERA = 0;  
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(TEMP_PHOTO_FILE)));  
startActivityForResult(intent, REQUEST_CAMERA);

拍摄图像后,我在 onActivityResult(int requestCode, int resultCode, Intent data) 中获取其结果:

if (requestCode == REQUEST_CAMERA && resultCode == RESULT_OK) {  
    String photo = MediaHandler.moveFile(TEMP_PHOTO_FILE, MediaHandler.SDCARD_IMAGE_PATH, System.currentTimeMillis());  
    BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();  
    // bitmapOptions.inSampleSize = 6;  
    imgBitmap = BitmapFactory.decodeFile(photo, bitmapOptions);  

位图非常小,我想知道为什么会发生这种情况。我知道它曾经工作正常。
有没有人有同样的问题,甚至有关于如何解决这个问题的提示?

谢谢,
斯特夫

I just don't get it: when I use the camera with an intent and also specify an output file, the returned image is always very small on many devices (e.g. Motorola Milestone 2.1, HTC Desire 2.1, Emulator 2.1, Emulator 2.0.1) but not on all (e.g. Nexus One). Here's what I do to bring up the camera app:

private final static String TEMP_PHOTO_FILE = Environment.getExternalStorageDirectory() + "/TEMP_PHOTO.JPG";  
private final static int REQUEST_CAMERA = 0;  
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(TEMP_PHOTO_FILE)));  
startActivityForResult(intent, REQUEST_CAMERA);

After the image has been taken I grab its outcome in onActivityResult(int requestCode, int resultCode, Intent data):

if (requestCode == REQUEST_CAMERA && resultCode == RESULT_OK) {  
    String photo = MediaHandler.moveFile(TEMP_PHOTO_FILE, MediaHandler.SDCARD_IMAGE_PATH, System.currentTimeMillis());  
    BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();  
    // bitmapOptions.inSampleSize = 6;  
    imgBitmap = BitmapFactory.decodeFile(photo, bitmapOptions);  

The bitmap is pretty small and I am wondering why this happens. I know that it used to work properly.
Does anyone have the same issue or even a hint on how to fix this?

Thanks,
Steff

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文