安卓. W/OpenGLRenderer:位图太大,无法上传到纹理中 [英] Android. W/OpenGLRenderer: Bitmap too large to be uploaded into a texture

查看:208
本文介绍了安卓. W/OpenGLRenderer:位图太大,无法上传到纹理中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我呼叫Canvas.drawBitmap()以获得一侧上大于4096像素的Bitmap时-我什么也没得到.没有错误,也没有绘制位图. LogCat中仅显示此消息:

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:位图太大,无法上传到纹理中(2880x4920,max = 4096x4096)

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

这导致了以下问题:

  1. 4096x4096的限制取决于什么? Android版?内核驱动程序?还是硬件?
  2. 如何在运行时检查当前设备的限制?
  3. 如何捕获错误"W/OpenGLRenderer:位图太大..." ?

推荐答案

这取决于硬件和软件.您可以在运行时使用有效的OpenGL上下文进行查询(请参阅:获取OpenGL最大纹理大小 )

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);

请注意,取决于纹理的格式,支持的大小可能会更小.例如,除了以像素为单位的最大大小外,您的硬件还可以具有以字节为单位的最大纹理大小.要检查支持的纹理大小,请创建具有所需大小和格式的代理纹理(GL_PROXY_TEXTURE_2D目标而不是GL_TEXTURE_2D),然后使用glGetTexLevelParameteriv()查询纹理大小(宽度或高度).如果纹理太大,则大小将设置为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.

这篇关于安卓. W/OpenGLRenderer:位图太大,无法上传到纹理中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆