Skobbler Android 3.0.1 requestScreenshot returns a transparent empty bitmap

116 Views Asked by At

Previous versions of the Skobbler SDK allowed for the developer to request a screenshot of the current mapView state by calling something like

mapView.requestScreenshot();

Followed by overriding a callback to listen for the bitmap result similar to:

@Override
public void onScreenshotReady(Bitmap bitmap) {
  // do something with passed bitmap
}

This code worked as expected in SDK version 2.5.1 but somewhere along the line the SDK appears to have changed such that this code no longer works. Instead now, when we receive the bitmap object, we see that the dimensions of the bitmap match those of the mapview, but the content is all just transparent pixels.

It's almost as if the bitmap was properly initialized with a transparent background with the correct width and height but when the surfaceview request to render to the bitmap was made internally, that portion failed.

Some additional details, the call to mapView.requestScreenshot() is made on the main UI thread, as is the handling of the callback onScreenshotReady().

Looking at the logs, the only output I see in between making the requestScreenshot() call and the calling of the callback is this possibly related error:

D/SKMapActivity: requesting screenshot
E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
D/SKMapActivity: screenshot ready

Since I'm not sure of the internals of how the SKMapSurfaceView class requests the render, I'm not sure if there is an additional step I need to take to ensure that a current OpenGL ES context is in place when the screenshot request is made.

Does anyone have any thoughts on the matter? Thanks!

Keith

1

There are 1 best solutions below

1
Amadeu Cavalcante Filho On

You could force to use openGL version 2.0. Something like that.

EGL10 mEgl = (EGL10) EGLContext.getEGL();
        int[] version = new int[2];
        EGLDisplay display = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
        boolean success = mEgl.eglInitialize(display, version);
        int EGL_OPENGL_ES2_BIT = 4;
        int[] configAttribs = {EGL10.EGL_RED_SIZE, 4, EGL10.EGL_GREEN_SIZE, 4, EGL10.EGL_BLUE_SIZE, 4, EGL10.EGL_RENDERABLE_TYPE,
                EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE};

        EGLConfig[] configs = new EGLConfig[10];
        int[] num_config = new int[1];
        mEgl.eglChooseConfig(display, configAttribs, configs, 10, num_config);
        Log.d("OpenGL", "glversion: " + String.valueOf(success));
        EGLConfig eglConfig = this.mapView.chooseConfig(mEgl, display);

`