如何在javascript中显示图像二进制字符串?

时间:2013-12-18 01:30:47

标签: javascript image-processing

如何在javascript中显示图像二进制字符串? 我不知道如何转换为图片网址。可能吗? (在我的例子中,我可以使用FileReader,Blob,URL.createObjectURL)

var img = new Image();
var img.src = '[URL]'; 

数据是这样的..

/tf/4AAQSkZJRgABAQEASABIAA//2wBDABsSFBcUERsXFhceHBsgKEIrKCUlKFE6PTBCYFVlZF9VXVtqe5iBanCQc1tdhLSGk52jqqyrZo+8yLmmxpioqqP/2wBDARweHigjKE4rK02kbl1up6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6Okp6P/wAARCA+rAQADASIAAhEBAxEB/sQAGgAAAwEBAQEAAAAAAAAAAAAAAQIDAAQFBf7EADoQAAEDAwIDBgQFBAIBBQAAAAEAAhEDEiEEMRNBUQUiYXCBkTGhsNEjQlHB8BRi4PFDchUWJDNEgf7EABgBAQEBAQEAAAAAAAAAAAAAAAABAgME/sQAGxEBAQEBAQEBAQAAAAAAAAAAABEBEiECMSH/2gAMAwEAAhEDEQA/A/HhaE8IwfU4khWE87QgSEYT2ytaqEhaEtm1qBIWh/WtCBIRh9+MIEhGE0HQgWFoTwtb44hVoTyHom4bkE4WhU4fUhCwfaQThKE9oWhAq0J4WhAsLQjhEDwRCQfCa0o2oFhFO6ZP+0Q0Apy80E0QnAAdIEokEphByQEYCqKGyMeEb6QPPqoVzhsrRCta3l9ELJ70hUwAmISg5E6CcUx4+ybhu4w1oHigkQxxJgP4IFneQhT4BqtHqiGGMkOlH6S+SwYY2BTbw2CTMHuWgAEHw3Uo4uCf0lCwbEx6LadBE9AzuhWJy0v4K0mPBEwSR1xsmLPpWgDJH8DdOQ/vdqoEEaIVzKdsAQavVIyRDWx5F8GZJ290wZRuWu2CLiKQg4BpIwJV5KKYKHEaNmN9lRAtI3+IpfHbg5+s2cR+UEHcYg4aEtVHhezhaw8xCYPJw4RF48ffxRAbp3qH8yjGlyJeFZacE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86hH2GivJHm4mY2yn/rjMDAjIA8yeWhquKzi9hwwHMtgcMfTYjY6k3vNlnuYi+PRQTB955EJhMSY2yHJSB7uHTDeUQQWiS8ukIKTvhDYRE+SVnwR46Hf4ghZbgQImaQIQaK6eO4u2L6iLje5U3yXNTH3Uy5e0ciVqXKTGCGtAP9b3c+X7PovNl3dHvXVRp06JCM9OWx3VWDWeaARglVjNzTghokkAdSo19fTZd1hed1XHnKjzUeJw/gL0KyaVMaPjyjit3vH5QQdQJZxu0KvApcmn4j67f1PKhs4+eZ/T0TuPvu9OO85upraZ5q1qhe+SJPLyQGWzvVQJ5YWtUoJmEyAhK0YGuA2Cm1BmMkybAQDd+EZKKUwc4kbN/9UBLPwUuZ+e20khZ+DhBMnZspyncZMHIU0Gv7LM8LNyBKDhiEBBVAdcGTdoVIH0QON03TAlPAw/VM7ergdEF2O43wM+CQRyPV6tSuQqm64jAMBTZ+bwGYj47nJFGyvUoVhWpi7EKbOHN6Eb12V6dem2pSLS0/l++3qD4rxXbGRywqa4lvaFffh7+SPEXFQOu2q0d1wAJ2I+ufbFno+IUgBUoscsAkj5hcjqtSlWHWPMBjB88kHY8treOLSSPvPXZSpG5rJzK/sjRy1pLIm/YKDv7Z

1 个答案:

答案 0 :(得分:0)

你能使用JQuery吗?

$('body').append('<img src="data:image/gif;base64,xxxxxxxxxxxxx"'>);

Here is a working fiddle。我对原生javascript不太好,但应该很容易适应......

编辑我显然误解/假设了不同的数据类型。 Try this question