如何从相机获取具有特定(内存容量)大小的位图?相机通过意图返回的位图大小?
我开始照相机与意图:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra("return-data", true);
photoUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "mytmpimg.jpg"));
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri);
startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA);
我这里处理结果:
// Bitmap photo = (Bitmap) intent.getExtras().get("data");
Bitmap photo = getBitmap(photoUri);
现在,如果我使用注释行 - 直接将位图,我总是得到一个160 x 120位图,这太小了。如果我使用我发现的一些标准东西(方法getBitmap)从URI加载它,它将加载一个2560 x 1920位图(!),并消耗近20 MB内存。
如何加载比方说480 * 800(同样大小的相机预览显示我)?
而无需将2560×1920加载到内存中和按比例缩小。
这有帮助吗? http://stackoverflow.com/questions/3331527/android-resize-a-large-bitmap-file-to-scaled-output-file – 2012-07-29 13:42:09
也许,但没有办法让我在屏幕上看到的东西当拍照时......?我不需要更多。 – Ixx 2012-07-29 13:46:21
Ben Rujil的链接指向我所知道的最佳答案。您的选择基本上是Intent中的缩略图或File中的原生分辨率照片。如果没有让相机应用程序以较低的分辨率保存照片,那是您的选择。 – Sparky 2012-07-29 22:25:46