Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
e280ae
#ifdef _MSC_VER
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4996)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef NOTE
Toshihiro Shimizu 890ddd
here
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
TTWAIN_Get???Value (TW_RANGE range) restituisce sempre un float e (ovviamente)
Toshihiro Shimizu 890ddd
funziona solo con gli item il cui sizeof() e' <= sizeof (float) (unica eccezione
Toshihiro Shimizu 890ddd
TW_FIX32)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
USA_LE_QUERY: -> non definito!
Toshihiro Shimizu 890ddd
Le query dovrebbero essere un modo per capire le azioni che sono permesse
Toshihiro Shimizu 890ddd
su una determinata capability, questo sta scritto in twainSpec1.8:
Toshihiro Shimizu 890ddd
nessun DS ha ritornato valori sensati, per cui non vengono usate.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <stdlib.h></stdlib.h>
Toshihiro Shimizu 890ddd
#include <string.h></string.h>
Toshihiro Shimizu 890ddd
#include <stdio.h></stdio.h>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <assert.h></assert.h>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ttwain_util.h"
Toshihiro Shimizu 890ddd
#include "ttwain_utilP.h"
Toshihiro Shimizu 890ddd
#include "ttwain_utilPD.h"
Toshihiro Shimizu 890ddd
#include "ttwainP.h"
Toshihiro Shimizu 890ddd
#include "ttwain.h"
Toshihiro Shimizu 890ddd
#include "ttwain_state.h"
Toshihiro Shimizu 890ddd
#include "ttwain_capability.h"
Toshihiro Shimizu 890ddd
#include "ttwain_conversion.h"
Toshihiro Shimizu 890ddd
#include "ttwain_error.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ttwain_global_def.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
Scommentare MACOSX_NO_PARAMS, per evitare che l'applicazione abbia il controllo
Toshihiro Shimizu 890ddd
dei parametri (Caps supportate, ImageLayout, XferCount)
Shinya Kitaoka 120a6e
Utile sotto MACOSX per evitare che i DS della HP si aprano alla richiesta,
Toshihiro Shimizu 890ddd
e rimangano li.... in attesa di una scansione (tutto continua a funzionare,
Toshihiro Shimizu 890ddd
alla prima scansione il DS si chiude correttamente e l'applicazione ottiene
Toshihiro Shimizu 890ddd
l'immagine)
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
#define MACOSX_NO_PARAMS
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef __cplusplus
Shinya Kitaoka 120a6e
    extern "C" {
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*#define USA_LE_QUERY*/
Shinya Kitaoka 120a6e
  /* local  */
Shinya Kitaoka 120a6e
  static int TTWAIN_GetPhysicalWidth(float *width);
Shinya Kitaoka 120a6e
  static int TTWAIN_GetPhysicalHeight(float *height);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static int TTWAIN_GetMinimumWidth(float *width);
Shinya Kitaoka 120a6e
  static int TTWAIN_GetMinimumHeight(float *height);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static int TTWAIN_IsCapSupported(void *cap);
Shinya Kitaoka 120a6e
  static int TTWAIN_IsCapSupportedTW_INT16(TW_INT16 cap);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* MISC AUX FUNCTIONS */
Shinya Kitaoka 120a6e
  static float TTWAIN_GetMinValue(TW_RANGE range);
Shinya Kitaoka 120a6e
  static float TTWAIN_GetMaxValue(TW_RANGE range);
Shinya Kitaoka 120a6e
  static float TTWAIN_GetDefValue(TW_RANGE range);
Shinya Kitaoka 120a6e
  static float TTWAIN_GetStepValue(TW_RANGE range);
Shinya Kitaoka 120a6e
  static int TTWAIN_IsItemInList(void *list, void *item, TUINT32 list_count,
Shinya Kitaoka 120a6e
                                 TUINT32 item_size);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static const size_t DCItemSize[13] = {
Shinya Kitaoka 120a6e
      sizeof(TW_INT8),   sizeof(TW_INT16),  sizeof(TW_INT32), sizeof(TW_UINT8),
Shinya Kitaoka 120a6e
      sizeof(TW_UINT16), sizeof(TW_UINT32), sizeof(TW_BOOL),  sizeof(TW_FIX32),
Shinya Kitaoka 120a6e
      sizeof(TW_FRAME),  sizeof(TW_STR32),  sizeof(TW_STR64), sizeof(TW_STR128),
Shinya Kitaoka 120a6e
      sizeof(TW_STR255),
Shinya Kitaoka 120a6e
  }; /* see twain.h */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define FLAVOR_UNUSED (0xffff)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  struct TTWAIN_PIXELTYPEP {
Shinya Kitaoka 120a6e
    TW_UINT16 type;
Shinya Kitaoka 120a6e
    TW_UINT16 flavor;
Shinya Kitaoka 120a6e
    TW_UINT16 bitDepth;
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
  static struct TTWAIN_PIXELTYPEP PixType[TTWAIN_PIXTYPE_HOWMANY] = {
Shinya Kitaoka 120a6e
      {TWPT_BW, TWPF_CHOCOLATE, 1},  /* BW    */
Shinya Kitaoka 120a6e
      {TWPT_BW, TWPF_VANILLA, 1},    /* WB    */
Shinya Kitaoka 120a6e
      {TWPT_GRAY, FLAVOR_UNUSED, 8}, /* GRAY8 */
Shinya Kitaoka 120a6e
      {TWPT_RGB, FLAVOR_UNUSED, 24}  /* RGB24 */
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*    GET CAPABILITIES */
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetResolution(float *min, float *max, float *step, float *def) {
Shinya Kitaoka 120a6e
    TW_RANGE range_data;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (!(min && max && step && def)) return FALSE;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_XRESOLUTION, TWON_RANGE, (void *)&range_data, 0);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    *min  = TTWAIN_GetMinValue(range_data);
Shinya Kitaoka 120a6e
    *max  = TTWAIN_GetMaxValue(range_data);
Shinya Kitaoka 120a6e
    *step = TTWAIN_GetStepValue(range_data);
Shinya Kitaoka 120a6e
    *def  = TTWAIN_GetDefValue(range_data);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetOpticalResolution(float *min, float *max, float *step,
Shinya Kitaoka 120a6e
                                  float *def) {
Shinya Kitaoka 120a6e
    TW_RANGE range_data;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (!(min && max && step && def)) return FALSE;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_XNATIVERESOLUTION, TWON_RANGE, (void *)&range_data,
Shinya Kitaoka 120a6e
                       0);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    *min  = TTWAIN_GetMinValue(range_data);
Shinya Kitaoka 120a6e
    *max  = TTWAIN_GetMaxValue(range_data);
Shinya Kitaoka 120a6e
    *step = TTWAIN_GetStepValue(range_data);
Shinya Kitaoka 120a6e
    *def  = TTWAIN_GetDefValue(range_data);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetBrightness(float *min, float *max, float *step, float *def) {
Shinya Kitaoka 120a6e
    TW_RANGE range_data;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    assert(min && max && step && def);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_BRIGHTNESS, TWON_RANGE, (void *)&range_data, 0);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    *min  = TTWAIN_GetMinValue(range_data);
Shinya Kitaoka 120a6e
    *max  = TTWAIN_GetMaxValue(range_data);
Shinya Kitaoka 120a6e
    *step = TTWAIN_GetStepValue(range_data);
Shinya Kitaoka 120a6e
    *def  = TTWAIN_GetDefValue(range_data);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetContrast(float *min, float *max, float *step, float *def) {
Shinya Kitaoka 120a6e
    TW_RANGE range_data;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    assert(min && max && step && def);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_CONTRAST, TWON_RANGE, (void *)&range_data, 0);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    *min  = TTWAIN_GetMinValue(range_data);
Shinya Kitaoka 120a6e
    *max  = TTWAIN_GetMaxValue(range_data);
Shinya Kitaoka 120a6e
    *step = TTWAIN_GetStepValue(range_data);
Shinya Kitaoka 120a6e
    *def  = TTWAIN_GetDefValue(range_data);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetThreshold(float *min, float *max, float *step, float *def) {
Shinya Kitaoka 120a6e
    TW_RANGE range_data;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    assert(min && max && step && def);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_THRESHOLD, TWON_RANGE, (void *)&range_data, 0);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    *min  = TTWAIN_GetMinValue(range_data);
Shinya Kitaoka 120a6e
    *max  = TTWAIN_GetMaxValue(range_data);
Shinya Kitaoka 120a6e
    *step = TTWAIN_GetStepValue(range_data);
Shinya Kitaoka 120a6e
    *def  = TTWAIN_GetDefValue(range_data);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static int TTWAIN_GetPhysicalWidth(float *width) {
Shinya Kitaoka 120a6e
    TW_ONEVALUE width_data;
Shinya Kitaoka 120a6e
    if (TTWAIN_GetCap(ICAP_PHYSICALWIDTH, TWON_ONEVALUE, (void *)&width_data,
Shinya Kitaoka 120a6e
                      0)) {
Shinya Kitaoka 120a6e
      *width = TTWAIN_Fix32ToFloat(*(TW_FIX32 *)&width_data.Item);
Shinya Kitaoka 120a6e
      return TRUE;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return FALSE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static int TTWAIN_GetPhysicalHeight(float *height) {
Shinya Kitaoka 120a6e
    TW_ONEVALUE height_data;
Shinya Kitaoka 120a6e
    if (TTWAIN_GetCap(ICAP_PHYSICALHEIGHT, TWON_ONEVALUE, (void *)&height_data,
Shinya Kitaoka 120a6e
                      0)) {
Shinya Kitaoka 120a6e
      *height = TTWAIN_Fix32ToFloat(*(TW_FIX32 *)&height_data.Item);
Shinya Kitaoka 120a6e
      return TRUE;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return FALSE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static int TTWAIN_GetMinimumWidth(float *width) {
Shinya Kitaoka 120a6e
    TW_ONEVALUE width_data;
Shinya Kitaoka 120a6e
    if (TTWAIN_GetCap(ICAP_MINIMUMWIDTH, TWON_ONEVALUE, (void *)&width_data,
Shinya Kitaoka 120a6e
                      0)) {
Shinya Kitaoka 120a6e
      *width = TTWAIN_Fix32ToFloat(*(TW_FIX32 *)&width_data.Item);
Shinya Kitaoka 120a6e
      return TRUE;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return FALSE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static int TTWAIN_GetMinimumHeight(float *height) {
Shinya Kitaoka 120a6e
    TW_ONEVALUE height_data;
Shinya Kitaoka 120a6e
    if (TTWAIN_GetCap(ICAP_MINIMUMHEIGHT, TWON_ONEVALUE, (void *)&height_data,
Shinya Kitaoka 120a6e
                      0)) {
Shinya Kitaoka 120a6e
      *height = TTWAIN_Fix32ToFloat(*(TW_FIX32 *)&height_data.Item);
Shinya Kitaoka 120a6e
      return TRUE;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return FALSE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetPhysicalWidthWAdf(float *width) {
Shinya Kitaoka 120a6e
    int rc = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(TRUE);
shun-iwasawa 443318
      if (rc) rc = TTWAIN_GetPhysicalWidth(width);
Shinya Kitaoka 120a6e
      TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetPhysicalHeightWAdf(float *height) {
Shinya Kitaoka 120a6e
    int rc = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(TRUE);
shun-iwasawa 443318
      if (rc) rc = TTWAIN_GetPhysicalHeight(height);
Shinya Kitaoka 120a6e
      TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetMinimumWidthWAdf(float *width) {
Shinya Kitaoka 120a6e
    int rc = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(TRUE);
shun-iwasawa 443318
      if (rc) rc = TTWAIN_GetMinimumWidth(width);
Shinya Kitaoka 120a6e
      TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetMinimumHeightWAdf(float *height) {
Shinya Kitaoka 120a6e
    int rc = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(TRUE);
shun-iwasawa 443318
      if (rc) rc = TTWAIN_GetMinimumHeight(height);
Shinya Kitaoka 120a6e
      TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetPhysicalWidthWoAdf(float *width) {
Shinya Kitaoka 120a6e
    int rc            = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status = FALSE;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(FALSE);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetPhysicalWidth(width);
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetPhysicalHeightWoAdf(float *height) {
Shinya Kitaoka 120a6e
    int rc            = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status = FALSE;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(TRUE);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetPhysicalHeight(height);
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetMinimumWidthWoAdf(float *width) {
Shinya Kitaoka 120a6e
    int rc            = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status = FALSE;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(FALSE);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetMinimumWidth(width);
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetMinimumHeightWoAdf(float *height) {
Shinya Kitaoka 120a6e
    int rc            = FALSE;
Shinya Kitaoka 120a6e
    int feeder_status = FALSE;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) {
Shinya Kitaoka 120a6e
      feeder_status = TTWAIN_GetFeeder();
Shinya Kitaoka 120a6e
      rc            = TTWAIN_SetFeeder(TRUE);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetMinimumHeight(height);
Shinya Kitaoka 120a6e
    if (TTWAIN_SupportsFeeder()) TTWAIN_SetFeeder(feeder_status);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SupportsPixelType(TTWAIN_PIXTYPE pix_type) {
Shinya Kitaoka 120a6e
    TW_HANDLE handle;
Shinya Kitaoka 120a6e
    TW_ENUMERATION *container;
Shinya Kitaoka 120a6e
    int rc, found = FALSE;
Shinya Kitaoka 120a6e
    TUINT32 size4data;
Shinya Kitaoka 120a6e
    TW_UINT16 twPix;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    twPix = PixType[pix_type].type;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_PIXELTYPE, TWON_ENUMERATION, (void *)0, &size4data);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    if (!size4data) return FALSE;
Shinya Kitaoka 120a6e
    handle = GLOBAL_ALLOC(GMEM_FIXED, size4data);
Shinya Kitaoka 120a6e
    if (!handle) return FALSE;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    container = (TW_ENUMERATION *)GLOBAL_LOCK(handle);
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_PIXELTYPE, TWON_ENUMERATION, (void *)container, 0);
Shinya Kitaoka 120a6e
shun-iwasawa 443318
    if (!rc || !container) goto done;
Shinya Kitaoka 120a6e
    found =
Shinya Kitaoka 120a6e
        TTWAIN_IsItemInList(container->ItemList, &twPix, container->NumItems,
Shinya Kitaoka 120a6e
                            DCItemSize[container->ItemType]);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  done:
Shinya Kitaoka 120a6e
    GLOBAL_UNLOCK(handle);
Shinya Kitaoka 120a6e
    GLOBAL_FREE(handle);
Shinya Kitaoka 120a6e
    return found;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SupportsCompressionType(TW_UINT16 comprType) {
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    TUINT32 size;
Shinya Kitaoka 120a6e
    int found                 = FALSE;
Shinya Kitaoka 120a6e
    TW_ENUMERATION *container = 0;
Shinya Kitaoka 120a6e
    TW_HANDLE handle          = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (!TTWAIN_IsCapCompressionSupported()) return FALSE;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(ICAP_COMPRESSION, TWON_ENUMERATION, (void *)0, &size);
Shinya Kitaoka 120a6e
    if (!rc || !size) return FALSE;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    handle = GLOBAL_ALLOC(GMEM_FIXED, size);
Shinya Kitaoka 120a6e
    if (!handle) return FALSE;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    container = (TW_ENUMERATION *)GLOBAL_LOCK(handle);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    rc =
Shinya Kitaoka 120a6e
        TTWAIN_GetCap(ICAP_COMPRESSION, TWON_ENUMERATION, (void *)container, 0);
Shinya Kitaoka 120a6e
shun-iwasawa 443318
    if (!rc || !container) goto done;
Shinya Kitaoka 120a6e
    found = TTWAIN_IsItemInList(container->ItemList, &comprType,
Shinya Kitaoka 120a6e
                                container->NumItems,
Shinya Kitaoka 120a6e
                                DCItemSize[container->ItemType]);
Shinya Kitaoka 120a6e
    found = TRUE;
Shinya Kitaoka 120a6e
  done:
Shinya Kitaoka 120a6e
    if (handle) {
Shinya Kitaoka 120a6e
      GLOBAL_UNLOCK(handle);
Shinya Kitaoka 120a6e
      GLOBAL_FREE(handle);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return found;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SupportsFeeder(void) {
Shinya Kitaoka 120a6e
    TW_ONEVALUE feeder;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    feeder.Item = 0;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(CAP_FEEDERENABLED, TWON_ONEVALUE, (void *)&feeder, 0);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetFeeder(void) /* TRUE->enabled */
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    TW_ONEVALUE feeder;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    feeder.Item = 0;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(CAP_FEEDERENABLED, TWON_ONEVALUE, (void *)&feeder, 0);
Shinya Kitaoka 120a6e
    return feeder.Item && rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsFeederLoaded(void) /* TRUE->loaded */
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    TW_ONEVALUE feeder;
Shinya Kitaoka 120a6e
    int rc;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX_NO_PARAMS
Shinya Kitaoka 120a6e
    printf("%s always returns false (disabled at compile time)\n",
Shinya Kitaoka 120a6e
           __FUNCTION__);
Shinya Kitaoka 120a6e
    return FALSE;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    feeder.Item = 0;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(CAP_FEEDERLOADED, TWON_ONEVALUE, (void *)&feeder, 0);
Shinya Kitaoka 120a6e
    return feeder.Item && rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  char *TTWAIN_GetManufacturer(void) {
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Shinya Kitaoka 120a6e
    static char msg[1024];
Shinya Kitaoka 120a6e
    strncpy(msg, (const char *)&TTwainData.sourceId.Manufacturer[1],
Shinya Kitaoka 120a6e
            *TTwainData.sourceId.Manufacturer);
Shinya Kitaoka 120a6e
    return msg;
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
  return (char *)TTwainData.sourceId.Manufacturer;
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  char *TTWAIN_GetProductFamily(void) {
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Shinya Kitaoka 120a6e
    static char msg[1024];
Shinya Kitaoka 120a6e
    strncpy(msg, (const char *)&TTwainData.sourceId.ProductFamily[1],
Shinya Kitaoka 120a6e
            *TTwainData.sourceId.ProductFamily);
Shinya Kitaoka 120a6e
    return msg;
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
  return (char *)TTwainData.sourceId.ProductFamily;
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  char *TTWAIN_GetProductName(void) {
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Shinya Kitaoka 120a6e
    static char msg[1024];
Shinya Kitaoka 120a6e
    strncpy(msg, (const char *)&TTwainData.sourceId.ProductName[1],
Shinya Kitaoka 120a6e
            *TTwainData.sourceId.ProductName);
Shinya Kitaoka 120a6e
    return msg;
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
  return (char *)TTwainData.sourceId.ProductName;
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  char *TTWAIN_GetVersion(void) {
Shinya Kitaoka 120a6e
    static char version[5 + 1 + 5 + 1 + 32 + 1];
Rozhuk Ivan 823a31
    snprintf(version, sizeof(version), "%d.%d %s",
Rozhuk Ivan 823a31
             TTwainData.sourceId.Version.MajorNum,
shun-iwasawa 443318
             TTwainData.sourceId.Version.MinorNum,
shun-iwasawa 443318
             (char *)TTwainData.sourceId.Version.Info);
Shinya Kitaoka 120a6e
    return version;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  char *TTWAIN_GetTwainVersion(void) {
Shinya Kitaoka 120a6e
    static char version[5 + 1 + 5 + 1];
Rozhuk Ivan 823a31
    snprintf(version, sizeof(version), "%d.%d",
Rozhuk Ivan 823a31
             TTwainData.sourceId.ProtocolMajor,
Rozhuk Ivan 823a31
             TTwainData.sourceId.ProtocolMinor);
Shinya Kitaoka 120a6e
    return version;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetSupportedCaps(void) {
Shinya Kitaoka 120a6e
    TW_ARRAY *container;
Shinya Kitaoka 120a6e
    TW_HANDLE handle = 0;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    TUINT32 size4data;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TTwainData.isSupportedCapsSupported = FALSE;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX_NO_PARAMS
Shinya Kitaoka 120a6e
    printf("%s always returns false (disabled at compile time)\n",
Shinya Kitaoka 120a6e
           __FUNCTION__);
Shinya Kitaoka 120a6e
    return FALSE;
Toshihiro Shimizu 890ddd
/* PER ora su mac sono disabilitate! */
Toshihiro Shimizu 890ddd
/*return FALSE;*/
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(CAP_SUPPORTEDCAPS, TWON_ARRAY, (void *)0, &size4data);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    if (!size4data) return FALSE;
Shinya Kitaoka 120a6e
    handle = GLOBAL_ALLOC(GMEM_FIXED, size4data);
Shinya Kitaoka 120a6e
    if (!handle) return FALSE;
Shinya Kitaoka 120a6e
    container = (TW_ARRAY *)GLOBAL_LOCK(handle);
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(CAP_SUPPORTEDCAPS, TWON_ARRAY, (void *)container, 0);
Shinya Kitaoka 120a6e
    if (rc) {
Shinya Kitaoka 120a6e
      /*
Shinya Kitaoka 120a6e
MEMORY LEAK !!! ma per ora va bene cosi'...
Shinya Kitaoka 120a6e
if (TTwainData.supportedCaps)
Shinya Kitaoka 120a6e
GLOBAL_FREE(TTwainData.supportedCaps);
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
      TTwainData.supportedCaps = container;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    TTwainData.isSupportedCapsSupported = TRUE;
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetCurrentPixelType(TTWAIN_PIXTYPE * pixType) {
Shinya Kitaoka 120a6e
    int rc1, rc2;
Shinya Kitaoka 120a6e
    TW_ONEVALUE pixelType, pixelFlavor;
Shinya Kitaoka 120a6e
    int i;
Shinya Kitaoka 120a6e
    rc1 = TTWAIN_GetCapCurrent(ICAP_PIXELTYPE, TWON_ONEVALUE, &pixelType, 0);
Shinya Kitaoka 120a6e
    if (!rc1) return FALSE;
Shinya Kitaoka 120a6e
    *pixType = TTWAIN_PIXUNKNOWN;
Shinya Kitaoka 120a6e
    if (pixelType.Item == TWPT_BW) {
Shinya Kitaoka 120a6e
      rc2 = TTWAIN_GetCapCurrent(ICAP_PIXELFLAVOR, TWON_ONEVALUE, &pixelFlavor,
Shinya Kitaoka 120a6e
                                 0);
Shinya Kitaoka 120a6e
      if (!rc2) pixelFlavor.Item = TWPF_CHOCOLATE; /*this is the default */
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      pixelFlavor.Item = FLAVOR_UNUSED;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    for (i = 0; i < TTWAIN_PIXTYPE_HOWMANY; i++) {
Shinya Kitaoka 120a6e
      if ((PixType[i].type == pixelType.Item) &&
Shinya Kitaoka 120a6e
          (PixType[i].flavor == pixelFlavor.Item)) {
Shinya Kitaoka 120a6e
        *pixType = (TTWAIN_PIXTYPE)i;
Shinya Kitaoka 120a6e
        return TRUE;
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return FALSE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*    SUPPORTED CAPABILITIES */
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static int TTWAIN_IsCapSupported(void *cap) {
Toshihiro Shimizu 890ddd
#ifdef USA_LE_QUERY
Shinya Kitaoka 120a6e
    int queryRc;
Shinya Kitaoka 120a6e
    TW_UINT16 pattern;
Shinya Kitaoka 120a6e
    int et;
Shinya Kitaoka 120a6e
    queryRc = TTWAIN_GetCapQuery(*((TW_INT16 *)cap), &pattern);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    et = pattern & (TWQC_SET | TWQC_GET);
Shinya Kitaoka 120a6e
    return (TTwainData.isSupportedCapsSupported && queryRc && et) ||
Shinya Kitaoka 120a6e
           (TTwainData.supportedCaps &&
Shinya Kitaoka 120a6e
            TTWAIN_IsItemInList(
Shinya Kitaoka 120a6e
                TTwainData.supportedCaps, cap,
Shinya Kitaoka 120a6e
                TTwainData.supportedCaps->NumItems,
Shinya Kitaoka 120a6e
                DCItemSize[TTwainData.supportedCaps->ItemType])) ||
Shinya Kitaoka 120a6e
           (queryRc && et);
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
  return TTwainData.isSupportedCapsSupported &&
Shinya Kitaoka 120a6e
         (TTwainData.supportedCaps &&
Shinya Kitaoka 120a6e
          TTWAIN_IsItemInList(TTwainData.supportedCaps, cap,
Shinya Kitaoka 120a6e
                              TTwainData.supportedCaps->NumItems,
Shinya Kitaoka 120a6e
                              DCItemSize[TTwainData.supportedCaps->ItemType]));
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static int TTWAIN_IsCapSupportedTW_INT16(TW_INT16 cap) {
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapResolutionSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_XRESOLUTION;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapOpticalResolutionSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_XNATIVERESOLUTION;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapBrightnessSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_BRIGHTNESS;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapContrastSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_CONTRAST;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapThresholdSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_THRESHOLD;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapPhysicalWidthSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_PHYSICALWIDTH;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapPhysicalHeightSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_PHYSICALHEIGHT;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapMinimumWidthSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_MINIMUMWIDTH;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapMinimumHeightSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_MINIMUMHEIGHT;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapPixelTypeSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_PIXELTYPE;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapFeederSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = CAP_FEEDERENABLED;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapImageLayoutSupported(void) {
Shinya Kitaoka 120a6e
    /*assert(0);*/
Shinya Kitaoka 120a6e
    return TRUE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapOrientationSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_ORIENTATION;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapDeviceOnLineSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = CAP_DEVICEONLINE;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapBitDepthSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_BITDEPTH;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapBitOrderSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_BITORDER;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsCapCompressionSupported(void) {
Shinya Kitaoka 120a6e
    TW_UINT16 cap = ICAP_COMPRESSION;
Shinya Kitaoka 120a6e
    return TTWAIN_IsCapSupported(&cap);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*    SET CAPABILITIES */
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetContrast(float contrast) {
Shinya Kitaoka 120a6e
    TW_FIX32 twfix = TTWAIN_FloatToFix32(contrast);
Shinya Kitaoka 120a6e
    return TTWAIN_SetCap(ICAP_CONTRAST, TWON_ONEVALUE, TWTY_FIX32,
Shinya Kitaoka 120a6e
                         (TW_UINT32 *)&twfix);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetBrightness(float brightness) {
Shinya Kitaoka 120a6e
    TW_FIX32 twfix = TTWAIN_FloatToFix32(brightness);
Shinya Kitaoka 120a6e
    return TTWAIN_SetCap(ICAP_BRIGHTNESS, TWON_ONEVALUE, TWTY_FIX32,
Shinya Kitaoka 120a6e
                         (TW_UINT32 *)&twfix);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetThreshold(float threshold) {
Shinya Kitaoka 120a6e
    TW_FIX32 twfix = TTWAIN_FloatToFix32(threshold);
Shinya Kitaoka 120a6e
    return TTWAIN_SetCap(ICAP_THRESHOLD, TWON_ONEVALUE, TWTY_FIX32,
Shinya Kitaoka 120a6e
                         (TW_UINT32 *)&twfix);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetResolution(float resolution) {
Shinya Kitaoka 120a6e
    int rc1, rc2;
Shinya Kitaoka 120a6e
    TW_FIX32 twfix = TTWAIN_FloatToFix32(resolution);
Shinya Kitaoka 120a6e
    rc1            = TTWAIN_SetCap(ICAP_XRESOLUTION, TWON_ONEVALUE, TWTY_FIX32,
shun-iwasawa 443318
                                   (TW_UINT32 *)&twfix);
shun-iwasawa 443318
    rc2            = TTWAIN_SetCap(ICAP_YRESOLUTION, TWON_ONEVALUE, TWTY_FIX32,
shun-iwasawa 443318
                                   (TW_UINT32 *)&twfix);
Shinya Kitaoka 120a6e
    return (rc1 & rc2);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetXScaling(float scale) {
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    TW_FIX32 twfix = TTWAIN_FloatToFix32(scale);
Shinya Kitaoka 120a6e
    rc             = TTWAIN_SetCap(ICAP_XSCALING, TWON_ONEVALUE, TWTY_FIX32,
shun-iwasawa 443318
                                   (TW_UINT32 *)&twfix);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetYScaling(float scale) {
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    TW_FIX32 twfix = TTWAIN_FloatToFix32(scale);
Shinya Kitaoka 120a6e
    rc             = TTWAIN_SetCap(ICAP_YSCALING, TWON_ONEVALUE, TWTY_FIX32,
shun-iwasawa 443318
                                   (TW_UINT32 *)&twfix);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetPixelType(TTWAIN_PIXTYPE pixtype) {
Shinya Kitaoka 120a6e
    TUINT32 twPix;
Shinya Kitaoka 120a6e
    int rc, rc2, rc3, rc4, rc5, bdRc;
Shinya Kitaoka 120a6e
    TW_ENUMERATION *container = 0;
Shinya Kitaoka 120a6e
    TW_HANDLE handle          = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TW_UINT16 twFlavor, twBitDepth;
Shinya Kitaoka 120a6e
    int found;
Shinya Kitaoka 120a6e
    TUINT32 size;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    twPix      = PixType[pixtype].type;
Shinya Kitaoka 120a6e
    twFlavor   = PixType[pixtype].flavor;
Shinya Kitaoka 120a6e
    twBitDepth = PixType[pixtype].bitDepth;
Shinya Kitaoka 120a6e
    /*the default in twain specs is chocolate*/
Shinya Kitaoka 120a6e
    TTwainData.transferInfo.nextImageNeedsToBeInverted =
Shinya Kitaoka 120a6e
        ((twFlavor != TWPF_CHOCOLATE) && (twFlavor != FLAVOR_UNUSED));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    rc = TTWAIN_SetCap(ICAP_PIXELTYPE, TWON_ONEVALUE, TWTY_UINT16,
Shinya Kitaoka 120a6e
                       (TW_UINT32 *)&twPix);
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapBitDepthSupported()) bdRc = TTWAIN_SetBitDepth(twBitDepth);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (rc) {
Shinya Kitaoka 120a6e
      if (twFlavor != FLAVOR_UNUSED) {
Shinya Kitaoka 120a6e
        rc2 =
Shinya Kitaoka 120a6e
            TTWAIN_GetCap(ICAP_PIXELFLAVOR, TWON_ENUMERATION, (void *)0, &size);
Shinya Kitaoka 120a6e
        if (rc2 && size) {
Shinya Kitaoka 120a6e
          handle = GLOBAL_ALLOC(GMEM_FIXED, size);
Shinya Kitaoka 120a6e
          if (!handle)
Shinya Kitaoka 120a6e
            return TRUE; /*non sono semplicamente riuscito a prendere info
Shinya Kitaoka 120a6e
riguardo
Shinya Kitaoka 120a6e
il pixelFlavor, ma setPixelType e' andato a buon fine */
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Shinya Kitaoka 120a6e
          container = (TW_ENUMERATION *)handle;
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
        container = (TW_ENUMERATION *)GLOBAL_LOCK(handle);
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
          rc3 = TTWAIN_GetCap(ICAP_PIXELFLAVOR, TWON_ENUMERATION,
Shinya Kitaoka 120a6e
                              (void *)container, 0);
Shinya Kitaoka 120a6e
          if (rc3) {
Shinya Kitaoka 120a6e
            found = TTWAIN_IsItemInList(container->ItemList, &twFlavor,
Shinya Kitaoka 120a6e
                                        container->NumItems,
Shinya Kitaoka 120a6e
                                        DCItemSize[container->ItemType]);
Shinya Kitaoka 120a6e
            /*let's try to set....*/
Shinya Kitaoka 120a6e
            if (found) {
Shinya Kitaoka 120a6e
              rc4 = TTWAIN_SetCap(ICAP_PIXELFLAVOR, TWON_ONEVALUE, TWTY_UINT16,
Shinya Kitaoka 120a6e
                                  (TW_UINT32 *)&twFlavor);
Shinya Kitaoka 120a6e
              if (rc4) {
Shinya Kitaoka 120a6e
                TW_UINT16 current, *itemList;
Shinya Kitaoka 120a6e
                /*check if it's properly set...*/
Shinya Kitaoka 120a6e
                rc5 = TTWAIN_GetCap(ICAP_PIXELFLAVOR, TWON_ENUMERATION,
Shinya Kitaoka 120a6e
                                    (void *)container, 0);
Shinya Kitaoka 120a6e
                if (rc5) {
Shinya Kitaoka 120a6e
                  itemList = (TW_UINT16 *)container->ItemList;
Shinya Kitaoka 120a6e
                  current  = itemList[container->CurrentIndex];
Shinya Kitaoka 120a6e
                  if (current == twFlavor) {
Shinya Kitaoka 120a6e
                    TTwainData.transferInfo.nextImageNeedsToBeInverted = FALSE;
Shinya Kitaoka 120a6e
                  }
Shinya Kitaoka 120a6e
                }
Shinya Kitaoka 120a6e
              }
Shinya Kitaoka 120a6e
            }
Shinya Kitaoka 120a6e
          }
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (handle) {
Shinya Kitaoka 120a6e
      GLOBAL_UNLOCK(handle);
Shinya Kitaoka 120a6e
      GLOBAL_FREE(handle);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetBitDepth(USHORT bitDepth) {
Shinya Kitaoka 120a6e
    TUINT32 bd = bitDepth;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    rc = TTWAIN_SetCap(ICAP_BITDEPTH, TWON_ONEVALUE, TWTY_UINT16,
Shinya Kitaoka 120a6e
                       (TW_UINT32 *)&bd);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetBitOrder(TTWAIN_BITORDER bitOrder) {
Shinya Kitaoka 120a6e
    TUINT32 bo = bitOrder;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    rc = TTWAIN_SetCap(ICAP_BITORDER, TWON_ONEVALUE, TWTY_UINT16,
Shinya Kitaoka 120a6e
                       (TW_UINT32 *)&bo);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetImageLayout(float L, float T, float R, float B) {
Shinya Kitaoka 120a6e
    TW_IMAGELAYOUT layout;
Shinya Kitaoka 120a6e
    TW_IMAGELAYOUT layout2;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    int rc2;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX_NO_PARAMS
Shinya Kitaoka 120a6e
    printf("%s always returns true (disabled at compile time)\n", __FUNCTION__);
Shinya Kitaoka 120a6e
    return TRUE;
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 120a6e
if (TTWAIN_GetState() != TWAIN_SOURCE_OPEN)
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
TTWAIN_RecordError();
Shinya Kitaoka 120a6e
return FALSE;
Shinya Kitaoka 120a6e
}
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
    layout.Frame.Left   = TTWAIN_FloatToFix32(L);
Shinya Kitaoka 120a6e
    layout.Frame.Top    = TTWAIN_FloatToFix32(T);
Shinya Kitaoka 120a6e
    layout.Frame.Right  = TTWAIN_FloatToFix32(R);
Shinya Kitaoka 120a6e
    layout.Frame.Bottom = TTWAIN_FloatToFix32(B);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    layout.DocumentNumber = TWON_DONTCARE32;
Shinya Kitaoka 120a6e
    layout.PageNumber     = TWON_DONTCARE32;
Shinya Kitaoka 120a6e
    layout.FrameNumber    = TWON_DONTCARE32;
shun-iwasawa 443318
    rc  = (TTWAIN_DS(DG_IMAGE, DAT_IMAGELAYOUT, MSG_SET, &layout) ==
Shinya Kitaoka 120a6e
          TWRC_SUCCESS);
Shinya Kitaoka 120a6e
    rc2 = (TTWAIN_DS(DG_IMAGE, DAT_IMAGELAYOUT, MSG_GET, &layout2) ==
Shinya Kitaoka 120a6e
           TWRC_SUCCESS);
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_NegotiateXferCount(TUINT32 nXfers) {
Toshihiro Shimizu 890ddd
#ifdef MACOSX_NO_PARAMS
Shinya Kitaoka 120a6e
    printf("%s always returns true (disabled at compile time)\n", __FUNCTION__);
Shinya Kitaoka 120a6e
    return TRUE;
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
    return TTWAIN_SetCap(CAP_XFERCOUNT, TWON_ONEVALUE, TWTY_INT16,
Shinya Kitaoka 120a6e
                         (TW_UINT32 *)&nXfers);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetXferMech(TTWAIN_TRANSFER_MECH mech, void *ptr, TUINT32 size,
Shinya Kitaoka 120a6e
                         int preferredLx, int preferredLy,
Shinya Kitaoka 120a6e
                         TUINT32 numberOfImages) {
Shinya Kitaoka 120a6e
    TW_UINT32 theMech = mech;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TTwainData.transferInfo.preferredLx = preferredLx;
Shinya Kitaoka 120a6e
    TTwainData.transferInfo.preferredLy = preferredLy;
Shinya Kitaoka 120a6e
    if (mech == TTWAIN_TRANSFERMODE_NATIVE) {
Shinya Kitaoka 120a6e
      /*assert(!ptr);*/
Shinya Kitaoka 120a6e
      /*invalidate mem  & len*/
Shinya Kitaoka 120a6e
      TTwainData.transferInfo.memorySize   = -1;
Shinya Kitaoka 120a6e
      TTwainData.transferInfo.memoryBuffer = 0;
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      /*assert(ptr);*/
Shinya Kitaoka 120a6e
      /*store*/
Shinya Kitaoka 120a6e
      assert(!ptr); /* questo va rivisto, comunque NON si puo' fornire il
Shinya Kitaoka 120a6e
                       buffer! */
Shinya Kitaoka 120a6e
      TTwainData.transferInfo.memorySize   = size;
Shinya Kitaoka 120a6e
      TTwainData.transferInfo.memoryBuffer = (UCHAR *)ptr;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (TTWAIN_SetCap(ICAP_XFERMECH, TWON_ONEVALUE, TWTY_UINT16,
Shinya Kitaoka 120a6e
                      (TW_UINT32 *)&theMech)) {
Shinya Kitaoka 120a6e
      if (numberOfImages != -1) TTWAIN_NegotiateXferCount(numberOfImages);
Shinya Kitaoka 120a6e
      TTwainData.transferInfo.transferMech = mech;
Shinya Kitaoka 120a6e
      return TRUE;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return FALSE;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_SetFeeder(int status) /* TRUE->enabled */
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    rc = TTWAIN_SetCap(CAP_FEEDERENABLED, TWON_ONEVALUE, TWTY_BOOL,
Shinya Kitaoka 120a6e
                       (TW_UINT32 *)&status);
Shinya Kitaoka 120a6e
    /*
Toshihiro Shimizu 890ddd
if (TTwainData.transferInfo.usageMode == TTWAIN_MODE_UNLEASHED)
Shinya Kitaoka 120a6e
TTwainData.transferInfo.multiTransfer = status;
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
    return rc;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*    USER INTERFACE */
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_HasControllableUI(void) {
Shinya Kitaoka 120a6e
    TW_ONEVALUE onevalue_data;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(CAP_UICONTROLLABLE, TWON_ONEVALUE,
Shinya Kitaoka 120a6e
                       (void *)&onevalue_data, 0);
Shinya Kitaoka 120a6e
    if (!rc) return FALSE;
Shinya Kitaoka 120a6e
    return (int)onevalue_data.Item;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetUIStatus(void) { return TTwainData.UIStatus; }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  void TTWAIN_SetUIStatus(int status) { TTwainData.UIStatus = status; }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_GetModalStatus(void) { return TTwainData.modalStatus; }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsDeviceOnLine(void) /* -1 unknown, 0 no, 1 yes */
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    TW_ONEVALUE onevalue_data;
Shinya Kitaoka 120a6e
    int rc;
Shinya Kitaoka 120a6e
    rc = TTWAIN_GetCap(CAP_DEVICEONLINE, TWON_ONEVALUE, (void *)&onevalue_data,
Shinya Kitaoka 120a6e
                       0);
Shinya Kitaoka 120a6e
    if (!rc) return -1;
Shinya Kitaoka 120a6e
    return (int)onevalue_data.Item;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*    TWAIN AVAILABILITY */
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_IsAvailable(void) {
Shinya Kitaoka 120a6e
    TTWAIN_InitVar();
Shinya Kitaoka 120a6e
    if (TTWAIN_DSM_HasEntryPoint()) return TRUE;
Shinya Kitaoka 120a6e
Rozhuk Ivan 823a31
    if (TTwainData.twainAvailable == AVAIABLE_DONTKNOW) {
Rozhuk Ivan 823a31
      if (TTWAIN_LoadSourceManager()) {
Shinya Kitaoka 120a6e
        TTWAIN_UnloadSourceManager();
Rozhuk Ivan 823a31
      } else {
Shinya Kitaoka 120a6e
        TTwainData.twainAvailable = AVAIABLE_NO;
Rozhuk Ivan 823a31
      }
Rozhuk Ivan 823a31
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    return (TTwainData.twainAvailable == AVAIABLE_YES);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  void TTWAIN_SetAvailable(TWAINAVAILABLE status) {
Shinya Kitaoka 120a6e
    TTwainData.twainAvailable = status;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*    MISC AUX FUNCTIONS */
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static float TTWAIN_GetMinValue(TW_RANGE range) {
Shinya Kitaoka 120a6e
    switch (range.ItemType) {
Shinya Kitaoka 120a6e
    case TWTY_INT8:
Shinya Kitaoka 120a6e
    case TWTY_INT16:
Shinya Kitaoka 120a6e
    case TWTY_INT32:
Shinya Kitaoka 120a6e
    case TWTY_UINT8:
Shinya Kitaoka 120a6e
    case TWTY_UINT16:
Shinya Kitaoka 120a6e
      return (float)range.MinValue;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case TWTY_FIX32: {
Shinya Kitaoka 120a6e
      TW_FIX32 *fix32 = (TW_FIX32 *)&range.MinValue;
Shinya Kitaoka 120a6e
      return (float)TTWAIN_Fix32ToFloat(*fix32);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    default:
Shinya Kitaoka 120a6e
      // TWTY_UINT32
Shinya Kitaoka 120a6e
      // TWTY_BOOL
Shinya Kitaoka 120a6e
      // TWTY_FRAME
Shinya Kitaoka 120a6e
      // TWTY_STR32
Shinya Kitaoka 120a6e
      // TWTY_STR64
Shinya Kitaoka 120a6e
      // TWTY_STR128
Shinya Kitaoka 120a6e
      // TWTY_STR255
Shinya Kitaoka 120a6e
      assert(!"Invalid type!!!");
Shinya Kitaoka 120a6e
      return 0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static float TTWAIN_GetMaxValue(TW_RANGE range) {
Shinya Kitaoka 120a6e
    switch (range.ItemType) {
Shinya Kitaoka 120a6e
    case TWTY_INT8:
Shinya Kitaoka 120a6e
    case TWTY_INT16:
Shinya Kitaoka 120a6e
    case TWTY_INT32:
Shinya Kitaoka 120a6e
    case TWTY_UINT8:
Shinya Kitaoka 120a6e
    case TWTY_UINT16:
Shinya Kitaoka 120a6e
      return (float)range.MaxValue;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case TWTY_FIX32: {
Shinya Kitaoka 120a6e
      TW_FIX32 *fix32 = (TW_FIX32 *)&range.MaxValue;
Shinya Kitaoka 120a6e
      return (float)TTWAIN_Fix32ToFloat(*fix32);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    default:
Shinya Kitaoka 120a6e
      // TWTY_UINT32
Shinya Kitaoka 120a6e
      // TWTY_BOOL
Shinya Kitaoka 120a6e
      // TWTY_FRAME
Shinya Kitaoka 120a6e
      // TWTY_STR32
Shinya Kitaoka 120a6e
      // TWTY_STR64
Shinya Kitaoka 120a6e
      // TWTY_STR128
Shinya Kitaoka 120a6e
      // TWTY_STR255
Shinya Kitaoka 120a6e
      assert(!"Invalid type!!");
Shinya Kitaoka 120a6e
      return 0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static float TTWAIN_GetDefValue(TW_RANGE range) {
Shinya Kitaoka 120a6e
    switch (range.ItemType) {
Shinya Kitaoka 120a6e
    case TWTY_INT8:
Shinya Kitaoka 120a6e
    case TWTY_INT16:
Shinya Kitaoka 120a6e
    case TWTY_INT32:
Shinya Kitaoka 120a6e
    case TWTY_UINT8:
Shinya Kitaoka 120a6e
    case TWTY_UINT16:
Shinya Kitaoka 120a6e
      return (float)range.DefaultValue;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case TWTY_FIX32: {
Shinya Kitaoka 120a6e
      TW_FIX32 *fix32 = (TW_FIX32 *)&range.DefaultValue;
Shinya Kitaoka 120a6e
      return (float)TTWAIN_Fix32ToFloat(*fix32);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    default:
Shinya Kitaoka 120a6e
      // TWTY_UINT32
Shinya Kitaoka 120a6e
      // TWTY_BOOL
Shinya Kitaoka 120a6e
      // TWTY_FRAME
Shinya Kitaoka 120a6e
      // TWTY_STR32
Shinya Kitaoka 120a6e
      // TWTY_STR64
Shinya Kitaoka 120a6e
      // TWTY_STR128
Shinya Kitaoka 120a6e
      // TWTY_STR255
Shinya Kitaoka 120a6e
      assert(!"Invalid type!!");
Shinya Kitaoka 120a6e
      return 0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static float TTWAIN_GetStepValue(TW_RANGE range) {
Shinya Kitaoka 120a6e
    switch (range.ItemType) {
Shinya Kitaoka 120a6e
    case TWTY_INT8:
Shinya Kitaoka 120a6e
    case TWTY_INT16:
Shinya Kitaoka 120a6e
    case TWTY_INT32:
Shinya Kitaoka 120a6e
    case TWTY_UINT8:
Shinya Kitaoka 120a6e
    case TWTY_UINT16:
Shinya Kitaoka 120a6e
      return (float)range.StepSize;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case TWTY_FIX32: {
Shinya Kitaoka 120a6e
      TW_FIX32 *fix32 = (TW_FIX32 *)&range.StepSize;
Shinya Kitaoka 120a6e
      return (float)TTWAIN_Fix32ToFloat(*fix32);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    default:
Shinya Kitaoka 120a6e
      // TWTY_UINT32
Shinya Kitaoka 120a6e
      // TWTY_BOOL
Shinya Kitaoka 120a6e
      // TWTY_FRAME
Shinya Kitaoka 120a6e
      // TWTY_STR32
Shinya Kitaoka 120a6e
      // TWTY_STR64
Shinya Kitaoka 120a6e
      // TWTY_STR128
Shinya Kitaoka 120a6e
      // TWTY_STR255
Shinya Kitaoka 120a6e
      assert(!"Invalid type!!");
Shinya Kitaoka 120a6e
      return 0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  int TTWAIN_Native2Raster(void *handle, void *the_ras, int *lx, int *ly) {
Shinya Kitaoka 120a6e
    return TTWAIN_Native2RasterPD(handle, the_ras, lx, ly);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  static int TTWAIN_IsItemInList(void *list, void *item, TUINT32 list_count,
Shinya Kitaoka 120a6e
                                 TUINT32 item_size) {
Shinya Kitaoka 120a6e
    int found     = FALSE;
Shinya Kitaoka 120a6e
    TUINT32 count = list_count;
Shinya Kitaoka 120a6e
    UCHAR *pList  = (UCHAR *)list;
Shinya Kitaoka 120a6e
    UCHAR *pItem  = (UCHAR *)item;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (!list || !item) return FALSE;
Shinya Kitaoka 120a6e
    while (count--) {
Shinya Kitaoka 120a6e
      if (memcmp(pList, pItem, item_size) == 0) {
Shinya Kitaoka 120a6e
        found = TRUE;
Shinya Kitaoka 120a6e
        break;
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      pList += item_size;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return found;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  void TTWAIN_DumpCapabilities(void (*trace_fun)(const char *fmt, ...)) {
Shinya Kitaoka 120a6e
    if (!trace_fun) return;
Shinya Kitaoka 120a6e
    trace_fun("list of supported (exported) capabilities\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_XFERCOUNT))
Shinya Kitaoka 120a6e
      trace_fun("CAP_XFERCOUNT");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_COMPRESSION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_COMPRESSION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PIXELTYPE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PIXELTYPE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_UNITS)) trace_fun("ICAP_UNITS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_XFERMECH))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_XFERMECH\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_AUTHOR)) trace_fun("CAP_AUTHOR\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_CAPTION)) trace_fun("CAP_CAPTION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_FEEDERENABLED))
Shinya Kitaoka 120a6e
      trace_fun("CAP_FEEDERENABLED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_FEEDERLOADED))
Shinya Kitaoka 120a6e
      trace_fun("CAP_FEEDERLOADED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_TIMEDATE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_TIMEDATE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_SUPPORTEDCAPS))
Shinya Kitaoka 120a6e
      trace_fun("CAP_SUPPORTEDCAPS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_EXTENDEDCAPS))
Shinya Kitaoka 120a6e
      trace_fun("CAP_EXTENDEDCAPS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_AUTOFEED))
Shinya Kitaoka 120a6e
      trace_fun("CAP_AUTOFEED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_CLEARPAGE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_CLEARPAGE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_FEEDPAGE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_FEEDPAGE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_REWINDPAGE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_REWINDPAGE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_INDICATORS))
Shinya Kitaoka 120a6e
      trace_fun("CAP_INDICATORS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_SUPPORTEDCAPSEXT))
Shinya Kitaoka 120a6e
      trace_fun("CAP_SUPPORTEDCAPSEXT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_PAPERDETECTABLE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_PAPERDETECTABLE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_UICONTROLLABLE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_UICONTROLLABLE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_DEVICEONLINE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_DEVICEONLINE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_AUTOSCAN))
Shinya Kitaoka 120a6e
      trace_fun("CAP_AUTOSCAN\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_THUMBNAILSENABLED))
Shinya Kitaoka 120a6e
      trace_fun("CAP_THUMBNAILSENABLED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_DUPLEX)) trace_fun("CAP_DUPLEX\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_DUPLEXENABLED))
Shinya Kitaoka 120a6e
      trace_fun("CAP_DUPLEXENABLED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_ENABLEDSUIONLY))
Shinya Kitaoka 120a6e
      trace_fun("CAP_ENABLEDSUIONLY\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_CUSTOMDSDATA))
Shinya Kitaoka 120a6e
      trace_fun("CAP_CUSTOMDSDATA\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_ENDORSER))
Shinya Kitaoka 120a6e
      trace_fun("CAP_ENDORSER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_JOBCONTROL))
Shinya Kitaoka 120a6e
      trace_fun("CAP_JOBCONTROL\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_ALARMS)) trace_fun("CAP_ALARMS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_ALARMVOLUME))
Shinya Kitaoka 120a6e
      trace_fun("CAP_ALARMVOLUME\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_AUTOMATICCAPTURE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_AUTOMATICCAPTURE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_TIMEBEFOREFIRSTCAPTURE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_TIMEBEFOREFIRSTCAPTURE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_TIMEBETWEENCAPTURES))
Shinya Kitaoka 120a6e
      trace_fun("CAP_TIMEBETWEENCAPTURES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_CLEARBUFFERS))
Shinya Kitaoka 120a6e
      trace_fun("CAP_CLEARBUFFERS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_MAXBATCHBUFFERS))
Shinya Kitaoka 120a6e
      trace_fun("CAP_MAXBATCHBUFFERS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_DEVICETIMEDATE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_DEVICETIMEDATE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_POWERSUPPLY))
Shinya Kitaoka 120a6e
      trace_fun("CAP_POWERSUPPLY\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_CAMERAPREVIEWUI))
Shinya Kitaoka 120a6e
      trace_fun("CAP_CAMERAPREVIEWUI\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_DEVICEEVENT))
Shinya Kitaoka 120a6e
      trace_fun("CAP_DEVICEEVENT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_SERIALNUMBER))
Shinya Kitaoka 120a6e
      trace_fun("CAP_SERIALNUMBER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_PRINTER)) trace_fun("CAP_PRINTER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_PRINTERENABLED))
Shinya Kitaoka 120a6e
      trace_fun("CAP_PRINTERENABLED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_PRINTERINDEX))
Shinya Kitaoka 120a6e
      trace_fun("CAP_PRINTERINDEX\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_PRINTERMODE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_PRINTERMODE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_PRINTERSTRING))
Shinya Kitaoka 120a6e
      trace_fun("CAP_PRINTERSTRING\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_PRINTERSUFFIX))
Shinya Kitaoka 120a6e
      trace_fun("CAP_PRINTERSUFFIX\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_LANGUAGE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_LANGUAGE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_FEEDERALIGNMENT))
Shinya Kitaoka 120a6e
      trace_fun("CAP_FEEDERALIGNMENT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_FEEDERORDER))
Shinya Kitaoka 120a6e
      trace_fun("CAP_FEEDERORDER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_REACQUIREALLOWED))
Shinya Kitaoka 120a6e
      trace_fun("CAP_REACQUIREALLOWED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_BATTERYMINUTES))
Shinya Kitaoka 120a6e
      trace_fun("CAP_BATTERYMINUTES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(CAP_BATTERYPERCENTAGE))
Shinya Kitaoka 120a6e
      trace_fun("CAP_BATTERYPERCENTAGE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_AUTOBRIGHT))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_AUTOBRIGHT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BRIGHTNESS))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BRIGHTNESS\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_CONTRAST))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_CONTRAST\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_CUSTHALFTONE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_CUSTHALFTONE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_EXPOSURETIME))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_EXPOSURETIME\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_FILTER)) trace_fun("ICAP_FILTER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_FLASHUSED))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_FLASHUSED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_GAMMA)) trace_fun("ICAP_GAMMA\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_HALFTONES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_HALFTONES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_HIGHLIGHT))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_HIGHLIGHT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_IMAGEFILEFORMAT))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_IMAGEFILEFORMAT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_LAMPSTATE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_LAMPSTATE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_LIGHTSOURCE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_LIGHTSOURCE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_ORIENTATION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_ORIENTATION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PHYSICALWIDTH))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PHYSICALWIDTH\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PHYSICALHEIGHT))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PHYSICALHEIGHT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_SHADOW)) trace_fun("ICAP_SHADOW\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_FRAMES)) trace_fun("ICAP_FRAMES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_XNATIVERESOLUTION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_XNATIVERESOLUTION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_YNATIVERESOLUTION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_YNATIVERESOLUTION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_XRESOLUTION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_XRESOLUTION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_YRESOLUTION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_YRESOLUTION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_MAXFRAMES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_MAXFRAMES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_TILES)) trace_fun("ICAP_TILES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BITORDER))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BITORDER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_CCITTKFACTOR))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_CCITTKFACTOR\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_LIGHTPATH))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_LIGHTPATH\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PIXELFLAVOR))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PIXELFLAVOR\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PLANARCHUNKY))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PLANARCHUNKY\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_ROTATION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_ROTATION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_SUPPORTEDSIZES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_SUPPORTEDSIZES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_THRESHOLD))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_THRESHOLD\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_XSCALING))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_XSCALING\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_YSCALING))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_YSCALING\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BITORDERCODES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BITORDERCODES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PIXELFLAVORCODES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PIXELFLAVORCODES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_JPEGPIXELTYPE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_JPEGPIXELTYPE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_TIMEFILL))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_TIMEFILL\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BITDEPTH))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BITDEPTH\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BITDEPTHREDUCTION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BITDEPTHREDUCTION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_UNDEFINEDIMAGESIZE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_UNDEFINEDIMAGESIZE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_IMAGEDATASET))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_IMAGEDATASET\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_EXTIMAGEINFO))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_EXTIMAGEINFO\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_MINIMUMHEIGHT))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_MINIMUMHEIGHT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_MINIMUMWIDTH))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_MINIMUMWIDTH\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_FLIPROTATION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_FLIPROTATION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BARCODEDETECTIONENABLED))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BARCODEDETECTIONENABLED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_SUPPORTEDBARCODETYPES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_SUPPORTEDBARCODETYPES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BARCODEMAXSEARCHPRIORITIES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BARCODEMAXSEARCHPRIORITIES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BARCODESEARCHPRIORITIES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BARCODESEARCHPRIORITIES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BARCODESEARCHMODE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BARCODESEARCHMODE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BARCODEMAXRETRIES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BARCODEMAXRETRIES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_BARCODETIMEOUT))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_BARCODETIMEOUT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_ZOOMFACTOR))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_ZOOMFACTOR\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PATCHCODEDETECTIONENABLED))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PATCHCODEDETECTIONENABLED\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_SUPPORTEDPATCHCODETYPES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_SUPPORTEDPATCHCODETYPES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PATCHCODEMAXSEARCHPRIORITIES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PATCHCODEMAXSEARCHPRIORITIES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PATCHCODESEARCHPRIORITIES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PATCHCODESEARCHPRIORITIES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PATCHCODESEARCHMODE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PATCHCODESEARCHMODE\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PATCHCODEMAXRETRIES))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PATCHCODEMAXRETRIES\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_PATCHCODETIMEOUT))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_PATCHCODETIMEOUT\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_FLASHUSED2))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_FLASHUSED2\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_IMAGEFILTER))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_IMAGEFILTER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_NOISEFILTER))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_NOISEFILTER\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_OVERSCAN))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_OVERSCAN\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_AUTOMATICBORDERDETECTION))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_AUTOMATICBORDERDETECTION\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_AUTOMATICDESKEW))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_AUTOMATICDESKEW\n");
Shinya Kitaoka 120a6e
    if (TTWAIN_IsCapSupportedTW_INT16(ICAP_AUTOMATICROTATE))
Shinya Kitaoka 120a6e
      trace_fun("ICAP_AUTOMATICROTATE\n");
Shinya Kitaoka 120a6e
    trace_fun("end-of-list\n");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  void TTWAIN_SetTwainUsage(TTWAIN_USAGE_MODE um) {
Shinya Kitaoka 120a6e
    TTwainData.transferInfo.usageMode = um;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  extern void registerTwainCallback();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void TTWAIN_SetOnDoneCallback(TTWAIN_ONDONE_CB * proc, void *arg) {
Shinya Kitaoka 120a6e
    TTwainData.callback.onDoneCb  = proc;
Shinya Kitaoka 120a6e
    TTwainData.callback.onDoneArg = arg;
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Shinya Kitaoka 120a6e
    registerTwainCallback();
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*---------------------------------------------------------------------------*/
Shinya Kitaoka 120a6e
  void TTWAIN_SetOnErrorCallback(TTWAIN_ONERROR_CB * proc, void *arg) {
Shinya Kitaoka 120a6e
    TTwainData.callback.onErrorCb  = proc;
Shinya Kitaoka 120a6e
    TTwainData.callback.onErrorArg = arg;
Shinya Kitaoka 120a6e
  }
shun-iwasawa 443318
  /*---------------------------------------------------------------------------*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef __cplusplus
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#endif