I didn't get anywhere with AVICap but have had some success with Window
Image Acquisition (WIA) so thought I'd share. This code is from articles
from Bernard Bout on Foxite.

I've also been testing it with scanners for a document
management/billing system I'm working on at the moment.

This code grabs an image from a webcam without any preview screen
 
cdg=Createobject("wia.commondialog")
 img = cdg.ShowAcquireImage
 try
 img.savefile(PUTFILE("Save as","MyPhoto.jpg","JPG"))
CATCH
FINALLY 
ENDTRY

This shows the standard Microsoft screens.

aLocal cdg As Object,dev As Object, IP As Object
SET STEP ON 
 * create the dialog object
 cdg=Createobject("wia.commondialog")
 * show it
 dev=cdg.ShowSelectDevice
 * get the path to temp photos buffered. The WIA buffers ALL old photos
in the Documents & Settings directory. We dont need them so we delete
them.
 cPath = dev.properties(24).Value
 * and erase the old ones
 Erase (cPath+"\*.jpg")
 *
 * get a photo - WIA has its own GUI
 img = cdg.ShowAcquireImage
 If Isnull(img)
 Wait Window Timeout 1 "User Cancelled"
 Return
 Endif
 
* I use TerminalServices so that only 256 colors are available. WIA
outputs by defa in JPG. So By converting to GIF and then BMP I get a 256
colour BMP.!!
 * used for processing the image
 IP = Createobject("WIA.ImageProcess")
 * sets up a conversion filter
 IP.Filters.Add (IP.FilterInfos("Convert").FilterID)

 IP.Filters(1).properties("FormatID").Value =
"{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" && GIF

 * make it a GIF - 256 colors
 img = IP.Apply(img)
 
IP.Filters(1).properties("FormatID").Value =
"{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" && BMP
 * convert the GIP to BMP (256 colors)
 img = IP.Apply(img)
 
* if the previous file is there then WIA complains with an error do we
delete it. Name is stored in Form var cFilename
 Erase ("\xphoto.bmp")
 * And finally - SAVE IT
 img.savefile("\xphoto.bmp")


 

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to