DTwainSource::EnumBrightnessValues

Top  Previous  Next

Syntax

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

 

Parameters

Values

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

 

ExpandRange

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

 

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

 

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

  DTwainDoubleArray BrightnessValues;

  Source.EnumBrightnessValues( BrightnessValues );

 

   if ( Source.IsCapContainerRange( DTWAIN_CV_ICAPBRIGHTNESS ) )

   {

         // Create a temporary range and expand the range into the BrightnessValues array

         MakeDoubleRange(BrightnessValues).Expand( BrightnessValues );

   }

 

   // display brightness values to console

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

       cout << "Brightness value " << i+1 << " = " << BrightnessValues[i] << endl;

}