When I convert stage canvas to png, sometimes the image is full with black
See original GitHub issueI use toDataUrl
to convert stage canvas to png, but sometimes the image is all black and with nothing else. Miraculously, there are times when the image displays the contents of the canvas normally. Does anyone know why?
Here is my code:
const canvas = document.querySelector('.stage_stage_1fD7k');
const image = canvas.toDataUrl('image/png');
const link = document.createElement('a');
link.href = image;
link.download = 'balabala.png';
const event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
When I convert canvas to png, sometimes the image is full with ...
One possibility is that the background of the canvas is transparent. Transparent PNGs in some editors (like MS Paint) appear with a black ......
Read more >HTML5 Canvas Export to High Quality Image Tutorial - Konva
How to export a high quality image from a stage?If you need to export a stage as an image or as base64 then...
Read more >How to Resolve Color Banding in Your Images
Open the actual file in an editor like Photoshop or Lightroom and zoom in to view the banding at 100% scale. Verify whether...
Read more >Saving For The Web — Krita Manual 5.0.0 documentation
Use this for images with few colors or which are black and white, like comics and pixel-art. Select Save as indexed PNG, if...
Read more >ImageMagick Examples -- Multi-Image Layers
Flatten - onto a Background Image; Mosaics - Canvas Expanding ... Layering Thumbnails; Calculated Positioning of Images; Two Stage Positioning of Images ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/LLK/scratch-render/commit/550cd7aacf9a5df74d14af63cd5e8388dee6972f
See https://github.com/LLK/scratch-gui/blob/ab31d36251e21fd78aac34983ede6a75e9f1ff71/src/lib/project-saver-hoc.jsx#L66 for the right way to capture stage images