このリンクをたどることにより、次のコードを作成して、sdcard から大きな画像ビットマップを表示しました。
try {
InputStream lStreamToImage = context.getContentResolver().openInputStream(Uri.parse(imagePath));
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(lStreamToImage, null, options);
options.inSampleSize = 8; //Decrease the size of decoded image
options.inPreferredConfig = Bitmap.Config.ARGB_4444;
options.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeStream(lStreamToImage, null, options);
} catch(Exception e){}
image.setImageBitmap(bitmap);
しかし、ビットマップを返していません(nullを返すという意味です)。logcat では、以下のメッセージが繰り返し表示されています
08-02 17:21:04.389: D/skia(19359): --- SkImageDecoder::Factory returned null
options.inJustDecodeBounds行にコメントを付けて再実行すると、問題なく動作しますが、動作が遅くなります。上記の開発者ガイドのリンクには、inJustDecodeBoundsを使用してビットマップを効率的に読み込むように記載されています。
どこが間違っているのか教えてください。