I am populating resource images into an HTML table on a WebBrowser control. Thus far, I can convert images to Byte using the function listed below, but am unable to cast the memory stream into the HTML:
Dim imgBase64 As String = Convert.ToBase64String(BmpToBytes_MemStream(My.Resources.myimage))
Dim str1 as String = ""
str1 += ("<table class=" & """" & "mycssclass" & """" & " Align=center>")
str1 += ("<caption><b>My Caption</b></caption>")
str1 += "<tr><td><iframe width=100% height=100% src=imgBase64></iframe></td></tr>"
str1 += ("</table>")
WebBrowser1.Refresh()
WebBrowser1.DocumentText = str1
Below is the image BMP to byte function:
Private Function BmpToBytes_MemStream(ByVal bmp As Bitmap) As Byte()
Return new ImageConverter().ConvertTo(bmp, GetType(byte()))
End Function
There is an example of loading a pdf into an IFRAME inside the HTML, like this:
$"<iframe width=100% height=500 src=""data:Application/pdf;base64,{pdfBase64}"">"
However, I am unsure of the exact syntax required for displaying the Base64 image inside the IFRAME in HTML. Also, is the "$" character needed?