Original from: Original address
Because this error leads to a long waste of time to find out why, so hurry to 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, there is wood, 700*450, but read out is 525*337. If you have encountered this kind of situation, please look down
This mistake, we can only blame the drawable-ldpi, the reason is that you do not in the corresponding resource folder to put the picture is (mdpi ldpi), you must have only a folder
For example, compared to the film a 700*450 only in the MDPI, when Android will first determine the screen dpi if it is 120, it will go to ldpi, if it is 160 to mdpi, if it is 240 go hdpi
If it goes to ldpi and finds out you don't have a picture, it goes to mdpi, but it will scale the image to 525*337 approximate resolution. The algorithm is 700*0.75 450*0.75 = 525 * 337
See here if you're not quite sure about the numbers, get to know the dpi density, the DPI and pixel relationships, and so on.
The solution, at present, I have copied the picture into all the Pictures folder. So it will find the corresponding. It's normal to get the picture's width high.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How Android obtains images of real pixels through bitmapfactory, and why it doesn't get real pixels