Search in sources :

Example 1 with TrianglesMosaicFilter

use of cn.nekocode.camerafilter.filter.TrianglesMosaicFilter in project CameraFilter by nekocode.

the class CameraRenderer method run.

@Override
public void run() {
    initGL(surfaceTexture);
    // Setup camera filters map
    cameraFilterMap.append(R.id.filter0, new OriginalFilter(context));
    cameraFilterMap.append(R.id.filter1, new EdgeDetectionFilter(context));
    cameraFilterMap.append(R.id.filter2, new PixelizeFilter(context));
    cameraFilterMap.append(R.id.filter3, new EMInterferenceFilter(context));
    cameraFilterMap.append(R.id.filter4, new TrianglesMosaicFilter(context));
    cameraFilterMap.append(R.id.filter5, new LegofiedFilter(context));
    cameraFilterMap.append(R.id.filter6, new TileMosaicFilter(context));
    cameraFilterMap.append(R.id.filter7, new BlueorangeFilter(context));
    cameraFilterMap.append(R.id.filter8, new ChromaticAberrationFilter(context));
    cameraFilterMap.append(R.id.filter9, new BasicDeformFilter(context));
    cameraFilterMap.append(R.id.filter10, new ContrastFilter(context));
    cameraFilterMap.append(R.id.filter11, new NoiseWarpFilter(context));
    cameraFilterMap.append(R.id.filter12, new RefractionFilter(context));
    cameraFilterMap.append(R.id.filter13, new MappingFilter(context));
    cameraFilterMap.append(R.id.filter14, new CrosshatchFilter(context));
    cameraFilterMap.append(R.id.filter15, new LichtensteinEsqueFilter(context));
    cameraFilterMap.append(R.id.filter16, new AsciiArtFilter(context));
    cameraFilterMap.append(R.id.filter17, new MoneyFilter(context));
    cameraFilterMap.append(R.id.filter18, new CrackedFilter(context));
    cameraFilterMap.append(R.id.filter19, new PolygonizationFilter(context));
    cameraFilterMap.append(R.id.filter20, new JFAVoronoiFilter(context));
    setSelectedFilter(selectedFilterId);
    // Create texture for camera preview
    cameraTextureId = MyGLUtils.genTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
    cameraSurfaceTexture = new SurfaceTexture(cameraTextureId);
    // Start camera preview
    try {
        camera.setPreviewTexture(cameraSurfaceTexture);
        camera.startPreview();
    } catch (IOException ioe) {
    // Something bad happened
    }
    // Render loop
    while (!Thread.currentThread().isInterrupted()) {
        try {
            if (gwidth < 0 && gheight < 0)
                GLES20.glViewport(0, 0, gwidth = -gwidth, gheight = -gheight);
            GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
            // Update the camera preview texture
            synchronized (this) {
                cameraSurfaceTexture.updateTexImage();
            }
            // Draw camera preview
            selectedFilter.draw(cameraTextureId, gwidth, gheight);
            // Flush
            GLES20.glFlush();
            egl10.eglSwapBuffers(eglDisplay, eglSurface);
            Thread.sleep(DRAW_INTERVAL);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
    cameraSurfaceTexture.release();
    GLES20.glDeleteTextures(1, new int[] { cameraTextureId }, 0);
}
Also used : ChromaticAberrationFilter(cn.nekocode.camerafilter.filter.ChromaticAberrationFilter) ContrastFilter(cn.nekocode.camerafilter.filter.ContrastFilter) NoiseWarpFilter(cn.nekocode.camerafilter.filter.NoiseWarpFilter) TileMosaicFilter(cn.nekocode.camerafilter.filter.TileMosaicFilter) CrosshatchFilter(cn.nekocode.camerafilter.filter.CrosshatchFilter) MoneyFilter(cn.nekocode.camerafilter.filter.MoneyFilter) PixelizeFilter(cn.nekocode.camerafilter.filter.PixelizeFilter) IOException(java.io.IOException) MappingFilter(cn.nekocode.camerafilter.filter.MappingFilter) LegofiedFilter(cn.nekocode.camerafilter.filter.LegofiedFilter) PolygonizationFilter(cn.nekocode.camerafilter.filter.PolygonizationFilter) BlueorangeFilter(cn.nekocode.camerafilter.filter.BlueorangeFilter) EdgeDetectionFilter(cn.nekocode.camerafilter.filter.EdgeDetectionFilter) BasicDeformFilter(cn.nekocode.camerafilter.filter.BasicDeformFilter) CrackedFilter(cn.nekocode.camerafilter.filter.CrackedFilter) SurfaceTexture(android.graphics.SurfaceTexture) RefractionFilter(cn.nekocode.camerafilter.filter.RefractionFilter) TrianglesMosaicFilter(cn.nekocode.camerafilter.filter.TrianglesMosaicFilter) AsciiArtFilter(cn.nekocode.camerafilter.filter.AsciiArtFilter) OriginalFilter(cn.nekocode.camerafilter.filter.OriginalFilter) EMInterferenceFilter(cn.nekocode.camerafilter.filter.EMInterferenceFilter) LichtensteinEsqueFilter(cn.nekocode.camerafilter.filter.LichtensteinEsqueFilter) JFAVoronoiFilter(cn.nekocode.camerafilter.filter.JFAVoronoiFilter)

Aggregations

SurfaceTexture (android.graphics.SurfaceTexture)1 AsciiArtFilter (cn.nekocode.camerafilter.filter.AsciiArtFilter)1 BasicDeformFilter (cn.nekocode.camerafilter.filter.BasicDeformFilter)1 BlueorangeFilter (cn.nekocode.camerafilter.filter.BlueorangeFilter)1 ChromaticAberrationFilter (cn.nekocode.camerafilter.filter.ChromaticAberrationFilter)1 ContrastFilter (cn.nekocode.camerafilter.filter.ContrastFilter)1 CrackedFilter (cn.nekocode.camerafilter.filter.CrackedFilter)1 CrosshatchFilter (cn.nekocode.camerafilter.filter.CrosshatchFilter)1 EMInterferenceFilter (cn.nekocode.camerafilter.filter.EMInterferenceFilter)1 EdgeDetectionFilter (cn.nekocode.camerafilter.filter.EdgeDetectionFilter)1 JFAVoronoiFilter (cn.nekocode.camerafilter.filter.JFAVoronoiFilter)1 LegofiedFilter (cn.nekocode.camerafilter.filter.LegofiedFilter)1 LichtensteinEsqueFilter (cn.nekocode.camerafilter.filter.LichtensteinEsqueFilter)1 MappingFilter (cn.nekocode.camerafilter.filter.MappingFilter)1 MoneyFilter (cn.nekocode.camerafilter.filter.MoneyFilter)1 NoiseWarpFilter (cn.nekocode.camerafilter.filter.NoiseWarpFilter)1 OriginalFilter (cn.nekocode.camerafilter.filter.OriginalFilter)1 PixelizeFilter (cn.nekocode.camerafilter.filter.PixelizeFilter)1 PolygonizationFilter (cn.nekocode.camerafilter.filter.PolygonizationFilter)1 RefractionFilter (cn.nekocode.camerafilter.filter.RefractionFilter)1