Obtaining a snapshot of the canvas instance

  • I was trying to capture the screenshot of the canvas and use the binary.
    Normally one would do like:

    Code
    <canvas id = "mycanvas"></canvas><!-- Assuming that we call and load krpano renders in this canvas --><script>var img_binary = document.getElementById("mycanvas").toDataURL("image/png");</script>


    But the image binary is blank.
    I googled and found that it could happen because the draw buffer is being cleaned by browser.
    Technically speaking

    Code
    this.context = this.canvas.getContext("webgl");
    //And not using: this.context = this.canvas.getContext("webgl", {preserveDrawingBuffer: true});



    Could you help me with the problem?
    Is this how really Krpano is rendering the canvas in webgl? Or is something wrong at my end and it should work normally?
    If has to do with the buffer. Is there a way around to get a snapshot. In that case I wish I could write an event listener and handler to grab the buffer content just before cleaning up.

    Thanks in advance for the help :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!