|
-
Mar 30th, 2004, 08:51 PM
#1
Thread Starter
New Member
Saving an Image in vb.net
Hi,
I'm trying to save an image from a picturebox which contains a live webcam feed using the following line in a button,
pictureBox1.image.Save("data.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
but when I run this, I keep getting an error saying "Object reference not set to an instance of an object"..how can I can fix this problem??
Thx,
-
Mar 30th, 2004, 09:58 PM
#2
I wonder how many charact
I don't understand how you are actually able to run a webcam video through a picturebox, but by the looks of that error..
the picturebox does not actually contain the image data... so when you try to save the contents of its image property as you did above, there is nothing there, so it reports no object available.
-
Mar 30th, 2004, 11:13 PM
#3
I wonder how many charact
In other words, you are probably implementing the webcam video by drawing on picturebox's graphics surface, which does not mean the picturebox contains the image. It simply means you are overriding what the picturebox would normally draw on its surface (the image contained in its image property).
-
Mar 30th, 2004, 11:35 PM
#4
Thread Starter
New Member
so can I get a hold of the webcam data from the picturebox??
-
Mar 30th, 2004, 11:41 PM
#5
I wonder how many charact
Do you have the code you use to put the webcam data there?
-
Mar 31st, 2004, 01:57 AM
#6
just a suggestion, I dont have any idea whatsoever on what's going on... but as nemaroller said the picturebox.Image is probably null.... if you are drawing the stuff on the picturebox manually then I guess this would apply to you:
instead of using the graphics object passed in the paint event of the picturebox (of instead of calling picturebox.CreateGraphics) try to do something like this
VB Code:
dim gr as graphics = graphics.fromImage (yourPictureBox.Image)
'now when you call 'gr' it modifies the actual image in the picturebox
dunno if I'm helping, but thought I should mention it
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Mar 31st, 2004, 11:17 AM
#7
Thread Starter
New Member
I followed a tutorial from the following site to implement the live web cam feed..
http://www.webtropy.com/articles/art7.asp
-
Mar 31st, 2004, 06:08 PM
#8
I wonder how many charact
Ok, that code is what i suspected.
The image data does not reside inside the picturebox image property. The code is simply drawing on the picturebox's graphics surface. The picturebox isn't drawing the image, the VFW (Video For Windows) API is, therefore the picturebox knows nothing about what's being displayed.
There is no way to 'capture' the image using Picturebox methods.
However I suspect the VFW API may have a way to snapshot the image data, and fill a byte array or buffer with it.
-
Mar 31st, 2004, 08:44 PM
#9
Hyperactive Member
I don't know if you're interested in third party tools but...
I use an activeX add-in that I purchased from http://www.activevideotools.com for under a hundred bucks that made the task of capturing still photos from an incoming video feed extremely easy.
Im using a winnov videum capture card but any video card that supports VFW will work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|