可以在这里为背景图像设置滤镜吗

Is it possible to set a filter to a background image here?

本文关键字:设置 滤镜 图像 背景 在这里      更新时间:2023-09-26

我需要对我的背景图像应用过滤器,理想情况下,我希望在添加它的地方进行,并且不更改太多现有代码。这个函数里面有可能吗?

canvas.setBackgroundImage(image_library_selected_url, function() {
    canvas.renderAll();
    _canvasBrowser_update();
});

不是真的,但这对有效

if(requiresFilters) {
    fabric.Image.fromURL(image_library_selected_url, (function(image){
      image.filters.push(grayscale);
      image.filters.push(tint);
      image.applyFilters((function(){
        this.canvas.backgroundImage = image.getElement();
        this.canvas.renderAll();
      }).bind(this));
    }).bind(this));
} else {
    canvas.setBackgroundImage(image_library_selected_url, function() {
        canvas.renderAll();
        _canvasBrowser_update();
    });                     
}