Hi,
I am trying to capture screen every 0.5 seconds using a timer. It works fine for about 3-4 minutes (approx)... and from there the line
errors out giving "Parameter invalid" error. Not sure why it is happening. The images captured into the queue are frequently flushed to files. and hence Queue is more or less empty ... Any direction on the error would be helpful.
I am trying to capture screen every 0.5 seconds using a timer. It works fine for about 3-4 minutes (approx)... and from there the line
Code:
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format64bppPArgb)Code:
Dim qImg As New Queue(Of Image)
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
'Application.DoEvents()
Try
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
Cursor.Draw(graph, New Rectangle(New Point(Cursor.Position.X - Cursor.HotSpot.X, Cursor.Position.Y - Cursor.HotSpot.Y), Cursor.Size))
qImg.Enqueue(screenshot)
Catch ex As Exception
DE(ex)
Timer1.Stop()
Timer1.Enabled = False
End Try
End Sub