Example 9: Set Capabilities

Top  Previous  Next

Example: Set gamma value and author of the Twain device.

 

#include "cdtwain.h"

#include <iostream>

 

using namespace DTWAIN;

using namespace std; // for <iostream>

 

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;

 

  // Set the Gamma value of the Source

  if ( Source.IsCapSupported( DTWAIN_CV_ICAPGAMMA ))

  {

     // Create an array of values ( 1 value, initialized to 0.0 )

    DTwainDoubleArray GammaValue(1, 0.0);

     if ( Source.SetCapValues( DTWAIN_CV_ICAPGAMMA, GammaValue ) )

          cout << "Gamma capability was set to 0.0" << endl;

     else

          cout << "Gamma capability could not be set" << endl;

  }

 

  // Set the author (must be supported by the source)

  if ( Source.IsCapSupported( DTWAIN_CV_CAPAUTHOR ))

  {

     // Create an array of string values ( 1 value, initialized to "DynaRithmic")

    DTwainStringArray Author(1, "DynaRithmic");

     if ( Source.SetCapValues( DTWAIN_CV_CAPAUTHOR, Author) )

          cout << "Author capability was set " << endl;

     else

          cout << "Author capability was not set " << endl;

  }        

}