-
Camera Picture Update
I am loading a picture from a logitech camera into a picturebox, however when I try to update the picture, I cannot use the same filename because it is being used by my program. Is there a way to free the picture from my program?
For instance:
Code:
Dim bmp as bitmap
Dim img as image
AxVideoPortal1.PictureToFile(0, 24, "C:\tmp1.bmp", "Gray Scaled Camera") ' This just traps the image from the camera to a bitmap
bmp = New Bitmap("c:\documents and settings\mark\desktop\picture 1.bmp")
PictureBox1.Image = bmp
img = PictureBox1.Image(bmp)
grayscale(img) 'routine to get grayscale and change picture box to the grayscaled version
-
Works
I got it to work, so if anyone needs to do it, here is the code:
The problem was img was never being disposed.
Code:
Dim err As ErrObject
PictureBox1.Image = Nothing
Try
img.Dispose()
Catch
End Try
FileSystem.Kill("c:\tmp.bmp")
AxVideoPortal1.PictureToFile(0, 24, "C:\tmp.bmp", "Gray Scaled Camera")
img = img.FromFile("c:\tmp.bmp")
grayscale(img)
PictureBox1.Image = img