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.
精彩评论