So here I have a base64 encoded png image:
iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
and I decoded it using atob()
. It turns out to be:
PNG
IHDRo&åIDAT×cøÿÿ?Ã Ã Ð1ñXÍõ5ËÑIEND®B`
Is it possible to get out the color values from this string? (without using <canvas>
)
PS: It seems like it is possible since I found a demo:
http://labs.calyptus.eu/JSBin/Demo/Viewer.html
But I am not sure how he did it.
In the source of the page you pointed, there's a function that uses the PNG.js and some other utilities to do what you want:
If you look at the loop in this function , you will notice that it's reading the PNG, line by line and ploting the pixels.
A simplified example would be:
No, you cannot get the color values from that string directly. You must decode the PNG image data somehow (it is compressed). Using
<canvas>
is one way to do that.