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