以下代码获取页面加载时的图像名称:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim getImg As New GetImage.SoapClient
Dim ImageService As New Service.serviceClient
Dim imageName As String = ImageService.getImgName(imageID)
Dim binaryImage As Byte() = getImg.getImgDisplay(imageName )
Image123.ImageUrl = "data:image/png;base64," & imageName
End If
End Sub
<asp:Image ID="Image123" runat="server" Visible="true" />
在以下代码行中,我收到了图像名称“imageName”:
Dim binaryImage As Byte() = getImg.getImgDisplay(imageName )
如何在HTML上显示这个,因为它是一个字节?
答案 0 :(得分:1)
byte[]
不等于base64
,如果您尝试在网页上嵌入,则该图片需要采用何种格式。您需要转换byte[]
才能将图像嵌入到html中。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim getImg As New GetImage.SoapClient
Dim ImageService As New Service.serviceClient
Dim imageName As String = ImageService.getImgName(imageID)
Dim binaryImage As Byte() = getImg.getImgDisplay(imageName )
Image123.ImageUrl = "data:image/png;base64," & Convert.ToBase64(binaryImage)
End If
End Sub