开发者

Android Bitmap Height and Width equaling -1

I have a 200 x 30 png-24 image that I am trying to load into my application. I've already imported multiple other pngs using this same method and they all work fine. However when this png is loaded it causes the bitmap returned to have a -1 width and height. The bitmap wont draw.

mGameover=BitmapFactory.decodeResource(c.getResources(), R.drawable.gameover); 

The line where I load in the resource. It probably doesn't help. I have tried cleani开发者_Go百科ng my project and it still doesn't work. Also tried recreating the png but it still isn't working.

any ideas?


When bitmap factory returns -1,-1 in the bitmap for the width and height of the Bitmap it means that Android was unable to decode the resource. - Answer by Vector


Nope, according to BitmapFactory doc, null value is returned if Android could not decode the resource. If bitmap is not null then it has most certainly be decoded. See http://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeResource(android.content.res.Resources, int, android.graphics.BitmapFactory.Options)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜