Android. W/OpenGLRenderer: Bitmap too large to be uploaded into a texture

断了今生、忘了曾经 提交于 2020-01-07 03:51:09

问题


When I call Canvas.drawBitmap() for a Bitmap with more than 4096px on one side - I get nothing. No errors and no bitmap drawn. There appears only this message in LogCat:

W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (2880x4920, max=4096x4096)

This leads to these questions:

  1. What does the limit of 4096x4096 depend on? The Android version? The Kernel drivers? Or the Hardware?
  2. How can I check this limit at runtime for the current device?
  3. How can I catch the error "W/OpenGLRenderer: Bitmap too large ..."?

回答1:


It depends on both hardware and software. You can query at runtime with a valid OpenGL context (see: Get OpenGL max texture size)

int[] maxTextureSize = new int[1];
GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);

Note that the supported size might be smaller, depending on the format of the texture. For example, your hardware could also have a maximum texture size, in bytes, in addition to a maximum size in pixels. To check what texture size is supported, create a proxy texture (GL_PROXY_TEXTURE_2D target, instead of GL_TEXTURE_2D) with the size and format you want, and then query the texture size (width or height) with glGetTexLevelParameteriv(). If your texture is too big, the size will be set to 0.



来源:https://stackoverflow.com/questions/34976645/android-w-openglrenderer-bitmap-too-large-to-be-uploaded-into-a-texture

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