DTWAIN_SetCamera

Top  Previous  Next

The DTWAIN_SetCamera sets the current "camera" that is used when acquiring images. The Source must support TWAIN File System handling.

 

DTWAIN_BOOL DTWAIN_SetPrinterStrings (

DTWAIN_SOURCE

Source,

LONG

CameraName );

 

Parameters

Source

An open TWAIN Source.

 

CameraName

Name of the camera to set as the current camera

 

 
Return Values

The return value is TRUE if successful.  Otherwise FALSE is returned.

 

Comments

The DTWAIN_SetCamera function sets the current "camera" used when acquiring images.  This function is mostly used for duplex scanners and other equipment that have multiple input "cameras" that are responsible for recording the image data from the physical page.  For more information, please see Duplex Camera Processing.  The Source must support the TWAIN File System handling for this function to have any effect.

 

By setting the current camera, the application can control which camera will have resolution, bit depth, contrast, etc. set when acquiring an image.  Some duplex scanners contain multiple cameras, and the application may be required to select the appropriate camera to set the resolution.

 

If the Source supports the TWAIN File System, the list of camera names can be retrieved by calling DTWAIN_EnumCameras, DTWAIN_EnumTopCameras, and DTWAIN_EnumBottomCameras.  Once these names are retrieved, the CameraName parameter will be one of these names.  By setting the current camera, any subsequent settings for resolution, brightness, etc. will be applied to that camera.

 

Please note that the above scenario should be typical of most Sources that support multiple input cameras.

 

Below is a C/C++ sample of the usage of this function:

 

#include "dtwain.h"

#include <stdio.h>

 

void foo( )

{

   DTWAIN_ARRAY CameraArray;

   DTWAIN_BOOL  Ok;

   LONG Count;

  char szCameraName[256]; /* Must be at least 255 for DTWAIN_STRING's */

   DTWAIN_SOURCE Source;

 

   /* ... */

   /* Assume Source has been opened */

   /* ... */

 

   /* Discover all the camera names */

   Ok = DTWAIN_EnumCameras( Source, &CameraArray );

   if ( Ok )

   {

         LONG current;

         /* Get the number of camera names found */

         Count = DTWAIN_ArrayGetCount( CameraArray );

 

        /* print out each of the names */

         for ( current = 0; current < Count; ++current )

         {

            /* Since each element of the DTWAIN_ARRAY is a DTWAIN_STRING, use

               DTWAIN_ArrayGetAtString to retrieve the info */

 

            DTWAIN_ArrayGetAtString( CameraArray, current, szCameraName );

             printf ("Camera name %d is %s\n", current+1, szCameraName );

 

       }

 

        /* Let's set the resolution for the Bitonal camera that was found.  Assume that 300 DPI is a valid resolution to use */

       DTWAIN_ArrayGetAtString( CameraArray, 0, szCameraName );

       DTWAIN_SetCamera( Source, szCameraName );
      DTWAIN_SetResolution( Source, 300.0 );

 

       /* Remove the array from memory */

      DTWAIN_ArrayDestroy( CameraArray );

  }

}

 

Output::

Camera name 1 is \Camera_Bitonal

Camera name 2 is \Camera_Color

 

 

TWAIN State Transitions

The Source must be in State 4 or higher

 

Prerequisite Function Call(s)

DTWAIN_SysInitialize

DTWAIN Source Selection Function

 

 

See Also

Duplex Camera Processing