【问题标题】:Low quality angular electron screenshot低质量角电子屏幕截图
【发布时间】: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


    【解决方案1】:

    解决方案很简单,只需添加一个指示捕获大小的新选项,默认情况下它很小,这就是它看起来像这样的原因。一个例子:

    this._electronService.desktopCapturer.getSources(
    {
        types: ['screen'],
        thumbnailSize: {
            height: 720,
            width: 1000
        }
    }).then(async sources => {
      this.image = this.sanitizer.bypassSecurityTrustResourceUrl(sources[0].thumbnail.toDataURL());
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-06
      • 2021-03-23
      • 2014-10-11
      • 1970-01-01
      相关资源
      最近更新 更多