0

I would like to capture a picture from a video recording and save it into a folder. When i capture it for the second time, a problem stated that "A generic error occurred in GDI+". I have fully access right to the folder and the path of the folder is correct.

Below is my coding

PictureBox1 is picture box used to record video

picImage is another windows form used to capture picture

    Private Sub ButtonFOTO_Click(sender As Object, e As EventArgs) Handles ButtonFOTO.Click
        Capturer.picImage.Image = PictureBox1.Image
        Capturer.Show()
        Threading.Thread.Sleep(1000)
        Capturer.ButtonGUARDAR.PerformClick()
    End Sub




    Public Class Capturer
Private Sub ButtonGUARDAR_Click(sender As Object, e As EventArgs) Handles ButtonGUARDAR.Click

        Dim bm As Bitmap = New Bitmap(picImage.Image)


        bm.Save("C:\Users\lim\Desktop\photo\picture\test11.jpg", Imaging.ImageFormat.Jpeg)

        Me.Hide()
    End Sub
End Class
Beginner
  • 11
  • 4
  • All errors in the WinForms graphics subsystem (which is a wrapper around GDI+) are "generic" errors. This is basically the only error message you'll ever get. Very good odds that your problem is a resource leak. You are creating a new Bitmap object on each button click event, but never destroying it. Wrap the creation of all objects that implement the `IDisposable` interface (like `Bitmap`) in a `Using` block. – Cody Gray - on strike Mar 31 '17 at 15:31
  • How to implement IDisposable? Public Class Capturer : Implements IDisposable? Or create a new class ? – Beginner Apr 01 '17 at 04:25

0 Answers0