I have placed some bitmaps in res/drawable.
After I load the bitmaps by BitmapFactory.decodeResource(), I find out that they are resized automatically according the density.
This is not what I want. I want them to keep their original size (pixel size).
What should I do?
As was said in another question, using the drawable-nodpi folder will prevent android from resizing your pictures.
Additionally, if you want to have multiple versions of an image for hdpi and ldpi format, but don't want the system to resize them (to keep a power of two resolution for example), you can use the following code while loading your bitmpap :
// ask the bitmap factory not to scale the loaded bitmaps
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;
// load the bitmap
Bitmap bitmap = BitmapFactory.decodeResource(ctx.getResources(), R.id.mybmp, opts);
http://developer.android.com/guide/practices/screens_support.html
If you use the nodpi suffix, the system won't scale your pictures automatic. Hope it helps!
If you have kept separate images in your hdpi, ldpi, and mdpi, and you are using resources to access these images, then you can't do much.
If you just want one image to be used, keep a single copy of it in mdpi folder, and delete the others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With