In my game, I have a surfaceView and I’m using a bitmap of resolution 400 x 320 pixels as the background for it.
When I run my game on my phone, I see that the canvas size is, say, 600 x 400, and the bitmap I load reports a size of 500 x 400 (I don’t remember the exact figure).
When I run my game on an emulator that has a lower resolution than my phone, I see the canvas has a size of 533 x 380 (not exact), but the bitmap still reports a size of 500 x 400 (and so it ends up clipped).
How is this possible? First, is the size reported by bitmap.getWidth()/getHeight() in pixels? Second, how is it that the size of the bitmap ends up being same on both resolution screens?
Thanks
Yes,
getWidthandgetHeightreturn pixel sizes. Bitmaps are not scaled based on screen resolution. They are scaled based on screen density. In this case it seems your phone and emulator have the same density. Also note that bitmaps are sometimes not scaled at all. It depends on how they are created or loaded.