gitawego / cordova-screenshot

screenshot plugin for cordova/phonegap
Other
211 stars 168 forks source link

black screen for canvas element #87

Open herfedos opened 8 years ago

herfedos commented 8 years ago

Hi , I want to take a screenshot for my app with using canvas to display 2 charts, i use cordova-screenshot to do this and it works except for canvas elements , they didn't appear in the screenshot , instead there is only black. thank you :)

m0uneer commented 8 years ago

+1

szumbrunn commented 8 years ago

+1

m0uneer commented 8 years ago

A workaround: make an image element and fill it with canvas image and it will work properly

    const imageMask = document.createElement('img');
    imageMask.classList.add('image-mask');

    // Set imageMask width/height to fit current canvas

    // Get Canvas then extract a base46 image
    imageMask.src = canvas.toDataURL('png');

    // Hide canvas and show image mask instead and after taking the screenshot, hide mask and show canvas again
mayankkataria commented 3 years ago

I'm facing the same issue. Whenever I implement any method of context of my canvas than black screen appears. Else its working fine. And I can't move on with the given workaround because my saved image also contains some text which is not part of canvas but is written over canvas. Now those texts are shown over black screen instead of canvas. Is there any possibility to resolve this issue or is there any other better workaround?