Example usage for android.opengl GLSurfaceView setRenderMode

List of usage examples for android.opengl GLSurfaceView setRenderMode

Introduction

In this page you can find the example usage for android.opengl GLSurfaceView setRenderMode.

Prototype

public void setRenderMode(int renderMode) 

Source Link

Document

Set the rendering mode.

Usage

From source file:jp.co.cyberagent.android.gpuimage.sample.activity.ActivityCamera.java

License:asdf

private void takePicture() {
    // TODO get a size that is about the size of the screen
    Camera.Parameters params = mCameraLoader.mCameraInstance.getParameters();
    params.setPictureSize(1280, 960);/*from   www  .j a  va 2 s.c  o  m*/
    params.setRotation(90);
    mCameraLoader.mCameraInstance.setParameters(params);
    for (Camera.Size size2 : mCameraLoader.mCameraInstance.getParameters().getSupportedPictureSizes()) {
        Log.i("ASDF", "Supported: " + size2.width + "x" + size2.height);
    }
    mCameraLoader.mCameraInstance.takePicture(null, null, new Camera.PictureCallback() {

        @Override
        public void onPictureTaken(byte[] data, final Camera camera) {

            final File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
            if (pictureFile == null) {
                Log.d("ASDF", "Error creating media file, check storage permissions");
                return;
            }

            try {
                FileOutputStream fos = new FileOutputStream(pictureFile);
                fos.write(data);
                fos.close();
            } catch (FileNotFoundException e) {
                Log.d("ASDF", "File not found: " + e.getMessage());
            } catch (IOException e) {
                Log.d("ASDF", "Error accessing file: " + e.getMessage());
            }

            data = null;
            Bitmap bitmap = BitmapFactory.decodeFile(pictureFile.getAbsolutePath());
            // mGPUImage.setImage(bitmap);
            final GLSurfaceView view = (GLSurfaceView) findViewById(R.id.surfaceView);
            view.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
            mGPUImage.saveToPictures(bitmap, "GPUImage", System.currentTimeMillis() + ".jpg",
                    new OnPictureSavedListener() {

                        @Override
                        public void onPictureSaved(final Uri uri) {
                            pictureFile.delete();
                            camera.startPreview();
                            view.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
                        }
                    });
        }
    });
}

From source file:com.almalence.opencam.ApplicationScreen.java

public void glSetRenderingMode(final int renderMode) {
    if (renderMode != GLSurfaceView.RENDERMODE_WHEN_DIRTY
            && renderMode != GLSurfaceView.RENDERMODE_CONTINUOUSLY) {
        throw new IllegalArgumentException();
    }//from   w  ww. j a va 2 s  .c  o  m

    final GLSurfaceView surfaceView = glView;
    if (surfaceView != null) {
        surfaceView.setRenderMode(renderMode);
    }
}