|
|
 |
neal$2006275 neal 04/05/2007 :: 17:33
Registered
| | I can't seem to figure out how to make duplex scanning work. I have a duplex scanner and have tested it using the UI that comes with the scanner all works well.
I have used the following setting: oGdPicture.TwainEnableDuplex(.T.)
But I'm not sure how the images are referenced in the oGdPicture object. I thought at first it would be similar to that Auto-Document Feeder setup and followed the example on the site, but that did not work. I still only get the front of the page.
An example would be very welcome.
Thanks,
Neal. | |
 |
neal$2006275 neal 04/05/2007 :: 19:32
Registered
| | A bit of further information that may be of help. I noticed the following in the help for TwainEnableDuplex Before using this method check that the TWAIN state is 5 (TWAIN_SOURCE_ENABLED).
In checking, my Twain State is 4, I'm not at all sure how to get to a twain state of 5
ogdpicture.getVersion returns 3.100 although I just installed the latest release. Not sure if this is an issue.
My Code is here. (VFP 9) ======================= ogdpicture = thisform.ogdpicture ogdpicture.twainopendefaultsource ? ogdpicture.twaingetstate * State = 4 at this point oGdPicture.TwainEnableDuplex(.T.) oGdPicture.TwainSetAutoScan (.T.) oGdPicture.TwainSetHideUI (.T.) oGdPicture.TwainSetCurrentResolution (200) oGdPicture.TwainSetCurrentPixelType (0) oGdPicture.TwainSetCurrentBitDepth (2) oGdPicture.TwainSetAutoBrightness (.T.) oGdPicture.CreateImageFromTwain ogdpicture.cropborders ogdpicture.cropblackbands oGdPicture.TwainCloseSourceManager thisform.ogdViewer.displayFromImageRef(ogdpicture.getNativeImage()) thisform.ogdViewer.zoomMode = 6
| |
 |
Loïc$2006306 Loïc 04/06/2007 :: 11:28
Registered
| | Hi Neal,
First, please update your gdpicturepro.ocx and the gdtwain.dll with the last beta release: http://www.gdpicture.com/ressources/betas/
Now the ogdpicture.getVersion call must returns 3.300
And try this code:
ogdpicture = thisform.ogdpicture ogdpicture.twainopendefaultsource oGdPicture.TwainEnableDuplex(.T.) oGdPicture.TwainSetHideUI (.T.) oGdPicture.TwainSetCurrentResolution (200) oGdPicture.TwainSetCurrentPixelType (0) oGdPicture.TwainSetCurrentBitDepth (2) oGdPicture.TwainSetAutoBrightness (.T.)
&&FRONT oGdPicture.CreateImageFromTwain ogdpicture.cropborders ogdpicture.cropblackbands
thisform.ogdViewer.displayFromImageRef(ogdpicture.getNativeImage()) thisform.ogdViewer.zoomMode = 6
&&BACK oGdPicture.CreateImageFromTwain ogdpicture.cropborders ogdpicture.cropblackbands
thisform.ogdViewer.displayFromImageRef(ogdpicture.getNativeImage()) thisform.ogdViewer.zoomMode = 6
oGdPicture.TwainCloseSourceManager
Best regards,
Loïc Carrère | |
 |
neal$2006275 neal 04/09/2007 » 17:47
Registered
| | Hi Loic,
Thanks for the quick reply. I've updated and verified that ogdpicture.getVersion returns 3.300.
I've used the code you provided, and it doesn't seem to work properly. Rather than pulling the back from the scanner memory it scans again to get the back. The scanner I'm using is an Ambir DocketPort 485 (duplex sheetfed scanner). I'm using it to scan insurance cards and drivers licenses.
So here's what happens. I click on scan (run the code you provided) and the card runs through the scanner, updating the odgViewer control. A messagebox then pops up asking me to insert the item to be scanned into the scanner. (This message is coming from the scanner's interface I know, but this is telling me that the 2nd call to CreateImageFromTwain is not getting the data from already scanned back image. Using the software that came with the scanner I can scan both sides of the card in a singe pass.
The next problem is that the viewer control is finishing with only the last scanned image. I'd like to stitch the front and back together as a single image for the cards front above the back, but I could live with saving to a multi-page pdf.
Here's the Exact code I'm using ------------------------------------------ ogdpicture = thisform.ogdpicture ogdpicture.twainopendefaultsource ? ogdpicture.twaingetstate && returns 4 ogdpicture.TwainEnableDuplex(.T.) ogdpicture.TwainSetHideUI (.T.) ogdpicture.TwainSetCurrentResolution (200) ogdpicture.TwainSetCurrentPixelType (0) ogdpicture.TwainSetCurrentBitDepth (2) ogdpicture.TwainSetAutoBrightness (.T.)
&& Front ogdpicture.CreateImageFromTwain ogdpicture.cropborders ogdpicture.cropblackbands thisform.ogdViewer.displayFromImageRef(ogdpicture.getNativeImage()) thisform.ogdViewer.zoomMode = 6
&& Back ogdpicture.CreateImageFromTwain ogdpicture.cropborders ogdpicture.cropblackbands thisform.ogdViewer.displayFromImageRef(ogdpicture.getNativeImage()) thisform.ogdViewer.zoomMode = 6 ogdpicture.twainclosesourcemanager --------------------------------------------------------------
I've also just noted that TwainEnableDuplex(.T.) returns False
Thanks again for your help,
Neal
| |
 |
neal$2006275 neal 04/09/2007 :: 19:48
Registered
| | OK, I've partially solved this. It appears that the scanner I am using shows up as two different scanners in the device list. Once as DocketPORT 485 and once as WIA-DocketPORT 485. If the WIA version is chosen then the TwainEnableDuplex(.T.) command returns False, however with the other driver the command returns a True and the duplex scanning works. 
Now my only problem is how to get the images to display / save properly.
My current code is designed to save as a Multi-Page Tiff and then display it. When I try to do this I get the following error:
OLE Execption error: Exception code c0000005. OLE object may be corrupt.
This happens on the following line: ogpicture.TiffAddToNativeMultiPage(nimage)
Here is the full code:
--------------------------------------------- ogdpicture = thisform.ogdpicture ogdpicture.twainopendefaultsource ogdpicture.TwainEnableDuplex(.T.) ogdpicture.TwainSetHideUI (.T.) ogdpicture.TwainSetCurrentResolution (200) ogdpicture.TwainSetCurrentPixelType (0) ogdpicture.TwainSetCurrentBitDepth (2) ogdpicture.TwainSetAutoBrightness (.T.)
&& Front ogdpicture.CreateImageFromTwain ogdpicture.cropborders ogdpicture.cropblackbands ogdpicture.tiffsaveasNativeMultiPage("c:\multipage.tif",4)
&& Back nimage = ogdpicture.CreateImageFromTwain ogdpicture.cropborders ogdpicture.cropblackbands ogdpicture.tiffAddtoNativeMultipage(nimage) ogdpicture.tiffclosenativemultipage ogdpicture.twainclosesourcemanager
thisform.ogdviewer.displayfromfile("c:\multipage.tif")
--------------------------------------------
This isn't the way I'd like to handle this as I mentioned above I'd prefer to stitch the images into a single image.
Neal.
| |
 |
Loïc$2006306 Loïc 04/11/2007 :: 11:06
Registered
| | Hi neal,
1 - You do not have tu use the microsoft WIA gateway driver with multi-transfers mode. This does not works on all the scanners and cameras. This is a Microsoft bug !!
2 - For your multipage tif file i think the error come here:
ogdpicture.tiffAddtoNativeMultipage(nimage)
use instead:
ogdpicture.tiffAddtoNativeMultipage(ogdpicture.GetnativeImage())
PS: Don't forget to test the returned values of all the functions !
PS2: "WARNING: If success this method changes the native image ID. Use the GetnativeImage() method to catch the new native image ID." => http://www.gdpicture.com/references/gdpicturepro/content/cGdPicture-CropBorders.html
Best regards,
Loïc Carrère | |