我尝试将两个过滤器应用于Android中的同一图像,但结果是两个过滤器只应用于图像。我做错了什么?
public void asignarFiltro(){
gpuImage = new GPUImage(this);
gpuImage.setImage(imagenOriginal);
GPUImageFilterGroup group = new GPUImageFilterGroup();
group.addFilter(new GPUImageGrayscaleFilter());
group.addFilter(new GPUImageGaussianBlurFilter());
List<GPUImageFilter> filters = group.getMergedFilters();
Iterator<GPUImageFilter> iterator = filters.iterator();
while(iterator.hasNext()){
GPUImageFilter currentFilter = iterator.next();
gpuImage.setFilter(currentFilter);
}
imageView.setImageBitmap(gpuImage.getBitmapWithFilterApplied());
}
答案 0 :(得分:4)
是的,你可以。只需将您的GPUImageGroupFilter对象传递给gpuimage即可。示例gpuimage.setFilter(group);
答案 1 :(得分:0)
使用GPUImageFilterGroup
的正确方法:
List<GPUImageFilter> filterList = new ArrayList<>();
filterList.add(filter1);
filterList.add(filter2);
.
.
.
filterList.add(filterN);
GPUImageFilterGroup filterGroup = new GPUImageFilterGroup(filterList);
GPUImage gpuImage = new GPUImage(context);
gpuImage.setFilter(filterGroup);