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.dis pose
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_Cl ick(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btntakephoto.Cl ick
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(hHw nd, WM_CAP_EDIT_COP Y, 0, 0)
' Get image from clipboard and convert it to a bitmap
If Not System.Windows. Forms.Clipboard .GetDataObject( ) Is Nothing Then
If oDataObj.GetDat aPresent(System .Windows.Forms. DataFormats.Bit map) Then
oImgObj = oDataObj.GetDat a(DataFormats.B itmap, True)
'To Save as Bitmap
If My.Computer.Fil eSystem.FileExi sts(photopath & Me.Tag & ".bmp") Then
My.Computer.Fil eSystem.DeleteF ile(photopath & Me.Tag & ".bmp")
End If
oImgObj.Save(ph otopath & Me.Tag & ".bmp",
System.Drawing. Imaging.ImageFo rmat.Bmp)
ClosePreviewWin dow() 2 4422
Hi
Based on my understanding, you get the exception when the code line
"Image.Save " is executed.
If I have any understanding, please feel free to post here.
Can you post the detailed callstack and error message when the exception
occur?
Also have you tried to save to another name when you retake the photo, did
the problem persists?
From your description, the problem may be relieved if you all
picturebox1.dis pose and picturebox1 = nothing, but from your code snippet,
it did not tell us how do you associate the image with the picturebox1. I
just guess it is possible that the picturebox1 is locking the image
file(just an idea).
Can you explain your code logic thoroughlly?
Also you may try to call the GC.Collect after you are trying to dispose the
picturebox1 and set it to null.
Thanks for your efforts!
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi
Just want to say Hi, and I was wondering how everything is going.
If anything is unclear, please let me know.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: LG |
last post by:
Just have a question with regards to the clipboard, and how to read what
other applications (Adobe InDesignCS) place in the clipboard.
I am currently in the process of creating a booklet from a database, and I
need the data to be laid out in a tabular format, and set out in a specific
way. At the current point in time, I am copy/pasting the raw text from the
database into a table layout in InDesign. What I was thinking is that if I
could...
|
by: zbcong |
last post by:
hello
in my program,i have following method,it copy a jpg file to clipboard,and
works well:
Private Sub CopyImage()
Dim file As System.IO.Stream =
Me.GetType().Assembly.GetManifestResourceStream("ProductCatalog.Nwind.jpg")
Clipboard.SetDataObject(System.Drawing.Image.FromStream(file),
false)
End Sub
|
by: John Smith |
last post by:
Hi folks,
I know how to place text into the user's clipboard:
Clipboard.SetDataObject("My Copied Text");
but how do I place a file in there?
So, if I have a file C:\test.txt, how can I place that file into the user's
clipboard so that they can later paste it into explorer?
Thanks!!!
|
by: DraguVaso |
last post by:
Hi,
I'm looking for a way to Copy and Paste Files to the clipboard.
I found a lot of articles to copy pieces of text and bitmaps etc, but nog
whole files.
Whay I need is like you have in windows explorer: when you do a right-click
on a file and choose Copy, and than paste it somewhere in my application and
vice versa.
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard is proving to be more difficult. These
pictureboxes are bound to an AccessDB. If the user wants to add an image,
they select an image using an OpenFileDialog:
Dim result As DialogResult = Pic_Sel.ShowDialog()
If (result = DialogResult.OK) Then
| |
by: NoDozing |
last post by:
Trying load an embedded object to the clipboard and then save it to a file. When I try and save to the file, I'm getting a "Object reference not set to an instance of an object". I've marked the line with ---->>> where the error occurs. Any help would be appreciated.
Dim InShapeObj As Word.InlineShape
Dim SaveObj As New DataObject
Dim ImageObj As Image
Dim WordApp As New Word.ApplicationClass...
|
by: Ludwig Wittgenstein |
last post by:
Hi, all.
Here's the scenario: I embedd a .txt file in Word as OLE object,
then I copy it (manually), so now it's on the clipboard. How do I
programatically (in C#) get that OLE object file from the clipboard
and dump it into an actual text file on the file system? All I would
like to know is how to grab the OLE from the clipboard and transform
it into a file, stream, string, or anything that gives me the internal
contents of that txt...
|
by: exhuma.twn |
last post by:
As many might know, windows allows to copy an image into the clipboard
by pressing the "Print Screen" button on the keyboard. Is it possible
to paste such an image from the clipboard into a "Text" widget in
Tkinter? Here is my first attempt with just trying to print out the
image data:
-----------------
def pasteImg(tgt):
global clipboardEnabled
if not clipboardEnabled: return
|
by: active |
last post by:
Guess I'm looking for someone who likes to work difficult puzzles.
I can't seem to ever retrieve a palette handle from the clipboard.
Below is a simple test program that demonstrates the problem.
The program uses windows api to get a handle to a palette from the
clipboard.
The palette needs to be put there by another program - maybe Photoshop.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |