[英]How to change image opacity with camanjs?
我也嘗試過使用最新版本的caman js更改圖像不透明度。 仍然有問題。 是否需要實現這一目標? //未使用caman js定義的投擲。 在本參考中-https : //www.sitepoint.com/manipulating-images-web-pages-camanjs/ this.opacity(20);
在camen.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);
});
現在,不透明度過濾器將起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.