为什么在 GpuImageView android 中使用 GPUImageGroupFIlter 时屏幕闪烁?

时间:2021-01-03 08:01:58

标签: android view gpuimage flicker android-gpuimageview

我在安卓中使用 GPUImageView library。我想向图像添加多个过滤器,因此我在活动的 onCreate 方法中使用组过滤器的默认值初始化数组列表。

之后,当用户选择一个过滤器,例如亮度,然后更改搜索栏时,我正在更新数组列表的第 0 个索引(因为在初始化时亮度过滤器被分配到数组列表中硬编码的第 0 个索引),然后重新分配数组列表到 Group Filter 对象,然后使用 gpuImageView.setFilter(filters) 将其重新分配给 gpuIMageView;

这里是onCreate方法的代码

arraylist.add(new GPUBrightnessFilter());
arraylist.add(new GPUContrastFilter());

.....
arraylist.add(new GPUSaturationFilter()); //all filters are initialize like this

这里是seekbar的进度改变方法的代码

if(current == BRIGHTNESS) 
 { 
   arrayList.set(0, new GPUImageBrightnessFilter(progress)); 
 } 
 else if(current == CONTRAST)  
 {
    arrayList.set(1, new GPUImageContrastFilter(progress)); 
 } 
 else if(current == SATURATION)
 {
     arrayList.set(2, new GPUImageSaturationFilter(progress)); 
 }
 filters = new GPUImageFilterGroup(arrayList); 
 gpuImageView.setFilter(filters);

我认为在 onProgresschange 中设置视图会导致闪烁。还有其他替代方法吗?我希望更改实时发生。我见过使用我使用的相同库来实现这一点的应用程序。但我不确定他们是如何对其进行如此优化的。

如果我遗漏了任何其他代码部分,请告诉我会提供。

0 个答案:

没有答案
相关问题