如何使用 camanjs 更改图像不透明度?



如何使用Caman JS更改图像不透明度 我也尝试使用最新版本。问题仍然来了。如果有什么需要启用才能实现这一点? 投掷未用卡曼JS定义。在此参考中 - https://www.sitepoint.com/manipulating-images-web-pages-camanjs/这个不透明度(20(;

在卡门中添加这些过滤器.js

Filter.register("opacity", function (adjust) {
adjust = Math.floor(255 * (adjust / 100)); 
var imageData = this.imageData.data,
length = imageData.length;
// set every fourth value to 50
for (var i = 3; i < length; i += 4) {
imageData[i] = imageData[i] == 0 ? imageData[i] : adjust;
}
// after the manipulation, reset the data
this.imageData.data = imageData;
this.context.putImageData(this.imageData, 0, 0); 
});

现在不透明度过滤器将起作用。

最新更新