Hi,
It is not really the sample I gave

I see one error in your code: you are calling the
TwainSelectFeeder() method during your acquisition loop.
You must remove all the call to this method. Just add one call after axImaging1.TwainOpenDefaultSource()
Also, you are calling the ConvertTo1BPP() method before acquiring an image. Why ?
Here a cleaner version of your code. maybe your problem will be solved using this one.
- Code: Select all
long nImageCount = 0;
int nTiffOriginal;
int nImageID;
if (axImaging1.TwainOpenDefaultSource() == true)
{
//Check that the TWAIN is ready to scan
if (axImaging1.TwainGetState() == GdPicturePro5.TwainStatus.TWAIN_SOURCE_OPEN)
{
//TWAIN settings for scanning and compressing
axImaging1.TwainSelectFeeder(true);
axImaging1.TwainSetErrorMessage(false);
axImaging1.TwainSetHideUI(true);
axImaging1.TwainSetAutoFeed(true);
axImaging1.TwainSetAutoScan(true);
axImaging1.TwainSetCurrentResolution(300);
axImaging1.TwainSetCurrentPixelType(GdPicturePro5.TwainPixelType.TWPT_BW);
axImaging1.TwainSelectFeeder(true);
axImaging1.TwainSetCurrentBitDepth(1);
axImaging1.TwainSetIndicators(false);
axGdViewer1.SetZoomFitControl();
//While there is something to scan, scan it.
while (axImaging1.TwainAcquireToGdPictureImage(0) != 0)
{
nImageID = axImaging1.GetNativeImage();
nImageCount = nImageCount + 1;
//Create the file and show it in the viewer
if (nImageCount == 1)
{
backgroundWorker1.ReportProgress(0);
nTiffOriginal = axImaging1.TiffCreateMultiPageFromGdPictureImage(nImageID);
axGdViewer1.DisplayFromGdPictureImage(nImageID);
}
//Add to the file and display it in the viewer
else
{
backgroundWorker1.ReportProgress(0);
axImaging1.TiffAppendPageFromGdPictureImage(nTiffOriginal, nImageID);
axGdViewer1.DisplayFromGdPictureImage(nImageID);
axImaging1.CloseImage(nImageID);
}
}
//.tif and TWAIN cleanup
axImaging1.TiffCloseNativeMultiPage();
axImaging1.SetNativeImage(nTiffOriginal);
}
//Displays a message if unable to open printer.
else
{
MessageBox.Show("Unable to open printer");
}
}
//Displays a message if unable to connect to the printer.
else
{
MessageBox.Show("Could not connect to printer");
}
Best regards,
Loïc