How to catch the error "Bitmap is too large to load into texture"

My Android application has very large bitmaps. Because of this, I turned off hardware acceleration on images. However, some users have set the Force GPU-Acceleration Developer-Option Force GPU-Acceleration parameter. This leads to the error "The bitmap is too large to be loaded into the texture." If I test the view using isHardwareAccelerated (), it always returns false.

Is there a way to catch an OpenGL-Error bitmap too large to be loaded into a texture?

+6
java android bitmap
source share
2 answers

The raster image is composed of pixels, and you can count the number of pixels in the matrix of raster images, set a limit on the number of raster pixels. In OpenGl I can’t say, but in general we can easily deal with them, there is also a bitmap.inSampleSize () method;

if you appointed

Bitmap.inSampleSize()= 1; 

then the original raster pixel will be loaded.

 Bitmap.inSampleSize()= 2; 

then the pixels will become half the original pixel.

 Bitmap.inSampleSize() = 4 

then the pixels will become 1/4 of the original pixel. Thus, you can reduce the pixel size in the bitmap, I did it in my program, I hope it will work with you.

+2
source share

I did not work with OpenGL on Android and therefore I do not know if there is anything special that needs to be done in order to catch the excluded exceptions or errors. You can try to register a global exception handler and check if you can catch the OpenGL error here.

0
source share

All Articles