L_TwainSetImageUnit

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainSetImageUnit(hSession, nUnit)

HTWAINSESSION hSession;

/* handle to an existing TWAIN session */

L_INT nUnit;

/* image unit */

Sets the image unit value used to transfer images from the current TWAIN source.

Parameter

Description

hSession

Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.

nUnit

Specifies the unit value to set. For more information on possible values, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function internally sets the image unit capability ICAP_UNITS. For more information on this capability, refer to www.twain.org/download.htm and click on TWAIN Specification (Version 1.9).

To obtain the current image unit value, call the L_TwainGetImageUnit function

This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.

Required DLLs and Libraries

LTTWN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_TwainSetTransferOptions, L_TwainGetTransferOptions, L_TwainGetSupportedTransferMode, L_TwainSetResolution, L_TwainGetResolution, L_TwainSetImageFrame, L_TwainGetImageFrame, L_TwainGetImageUnit, L_TwainSetImageBitsPerPixel, L_TwainGetImageBitsPerPixel, L_TwainSetImageEffects, L_TwainGetImageEffects, L_TwainSetAcquirePageOptions, L_TwainGetAcquirePageOptions, L_TwainSetRGBResponse, L_TwainShowProgress, L_TwainEnableDuplex, L_TwainGetDuplexOptions, L_TwainSetMaxXferCount, L_TwainGetMaxXferCount

Topics:

Getting and Setting Capabilities

 

TWAIN Functionality: Capability Functions

Example

 L_INT TwainSetImageUnitExample(HTWAINSESSION hSession) 
{

   L_INT nRet = SUCCESS;

   nRet = L_TwainStartCapsNeg (hSession);
   if(nRet != SUCCESS)
      return nRet;

   L_INT nUnit;
   nRet = L_TwainGetImageUnit (hSession, &nUnit);
   if (nRet == SUCCESS)
   {
      if (nUnit != TWUN_INCHES)
      {
         nRet = L_TwainSetImageUnit(hSession, TWUN_INCHES);
         if(nRet != SUCCESS)
            return nRet;
      }
   }
   else
      return nRet;

   L_INT nBPP;
   nRet = L_TwainGetImageBitsPerPixel (hSession, &nBPP);
   if (nRet == SUCCESS)
   {
      if (nBPP != 24)
      {
         nRet = L_TwainSetImageBitsPerPixel (hSession, 24);
         if(nRet != SUCCESS)
            return nRet;
      }
   }
   else
      return nRet;

   nRet = L_TwainEndCapsNeg (hSession);
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}