0

I got an error on Large Image size is about 1600*2560. LogCat Detail is below :

E/AndroidRuntime(2451): FATAL EXCEPTION: main
E/AndroidRuntime(2451): java.lang.OutOfMemoryError
E/AndroidRuntime(2451): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime(2451): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCTextureCache$2.load(CCTextureCache.java:210)
E/AndroidRuntime(2451): at org.cocos2d.opengl.CCTexture2D.setLoader(CCTexture2D.java:194)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCTextureCache.createTextureFromFilePath(CCTextureCache.java:201)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCTextureCache.addImage(CCTextureCache.java:67)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCSprite.<init>(CCSprite.java:366)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCSprite.sprite(CCSprite.java:267)

What is the solution for this ?

Akarsh M
  • 1,629
  • 2
  • 24
  • 47
  • 2
    http://developer.android.com/training/displaying-bitmaps/load-bitmap.html check the link and this http://developer.android.com/training/displaying-bitmaps/manage-memory.html – Raghunandan Aug 03 '13 at 13:42
  • perhaps the device's texture limit is 2048x2048, have you checked? – CodeSmile Aug 03 '13 at 13:58

1 Answers1

1

When you use BitmapFactory to decode your file, you have to specify the Options, such as image width, height, color format, sample size. Then you will not run out of your memory.

yushulx
  • 11,695
  • 8
  • 37
  • 64