开发者

Maximum number of pixels in a Drawable image

开发者 https://www.devze.com 2023-03-13 06:24 出处:网络
Is there a maximum size for a Drawable jpg image in Android开发者_高级运维? Is perhaps2M the maximum ?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消