DTwainSource::EnumContrastValues

Top  Previous  Next

Syntax

bool DTwainSource::EnumContrastValues( DTwainDoubleArray& Values, bool ExpandRange = true ) const;

 

Parameters

Values

Vector of double values that on return will have the supported contrast values of the Twain Source.

 

ExpandRange

If true, expand the range into discrete values if the Twain driver defines the contrast value using a range instead of discrete values.

 

Return Value

true if successful, false otherwise.

 

Comments

This function returns a DTwainDoubleArray Values that denotes all of the supported contrast values of the Twain Source.  The ExpandRange parameter denotes whether to expand the range of values into discrete values (if the Source uses a range to define the contrast values).  By default, range expansion is turned off.

 

For example, if the Source defines the contrast values in the range from -100 to 100 using a step of 1, and the ExpandRange parameter is false, the DTwainDoubleArray will contain the following on return of EnumContrastValues:

 

DTwainDoubleArray[0] = -100.0

DTwainDoubleArray[1] = 100.0

DTwainDoubleArray[2] = 1.0

DTwainDoubleArray[3] = // some default value

DTwainDoubleArray[4] = // some curernt value

 

The values above define a range -- they are not all of the contrast values.

 

However, if ExpandRange were true, the DTwainDoubleArray on return wold contain these values:

 

DTwainDoubleArray[0] = -100.0

DTwainDoubleArray[1] = -99.0;

DTwainDoubleArray[2] = -98.0

DTwainDoubleArray[3] = -97.0

//...

 

All the way up to the last entry in the DTwainDoubleArray being 100.0

 

These values above are actual brightnness values (the DTwainDoubleArray no longer represents a range).

 

Please note that some Sources do not use ranges to define contrast values.  To test if the Source does or does not use a range to define contrast values, call the IsCapContainerRange( ) member function of DTwainSource using DTWAIN_CV_ICAPCONTRAST as the capability to check for range support.

 

The following is a small sample of expanding the values if a range is used to store the contrast values:

 

#include <cdtwain.h>

#include <iostream>

 

using namespace DTWAIN;

using namespace std;

 

int main( )

{

  DTwainInterface TI(NULL, NULL);

  DTwainSource Source = DTwainSource::Select( );

  if ( !Source.IsValid( ) )

     return 0;

 

  // Get contrast values.  Expand values if range is used

  DTwainDoubleArray ContrastValues;

  Source.EnumContrastValues( ContrastValues );

 

  // display contrast values to console

  for ( int i = 0; i < ContrastValues.size( ); ++i )

    cout << "Contrast value " << i+1 << " = " << ContrastValues[i] << endl;

}