接收图像数据作为JSON并将其注入DOM [英] Receive Image data as JSON and injecting it into the DOM
问题描述
我将图像打包成jSON并将其发送到客户端....在客户端,我希望将此数据显示为图像...
I am packaging an image into jSON and sending it to the client .... On the client side I wish to display this data as a image ...
我不是通过JSON发送图像URL ...我试图发送整个图像数据
I am not sending the Image URL via JSON ... I am trying to send the whole image data itself
我在客户端收到的JSON图像数据看起来像这样:
JSON image data that I receive in the client looks like this:
PNG Ûâ\IÂØ>ó4ã¯wcÏLÓQÆÝîHâèÖnò)©£M¡ÀÍ.j3µx¼ê#Ì{Þ±NÔÃïj$©N¨eÃyßÆR$id'|ýpøcå{ãyY'àþ½b|äô¹¨:Óç}@ÖÀdõÉÄ
推荐答案
除了IE7及以下版本,您可以在所有浏览器中使用数据URL完成此操作。基本格式是:
You can accomplish this with data URL's in all browsers save for IE7 and below. The basic format is this:
<img src="data:image/png;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub/
/ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcpp
V0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7">
您可以在此处阅读更多相关信息: http://www.websiteoptimization.com/speed/tweak/inline-images/
You can read more about it here: http://www.websiteoptimization.com/speed/tweak/inline-images/
这篇关于接收图像数据作为JSON并将其注入DOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!