ImageGear for C and C++ on Windows v19.10 - Updated
Simplify the Scanning Application
User Guide > How to Work with... > Common Operations > Scanning > ISIS Scanning > Simplify the Scanning Application

Now that you have seen how to individually load, initialize, and link drivers, there is a simpler way that can often be used to make the toolkit do much of this work for you: IG_ISIS_drv_load_init_pipe(). Here are the steps involved in writing the same scanning application using IG_ISIS_drv_load_init_pipe():

  1. Load, initialize, and link the scanner driver and the file writing driver:
     
    Copy Code
    IG_ISIS_drv_load_init_pipe (0, "SPEW|PIXFPACK", &hScan, 0);
    
  2. Set tags on the pipe to specify the filename, file type, and how to write the file:
     
    Copy Code
    IG_ISIS_tag_set_ascii(hScan, IG_ISIS_TAG_OUTPUTNAME, (char FAR *)"TEST.TIF");
    IG_ISIS_tag_set_long(hScan, IG_ISIS_TAG_FILETYPE, 0, IG_ISIS_FILETYPE_TIFF);
    

    This step is the same as before, except the tags are set on the scanner driver because there is no handle to the file writing driver. (ISIS propagates all tags to every driver in the pipe, so this is not a problem). If you need access to a particular driver's handle, that driver must be loaded, initialized, and linked separately.

  3. Invoke the pipe:
     
    Copy Code
    IG_ISIS_run_zone (hScan, Buffer, BUFSIZE);
    

    This step is the same as before.

  4. Unlink and unload the drivers when you are done with them:
     
    Copy Code
    IG_ISIS_drv_unload_pipe (hScan);
    

    This single function unloads the entire pipe. If you loaded and linked any drivers using separate functions, they also will be unlinked and unloaded by the call to IG_ISIS_drv_unload_pipe().

Example:

Here is the complete simplified code to scan a page to a file:

 
Copy Code
#include <windows.h>

#include "gear.h"
#include "i_ISIS.h"

void ScanPageToFileUsingPipe( )
{
    BYTE buffer[8192];
    HISISDRV hScan = 0;

    // Load and initialize the pipe.
    IG_ISIS_drv_load_init_pipe(0, "SPEW|PIXFPACK", &hScan, 0);

    // Set tags to correctly write the file. 
    IG_ISIS_tag_set_ascii(hScan, IG_ISIS_TAG_OUTPUTNAME, (char FAR *)"Test.tif");
    IG_ISIS_tag_set_long(hScan, IG_ISIS_TAG_FILETYPE, 0, IG_ISIS_FILETYPE_TIFF);

    // Invoke the pipe and scan the page.
    IG_ISIS_run_zone(hScan, buffer, sizeof(buffer));

    // Unlink and unload the drivers.
    IG_ISIS_drv_unload_pipe(hScan);
}