将位图蒙版应用于html5画布上的图像 [英] Apply bitmap mask to image on html5 canvas

查看:52
本文介绍了将位图蒙版应用于html5画布上的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,我有一个带有背景图像的画布,我需要在其上放置另一个图像,并在其上应用蒙版以具有一定的透明度.在这里,您可以找到我需要的最终结果样本的链接.谁能帮我吗?

解决方案

  imagecontext.drawImage(mask,0,0,width,height);imagecontext.globalCompositeOperation ='源头';imagecontext.drawImage(img,0,0); 

http://codepo8.github.io/canvas-masking/

Good morning, i have a canvas with a background image, i need to put another image over it and apply a mask on it to have some transparency. Here you can find a link to a sample of the final result i need. Can anyone help me?

解决方案

imagecontext.drawImage(mask, 0, 0, width, height);
imagecontext.globalCompositeOperation = 'source-atop';
imagecontext.drawImage(img, 0, 0);

http://codepo8.github.io/canvas-masking/

这篇关于将位图蒙版应用于html5画布上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆