【发布时间】:2020-11-14 01:10:47
【问题描述】:
我需要截屏以便显示或保存,我正在尝试这样:
this._electronService.desktopCapturer.getSources({types: ['screen']}).then(async sources => {
this.image = this.sanitizer.bypassSecurityTrustResourceUrl(sources[0].thumbnail.toDataURL());
});
如果我这样做,我会得到一个缩小的图像,我什么都看不到。我附上了我得到的捕获样本。如果我设置更大的宽度或高度,图像就会被像素化。
此外,我需要保存这个 img,我尝试了这个:
writeContents(content, fileName, contentType) {
let a = document.createElement('a');
let file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
【问题讨论】:
标签: angular image electron desktop-application screen-capture