small size picture problem

心不动则不痛 提交于 2019-12-06 16:41:46

Look at what you are doing:

  • you specify a path where your just taken picture is stored with intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File (Environment.getExternalStorageDirectory(), "testExtra" + String.valueOf (System.currentTimeMillis()) + ".jpg")));
  • when you access the picture you 'drag' the data out of the intent with Bitmap mPicture = (Bitmap) data.getExtras().get("data");

Obviously, you don't access the picture from its file. As far as I know Intents are not designed to carry a large amount of data since they are passed between e.g. Activities. What you should do is open the picture from the file created by the camera intent. Looks like that:

BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();  
// Limit the filesize since 5MP pictures will kill you RAM  
bitmapOptions.inSampleSize = 6;  
imgBitmap = BitmapFactory.decodeFile(pathToPicture, bitmapOptions);

That should do the trick. It used to work for me this way but I am experiencing problems since 2.1 on several devices. Works (still) fine on Nexus One.
Take a look at MediaStore.ACTION_IMAGE_CAPTURE.

Hope this helps.
Regards,
Steff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!