BitmapFactory.decodeResource Bitmap not original size in pixels

柔情痞子 提交于 2019-12-07 13:33:55

问题


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:


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



来源:https://stackoverflow.com/questions/15264489/bitmapfactory-decoderesource-bitmap-not-original-size-in-pixels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!