Windows下bmp(即DIB文件)的具体格式可参见《Windows程序设计(第5版)》,在此不做介绍。
Dim fs As FileStream = New FileStream("test.bmp", FileMode.Open, FileAccess.Read)
Dim br As BinaryReader = New BinaryReader(fs)
br.ReadBytes(14) '先读BITMAPFILEHEADER结构,共14字节
Dim img() As Byte = br.ReadBytes(fs.Length - 14)
br.Close()
fs.Close()
Dim ms As MemoryStream = New MemoryStream
ms.Write(img, 0, img.Length)
Clipboard.Clear()
Clipboard.SetData(DataFormats.Dib, ms)'必须利用MemoryStream,不能直接传Byte数组
ms.Dispose()