[英]Correcting error with toJpeg in ElectronJS
I have problem with this block of code. 我对这段代码有疑问。
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)]);
}
The error is: 错误是:
Can someone help me? 有人能帮我吗?
There is no method: .toJpeg
没有方法:
.toJpeg
if You check manual You'll see that it's toJPEG
如果您查看手册,您会发现它是
toJPEG
image.toJPEG(quality)
image.toJPEG(质量)
- quality Integer (required) - Between 0 - 100.
quality整数(必需)-0-100之间。
Returns Buffer - A Buffer that contains the image's JPEG encoded data.
返回Buffer-一个包含图像的JPEG编码数据的Buffer。
So fix: 因此修复:
croppedFrame = new Blob([
electron.nativeImage
.createFromDataURL(ctx.canvas.toDataURL())
.toJPEG(100),
new Uint8Array(6)
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.