问题
If a 16-bit single channel (Gray-scale) raw pixel data losslessly encoded into Image format(e.g.PNG, Webp , Jpeg-2000 or JPEG-XR) and Image rendered to HTML5 canvas, then is there any way to retrieve original 16-bit Raw pixel data from the canvas?
回答1:
No.
When drawn to a canvas the image is uncompressed, and all the pixels data are pre-multiplied and converted to 24-bit data + an 8-bit alpha channel (RGBA).
In this process the image looses everything from the original, even for same color depth original image because of various rounding errors (See Canvas fingerprinting.)
So even lossless formats are loosy on a canvas.
If you need the raw data, you'll need to write a parser yourself and treat directly your images files as arrayBuffer.
来源:https://stackoverflow.com/questions/43412842/reconstruct-original-16-bit-raw-pixel-data-from-the-html5-canvas