티스토리 뷰

공부

[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

'공부' 카테고리의 다른 글

[Java] encoding in server  (0) 2020.05.17
[Spark] `spark.executor.extraJavaOptions` log4j.xml (multi options)  (0) 2020.05.17
[JS] check isEmpty  (0) 2020.05.17
[SpringBoot] configuration memory heap size  (0) 2020.05.17
[JS] uniqBy array by Lodash  (0) 2020.05.17
댓글