获得全尺寸图像从相机不能在Galaxy S的工作 [英] Getting full-sized image from the camera does not work on Galaxy S

查看:136
本文介绍了获得全尺寸图像从相机不能在Galaxy S的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,从拍摄的图像内置的三星Galaxy S上的摄像头应用程序。

I am having a problem capturing an image from the built-in camera app on the Samsung Galaxy S.

我有我的应用程序的按钮时,pressed启动相机:

I have a button on my app that when pressed launches the camera:

ContentValues values = new ContentValues();
values.put(Images.Media.MIME_TYPE, "image/jpeg");

mPicUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);

intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mPicUri.getPath());
startActivityForResult(intent, REQ_CODE_TAKE_PIC);

从我读的interwebz,我可以拿到全尺寸刚刚拍摄的照片使用URI我传递的意图。所以我有这个在我的onActivityResult:

From what I read on the interwebz, I can get the full-sized just-taken picture using the URI I passed to the intent. And so I have this on my onActivityResult:

Uri selectedImage = mPicUri;
String[] filePathColumn = {MediaStore.Images.Media.DATA};

Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();

int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();

和然后使用可变文件路径,我在一个ImageView的设定的影像。我越来越没有图像,而当我在code踩,我发现 BitmapFactory.de codeFILE()将返回

And then using the variable filePath, I set the image in an ImageView. I am getting no image, and when I stepped through the code, I found out that BitmapFactory.decodeFile() is returning null.

Bitmap chosenPic = BitmapFactory.decodeFile(filePath);

所以,我想多一点的调试。我发现mPicUri返回一个看似有效的URI,如:内容://媒体/外部/图片/媒体/ 90 。后在拍摄照片和用户选择保存图片,光标解析为以下文件路径: /sdcard/DCIM/Camera/1285601413961.jpg 。无位图德codeD虽然,但是当我看了看,通过画廊,照片我只是把在那里。于是,我就看看那张照片的URI,这是我得到了什么:

So I tried a little more debugging. I found out that mPicUri returns a seemingly valid URI, such as: content://media/external/images/media/90. After the picture is taken and the user chooses to save the picture, the cursor resolves to the following filePath: /sdcard/DCIM/Camera/1285601413961.jpg. No bitmap is decoded though, BUT when I looked through the gallery, the picture I just took is there. So I tried to take a look at the URI of that picture, and this is what I got:

URI is:           content://media/external/images/media/91
File path is:     /sdcard/DCIM/Camera/2010-09-27 23.30.30.jpg

因此​​,它看起来像我从mPicUri得到的值不是的最后的URI将被使用。

And so, it looks like the value I got from mPicUri is not the final URI that will be used.

我在这里丢失了一步?我真正想要做的是找回了刚刚拍摄的照片的文件。

Am I missing a step here? All I really want to do is retrieve the file of the just-taken picture.

在此先感谢, Zarah。

Thanks in advance, Zarah.

推荐答案

你有没有尝试拍照和相同的前后指定文件在这两种情况下?

Did you try to specify File in both cases before taking picture and the same after?

public static File getTempFile() {
    //it will return /sdcard/image.jpg
    final File path = new File(Environment.getExternalStorageDirectory(), "MyApp");
    if (!path.exists()) {
        path.mkdir();
    }
    return new File(path, "image.jpg");
}

我用这个函数来获取和设置文件的路径。

I'm using this function to get and set file path.

这篇关于获得全尺寸图像从相机不能在Galaxy S的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆