Search in sources :

Example 16 with GLSurfaceView

use of android.opengl.GLSurfaceView in project android-gif-drawable by koral--.

the class GifTexImage2DFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (!isOpenGLES2Supported()) {
        Snackbar.make(container, R.string.gles2_not_supported, Snackbar.LENGTH_LONG).show();
        return null;
    }
    try {
        GifOptions options = new GifOptions();
        options.setInIsOpaque(true);
        mGifTexImage2D = new GifTexImage2D(new InputSource.ResourcesSource(getResources(), R.drawable.anim_flag_chile), options);
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
    final GLSurfaceView view = (GLSurfaceView) inflater.inflate(R.layout.opengl, container, false);
    view.setEGLContextClientVersion(2);
    view.setRenderer(new Renderer());
    view.getHolder().setFixedSize(mGifTexImage2D.getWidth(), mGifTexImage2D.getHeight());
    mGifTexImage2D.startDecoderThread();
    return view;
}
Also used : IOException(java.io.IOException) GifOptions(pl.droidsonroids.gif.GifOptions) GifTexImage2D(pl.droidsonroids.gif.GifTexImage2D) GLSurfaceView(android.opengl.GLSurfaceView)

Example 17 with GLSurfaceView

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

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 18 with GLSurfaceView

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

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 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) OnPictureSavedListener(jp.co.cyberagent.android.gpuimage.GPUImage.OnPictureSavedListener) 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 19 with GLSurfaceView

use of android.opengl.GLSurfaceView in project platform_frameworks_base by android.

the class DemoPresentation method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Be sure to call the super class.
    super.onCreate(savedInstanceState);
    // Get the resources for the context of the presentation.
    // Notice that we are getting the resources from the context of the presentation.
    Resources r = getContext().getResources();
    // Inflate the layout.
    setContentView(R.layout.presentation_content);
    // Set up the surface view for visual interest.
    mRenderer = new CubeRenderer(false);
    mSurfaceView = (GLSurfaceView) findViewById(R.id.surface_view);
    mSurfaceView.setRenderer(mRenderer);
    // Add a button.
    mExplodeButton = (Button) findViewById(R.id.explode_button);
    mExplodeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mRenderer.explode();
        }
    });
}
Also used : Resources(android.content.res.Resources) GLSurfaceView(android.opengl.GLSurfaceView) View(android.view.View)

Example 20 with GLSurfaceView

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

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(com.dubu.livecamera.gpuimage.GPUImage) GLSurfaceView(android.opengl.GLSurfaceView) View(android.view.View) CameraHelper(com.dubu.livecamera.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