-1
我需要使用下载URL显示图像。我正在使用下面的逻辑将其转换为基本64字符串。使用Base 64字符串显示下载的图像
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(downloadUrl);
HttpWebResponse fileResp = (HttpWebResponse)(fileReq.GetResponse());
fileResp.GetResponseStream().CopyTo(ms);
byte[] byteArray = ms.ToArray();
if (byteArray != null)
{
return Convert.ToBase64String(byteArray);
}
试图用它来显示图像。我在“response.data”中正确地获得Base 64字符串
<img src="data:image/tiff;charset=utf-8;base64,' + response.data + '" />
不过我只看到一张破碎的图像。任何我缺少的东西?
Tiff是一种在浏览器中支持的图像格式吗? – 2014-09-23 15:45:45
可能重复的[有没有HTML5的方法来显示已经加载到内存中的TIFF图像数据](http://stackoverflow.com/questions/16310801/is-there-an-html5-method-for-displaying-a- tiff-image-data-already-loaded-into-me) – MrTux 2014-09-23 15:45:49
你知道这是一个'tiff'文件吗?我以前只和png一起工作过。另外,response.data实际上看起来是什么样的(例如前20个字符)。并且标记和它的src属性是相应的渲染? – ne1410s 2014-09-23 15:46:56