question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Take screenshot from canvas?

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
jourdaincommented, Jul 25, 2019

Then just trigger a render() to allow the promise to resolve.

1reaction
jourdaincommented, Jul 25, 2019

The promise content will have the data you are looking for.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found