0

这个问题可能有点傻。想法是使用 getDisplayMedia() 截屏并获取 ImageCapture,在我将其显示到画布上后,分辨率很差,就像模糊一样,有没有办法改变分辨率?另外,分辨率会影响blob吗?因为我更关心blob而不是显示图像。

let canvas = document.getElementById('canvas');

      navigator.mediaDevices.getDisplayMedia().then(stream => {
        let track = stream.getVideoTracks()[0];
        let capture = new ImageCapture(track);
        capture.grabFrame().then(bitmap => {
          track.stop();

          canvas.width = bitmap.width;
          canvas.height = bitmap.height;
          canvas.getContext('2d').drawImage(bitmap, 0, 0);});
          canvas.toBlob(blob => {
             console.log(blob);
          });
      })
4

0 回答 0