If I have an array of pixel data in JavaScript, is there a good way to display it on an HTML page?
- On recent versions of Safari and Firefox, I can make a
<canvas>
element and useputImageData
to display the pixels, but ideally a solution could work on older versions as well and more importantly, work on Internet Explorer. - Another solution which seems more tangible could be to encode the pixels into a standard image format and create a
data:
URI with the pixels and set that as thesrc
of an<img>
element. Unfortunately, it seems like most image formats are complex and I'm having a hard time finding a simple one that can do the job (BMP looks like a possibility but does not work on Safari). Also, versions of Internet Explorer before IE 8 don't supportdata:
URIs at all.
I doubt any exist, but does anyone know of image libraries for JavaScript that can generate image in a standard format? Is there a way to replicate the functionality of a data:
URI in IE 7?