也就是说,android开启硬件加速渲染,Bitmap的图层超出了GPU对于openglRender的限制值,这个不同的手机会有不同的限制。
第一步:拿到本设备的GPU对于openglRender的限制值
//added by Jack for handle exception "Bitmap too large to be uploaded into a texture".
public boolean isNeedCloseHardwareAcceleration(int w, int h) {
int[] maxSize = new int[1];
GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSize, 0);
if(maxSize[0] < h || maxSize[0] < w) {
return true;
}
return false;
}
第二步:在你初始化视图的时候判断一下你的Bitmap的长宽是否超出了这个值,选择关闭硬件加速。当然你也可以分片来绘图。
至于如何开启、关闭、判断是否有硬件加速大家可以看看以下博文,这里我就不做介绍了。
http://www.cnblogs.com/frydsh/archive/2012/10/23/2733581.html
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.