Canvas.toDataURL is not base64 encoded
See original GitHub issuecalling toDataURL and logging the result gives the below:
data:image/png;base64,�PNG
�Om
�╝\ ╔+.�� IEND�B`�
there is a base64 function here - https://github.com/ReneNyffenegger/cpp-base64 would that be suitable do you think? I can cut a PR if you think that one could work.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Getting binary (base64) data from HTML5 Canvas ...
The canvas element provides a toDataURL method which returns a data: URL that includes the base64-encoded image data in a given format.
Read more >HTMLCanvasElement.toDataURL() - Web APIs | MDN
The HTMLCanvasElement.toDataURL() method returns a data URL containing a representation of the image in the format specified by the type ...
Read more >How to Get and Set a Base64 Image on Canvas Using ...
In simpler terms, you will get a PNG image but it has been encoded in base64. For the toDataURL() method, the PNG format...
Read more >Canvas.toDataURL is not base64 encoded · Issue #704 - GitHub
So we could probably get this as an ArrayBuffer (therefore implementing toBlob ), and use Buffer to convert that to a base64 string....
Read more >Google Groups
I am not pretty sure the method canvas.toDataURL() returns an encoded 64 base string.I create an png image by mspaint.exe (pic ). The...
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 Free
Top 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
I had exactly the same thought, i had a branch but had some problems sending the buffer back. I see you have it in hand though 😃
Actually I see this is done by Skia: https://github.com/webmixedreality/exokit/blob/master/deps/exokit-bindings/canvascontext/src/canvas-context.cc#L1259
So we could probably get this as an ArrayBuffer (therefore implementing
toBlob
), and useBuffer
to convert that to abase64
string.