How to use the clipboard.writeImage function in clipboard

To help you get started, we’ve selected a few clipboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hirokidaichi / guiflow / js / script.js View on Github external
var match = strSvg.match(/svg width="(\d+)pt" height="(\d+)pt"/);
            var width = match[1];
            var height = match[2];

            image.src = "data:image/svg+xml," + encodeURIComponent(svg);
            var cElement = document.createElement("canvas");
            cElement.width = width * 2;
            cElement.height = height * 2;
            var cContext = cElement.getContext("2d");
            cContext.fillStyle = "#fff";
            cContext.fillRect(-10, -10, width * 3, height * 3);
            cContext.drawImage(image, 0, 0, width * 2, height * 2);
            var png = cElement.toDataURL("image/png");

            var image = nativeImage.createFromDataURL(png);
            clipboard.writeImage(image);

            alert("Copied Image to Clipboard");
        })();
    });
github markushedvall / plantuml-viewer / lib / plantuml-viewer-view.js View on Github external
gen.out.on('end', () => {
      var buffer = Buffer.concat(chunks)
      var image = nativeImage.createFromBuffer(buffer)
      clipboard.writeImage(image)
    })
  }