【发布时间】:2023-03-24 00:45:01
【问题描述】:
我有一个视频元素,其中应用了用户选择的过滤器。当我尝试对其进行快照时,应用于视频的过滤器不会应用于快照:
// live is a video element and snapshot is a canvas
function onTakeSnapshot() {
// Make the canvas the same size as the video
snapshot.width = live.clientWidth;
snapshot.height = live.clientHeight;
// Draw a frame of the live video onto the canvas
var c = snapshot.getContext("2d");
c.drawImage(live, 0, 0, snapshot.width, snapshot.height);
snapshot.style.opacity = 1;
}
我意识到我可以对快照应用相同的过滤器,例如,snapshot.className='';snapshot.classList.add('grayscale');,但是我在将其保存到磁盘时遇到了同样的问题,即var img = snapshot.toDataURL(); 导致图像没有应用任何过滤器.我目前使用getImageData()\putImageData() 单独处理图像,但结果通常与画布+过滤器不同。我是画布的新手,想知道是否有一种方法可以绘制和保存已应用过滤器的图像。谢谢!
【问题讨论】:
标签: css html5-video html5-canvas