如何從相機獲取具有特定(內存容量)大小的位圖?相機通過意圖返回的位圖大小?
我開始照相機與意圖:
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