2012-07-27 3 views

答えて

28

あなたはより多くの詳細については、メモリ

BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); 
bitmapOptions.inJustDecodeBounds = true; 
BitmapFactory.decodeStream(inputStream, null, bitmapOptions); 
int imageWidth = bitmapOptions.outWidth; 
int imageHeight = bitmapOptions.outHeight; 
inputStream.close(); 

にビットマップのピクセルをロードせずに画像の幅と高さを取得するためにinJustDecodeBoundsでBitmapFactory.Optionsを設定することができます。

公共ブールinJustDecodeBounds

導入されたバージョン:APIレベル1 がtrueの場合、デコーダはnull(ビットマップなし)を返しますが、out ...フィールドはまだ になります呼び出し側が ビットマップを照会してそのピクセルにメモリを割り当てることができます。

http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inJustDecodeBounds

+1

あなたは最終的にはビットマップをロードする必要があるときに、システムが画面密度に関するビットマップを拡大縮小することができますので、正常に動作しません。 これは、BitmapFactory.Options.inScaled = falseの場合にのみ常にtrueです。 – Tobliug

関連する問題