简体   繁体   English

我们可以使用纯CSS或jQuery使用“色度键”技术吗?

[英]Can we have “Chroma key” technique using plain CSS or jQuery?

This one is not trivial. 这不是一件小事。 I want to create a chroma key menu. 我想创建一个色度键菜单。 For those not familiar, it is the same in video with the green background (or whatever color) being removed and special background is added. 对于不熟悉的人,视频中的背景是一样的,其中去除了绿色背景(或任何颜色)并添加了特殊背景。

在此输入图像描述

I have images as a background in a menu. 我在菜单中有图像作为背景。 What I want is to set in someway the section where the background is transparent and the rest being filled with a color. 我想要以某种方式设置背景为透明的部分,其余部分以颜色填充。 In the example below, the background of the menu is image. 在下面的示例中,菜单的背景是图像。 Can we have such a background without one? 我们可以没有这样的背景吗?

I am interested in unified solutions, not ones using css3. 我对统一解决方案感兴趣,而不是对使用CSS3的解决方案感兴趣。

I'm happy to be proven wrong, but I'm fairly sure the answer is no, not even with CSS3. 我很高兴被证明是错误的,但是我很确定答案是否定的,甚至CSS3也不行。 Maybe using IE's very advanced filter() s but those aren't cross-browser. 也许使用IE的非常高级的filter()但是它们不是跨浏览器的。

Using a transparent channel for the background is the only way to go. 唯一的方法是使用透明通道作为背景。 It won't be trivial, but you could use a server-side script to change a specific colour into the transparent colour. 这不会很简单,但是您可以使用服务器端脚本将特定颜色更改为透明颜色。

ImageMagick should be able to do this. ImageMagick应该能够做到这一点。 Here's a promising example. 这是一个有希望的例子。

However, these examples are for replacing one colour. 但是,这些示例用于替换一种颜色。 Whether it's possible to make this look good for anti-aliased edges (where the "transparent" colour blends into the surface colour, creating a mixture that the program would have to detect), I don't know. 我不知道是否可以使它看起来更适合于抗锯齿的边缘(将“透明”颜色融合到表面颜色中,从而创建程序必须检测到的混合物)。

If at all possible, use proper transparency from the start. 如果可能话,使用从一开始就正确的透明度。

I imagine this would be possible on the client-side by copying the image into a <canvas> rendering context, processing the image data (like ImageMagick does) then outputting a data uri which you can use as the CSS background-image of your menu. 我想通过将图像复制到<canvas>渲染上下文中,处理图像数据(如ImageMagick一样),然后输出一个数据uri,将其用作菜单的CSS背景图像,可以在客户端实现此功能。

For reference see: 供参考,请参阅:

http://www.hmp.is.it/creating-chroma-key-effect-html5-canvas/ http://www.hmp.is.it/creating-chroma-key-effect-html5-canvas/

http://www.html5canvastutorials.com/advanced/html5-canvas-get-image-data-url/ http://www.html5canvastutorials.com/advanced/html5-canvas-get-image-data-url/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM