Saving VB6 picturebox image content to file?
-
- Posts: 22
- Joined: Tue Aug 14, 2007 7:26 am
Saving VB6 picturebox image content to file?
Using VB6, I use "objCamera.DrawFrame oNewFrame, pic1.hwnd" to update a picturebox with the current frame image. How can I save this image to file?
Re: Saving VB6 picturebox image content to file?
This is inefficient, but should work.
Code: Select all
' save VGA image from V100 camera
' assumes control named pic1,size 640x480, scalemode = pixel,autoredraw = true
' assumes camera frame of oNewFrame exists and is valid
Dim arrayImageBuf(921600) As Byte ' 640 x 480 x 3 = 921600 bytes for 24 bit depth
Dim pxRed, pxGreen, pxBlue
Dim x,y
' render the frame image into a buffer
' 640x480, auto calculate byte span, 24 bits per pixel
oCamera.GetFrameImage oNewFrame, 640, 480, 0, 24, arrayImageBuf(1)
' copy image from buffer into picturebox control
' inefficient, SetBitmapBits from gdi32.dll would be faster
For x = 0 To 639
For y = 0 To 479
pxRed = arrayImageBuf((((y * 640) + x) * 3) + 3)
pxGreen = arrayImageBuf((((y * 640) + x) * 3) + 2)
pxBlue = arrayImageBuf((((y * 640) + x) * 3) + 1)
pic1.PSet (x, y), RGB(pxRed, pxGreen, pxBlue)
Next y
Next x
' save the image to a file
SavePicture pic1.Image, "c:\Example.bmp"
-
- Posts: 22
- Joined: Tue Aug 14, 2007 7:26 am
Re: Saving VB6 picturebox image content to file?
Thanks! That works fine for me!