Original from: Original address
Because this error causes a lot of wasted time to find out why, so hurry up and record it.
The process is this, when using Android to read pictures, is the use of Bitmapfactory.decoderesource (This.getresources (), r.drawable.base) when
The size of the returned picture is not the same as the real picture size, for example, the picture is 700*450, but read out is 525*337. If you have encountered this kind of situation, please look down
This mistake, just can blame us for not fine, because you did not in the corresponding resource directory in the picture is (drawable-ldpi mdpi ldpi), you must only put a directory
For example, for example, picture a 700*450 just put in mdpi, when Android will first infer that the screen dpi hypothesis is 120 it went to ldpi, assuming 160 went to mdpi, assuming 240 went hdpi
Assuming it went to ldpi and found out you didn't have a picture, it went to MDPI, but it would scale the image to 525*337 approximate resolution.
The algorithm is 700*0.75 450*0.75 = 525 * 337
See here assuming you're not quite sure about these numbers, go to the dpi density, the DPI and pixel relationships, and so on.
By the way, I am now copying the pictures into the entire catalogue. So it will find the corresponding.
It's normal to get the picture's width high.
How Android obtains images of real pixels through bitmapfactory, and why it doesn't get real pixels