-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