Maximum number of pixels in a Drawable image
Is there a maximum size for a Drawable jpg image in Android开发者_高级运维? Is perhaps 2M the maximum ?
I create a Drawable from a jpg file in the drawable folder this way:
Drawable image=getResources().getDrawable(R.drawable.file);
If number of pixels > 2M then I get a runtime error:
06-16 17:01:17.108: ERROR/AndroidRuntime(10830): java.lang.NullPointerException
If number of pixels < 2M then the code works perfectly
I compute the number of pixels as Xpixels times ypixels
Is that true? is 2M the maximum number of pixels allowed? Or perhaps I'm doing something wrong? Thanks
I think it depends on the size of the VM heap, and how much of it is available. It's usually 24MB, but I'm guessing creating a drawable involves decompressing the JPG into a much larger bitmap.
精彩评论