public void onCreate(ViewGroup groupView) { log.pushTimer(this, "start"); // Create OpenCV part: if (RUN_OPENCV) { opencv = new OpenCVInterface(this, this.mainActivity); JavaCameraView cameraView = new JavaCameraView(mainActivity, JavaCameraView.CAMERA_ID_ANY); cameraView.setLayoutParams( new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); cameraView.enableFpsMeter(); cameraView.setVisibility(JavaCameraView.GONE); groupView.addView(cameraView); opencv.onCreate(cameraView); } // Create OpenGL render part: if (RUN_RENDERER) { render = new RenderInterface(this); GLSurfaceView renderView = new GLSurfaceView(mainActivity.getApplicationContext()); renderView.setLayoutParams( new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); groupView.addView(renderView); render.onCreate(renderView); } // Set layout things: mainActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); log.log(TAG, "Framework created in " + log.popTimer(this).time + "ms."); }
@Override public void onCreate(Bundle savedInstanceState) { Logger.log("onCreate"); if (master != null) { copy(master); } super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); mGLView = new GLSurfaceView(getApplication()); mGLView.setEGLConfigChooser( new GLSurfaceView.EGLConfigChooser() { public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { // Ensure that we get a 16bit framebuffer. Otherwise, we'll fall // back to Pixelflinger on some device (read: Samsung I7500) int[] attributes = new int[] {EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE}; EGLConfig[] configs = new EGLConfig[1]; int[] result = new int[1]; egl.eglChooseConfig(display, attributes, configs, 1, result); return configs[0]; } }); mGLView.setLayoutParams( new FrameLayout.LayoutParams( FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT)); mGLView.setRenderer(new BRenderer()); this.setContentView(mGLView); wakeLock = getWakeLock(this, TAG); }
public void handleMessage(android.os.Message msg) { if (msg.what == 1 || msg.what == 2) { if (isOneShow) { layoutConnPrompt.setVisibility(View.GONE); isOneShow = false; } } switch (msg.what) { case 1: { // h264 textTimeStamp.setText(timeShow); myRender.writeSample(videodata, nVideoWidth, nVideoHeight); playImg.setVisibility(View.GONE); int width = getWindowManager().getDefaultDisplay().getWidth(); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(width, width * 3 / 4); lp.gravity = Gravity.CENTER; myGlSurfaceView.setLayoutParams(lp); } break; case 2: { // jpeg textTimeStamp.setText(timeShow); Bitmap bmp = BitmapFactory.decodeByteArray(videodata, 0, videoDataLen); if (bmp == null) { return; } Bitmap bitmap = null; int width = getWindowManager().getDefaultDisplay().getWidth(); int height = getWindowManager().getDefaultDisplay().getHeight(); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(width, width * 3 / 4); lp.gravity = Gravity.CENTER; playImg.setLayoutParams(lp); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { bitmap = Bitmap.createScaledBitmap(bmp, width, width * 3 / 4, true); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { bitmap = Bitmap.createScaledBitmap(bmp, width, height, true); } playImg.setVisibility(View.VISIBLE); playImg.setImageBitmap(bitmap); } break; default: break; } }