Android - How to know maximal size/dimensions of the image that the device can load

天大地大妈咪最大 提交于 2019-12-12 02:50:09

问题


My question may not be very correct, but let me describe it in details. I use cocos2d-x (renders using opengl-es 2) game engine to show images on Android device. In some cases when image dimensions are very large the images are not being displayed. They just get skipped. But I see that the size of the image is smaller then the size of my device VRAM. Checked with this method with /dev/graphics/fb0: How to measure VRAM consumption on Android?. So my file size is 532,042 bytes, its dimension are 2160x1224 and my vram size is 3072000 bytes. Why this image is not being handled by the device? And what is the criteria and limit? How can I check the limit for a device?


回答1:


Why this image is not being handled by the device?

Because there's a difference between how much can be placed in RAM and the maximum size of a single chunk of data that can be processed. There's a certain limit to each GPU on the maximum size of an image it can handle. The size of the RAM just tells you, how many images will fit there. However OpenGL's memory model is purely abstract and the amount of VRAM doesn't tell you anything about how many textures you can load. Data can and will be swapped in and out of VRAM whenever required. The actual limit is in fact the amount of memory available to your system as a whole.

I can't tell you for Cocos2D but in OpenGL and OpenGL-ES you can query the maximum sizes supported for various texture types using glGetInteger OpenGL-ES glGetInteger reference. In your case you're probably interested in the value GL_MAX_TEXTURE_SIZE. Note that for texture targets other than GL_TEXTURE_1D and GL_TEXTURE_2D different values must be queried.



来源:https://stackoverflow.com/questions/26561282/android-how-to-know-maximal-size-dimensions-of-the-image-that-the-device-can-l

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