Android : Why are the values returned by getWidth() and getHeight() double the actual image dimensions?

on Sunday, March 8, 2015


I'm developing for Android, and my program involves a lot of bitmap images - these are set using BitmapFactory. One of my images is 80x30, and I assign it to a Bitmap variable wit the following instruction:



bmapImg = BitmapFactory.decodeResource(currContext.getResources(), R.drawable.brick);


When I then use the instruction



myImgWidth = bmapImg.getWidth();


myImgWidth is evaluated to 160 instead of 80. Likewise, when I run



myImgHeight = bmapImg.getHeight();


myImgHeight is evaluated to 60 instead of 30. I've looked through other questions on StackOverflow relating to these methods, but all of those issues were about getWidth() and getHeight() returning 0. Am I doing something wrong, or is there a reason as to why these functions return double the actual image dimensions?


0 comments:

Post a Comment