Out of memory error with loading image

后端 未结 1 1792
旧巷少年郎
旧巷少年郎 2021-01-23 04:26

I want to load an image on android

background = BitmapFactory.decodeResource(getResources(),R.drawable.hangmanbegin);    
background =  Bitmap.createScaledBitmap         


        
相关标签:
1条回答
  • 2021-01-23 05:08

    Bitmaps take up a lot of memory, especially for rich images like photographs. For example, the camera on the Galaxy Nexus takes photos up to 2592x1936 pixels (5 megapixels). If the bitmap configuration used is ARGB_8888 (the default from the Android 2.3 onward) then loading this image into memory takes about 19MB of memory (2592*1936*4 bytes), immediately exhausting the per-app limit on some devices.

    from http://developer.android.com/training/displaying-bitmaps/index.html

    credit and below it a way to approach a fix https://stackoverflow.com/a/10127787/643500

    0 讨论(0)
提交回复
热议问题