Skip to content Skip to sidebar Skip to footer

How To Using Gpuimage

How can I use GPUImage, is there a site that explains how I can use all of its features? I looked at some sites on the internet, only found a few lines of code. How can I use all t

Solution 1:

To apply the filters mentioned in your comment I've written a sample app with the following :

First you need to create a GPUImageFilterGroup in order to apply all filters mixed :

publicstatic GPUImageFilterGroup setAdjustment(int HueOpacity, float SaturationOpacity, int ShadowOpacity, float WarmOpacity) {
        GPUImageFilterGroupfilterGroup=newGPUImageFilterGroup();
        filterGroup.addFilter(newGPUImageHueFilter(range(HueOpacity, 0.0f, 360.0f)));
        filterGroup.addFilter(newGPUImageHighlightShadowFilter(range(ShadowOpacity, 0.0f, 1.0f), range(0, 1.0f, 0.0f)));
        filterGroup.addFilter(newGPUImageWhiteBalanceFilter(range((int) WarmOpacity, 4000.0f, 8000.0f), range((int) SaturationOpacity, 0.0f, -2.0f)));
        return filterGroup;
    }


 protectedstaticfloatrange(int percentage, float start, float end) {
        return (((end - start) * ((float) percentage)) / 100.0f) + start;
    }

To apply those filters to your GPUImageView :

private GPUImageView mainImageView;

//The default valuesprivatefloat SaturationOpacity = 50.0f;
privatefloat WarmOpacity = 50.0f;
privateint ShadowOpacity = 0;
privateint HueOpacity = 0;
mainImageView.setImage(YOUR BITMAP HERE);

Create 3 SeekBars for Hue, Shadow & WhiteBalance :

Hue :

seekBarHue.setOnSeekBarChangeListener(newSeekBar.OnSeekBarChangeListener() {
            @OverridepublicvoidonProgressChanged(SeekBar seekBar, int i, boolean fromUser) {
                HueOpacity = i;
                mainImageView.setFilter(setAdjustment(HueOpacity,SaturationOpacity, ShadowOpacity, WarmOpacity));
               
            }

            @OverridepublicvoidonStartTrackingTouch(SeekBar seekBar) {

            }

            @OverridepublicvoidonStopTrackingTouch(SeekBar seekBar) {

            }
        });

Shadow :

seekBarShadow.setOnSeekBarChangeListener(newSeekBar.OnSeekBarChangeListener() {
        @OverridepublicvoidonProgressChanged(SeekBar seekBar, int i, boolean b) {
            ShadowOpacity = i;
            mainImageView.setFilter(setAdjustment(HueOpacity,SaturationOpacity, ShadowOpacity, WarmOpacity));
        }

        @OverridepublicvoidonStartTrackingTouch(SeekBar seekBar) {

        }

        @OverridepublicvoidonStopTrackingTouch(SeekBar seekBar) {
        }
    });

WhiteBalance :

seekBarwarm.setOnSeekBarChangeListener(newSeekBar.OnSeekBarChangeListener() {
            @OverridepublicvoidonProgressChanged(SeekBar seekBar, int i, boolean b) {
                WarmOpacity = (float) i;
                mainImageView.setFilter(setAdjustment(HueOpacity,SaturationOpacity, ShadowOpacity, WarmOpacity));
            }
            }

            @OverridepublicvoidonStartTrackingTouch(SeekBar seekBar) {

            }

            @OverridepublicvoidonStopTrackingTouch(SeekBar seekBar) {

            }
        });

Post a Comment for "How To Using Gpuimage"