I'm currently working on a WebSocket application that is displaying images send by a C++ server. I've seen a couple of topics around there but I can't seem to get rid of this error in Firefox:
Image corrupt or truncated: data:image/png;base64,[some data]
Here's the Javascript code I'm using to display my blob:
socket.onmessage = function(msg) {
var blob = msg.data;
var reader = new FileReader();
reader.onloadend = function() {
var string = reader.result;
var buffer = Base64.encode(string);
var data = "data:image/png;base64,"+buffer;
var image = document.getElementById('image');
image.src = data;
};
reader.readAsBinaryString(blob);
}
I'm using the image of a red dot that I found on this topic: https://stackoverflow.com/a/4478878/1464608 And the Base64 class is from here: https://stackoverflow.com/a/246813/1464608
But the base64 outcome I get doesn't match and Firefox retrieves me an error of the image being corrupted.
I know this ain't much informations but I don't have a clue where to look :/ Any help is more than welcome!!