1
我正在使用網絡攝像頭的安全攝像頭應用程序,該攝像頭每隔x毫秒用戶選擇一張照片就會拍攝一張照片。 (默認值爲2000毫秒或2秒)目前,這些文件默認存儲在用戶的硬盤上。VB.NET保存圖像作爲日期
我想要做的不是將它保存爲1.bmp,2.bmp,3.bmp等:但是到日期和時間,例如。 「Jul 03 12:14:53.bmp」使用此 - DateTime.Now.ToString(「MMM dd hh:mm:ss」)
但是很明顯,我沒有運氣,並繼續得到錯誤。所以這裏是我的代碼之前,我得到了所有這些錯誤,任何幫助將不勝感激。謝謝!
Dim frame As Integer
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
frame += 1
Dim r As RECT = New RECT()
GetWindowRect(hWnd, r)
Dim cWidth As Integer = r.right - r.left
Dim cHeight As Integer = r.bottom - r.top
Dim bmp As Bitmap = New Bitmap(cWidth, cHeight)
Dim gfx As Graphics = Graphics.FromImage(bmp)
Dim gHdc As IntPtr = gfx.GetHdc()
'refresh the image
SendMessage(hWnd, WM_CAP_GRAB_FRAME, IntPtr.Zero, IntPtr.Zero)
PrintWindow(hWnd, gHdc, 0)
gfx.ReleaseHdc(gHdc)
gfx.Dispose()
bmp.Save("photos-taken\" & frame & ".bmp")
bmp.Dispose()
End Sub
Private Sub RecordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RecordToolStripMenuItem.Click
If Not Directory.Exists("photos-taken") Then
Directory.CreateDirectory("photos-taken")
End If
If RecordToolStripMenuItem.Checked = False Then
RecordToolStripMenuItem.Checked = True
frame = 0
Timer2.Interval = 2000
Timer2.Start()
Else
RecordToolStripMenuItem.Checked = False
frame = 0
Timer2.Stop()
End If
End Sub
什麼是錯誤? –