S
steve
Hi All
I have a program which takes photos of members using a web cam, then saves
them as bitmap files
The bitmap is used by a Picturebox to display the photo and clicking on a
button enables the camera and another button takes the photo and saves it
In VS 2003(VB) all worked fine, but since moving up to VS 2005 (VB) when I
try to retake a photo and save it I get error messages
'General exception occurred in GDI+' when I try to save the new photo with
the same name as an existing one
I now call ...
picturebox1.dispose
picturebox1 = nothing
before taking the new photo and saving but occasionally get messages that
another process has locked the file when I try to delete the existing file
Has anything changed in VS 2005 ???
Below is the full code for the picture capture routine
Regards
Steve
Private Sub btntakephoto_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntakephoto.Click
Dim oDataObj As IDataObject = System.Windows.Forms.Clipboard.GetDataObject()
Dim sql As String = ""
Dim oImgObj As System.Drawing.Image
Try
Clipboard.Clear()
' Copy image to clipboard
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
' Get image from clipboard and convert it to a bitmap
If Not System.Windows.Forms.Clipboard.GetDataObject() Is Nothing Then
If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
oImgObj = oDataObj.GetData(DataFormats.Bitmap, True)
'To Save as Bitmap
If My.Computer.FileSystem.FileExists(photopath & Me.Tag & ".bmp") Then
My.Computer.FileSystem.DeleteFile(photopath & Me.Tag & ".bmp")
End If
oImgObj.Save(photopath & Me.Tag & ".bmp",
System.Drawing.Imaging.ImageFormat.Bmp)
ClosePreviewWindow()
I have a program which takes photos of members using a web cam, then saves
them as bitmap files
The bitmap is used by a Picturebox to display the photo and clicking on a
button enables the camera and another button takes the photo and saves it
In VS 2003(VB) all worked fine, but since moving up to VS 2005 (VB) when I
try to retake a photo and save it I get error messages
'General exception occurred in GDI+' when I try to save the new photo with
the same name as an existing one
I now call ...
picturebox1.dispose
picturebox1 = nothing
before taking the new photo and saving but occasionally get messages that
another process has locked the file when I try to delete the existing file
Has anything changed in VS 2005 ???
Below is the full code for the picture capture routine
Regards
Steve
Private Sub btntakephoto_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntakephoto.Click
Dim oDataObj As IDataObject = System.Windows.Forms.Clipboard.GetDataObject()
Dim sql As String = ""
Dim oImgObj As System.Drawing.Image
Try
Clipboard.Clear()
' Copy image to clipboard
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)
' Get image from clipboard and convert it to a bitmap
If Not System.Windows.Forms.Clipboard.GetDataObject() Is Nothing Then
If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
oImgObj = oDataObj.GetData(DataFormats.Bitmap, True)
'To Save as Bitmap
If My.Computer.FileSystem.FileExists(photopath & Me.Tag & ".bmp") Then
My.Computer.FileSystem.DeleteFile(photopath & Me.Tag & ".bmp")
End If
oImgObj.Save(photopath & Me.Tag & ".bmp",
System.Drawing.Imaging.ImageFormat.Bmp)
ClosePreviewWindow()