DTwainSourceFileTransfer Overview

Top  Previous  Next

The DTwainSourceFileTransfer class is derived from DTwainCompressedTransfer. Therefore public functions available to DTwainCompressedTransfer are available to DTwainSourceFileTransfer.

 

The DTwainSourceFileTransfer class allows your application to use the Twain Source's internal file transfer mechanism.  Many Twain Source's have the ability to acquire to files.  In some situations, the application may desire to use the Source's file transfer support.  For example, the Source may be able to save to file types not available with DTWAIN's file transfer support.

 

Please note that the file transfer that is supported by the Twain Source is not the same as the DTWAIN file transfer support.  The DTWAIN file transfer support works for any Twain Source, even ones that do not have internal file transfer support.  There are vast differences between the two methods, most notably that

 

1) The DTWAIN file transfer support actually transfers images from the device using the native or buffered transfer, and then saves the acquired image to a file.   On the other hand, the internal Source's file transfer is separate and apart from native or buffered transfers.

 

2) The DTWAIN file transfer support can save to a set number of image file formats for all TWAIN devices, while the internal Source file transfer support varies between devices as to the number of formats available.  For example, some devices can acquire to multi-page TIFF files, while others only offer BMP transfers.

 

3) Some Sources do not support internal file transfer support at all.  The DTWAIN file transfer support is available for all devices, since the actual transfer that is being done is either native or buffered (where either one must be supported by all TWAIN Sources).

 

4) The Source's internal file transfer support may offer file formats that are not available with DTWAIN file transfers.  For example, some TWAIN enabled cameras offer the FPX image format for acquired image.  Currently FPX format is not available with DTWAIN file transfers.

 

The program below is an example of acquiring using the Source's file transfer support.

 

#include "cdtwain.h"  // CDTwain

using namespace DTWAIN;

 

int main( )

{

  // Initialize DTWAIN - return if initialization does not work

  DTwainInterface TI;

  if ( !TI.IsValid( ) )

      return 0;

 

  // Select a source

  DTwainSource Source = DTwainSource::Select( );

  if ( !Source.IsValid( ) )

     return 0;

 

  // Create an acquire object, attach the source

  DTwainAcquirer Acq( Source );

 

  // Create a source mode file transfer object, and attach Source to the object,

  DTwainSourceFileTransfer FT(Source);

 

  // check if BMP file transfers are supported by the Source

  if ( !FT.IsSupported( FILETYPE_SOURCE_BMP ) )

       return 0;  // not supported

 

  // Set the transfer type

  FT.SetTransferType( FILETYPE_SOURCE_BMP );

 

  // Go.

  Acq.Acquire( FT, "FILE.BMP"  );  

} // If acquisition completed, a file called FILE.BMP contains the raw image data that was transferred.

 

The program above declares a DTwainSourceFileTransfer FT, and attaches the source Source to it.  From there, your application can query whether a certain file format is supported, set or get the current transfer type, and many other things (in addition to calling the DTwainCompressedTransfer functions).

 

Note the call to Acq.Acquire; the argument passed to this function is the DTwainSourceFileTransfer, and the file name to use to save the file.