Search in sources :

Example 1 with MultiInputFilter

use of com.marshalchen.common.uimodule.imageprocessing.filter.MultiInputFilter in project UltimateAndroid by cymcsg.

the class ImageProcessingTwoInputfilterActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    view = new FastImageProcessingView(this);
    pipeline = new FastImageProcessingPipeline();
    view.setPipeline(pipeline);
    setContentView(view);
    usingCamera = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH);
    if (usingCamera) {
        input = new CameraPreviewInput(view);
    } else {
        input = new ImageResourceInput(view, this, R.drawable.image_processing_kukulkan);
    }
    input2 = new ImageResourceInput(view, this, R.drawable.test_back1);
    filters = new ArrayList<MultiInputFilter>();
    screen = new ScreenEndpoint(pipeline);
    addFilter(new MaskFilter());
    addFilter(new LinearBurnBlendFilter());
    //TODO fix android 2.2
    addFilter(new LuminosityBlendFilter());
    //TODO fix android 2.2
    addFilter(new SaturationBlendFilter());
    addFilter(new HueBlendFilter());
    //TODO fix android 2.2
    addFilter(new ColourBlendFilter());
    addFilter(new NormalBlendFilter());
    addFilter(new SourceOverBlendFilter());
    addFilter(new SoftLightBlendFilter());
    addFilter(new HardLightBlendFilter());
    addFilter(new DifferenceBlendFilter());
    addFilter(new ExclusionBlendFilter());
    addFilter(new ScreenBlendFilter());
    addFilter(new ColourDodgeBlendFilter());
    addFilter(new ColourBurnBlendFilter());
    addFilter(new LightenBlendFilter());
    addFilter(new DarkenBlendFilter());
    addFilter(new OverlayBlendFilter());
    addFilter(new DivideBlendFilter());
    addFilter(new SubtractBlendFilter());
    //TODO fix
    addFilter(new AddBlendFilter());
    addFilter(new MultiplyBlendFilter());
    addFilter(new DissolveBlendFilter(0.7f));
    addFilter(new ChromaKeyBlendFilter(new float[] { 1.0f, 0.3f, 0.0f }, 0.4f, 0.1f));
    addFilter(new AlphaBlendFilter(0.9f));
    input.addTarget(filters.get(0));
    input2.addTarget(filters.get(0));
    pipeline.addRootRenderer(input);
    pipeline.addRootRenderer(input2);
    pipeline.startRendering();
    final Context context = this;
    view.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent e) {
            if (System.currentTimeMillis() - touchTime > 100) {
                pipeline.pauseRendering();
                touchTime = System.currentTimeMillis();
                input.removeTarget(filters.get(curFilter));
                input2.removeTarget(filters.get(curFilter));
                curFilter = (curFilter + 1) % filters.size();
                input.addTarget(filters.get(curFilter));
                input2.addTarget(filters.get(curFilter));
                Toast.makeText(context, filters.get(curFilter).getClass().getSimpleName(), Toast.LENGTH_SHORT).show();
                pipeline.startRendering();
                view.requestRender();
            }
            return false;
        }
    });
    Toast.makeText(this, "Tap the screen to change filter.", Toast.LENGTH_LONG).show();
}
Also used : MultiInputFilter(com.marshalchen.common.uimodule.imageprocessing.filter.MultiInputFilter) Context(android.content.Context) ImageResourceInput(com.marshalchen.common.uimodule.imageprocessing.input.ImageResourceInput) ScreenEndpoint(com.marshalchen.common.uimodule.imageprocessing.outputs.ScreenEndpoint) FastImageProcessingView(com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingView) View(android.view.View) FastImageProcessingPipeline(com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingPipeline) MotionEvent(android.view.MotionEvent) FastImageProcessingView(com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingView) CameraPreviewInput(com.marshalchen.common.uimodule.imageprocessing.input.CameraPreviewInput)

Aggregations

Context (android.content.Context)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 FastImageProcessingPipeline (com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingPipeline)1 FastImageProcessingView (com.marshalchen.common.uimodule.imageprocessing.FastImageProcessingView)1 MultiInputFilter (com.marshalchen.common.uimodule.imageprocessing.filter.MultiInputFilter)1 CameraPreviewInput (com.marshalchen.common.uimodule.imageprocessing.input.CameraPreviewInput)1 ImageResourceInput (com.marshalchen.common.uimodule.imageprocessing.input.ImageResourceInput)1 ScreenEndpoint (com.marshalchen.common.uimodule.imageprocessing.outputs.ScreenEndpoint)1