Using this code:
Drawable blankDrawable = context.getResources().getDrawable(image);
Bitmap blankBitmap=((BitmapDrawable)blankDrawable).getBitmap();
I get a bitmap that is scaled to the density of the context, preserving the physical size of the bitmap (based on its dpi value). So for example, I have a 405x500 bitmap (dpi=96) as a resource. But when I load it on a device, I get a 608x750 image with density=240. I want to load the bitmap without scaling. How do I do that?
This question is very similar to:
How to create a Drawable from a stream without resizing it?
However, that solution cannot be used in my case, because I don't have an input stream. All I have is a resource id, and the getDrawable() method does not have parameters for density. Once the bitmap is loaded, it is too late - it was already resized.
Thank you.