canvas 视频截图模糊问题解决

//获取像素比
let backingStore = ctx.backingStorePixelRatio ||
                    ctx.webkitBackingStorePixelRatio ||
                    ctx.mozBackingStorePixelRatio ||
                    ctx.msBackingStorePixelRatio ||
                    ctx.oBackingStorePixelRatio ||
                    ctx.backingStorePixelRatio || 1;

var ratio = (window.devicePixelRatio || 1) / backingStore;
                                
var canvas = document.createElement('canvas'); //  创建canvas 用来截图
var ctx = canvas.getContext('2d')
var CWH = that.getVideoContainerWH()
//设置canvas的截图大小,根据像素比设置画布大小
canvas.width = CWH.width * ratio;
canvas.height = CWH.height * ratio;
canvas.style.width = `${CWH.width}px`; // 控制显示大小
canvas.style.height = `${CWH.height}px`; // 控制显示大小

var drawW = CWH.width  * ratio
var drawH = CWH.height * ratio
//绘图
ctx.drawImage(video,0, 0, drawW, drawH);
......


标签:js 截图
版权属于:瑶玲OvO 所有,转载请注明文章来源。

本文链接: https://www.linmy.cn/index.php/qd/82.html

赞 (1)

评论区

发表评论

字数
0
/200
23+49=?

暂无评论,要不来一发?

回到顶部