开发者

Android bitmap.getwidth returns null?

I want to get the width of a bitmap after loading it and i am using this code where mybackground is an int that is equal to R.drawable.background.

background=BitmapFactory.decodeResource(开发者_JAVA技巧context.getResources(),mybackground );

scalefactorbackx=WindowInfo.Width/background.getWidth();
scalefactorbacky=WindowInfo.Height/background.getHeight();

So far it returns a null pointer exception on this line. I have to be doing something fundamentally wrong for this to fail. Tutorials online that I read appeared to just call the .getWidth() function and it was suppose to work.

Thanks


Your bitmap may be incorrect. Otherwise try to simplify your code to see where's the error. Or just check out some web pages.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜