【问题标题】:Correcting error with toJpeg in ElectronJS在 ElectronJS 中使用 toJpeg 纠正错误
【发布时间】:2019-04-06 07:18:03
【问题描述】:

我对这段代码有疑问。

ctx.drawImage(document.getElementById("videoScreen"), 0, 0);
imgData = ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height).data;
if (sendFullScreenshot || lastFrame == undefined) {
    sendFullScreenshot = false;
    croppedFrame = new Blob([electron.nativeImage.createFromDataURL(ctx.canvas.toDataURL()).toJpeg(100), new Uint8Array(6)]);
}

错误是:

Image of error

有人可以帮我吗?

【问题讨论】:

标签: node.js electron electron-builder


【解决方案1】:

没有方法:.toJpeg

如果您检查manual,您会看到它是toJPEG

image.toJPEG(质量)

  • 质量整数(必需)- 介于 0 到 100 之间。

返回缓冲区 - 包含图像的 JPEG 编码数据的缓冲区。

所以修复:

croppedFrame = new Blob([
  electron.nativeImage
          .createFromDataURL(ctx.canvas.toDataURL())
          .toJPEG(100), 
  new Uint8Array(6)
]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多