PNG square with sides of 720 x 720. When drawing it on onDraw, the size becomes much larger, depending on the screen resolution. If the screen is 800x480, then the bitmap size is 1080 x 1080, if 2560x1440 is 2520 x 2520 bitmap (this can be seen with the eye and through bitmap.getWidth () bitmap.getHeight ()) If you measure the size without downloading the bitmap (via BitmapFactory.Options ) it corresponds to the original 720 x 720. I have a suspicion that there is again some nonsense with dpi and px. The actual size of the bitmap on the screen is exactly in pixels, it turns out that the size of PNG (720x720) in parrots? Just in case the code is:

Bitmap bitmap; Paint paint = new Paint(); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.back); canvas.drawBitmap(bitmap,0,0, paint); 
  • If you look in Photoshop, the size of the image 720x720 is specified in pixels. The puzzles in the dark, damn it. - lmihael
  • Here is what I read: "the decodeResource method takes into account the density of the device and pulls a picture from the necessary folder." It remains to understand how to deal with this. Moreover, I have only one file and it is in the res \ drawable folder. - lmihael
  • I found it in "neighbors": "But I have a file and so in the res / drawable folder! - lmihael

1 answer 1

In general, figured out. That the pixel density is not taken into account and the real size is used - you need to place the file in the res / drawable-nodpi folder