DrawBitmap where one pixel equals one pixel

If I draw a bitmap image on the canvas of the view using drawBitmap (), the images will be resampled so that 1 pixel in the image will be 1 drop onto the screen. I have a high pixel density on the device, which means that each pixel of the image extends to 1.5 pixels of the screen, degrading the image. In general, it is useful, but in some cases I want to carefully select the images that I want to draw, and then draw them explicitly in their own size so that they do not deteriorate. How to do it?

+3
source share
1 answer
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;
Bitmap mBitmap = BitmapFactory.decodeResource(mResource, R.drawable.resource, opts);

alternatively, you can store your resources inside the res / drawable-nodpi folder

+3
source

Source: https://habr.com/ru/post/1781932/


All Articles