I do not want Android to automatically resize the bitmap

I placed some bitmaps in res / drawable.

After loading the bitmaps using BitmapFactory.decodeResource (), I find that they automatically change in density.

This is not what I want. I want them to keep their original size (pixel size).

What should I do?

+7
source share
4 answers

As mentioned in another question, using the drawable-nodpi folder will allow the android to resize your images.

In addition, if you want to have several versions of the image for the hdpi and ldpi formats, but do not want the system to resize them (for example, to preserve the power with two resolutions), you can use the following code while downloading the bitbip:

// 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); 
+17
source

http://developer.android.com/guide/practices/screens_support.html

If you use the nodpi suffix, the system will not automatically scale your images. Hope this helps!

+5
source

If you saved individual images in hdpi, ldpi, and mdpi, and you use resources to access these images, you cannot do much.

If you want one image to be used, save one copy in the mdpi folder and delete the rest.

+1
source

Put your images in a folder called "drawable" (without the suffix ldpi, mdpi, hdpi et al.). You may need to create it yourself (for example, Eclipse does not automatically create it).

After that, delete the resource that can be extracted from other folders accessible with drawable-something.

-one
source

All Articles