0
A
回答
2
爲了在使用圖像形式的數據url,僅使用src屬性中的base64編碼圖像數據是不夠的,您還需要使用前綴來告訴瀏覽器數據url正在跟隨。
用途:
<img src="data:image/png;base64,<%= FlagPic %>" alt="Bla"/>
注意,內容類型(這裏圖像/ PNG)必須適合圖像圖形格式。
4
由於SRC具有開始與 「數據:{圖像/格式}; BASE64,」
嘗試這種情況:
public string FlagPic
{
get
{
using (System.IO.MemoryStream m = new System.IO.MemoryStream())
{
ClassLibrary1.Resource1.flag.Save(m, ClassLibrary1.Resource1.flag.RawFormat);
byte[] imageBytes = m.ToArray();
base64Image = System.Convert.ToBase64String(imageBytes);
return String.Format("data:{1};base64,{0}", base64Image, ClassLibrary1.Resource1.flag.RawFormat);
}
}
}
相關問題
- 1. 好奇爲什麼我的圖像沒有出現
- 2. 爲什麼我的圖像沒有出現在我的Spring Web Flow項目中
- 3. 爲什麼我的圖像沒有出現在D3圖表的節點中?
- 4. 當我的ListBox中有圖像時,爲什麼會出現OutOfMemoryException?
- 5. 爲什麼我的線路沒有出現在地圖上?
- 6. 爲什麼我的圖片沒有出現在Firefox中?
- 7. 爲什麼它沒有出現圖像選項?
- 8. 爲什麼我的div沒有出現? - 沒有CSS/JS
- 9. PyGame:我的圖像沒有出現
- 10. 爲什麼我的標註沒有出現在我的地圖視圖中?
- 11. 爲什麼我的盒子沒有出現在我的部分?
- 12. 爲什麼圖中的圖像沒有出現在橫幅區域?
- 13. 爲什麼我的文字沒有包裹我的圖像?
- 14. 爲什麼我的文字沒有包裹我的圖像?
- 15. 爲什麼我的圖像沒有顯示在我的UserControl中?
- 16. 爲什麼文本框沒有出現
- 17. 爲什麼OpenGL霧沒有出現?
- 18. 爲什麼沒有出現ActionBar? Nativescript/Angular2
- 19. 爲什麼我的vtkContourFilter沒有輸出?
- 20. 爲什麼我的混合圖像畫布不會出現? (ReactJS)
- 21. 爲什麼我的背景CSS圖像不出現在DIV中?
- 22. 爲什麼圖像不會出現在我的網站上
- 23. 爲什麼圖像(在CSS中)不出現在我的HTML?
- 24. 爲什麼我的圖像出現亂碼?
- 25. 爲什麼我沒有在我的點輸出中獲得任何圖像?
- 26. 爲什麼我的K2程序沒有出現在報告中?
- 27. 爲什麼我的畫布上沒有任何東西出現?
- 28. 爲什麼我的節點沒有出現在SpriteKit模板中?
- 29. 爲什麼我的網站沒有出現在Internet Explorer中?
- 30. 爲什麼我的Write-Verbose消息沒有出現?
當您檢查瀏覽器中的元素時,標記看起來像什麼? – terbubbs
請不要使用屏幕截圖來顯示代碼,而是實際上將代碼複製到問題中 – NineBerry