Search in sources :

Example 6 with GLSurfaceView

use of android.opengl.GLSurfaceView in project robotium by RobotiumTech.

the class ScreenshotTaker method wrapAllGLViews.

/**
	 * Extract and wrap the all OpenGL ES Renderer.
	 */
private void wrapAllGLViews(View decorView) {
    ArrayList<GLSurfaceView> currentViews = viewFetcher.getCurrentViews(GLSurfaceView.class, true, decorView);
    final CountDownLatch latch = new CountDownLatch(currentViews.size());
    for (GLSurfaceView glView : currentViews) {
        Object renderContainer = new Reflect(glView).field("mGLThread").type(GLSurfaceView.class).out(Object.class);
        Renderer renderer = new Reflect(renderContainer).field("mRenderer").out(Renderer.class);
        if (renderer == null) {
            renderer = new Reflect(glView).field("mRenderer").out(Renderer.class);
            renderContainer = glView;
        }
        if (renderer == null) {
            latch.countDown();
            continue;
        }
        if (renderer instanceof GLRenderWrapper) {
            GLRenderWrapper wrapper = (GLRenderWrapper) renderer;
            wrapper.setTakeScreenshot();
            wrapper.setLatch(latch);
        } else {
            GLRenderWrapper wrapper = new GLRenderWrapper(glView, renderer, latch);
            new Reflect(renderContainer).field("mRenderer").in(wrapper);
        }
    }
    try {
        latch.await();
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
}
Also used : Renderer(android.opengl.GLSurfaceView.Renderer) CountDownLatch(java.util.concurrent.CountDownLatch) GLSurfaceView(android.opengl.GLSurfaceView)

Example 7 with GLSurfaceView

use of android.opengl.GLSurfaceView in project android-gpuimage-ndkbuild-sample by mugku.

the class ActivityCamera method takePicture.

private void takePicture() {
    // TODO get a size that is about the size of the screen
    Camera.Parameters params = mCamera.mCameraInstance.getParameters();
    params.setRotation(90);
    mCamera.mCameraInstance.setParameters(params);
    for (Camera.Size size : params.getSupportedPictureSizes()) {
        Log.i("ASDF", "Supported: " + size.width + "x" + size.height);
    }
    mCamera.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 GPUImage.OnPictureSavedListener() {

                @Override
                public void onPictureSaved(final Uri uri) {
                    pictureFile.delete();
                    camera.startPreview();
                    view.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
                }
            });
        }
    });
}
Also used : Parameters(android.hardware.Camera.Parameters) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) GLSurfaceView(android.opengl.GLSurfaceView) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) FileOutputStream(java.io.FileOutputStream) Camera(android.hardware.Camera) File(java.io.File)

Example 8 with GLSurfaceView

use of android.opengl.GLSurfaceView in project UltimateAndroid by cymcsg.

the class FlipViewController method setupSurfaceView.

//--------------------------------------------------------------------------------------------------------------------
// Internals
private void setupSurfaceView(Context context) {
    surfaceView = new GLSurfaceView(getContext());
    cards = new FlipCards(this, flipOrientation == VERTICAL);
    renderer = new FlipRenderer(this, cards);
    surfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    surfaceView.setZOrderOnTop(true);
    surfaceView.setRenderer(renderer);
    surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
    addViewInLayout(surfaceView, -1, new AbsListView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT), false);
}
Also used : AbsListView(android.widget.AbsListView) GLSurfaceView(android.opengl.GLSurfaceView)

Example 9 with GLSurfaceView

use of android.opengl.GLSurfaceView in project android-flip by openaphid.

the class FlipViewGroup method setupSurfaceView.

private void setupSurfaceView() {
    surfaceView = new GLSurfaceView(getContext());
    renderer = new FlipRenderer(this);
    surfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    surfaceView.setZOrderOnTop(true);
    surfaceView.setRenderer(renderer);
    surfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    addView(surfaceView);
}
Also used : GLSurfaceView(android.opengl.GLSurfaceView)

Example 10 with GLSurfaceView

use of android.opengl.GLSurfaceView in project android-gpuimage by CyberAgent.

the class ActivityCamera method onCreate.

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera);
    ((SeekBar) findViewById(R.id.seekBar)).setOnSeekBarChangeListener(this);
    findViewById(R.id.button_choose_filter).setOnClickListener(this);
    findViewById(R.id.button_capture).setOnClickListener(this);
    mGPUImage = new GPUImage(this);
    mGPUImage.setGLSurfaceView((GLSurfaceView) findViewById(R.id.surfaceView));
    mCameraHelper = new CameraHelper(this);
    mCamera = new CameraLoader();
    View cameraSwitchView = findViewById(R.id.img_switch_camera);
    cameraSwitchView.setOnClickListener(this);
    if (!mCameraHelper.hasFrontCamera() || !mCameraHelper.hasBackCamera()) {
        cameraSwitchView.setVisibility(View.GONE);
    }
}
Also used : SeekBar(android.widget.SeekBar) GPUImage(jp.co.cyberagent.android.gpuimage.GPUImage) GLSurfaceView(android.opengl.GLSurfaceView) View(android.view.View) CameraHelper(jp.co.cyberagent.android.gpuimage.sample.utils.CameraHelper)

Aggregations

GLSurfaceView (android.opengl.GLSurfaceView)24 View (android.view.View)7 Resources (android.content.res.Resources)4 IOException (java.io.IOException)3 Bitmap (android.graphics.Bitmap)2 Camera (android.hardware.Camera)2 Parameters (android.hardware.Camera.Parameters)2 Uri (android.net.Uri)2 AbsListView (android.widget.AbsListView)2 SeekBar (android.widget.SeekBar)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2 ActivityManager (android.app.ActivityManager)1 Intent (android.content.Intent)1 ConfigurationInfo (android.content.pm.ConfigurationInfo)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Renderer (android.opengl.GLSurfaceView.Renderer)1 DisplayMetrics (android.util.DisplayMetrics)1 FrameLayout (android.widget.FrameLayout)1