cordova-screenshot icon indicating copy to clipboard operation
cordova-screenshot copied to clipboard

black screen for canvas element

Open herfedos opened this issue 8 years ago • 4 comments

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 :)

herfedos avatar May 20 '16 15:05 herfedos

+1

m0uneer avatar Jul 25 '16 14:07 m0uneer

+1

szumbrunn avatar Oct 14 '16 10:10 szumbrunn

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

m0uneer avatar Oct 14 '16 22:10 m0uneer

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?

mayankkataria avatar Feb 21 '21 15:02 mayankkataria