공부

[JS] convert bytes array to image

승가비 2020. 5. 17. 05:23
728x90
[137,80,78,71,13,10,26,10,0,...]

<img id="image" src="" />

var imgsrc = "data:image/png;base64," + btoa(String.fromCharCode.apply(null, new Uint8Array([137,80,78,71,13,10,26,10,0,...])));

document.getElementById('image').src = imgsrc;

https://stackoverflow.com/questions/4564119/how-to-convert-a-byte-array-into-an-image

 

How to convert a byte array into an image?

Using Javascript, I'm making an AJAX call to a WCF service, and it is returning a byte array. How can I convert that to an image and display it on the web page?

stackoverflow.com

 

728x90