LoginSignup
1
1

More than 5 years have passed since last update.

Galaxy系端末でBitmapFactory.decodeResourceが失敗する

Last updated at Posted at 2012-05-30

drawable配下においた画像のBitmapオブジェクトを取得するのは以下でいけるはずだが、
Galaxy系(4.0未満?)は失敗する(nullが返る)。
#または、OpenGLのテクスチャに渡すとNGだったかも。ちょっと記憶が曖昧。

Bitmap bmp = BitmapFacgtory.decodeRecouce(resourceId);

BitmapFactory#decodeStream/decodeByteArrayなどを使用すればいけるはず。

InputStream is = null;

try{
    is = getResources().openRawResource(resourceId);
    Bitmap bmp = BitmapFactory.decodeStream(is);

}finally{
    if(is!=null){
        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1