如何捕捉错误“位图太大而不能上传到纹理' [英] How to catch error 'Bitmap too large to be uploaded into a texture'

查看:189
本文介绍了如何捕捉错误“位图太大而不能上传到纹理'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用程序处理非常大的位图。正因为如此,我对图像视图接通硬件加速关闭。 然而,一些用户已经设置了开发人员选项强制GPU加速功能开启。这就导致了错误位图太大而不能上传到纹理'。 如果我检查使用isHardwareAccelerated()认为,它始终返回false。

My android application handles very large Bitmaps. Because of this, I turned hardware-acceleration off on the image views. However, some users have set the Developer-Option 'Force GPU-Acceleration' turned on. This leads to the error 'Bitmap too large to be uploaded into a texture'. If I check the view using isHardwareAccelerated(), it always returns false.

有没有办法赶上OpenGL的错误位图太大,无法上传到纹理?

Is there any way to catch the OpenGL-Error 'Bitmap too large to be uploaded into a texture'?

推荐答案

位图是由像素组成的,你可以指望位图矩阵像素数,,设置限制你的位图的像素数。在OpenGL我不能说,但总的来说,我们可以很容易地处理它们,也有一种方法
    bitmap.inSampleSize();

Bitmap is Composed of Pixels and you can count the number of pixels in the bitmap matrix ,, set a limit to your number of bitmap pixels . In OpenGl i can't say , but in general we can easily handle them , also there is a method
bitmap.inSampleSize();

如果您分配

Bitmap.inSampleSize()= 1;

那么原来的位图的像素将被加载。

then the original bitmap pixel will be loaded.

Bitmap.inSampleSize()= 2;

则像素将成为原来的一半像素。

then the pixels will become half of the original pixel.

Bitmap.inSampleSize() = 4

则像素将变成原始像素的1/4。 这种方式可以减少像素大小的位图, 我已经在我的程序做这个事情,希望它会与你工作了。

then the pixels will become 1/4 of the original pixel . This way you can reduce the size of the pixels in the bitmap , I have done this thing in my program , hopefully it will work with you too.

这篇关于如何捕捉错误“位图太大而不能上传到纹理'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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