Vtk-js: Take screenshot from canvas?

Created on 25 Jul 2019  路  6Comments  路  Source: Kitware/vtk-js

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;

All 6 comments

It didn't work out, I tried console.log(openglRenderWindow.captureNextImage()); but just received a message Promise聽{<pending>} in browser's console. @jourdain

Great, that is what you are suppose to get...

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

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

Thanks for the assistance! I truly appreciate your patience 馃槂 @jourdain

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mix3d picture mix3d  路  6Comments

rjsgml5698 picture rjsgml5698  路  4Comments

johannesring picture johannesring  路  6Comments

kabhari picture kabhari  路  8Comments

rjsgml5698 picture rjsgml5698  路  4Comments