HTML5 load a png buffer into a canvas (for streaming purpose)
问题 Through a websocket, I retrieve a binary buffer of an image in a PNG format (something like that). I want to load this PNG buffer into a canvas, and then read the different pixels to read the uncompressed data. I managed to do it but it is stupid: function onBinaryMessage(/*ArrayBuffer*/ input) { input = new Uint8Array(input); var str = ''; for (var i = 0; i < input.byteLength; i++) str = str + String.fromCharCode(input[i]); var image = document.getElementById("image"); image.src = 'data