【问题标题】:Android5.0 Bitmap.copyPixelsFromBuffer crash, "call to OpenGL ES API with no current context"Android5.0 Bitmap.copyPixelsFromBuffer 崩溃,“在没有当前上下文的情况下调用 OpenGL ES API”
【发布时间】:2014-12-09 08:41:06
【问题描述】:

我想将视图的快照保存到文件中,但出现了错误。 我的代码如下:

View decor = ***; //

int width = decor.getWidth();
int height = decor.getHeight();
Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

Canvas canvas = new Canvas(bitmap);
decor.draw(canvas);

int bytes = bitmap.getByteCount() + 8;
ByteBuffer buffer = ByteBuffer.allocate(bytes);
buffer.putInt(width);
buffer.putInt(height);
bitmap.copyPixelsToBuffer(buffer);
byte[] array = buffer.array();

但是 bitmap.copyPixelsToBuffer(buffer);会崩溃。

错误是这样的:

12-09 08:36:43.107:E/libEGL(14642):在没有当前上下文的情况下调用 OpenGL ES API(每个线程记录一次)

这个错误只出现在Android 5.0上,新平台有什么变化吗?我知道 android 5.0 使用 ThreadedRender 来渲染表面,我该如何处理这个问题?非常感谢!!!

【问题讨论】:

    标签: opengl-es android-5.0-lollipop


    【解决方案1】:

    即使我也面临同样的问题!似乎在棒棒糖之前的版本中,上下文正在泄漏并且默认情况下正在使用(我假设)。但是对于棒棒糖,必须明确地创建或传递上下文!

    希望这些有帮助! https://stackoverflow.com/a/27092070

    【讨论】:

      猜你喜欢
      • 2012-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多