How to load bitmap from res without resizing?

Create a drawable (without hdpi/mdpi etc) folder in res. Keep the drawable in that folder. Now try it. This may help you.


When you're decoding the bitmap with

BitmapFactory.decodeResource (Resources res, int id, BitmapFactory.Options opts) 

Set the flag inScaled in BitmapFactory.Options to false first.

Example:

/* Set the options */
Options opts = new Options();
opts.inDither = true;
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inScaled = false; /* Flag for no scalling */ 


/* Load the bitmap with the options */
bitmapImage = BitmapFactory.decodeResource(context.getResources(),
                                           R.drawable.imageName, opts);

Another good option may be to put the bitmap in the drawable-nodpi resource folder


use this

InputStream is = this.getResources().openRawResource(imageId);
Bitmap originalBitmap = BitmapFactory.decodeStream(is);  
imageview.setImageBitmap(originalBitmap);

Tags:

Android

Bitmap