Take screenshot from canvas?
See original GitHub issueHi, I would like to take a screenshot from the rendered canvas but when I tried to apply to toDataURL() to get the base64, the result is completely blank. In addition, I already took a look at the ParaView Glance’s source code covering the screenshot feature but I am still very confused at the part img.addEventListener('load', () => {}. Here is my source code, hope to reiceve the answer from you. Thanks. @jourdain
function convertCanvasToImage(canvas) {
    var image = new Image();
    image.src = canvas.toDataURL("image/png");
    return image;
}
base64 = convertCanvasToImage($('#3d canvas').get(0)).src;
Issue Analytics
- State:
 - Created 4 years ago
 - Comments:6
 
Top Results From Across the Web
How to take screenshot of canvas? [duplicate] - Stack Overflow
It depends what you want to do, the easiest way is to use toDataUrl on your canvas. canvas.toDataURL('png'). This will encode your canvas...
Read more >Capturing an image from an HTML5 Canvas or Video Element
With this trick you can capture a screenshot from a video, save a rendered graphic, pretty much anything within the canvas element.
Read more >How to Create & Submit a Screenshot in Canvas
Paste your screenshot into the open Word document. The screenshot will appear on the blank Word page. Proceed to Step 5. If you...
Read more >canvas-screenshot - npm
A one trick pony package to download an image from a canvas.. Latest version: 4.1.0, last published: a year ago.
Read more >Does the Quiz Log record screenshots? - Instructure Community
As far as I know, no, it doesn't record if a student took a screen shot or not. The best way to confirm...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Then just trigger a render() to allow the promise to resolve.
The promise content will have the data you are looking for.