Search code examples
androidimage-processingandroid-gpuimageview

How to apply one effect over another in GPUImageView?


I am using GPUImageView to apply effects on images displayed on GPUImageView, I want to apply one effect over another, say I applied sepia effect first, then on top of that, I want to apply Contrast. How can I achieve this?


Solution

  • You need to create GPUImageFilterGroup object and add filters to it with addFilter(). After that you can apply the resulting filter to the GPUImageView. For example:

    GPUImageView mImageView;
    
    private void applyFilters(float contrast, float brightness) {
        GPUImageFilterGroup filterGroup = new GPUImageFilterGroup();
        filterGroup.addFilter(new GPUImageContrastFilter(contrast));
        filterGroup.addFilter(new GPUImageBrightnessFilter(brightness));
    
        mImageView.setFilter(filterGroup);
    }