我可以通过以下方式获取图像文件的字节:
Dim nBytes() As Byte
nBytes = File.ReadAllBytes(uPath)
这很好,但我想从仅存在于内存中的位图中获取字节。 我不想先将其保存到文件中。 是否可能,如果是,如何实现?谢谢。
System.Drawing.Bitmap
。Using ms As New MemoryStream()
myBitmap.Save(ms, ImageFormat.xxx)
ms.Position = 0
Return ms.ToArray()
End Using
ms.Position = 0
这行可能在仅调用 ToArray()
时不需要。我是将内存流设置为另一个对象的流属性,因此在那种情况下需要重置。