-1

我正在尝试将字节数组转换为图像这是我的代码:

Public img As BitmapImage
Public bytes As Byte()
Sub convert()
    Using ms As New MemoryStream(bytes, 0, bytes.Length)
        ms.Write(bytes, 0, bytes.Length)
        'Dim bitmg As New BitmapImage
        'bitmg.SetSource(ms)
        img.SetSource(ms)
    End Using
End Sub

但是当我运行应用程序时出现此错误:最后一行未处理空引用

img.SetSource(ms)

有任何想法吗 ?谢谢你

4

1 回答 1

1

您没有显示任何实际给出img值的代码。你有

img = New BitmapImage

任何地方?

于 2012-11-08T13:59:01.893 回答