Android Bitmap Factory does not resize the resized image


I had an image which was originally 854 by 190 which I resized using GIMP to 567 by 120. When i click the image it shows these dimensions so all looks good ( I also tried the same process with Paint).

I load the image through java by calling:

Bitmap test = BitmapFactory.decodeResource(getResources(), R.drawable.launch);

However when i call test.getWidth() it is still returning the original 854, I have rebuilt, refreshed, readded under a different name no matter what I do it is always returns this width instead of the new 567.

Any ideas? thanks L.

decodeRecource reads file as it is and resize using scale factor. you have probably hdpi-screen device/emulator and don't have this drawable in drawable-hdpi, so android scales up by factor 1.5. Android tries to create same DPI size bitmap, not pixel-oriented, e.g. drawable is in drawable/ folder, not in drawable-xxx/ where xx is like below

xxhdpi: 3.0 xhdpi: 2.0 hdpi: 1.5 mdpi: 1.0 (baseline) ldpi: 0.75, more in documentation ang Goole, search for "scale factor android"