FFTwainScan
TWAIN scanner multi page scan from the Automatic Document Feeder

Prototype

Put the following prototype in the prototypes section of the application program header file:

int ( __stdcall *pFFTwainScan )( HWND, char*, int, int, int, char*, char*, int, int, int );

Purpose

The purpose of this routine is to continuously scan a group of pages from the Automatic Document Feeder, using some of the most popular TWAIN scanners (see specification). Scanning a single page from the flatbed, if present, is also supported. You can see the images on the PC screen as the pages are passing through the feeder. A set of ready to use TIFF files are generated on the hard disk.

Description and use

This function only deals with A4 and A3 paper size sheets. Letter size is almost similar to A4 and you can use it as well. The sheets are scanned black & white at 200 dpi. The images are compressed and put each one into a separate numbered TIFF file. You don't have to allocate any memory area, it's automatically allocated by the function itself.

Simplex and duplex scanners are supported both. If you own a simplex scanner and want to emulate a duplex scanner you can. In fact using this function in a convenient manner you can scan pages both sides (one side at a time) and obtain the results of a duplex scanner while using only a simplex scanner. Instruct your application program to do the following:

  • tell the user to put the sheets in the feeder
  • scan the sheets and put the resulting TIFF files into a park directory
  • set a variable to the number of scanned images (it is the value returned by the function)
  • tell the user to put again the sheets in the feeder, but offering the other side to scan
  • scan the sheets again and put the resulting TIFF files into a separate park directory
  • check that the number of scanned images is the same in the first and in the second pass
  • create a new set of TIFF files (use a copy function) alternating the images from the first park directory in ascending order with the images from the other park directory in descending order
  • delete the images in the park directories

Specification

You can use one of the following scanners:
  • Kodak
  • Canon
The scanning routine has been tested with the following scanners: Kodak i1210C, Kodak i1220C (with A3 flatbed accessory), Kodak i260 and Canon DR-2010C. I believe that the scanning routine works with any Kodak and Canon scanners. In fact I don't think that these big manufacturers release a different TWAIN driver for each scanner model. Yes, there is a difference between Kodak and Canon, but the scanner behaviour among the scanners of the same manufacturer I bet is always the same (see the notes below).

Parameters
  • application handle: the handle to the calling application program (HWND)
  • pointer to a string that will be printed on the top of every image coming from the scanner; optional, if unused set this parameter to zero (char*)
  • paper handling, supported values (int):
    • 0 = scanner flatbed
    • 1 = ADF (Automatic Document Feeder)
  • paper size, supported values (int):
    • 4 = A4 (mm 210 x 297)
    • 3 = A3 (mm 420 x 297)
  • file name starting number (int) e.g. if you set 5 and put 3 sheets in the feeder the result files will be named 00000005.TIF, 00000006.TIF and 00000007.TIF
  • pointer to the path of the destination directory, an ASCIIZ string, TIFF files will be created there (char*)
  • pointer to the comment, an ASCIIZ string that will be written into the ImageDescription tag of the output TIFF files (char*)
  • threeshold: the intensity of the image; any value from 0 to 255; use 128 to start with; adjust according to the clarity of the image; this parameter has no effect on Kodak scanners, see notes below (int)
  • scanner family, supported values (int):
    • 0 = Kodak
    • 1 = Canon
    • 2 = Plustek
  • scanning mode, supported values (int):
    • 0 = simplex scanner
    • 1 = duplex scanner (but only scan front side)
    • 2 = duplex scanner (both sides scanning)

Return value

The function returns an integer: the number of sheets that passed throug the Automatic Document Feeder of the scanner. If the flatbed was selected, it returns 1, obviously.

Application example

See also

Notes

The differences between Kodak and Canon, according to my findings, are the following:
  • setting the ICAP_THRESHOLD capability returns an error from the Kodak i1210C scanner; actually the images returned by this scanner are always perfect and deskewed, and I am sure that image processing is performed in realtime by the firmware of this excellent device
  • setting the ICAP_THRESHOLD capability does not return any error from Canon scanner DR-2010C, but it looks like this capability is more related to the contrast rather than the threshold; anycase it works, even if I think that it is unuseful: in fact leaving the threshold in its middle value (127) always returns excellent images
  • returning from "DG_IMAGE, DAT_IMAGENATIVEXFER, MSG_GET" triplet Kodak i1210C returns a pointer to the bitmap, whereas Canon DR-2010C returns a pointer to a pointer to the bitmap (there is one more level of indirection). I think that the Canon TWAIN driver is flawed, but actually the TWAIN standard itself is not truly standard, too many things are left untold, and the explanation of the mentionned triplet is ambiguous and might have led the Canon programmer to a mistake
  • this is a list of scanners that I have personally tested:
    • Canon DR-2010C:
      • cheap
      • slow (15 ppm A4 @ 200 dpi B&W)
      • no firmware deskew
      • duplex
      • small footprint, excellent ergonomy, excellent lead-in and lead-out paper trays
      • folio mode* feature to scan A3 sheets
      • does not support high volume page scanning; paper transport is poor
    • Kodak i1210C:
      • fast (30 ppm A4 @ 200 dpi B&W)
      • realtime firmware deskew
      • simplex
      • cumbersome lead-in and lead-out paper trays
    • Kodak i1220C Plus:
      • very fast (45 ppm A4 @ 200 dpi B&W; 90 ipm A4 @ 200 dpi B&W)
      • realtime firmware deskew
      • duplex
      • cumbersome lead-in and lead-out paper trays
      • excellent and fast A3 flatbed accessory

In conclusion: I prefer Kodak scanners. On my desk at office I have a Kodak i1220 Plus (with its A3 companion flatbed accessory).

(*) What is "folio mode" ? The scanner is A4, but you can fold in the middle an A3 sheet, and pass it through the scanner. A little special lever increases the gap between the transport rollers, and permits the folded A3 sheet to pass through the scanner without being skewed or wrinkled during the process. Being duplex the scanner, it returns the image for both halves of the A3 paper sheet. The task of building the A3 image from two A4 halves is left up to the application software (it's not a service provided by the TWAIN driver of the scanner; Canon only provides the lever that increases the gap between the rollers).