Hi Experts,
I have used the code below to capture screenshot in other AR apps.
public Bitmap SavePixels(int x, int y, int w, int h, GL10 gl)
{
int b[]=newint[w*(y+h)];
int bt[]=newint[w*h];
IntBuffer ib=IntBuffer.wrap(b);
ib.position(0);
int image_size = w * h * BYTES_PER_PIXEL;
ByteBuffer mBuffer = ByteBuffer.allocate(image_size);
//gl.glReadPixels(x, 0, w, y+h, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib);
GLES20.glReadPixels(x, 0, w, y+h,
DominoesRenderer.PIXEL_FORMAT,
DominoesRenderer.PIXEL_TYPE,
mBuffer);
try {
BufferedWriter mImageListWriter = null;
String filename = "/sdcard/PictAR/ScreenCapture/Save.png";
File image_list = new File(filename);
image_list.delete();
mImageListWriter = new BufferedWriter(new FileWriter(image_list));
mImageListWriter.write(filename);
mImageListWriter.newLine();
FileOutputStream fos = new FileOutputStream(filename);
fos.write(mBuffer.array());
fos.close();
} catch (java.io.IOException e) {
Log.e("DominoesRenderer", e.getMessage(), e);
}
for(int i=0, k=0; i<h; i++, k++)
{//remember, that OpenGL bitmap is incompatible with Android bitmap
//and so, some correction need.
for(int j=0; j<w; j++)
{
int pix=b[i*w+j];
int pb=(pix>>16)&0xff;
int pr=(pix<<16)&0x00ff0000;
int pix1=(pix&0xff00ff00) | pr | pb;
bt[(h-k-1)*w+j]=pix1;
}
}
Bitmap sb=Bitmap.createBitmap(bt, w, h, Bitmap.Config.ARGB_8888);
return sb;
}
However, when I use the same in Dominoes sample of vuforia-sdk-android-1-5-9, it returns only the camera image. Not the AR content drawn on it. I call this method from onDrawFrame of the DominoesRenderer class.
Please help.
Best regards,
lucky
Capturing Camera image with Overlay Content
This can occur if the augmentation isn't fully rendered. Are you calling this after the call to renderFrame()? If so, you might need to implement a callback, to ensure that the frame is complete before reading it.