最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Blend mode:multiply in Internet Explorer - Stack Overflow

programmeradmin1浏览0评论

I need to have an Image blended together with an red square in mode multiply. As I know, IE and Safari doesn't support the css-property "blend-mode", so I tried it with blending them together in a canvas and everything worked fine - except in IE. Is there any way to get those blended together in IE or isn't that supported yet?

I need to have an Image blended together with an red square in mode multiply. As I know, IE and Safari doesn't support the css-property "blend-mode", so I tried it with blending them together in a canvas and everything worked fine - except in IE. Is there any way to get those blended together in IE or isn't that supported yet?

Share Improve this question asked Aug 6, 2014 at 11:02 Dominik SeemayrDominik Seemayr 8892 gold badges14 silver badges31 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 11

For Internet Explorer, Canvas blending modes are "under consideration".

https://developer.microsoft./en-us/microsoft-edge/platform/status/mixblendmode/?q=blend

Until blends are implemented in IE, you can roll-your-own multiply filter:

function multiply(R, G, B) {
  var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  var data = imgData.data;

  for (var i = 0; i < data.length; i += 4) {
    data[i    ] = R * data[i    ] / 255;
    data[i + 1] = G * data[i + 1] / 255;
    data[i + 2] = B * data[i + 2] / 255;
  }

  ctx.putImageData(imgData, 0, 0);
}

And this multiply image filter is cross-browser patible too.

Here I found a fully css solution:

https://teamtreehouse./munity/fallback-for-css-blending-modes

which is:

<!--[if IE]>
  <style>
          .yourTargetClass:before {
               content: "";
               position: absolute;
               height: 100%;
               width: 100%;
               background: rgba(10, 36, 54, 0.9); /* THIS IS WHAT EVER OVERLAY COLOUR YOU WANT */
           }
   </style>

发布评论

评论列表(0)

  1. 暂无评论