Given a typed array such as:
const myBuffer = new Uint8Array([255,0,0,255])
How could I obtain a base64 encoded an image, to be put in the DOM?
<img src={ whatToDoHere(myBuffer) }/>
I'd like to see a 1px x 1px red image.
I'm reading a WebGL render target using gl.readPixels()
. My mind melted from reading about a dozen different questions regarding this, and none of them solved my issue.
If I render directly to the canvas, I can use toDataURL
on the DOM element (canvas) and get what I need. I'd like to do it from a target though, not the drawing buffer.