Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Image as byte array does not get visualzied with the 'src' attribute of 'img' element

I have this image that I receive as byte[], but then as I try to display it using the src attribute of the img element as data:image/png;base64,[byte array here] it displays System.Byte[] and not the actual array, therefore the image does not get displayed.
Below are two images of my code and the result of it
My code and what I receive in my object that contains the image byte array

The result of the code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to convert the byte array to base64 string. You can use Convert.ToBase64String method.

<img src="data:image/png;base64,@Convert.ToBase64String(card.Image)" />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading