DTwainSource::EnumResolutionValues

Top  Previous  Next

Syntax

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

 

Parameters

Values

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

 

ExpandRange

If true, expand the range into discrete values if the Twain driver defines the resolution 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 resolution 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 resolution values).  By default, range expansion is turned off.

 

For example, if the Source defines the resolution 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 EnumResolutionValues:

 

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 resolution 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 resolution values.  To test if the Source does or does not use a range to define resolution values, call the IsCapContainerRange( ) member function of DTwainSource using DTWAIN_CV_ICAPXRESOLUTION 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 resolution 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 resolution values.  Expand values if range is used

  DTwainDoubleArray ResolutionValues;

  Source.EnumResolutionValues( ResolutionValues );

 

  // display resolution values to console

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

    cout << "Resolution value " << i+1 << " = " << ResolutionValues[i] << endl;

}