By carlespuig
on Mon, 11/25/2013 - 16:05
Hi. I'm trying to take a screenshot of the QCARUnityPlayer but I'm getting a blank screen. I have seen the examples at https://developer.vuforia.com/resources/dev-guide/unity-screenshots and also the ImageTargets sample, but I would like to know if is it possible to capture the Unity Player view (QCARUnityPlayer with the AR scene) directly from Android code. Is it possible to get a GLSurfaceView and GLSurfaceView.Renderer from the Unity Player in order to make calls to the OpenGL API, as in the ImageTargets sample at https://developer.vuforia.com/forum/faq/android-how-can-i-capture-ar-view ? I have a Button which is working fine when calling a ScerenShotTaker class with three different methods to try, capturing other views and returning the Bitmap:
public class ScreenShotTaker { public static Bitmap getBitmapFromView(View v) { Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(),Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); v.setDrawingCacheEnabled(true); v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); v.draw(canvas); canvas = null; return bitmap; } public static Bitmap getBitMap (View v){ v.setDrawingCacheEnabled(true); v.buildDrawingCache(); Bitmap b1 = v.getDrawingCache(); Rect frame = new Rect(); v.getWindowVisibleDisplayFrame(frame); Bitmap b = Bitmap.createBitmap(b1); v.destroyDrawingCache(); return b; } public static Bitmap getBitMap2 (View v){ v.setDrawingCacheEnabled(true); return v.getDrawingCache(); } }
Any help will be appreciated.
Regards,Luis