Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display images which are stored as string array in html?

I have been trying to load images which are in database(on local phone) .JSON talks to java and gets the byte array which i am encoding as 64 bit data and returns a string array . Now i am trying to parse the json data. I see the array but how do i read it or set it image tag in html . All answers are appreciated

like image 250
Preethi Avatar asked Dec 22 '22 12:12

Preethi


1 Answers

Use the data:// URI scheme.

For example, if the base64-encoded data is:

iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==

then you'd drop that data into an image's src attribute like so:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

which draws this image:

small red dot

like image 162
Matt Ball Avatar answered Dec 24 '22 01:12

Matt Ball