Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

After 3-4 minutes of capture, it gives "Parameter Invalid Error"

$
0
0
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
Code:

            screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format64bppPArgb)
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.
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


Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>