非常奇怪,我通过查看插入到自己的数据库中的_ID值来找到解决方案/答案。首先我注意到,当我选择一个现有图像时(通过内置的Android图库),我没有得到完整大小的图片。
当我第一次拍了一张照片,我缩放的图像。所以区别在哪里。在照片的_ID存储在我的数据库中的位置进行可视化。在我的情况下,也可能是大多数情况下,这发生在onActivityResult过程中。
首先来看看什么我最初有:
if(requestCode == REQUEST_CAMERA && resultCode == RESULT_OK){
String timestamp = Long.toString(System.currentTimeMillis());
// get the picture
mPicture = (Bitmap)result.getExtras().get("data");
//save image to gallery
String pictureUrl = MediaStore.Images.Media.insertImage(getContentResolver(), mPicture, getResources().getString(R.string.app_name_short), timestamp);
insertPictureAttachment(mRowId.intValue(), Integer.parseInt(Uri.parse(pictureUrl).getLastPathSegment()));
的“insertPictureAttachment” - 方法执行实际插入到数据库中。
回想起来,这有点奇怪......制作一张照片,所以我可以制作一个URI,然后得到最后一个路径段(这是_ID),所以我可以将它插入到我的数据库。
最终,事实证明,我可以只用一行替换上面代码:
insertPictureAttachment(mRowId.intValue(), Integer.parseInt(result.getData().getLastPathSegment()));
要短得多,实际上更有意义......而不是正从result.getExtras的信息() .get(“data”),我从result.getData()得到我的信息,它给出了原始的全尺寸图像的_ID。
我会对此做一些进一步的研究,因为我不清楚为什么我实际上不必调用MediaStore.Images.Media.insertImage(...)...也许我将不得不如果我想要特定功能(如自定义文件位置或类似的东西)。
Greetingz, 柯恩<
尝试使用yourImageView.setImageDrawable(yourNewPicture);如果这不是你已经在做什么来显示预览 – Sephy 2010-08-09 19:30:19