Hello!
We have integrated Google Maps to our app for make can-bus data of Mitsubishi i-MiEV/Citroen C-Zero/Peugeot iOn visible via obd bluetooth-tongle - it's one of the panels.
Our integrated screencap function is working well with all panels, except Google Maps. I heard Google Maps is implemented in OpenGL. So it's necessary to use opengl-library-functions to do a screenshot of this.
I'm not familiar with OpenGL, but i found a pice of source code handling this in java, i think:
If(screenshot){
Int screenshotSize = width * height;
ByteBuffer bb = ByteBuffer.allocateDirect(screenshotSize * 4);
bb.order(ByteOrder.nativeOrder());
gl.glReadPixels(0, 0, width, height, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, bb);
Int pixelsBuffer[] = new Int[screenshotSize];
bb.asIntBuffer().get(pixelsBuffer);
bb = Null;
Bitmap Bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
Bitmap.setPixels(pixelsBuffer, screenshotSize-width, -width, 0, 0, width, height);
pixelsBuffer = Null;
Short sBuffer[] = new Short[screenshotSize];
ShortBuffer sb = ShortBuffer.wrap(sBuffer);
Bitmap.copyPixelsToBuffer(sb);
//Making created Bitmap (from OpenGL points) compatible with Android Bitmap
For (Int i = 0; i < screenshotSize; ++i) {
Short v = sBuffer;
sBuffer = (Short) (((v&0x1f) << 11) | (v&0x7e0) | ((v&0xf800) >> 11));
}
sb.rewind();
Bitmap.copyPixelsFromBuffer(sb);
lastScreenshot = Bitmap;
screenshot = False;
}
I can't transform this to b4a. No idea how i can get this running in b4a.
Is somebody able to transform this?
Martin