华为系列手机在GLSurfaceView截屏后黑屏

xieluhong09 2018-05-07 06:43:31
我在onDrawFrame里面调用glReadPixels获取像素点数组,结果是数据错误,全是-16777216,导致截图后显示黑屏,其它手机(小米,魅族,ov等)调用glReadPixels方法后都是获取到正确的像素点,显示正常,
private Bitmap createBitmapFromGLSurface(int x, int y, int w, int h, GL10 gl) {
int bitmapBuffer[] = new int[w * h;
int bitmapSource[] = new int[w * h;
IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer);
intBuffer.position(0);
try {
gl.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE,
intBuffer);
int offset1, offset2;
for (int i = 0; i < h; i++) {
offset1 = i * w;
offset2 = (h - i - 1) * w;
for (int j = 0; j < w; j++) {
int texturePixel = bitmapBuffer[offset1 + j;
int blue = (texturePixel >> 16) & 0xff;
int red = (texturePixel << 16) & 0xffff0000;
int pixel = (texturePixel & 0xff00ff00) | red | blue;
bitmapSource[offset2 + j] = pixel;
}
}
} catch (GLException e) {
LogManager.e(TAG, "GLException: " + e.toString());
return null;
}


LogManager.e(TAG, "bitmapBuffer: " + Arrays.toString(bitmapBuffer));
LogManager.e(TAG, "bitmapSource: " + Arrays.toString(bitmapSource));
return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888);
}
...全文
778 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Orion-W 2019-12-01
  • 打赏
  • 举报
回复
https://blog.csdn.net/androidwubo/article/details/100927784

80,362

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧