I needed to embed large amounts (some MB) of binary data for a three-dimensional 3D display.
Here is what I came up with:
- write 8-bit binary data to png file
- base64 encodes the resulting compressed png file with a string length
- use
<img src="data:image/png;base64,...."> to include this in the html5 file - create a hidden canvas of the appropriate size and use context.drawImage and context.getImageData to retrieve the binary data that is finally stored in Uint8ClampedArray
- compute required Float32Array values for three js from this Uint8ClampedArray
I don’t know if this also works for providing binary music data, but the question was not about music data, and it may be useful for others who are here, like me, looking for common solutions for including binary data in HTML5 :-)
source share