4

I have this code that crop a portion of a image sheet.

The problem is when I use BitmapFactory.decodeResource and when log the width and height, the size is not the same as the original.

Bitmap spriteSheet = BitmapFactory.decodeResource(context.getResources(), R.drawable.imageSheet);

Log.i("Sprite Sheet Size",spriteSheet.getWidth()+"w "+spriteSheet.getHeight()+"h");

This is the log 1536w 330h but the original size of the drawable(png) is 1024x220

How do decode my resources to bitmap in their original sizes.

1 Answer 1

16

The image is scaled according to the dpi of the device you are using, you can put the resources in res/drawable-nodpi or res/drawable folder to get the correct size

Sign up to request clarification or add additional context in comments.

1 Comment

To me works using the res/drawable-nodpi folder. Using res/drawable does not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.