我有一个使用此源代码使用网络摄像头捕获图像的程序... http://www.thaiio.com/prog-cgi/vbnetwebcam.html 这是Sub,它将从剪贴板中获取图像并将其转换为Bitmap ...
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim data As IDataObject
Dim bmap As Bitmap
'
' Copy image to clipboard
'
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
'
' Get image from clipboard and convert it to a bitmap
'
data = Clipboard.GetDataObject()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
picCapture.Image = bmap
ClosePreviewWindow()
btnSave.Enabled = False
btnStop.Enabled = False
btnStart.Enabled = True
btnInfo.Enabled = False
Trace.Assert(Not (bmap Is Nothing))
sfdImage.Filter = ("Jpeg|*.jpg")
If sfdImage.ShowDialog = DialogResult.OK Then
bmap.Save(sfdImage.FileName, Imaging.ImageFormat.Jpeg)
End If
End If
End Sub
我收到错误“值不能为空。参数名称:编码器” 当试图将它保存在Memorystream上时,也许是因为我应该首先获得原始格式。关于我该怎么办的任何想法?
答案 0 :(得分:0)
很抱歉发布这个问题,我想出了答案。请求帮助。
Dim ms As New MemoryStream()
bmap.Save(ms,Imaging.ImageFormat.Jpeg)
Dim arrImage()As Byte = ms.GetBuffer
ms.Close()