Set img src from Byte Array

后端 未结 3 1831
不思量自难忘°
不思量自难忘° 2020-12-01 21:50

I need to set the img src property from a byte array that I have in a Object.


    

        
相关标签:
3条回答
  • 2020-12-01 22:29

    I use this site to convert images to the base64 byte array data, it gives me the tags in html and css so I just upload and copy/paste.

    http://base64.wutils.com/encoding-online/

    0 讨论(0)
  • 2020-12-01 22:38

    Replace the jpg with the type of image, and [your byte array] with your byte array. You need to convert it to base64 if it isn't already.

    <img id="profileImage" src="data:image/jpg;base64, [your byte array]">
    
    0 讨论(0)
  • 2020-12-01 22:38

    In my case the base64 byte array had to be chunked, in the way:

    <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QCARXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUA
    AAABAAAARgEoAAMAAAABAAIAAIdpAAQAAAABAAAATgAAAAAAAABIAAAAAQAAAEgAAAABAAOQAAAH
    ...
    

    To make this solution works.

    0 讨论(0)
提交回复
热议问题