3 ms·
That raw PNG data doesn't make it into a canvas via the canvas 2D API is not a bug, as pointed out in the responses in the bug report. It's the way the 2D canva
by greggman3 5y ago
That raw PNG data doesn't make it into a canvas via the canvas 2D API is not a bug, as pointed out in the responses in the bug report. It's the way the 2D canvas API has always been.
WebGL on the other hand, has the option to tell the browser not to apply colorspace info or whatever other tweaks the browser would usually to do the data so if you want to read a PNG raw you can load it as a texture, attach it to a framebuffer, and call readPixels and get the raw data. You don't need to decode PNGs in JS although that's certainly a viable solution.
- OmarShehata 5y agoThanks greggman! It does make sense why it behaves this way, I was confused why Chrome doesn't behave similarly. (huge fan of your work by the way!)
- greggman3 5y agoDifferent browsers behave differently because the spec is flexible (good or bad). For example exactly what algo is used to draw a line is not specified AFAIK which allows a browser to use a faster algo if they have one rather than spell it out down to the pixel. For example if they fall back to software rendering maybe they don't antialias. Of course that has pluses and minus. The plus is browsers can try to be more efficient. The minus is the issue you ran into which is frustrating. Maybe someone (me?) should go update the MDN docs with a note :P