问题描述
如何使用 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 the features I want?
推荐答案
要应用您评论中提到的过滤器,我编写了一个示例应用,其中包含以下内容:
To apply the filters mentioned in your comment I've written a sample app with the following :
首先,您需要创建一个GPUImageFilterGroup
才能应用所有混合的过滤器:
First you need to create a GPUImageFilterGroup
in order to apply all filters mixed :
public static GPUImageFilterGroup setAdjustment(int HueOpacity, float SaturationOpacity, int ShadowOpacity, float WarmOpacity) {
GPUImageFilterGroup filterGroup = new GPUImageFilterGroup();
filterGroup.addFilter(new GPUImageHueFilter(range(HueOpacity, 0.0f, 360.0f)));
filterGroup.addFilter(new GPUImageHighlightShadowFilter(range(ShadowOpacity, 0.0f, 1.0f), range(0, 1.0f, 0.0f)));
filterGroup.addFilter(new GPUImageWhiteBalanceFilter(range((int) WarmOpacity, 4000.0f, 8000.0f), range((int) SaturationOpacity, 0.0f, -2.0f)));
return filterGroup;
}
protected static float range(int percentage, float start, float end) {
return (((end - start) * ((float) percentage)) / 100.0f) + start;
}
要将这些过滤器应用于您的GPUImageView
:
To apply those filters to your GPUImageView
:
private GPUImageView mainImageView;
//The default values
private float SaturationOpacity = 50.0f;
private float WarmOpacity = 50.0f;
private int ShadowOpacity = 0;
private int HueOpacity = 0;
mainImageView.setImage(YOUR BITMAP HERE);
为色相,阴影和阴影创建3个SeekBars
. WhiteBalance:
Create 3 SeekBars
for Hue, Shadow & WhiteBalance :
色调:
seekBarHue.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean fromUser) {
HueOpacity = i;
mainImageView.setFilter(setAdjustment(HueOpacity,SaturationOpacity, ShadowOpacity, WarmOpacity));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
阴影:
seekBarShadow.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
ShadowOpacity = i;
mainImageView.setFilter(setAdjustment(HueOpacity,SaturationOpacity, ShadowOpacity, WarmOpacity));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
WhiteBalance:
seekBarwarm.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
WarmOpacity = (float) i;
mainImageView.setFilter(setAdjustment(HueOpacity,SaturationOpacity, ShadowOpacity, WarmOpacity));
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
这篇关于如何使用GPUImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!