Android Open Source - OpenGLAndroid-Camera Cam G L Surface View






From Project

Back to project page OpenGLAndroid-Camera.

License

The source code is released under:

Apache License

If you think the Android project OpenGLAndroid-Camera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.andrewtremblay.openglandroidcamera;
/*from www  .j a  va2s .  co m*/
import com.andrewtremblay.openglandroidcamera.helpers.CameraHelpers;
import com.andrewtremblay.openglandroidcamera.helpers.DebugHelpers;

import android.content.Context;
import android.hardware.Camera;
import android.opengl.GLSurfaceView;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class CamGLSurfaceView extends GLSurfaceView  {
    CamRenderer mRenderer;
    Camera mCamera;

    public CamGLSurfaceView(Context context) {
        super(context);
        setEGLContextClientVersion(2);
        mRenderer = new CamRenderer(context);
        setRenderer(mRenderer);
        
        setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, final MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_UP){
                    queueEvent(new Runnable(){
                        public void run() {
                        mRenderer.setPosition(event.getX() / getWidth(),
                                              event.getY() / getHeight());
                    }});
                    return true;
                }
                return false;
            }
        });
    
    }

    
    @Override
    public void onPause() {
        super.onPause();
        mCamera.stopPreview();
        mCamera.release();
    }

    @Override
    public void onResume() {
        mCamera = Camera.open();
        Camera.Parameters p = mCamera.getParameters();
        // No changes to default camera parameters
        Log.d(DebugHelpers.TAG, CameraHelpers.cameraParamsToString(p));
        
        mCamera.setParameters(p);

        queueEvent(new Runnable(){
                public void run() {
                    mRenderer.setCamera(mCamera);
                }});

        super.onResume();
    }

}




Java Source Code List

com.andrewtremblay.openglandroidcamera.CamGLSurfaceView.java
com.andrewtremblay.openglandroidcamera.CamRenderer.java
com.andrewtremblay.openglandroidcamera.CameraFilterActivity.java
com.andrewtremblay.openglandroidcamera.CameraPreview.java
com.andrewtremblay.openglandroidcamera.MyOpenGLShaders.java
com.andrewtremblay.openglandroidcamera.helpers.CameraHelpers.java
com.andrewtremblay.openglandroidcamera.helpers.DebugHelpers.java
com.andrewtremblay.openglandroidcamera.helpers.ImageHelpers.java
com.andrewtremblay.openglandroidcamera.helpers.MediaStorageHelpers.java
com.bigflake.androidmediacodecstuff.ExtractMpegFramesTest.java