Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <texception.h></texception.h>
Toshihiro Shimizu 890ddd
#include <tscanner.h></tscanner.h>
Toshihiro Shimizu 890ddd
#include "tscannertwain.h"
Toshihiro Shimizu 890ddd
#include "tscannerutil.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace TScannerUtil;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
extern "C" {
Toshihiro Shimizu 890ddd
#include "../common/twain/ttwain_util.h"
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/* callback used to handle TTWAIN done/error status*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void throwIT(const char *msg)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	throw TException(msg);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
extern "C" void TTWAIN_ErrorBox(const char *msg)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	throwIT(msg);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
extern "C" int onDoneCB(UCHAR *buffer, TTWAIN_PIXTYPE pixelType,
Toshihiro Shimizu 890ddd
						int lx, int ly, int wrap,
Toshihiro Shimizu 890ddd
						float xdpi, float ydpi, void *usrData)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TRasterP ras;
Toshihiro Shimizu 890ddd
	switch (pixelType) {
Toshihiro Shimizu 890ddd
	case TTWAIN_BW:
Toshihiro Shimizu 890ddd
	case TTWAIN_WB: {
Toshihiro Shimizu 890ddd
		try {
Toshihiro Shimizu 890ddd
			TRasterGR8P ras8(lx, ly);
Toshihiro Shimizu 890ddd
			copy90BWBufferToRasGR8(buffer, lx, ly, wrap, (pixelType == TTWAIN_BW), ras8, 1, 0);
Toshihiro Shimizu 890ddd
			ras8->xMirror();
Toshihiro Shimizu 890ddd
			ras8->yMirror();
Toshihiro Shimizu 890ddd
			ras = ras8;
Toshihiro Shimizu 890ddd
		} catch (...) {
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} break;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	case TTWAIN_RGB24: {
Toshihiro Shimizu 890ddd
		try {
Toshihiro Shimizu 890ddd
			TRaster32P ras32(lx, ly);
Toshihiro Shimizu 890ddd
			copyRGBBufferToTRaster32(buffer, lx, ly, ras32, false);
Toshihiro Shimizu 890ddd
			ras = ras32;
Toshihiro Shimizu 890ddd
		} catch (...) {
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} break;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	case TTWAIN_GRAY8: {
Toshihiro Shimizu 890ddd
		try {
Toshihiro Shimizu 890ddd
			TRasterGR8P ras8(lx, ly);
Toshihiro Shimizu 890ddd
			copyGR8BufferToTRasterGR8(buffer, lx, ly, ras8, false);
Toshihiro Shimizu 890ddd
			ras = ras8;
Toshihiro Shimizu 890ddd
		} catch (...) {
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} break;
Toshihiro Shimizu 890ddd
	default:
Toshihiro Shimizu 890ddd
		break;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterImageP rasImg;
Toshihiro Shimizu 890ddd
	if (ras) {
Toshihiro Shimizu 890ddd
		rasImg = TRasterImageP(ras);
Toshihiro Shimizu 890ddd
		rasImg->setDpi(xdpi, ydpi);
Toshihiro Shimizu 890ddd
		//rasImg->sethPos(hpos);
Toshihiro Shimizu 890ddd
		rasImg->setSavebox(ras->getBounds());
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TScanner *scannerDevice = reinterpret_cast<tscanner *="">(usrData);</tscanner>
Toshihiro Shimizu 890ddd
	scannerDevice->notifyImageDone(rasImg);
Toshihiro Shimizu 890ddd
	TTWAIN_FreeMemory(buffer);
Toshihiro Shimizu 890ddd
	scannerDevice->decrementPaperLeftCount();
Toshihiro Shimizu 890ddd
	return scannerDevice->getPaperLeftCount();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
extern "C" void onErrorCB(void *usrData, void *alwaysZero)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TScanner *scannerDevice = reinterpret_cast<tscanner *="">(usrData);</tscanner>
Toshihiro Shimizu 890ddd
	scannerDevice->notifyError();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TScannerTwain::TScannerTwain()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TScannerTwain::~TScannerTwain()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
bool deviceSelected = false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TScannerTwain::selectDevice()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TTWAIN_SelectImageSource(0);
Toshihiro Shimizu 890ddd
	deviceSelected = true;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (TTWAIN_OpenDefaultSource()) {
Toshihiro Shimizu 890ddd
		QString twainVersion(TTWAIN_GetTwainVersion());
Toshihiro Shimizu 890ddd
		QString manufacturer(TTWAIN_GetManufacturer());
Toshihiro Shimizu 890ddd
		QString productFamily(TTWAIN_GetProductFamily());
Toshihiro Shimizu 890ddd
		QString productName(TTWAIN_GetProductName());
Toshihiro Shimizu 890ddd
		QString version(TTWAIN_GetVersion());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TTWAIN_CloseAll(0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (manufacturer != "") {
Toshihiro Shimizu 890ddd
			// se c'e' il nome della marca lo tolgo dal productFamily e productName
Toshihiro Shimizu 890ddd
			productFamily.replace(manufacturer, "");
Toshihiro Shimizu 890ddd
			productName.replace(manufacturer, "");
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		setName(manufacturer + " " + productFamily + " " + productName + " (" + version + ")");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TScannerTwain::isDeviceSelected()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return deviceSelected;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TScannerTwain::isDeviceAvailable()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return !!TTWAIN_IsAvailable();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TODO!! renderla un update
Toshihiro Shimizu 890ddd
void TScannerTwain::updateParameters(TScannerParameters ¶m)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int rc = TTWAIN_OpenDefaultSource();
Toshihiro Shimizu 890ddd
	if (!rc)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Toshihiro Shimizu 890ddd
//TTWAIN_DumpCapabilities(printf);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
	if (isAreaSupported()) {
Toshihiro Shimizu 890ddd
		float w, h;
Toshihiro Shimizu 890ddd
		TTWAIN_GetPhysicalWidthWoAdf(&w);
Toshihiro Shimizu 890ddd
		TTWAIN_GetPhysicalHeightWoAdf(&h);
Toshihiro Shimizu 890ddd
		double width_mm = w * 25.4;
Toshihiro Shimizu 890ddd
		double height_mm = h * 25.4;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		param.setMaxPaperSize(width_mm, height_mm);
Toshihiro Shimizu 890ddd
		// sembra sbagliato: bisognerebbe comunque tenere conto del paperFormat selezionato
Toshihiro Shimizu 890ddd
		//    param.m_scanArea = TRectD(0,0, width_mm,height_mm);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	TScanParam defaultTwainParam(0., 255., 128., 1.);
Toshihiro Shimizu 890ddd
	if (TTWAIN_IsCapBrightnessSupported()) {
Toshihiro Shimizu 890ddd
		m_brightness.m_supported = true;
Toshihiro Shimizu 890ddd
		TTWAIN_GetBrightness(&m_brightness.m_min, &m_brightness.m_max, &m_brightness.m_step, &m_brightness.m_def);
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		//m_brightness.m_def = m_brightness.m_max = m_brightness.m_min = m_brightness.m_step = 0.;
Toshihiro Shimizu 890ddd
		m_brightness.update(defaultTwainParam);
Toshihiro Shimizu 890ddd
		m_brightness.m_supported = false;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	//m_brightness.m_value = m_brightness.m_def;
Toshihiro Shimizu 890ddd
	param.m_brightness.update(m_brightness);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (TTWAIN_IsCapContrastSupported()) {
Toshihiro Shimizu 890ddd
		m_contrast.m_supported = true;
Toshihiro Shimizu 890ddd
		TTWAIN_GetContrast(&m_contrast.m_min, &m_contrast.m_max, &m_contrast.m_step, &m_contrast.m_def);
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		//m_contrast.m_def = m_contrast.m_max = m_contrast.m_min = m_contrast.m_step = 0.;
Toshihiro Shimizu 890ddd
		m_contrast.update(defaultTwainParam);
Toshihiro Shimizu 890ddd
		m_contrast.m_supported = false;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	//m_contrast.m_value = m_contrast.m_def;
Toshihiro Shimizu 890ddd
	param.m_contrast.update(m_contrast);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (TTWAIN_IsCapThresholdSupported()) {
Toshihiro Shimizu 890ddd
		m_threshold.m_supported = true;
Toshihiro Shimizu 890ddd
		TTWAIN_GetThreshold(&m_threshold.m_min, &m_threshold.m_max, &m_threshold.m_step, &m_threshold.m_def);
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		//m_threshold.m_def = m_threshold.m_max = m_threshold.m_min = m_threshold.m_step = 0.;
Toshihiro Shimizu 890ddd
		m_threshold.update(defaultTwainParam);
Toshihiro Shimizu 890ddd
		m_threshold.m_supported = false;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//m_threshold.m_value = m_threshold.m_def;
Toshihiro Shimizu 890ddd
	param.m_threshold.update(m_threshold);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (TTWAIN_IsCapResolutionSupported()) {
Toshihiro Shimizu 890ddd
		m_dpi.m_supported = true;
Toshihiro Shimizu 890ddd
		TTWAIN_GetResolution(&m_dpi.m_min, &m_dpi.m_max, &m_dpi.m_step, &m_dpi.m_def);
Toshihiro Shimizu 890ddd
		param.m_dpi.update(m_dpi);
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		//m_dpi.m_def = m_dpi.m_max = m_dpi.m_min = m_dpi.m_step = 0.;
Toshihiro Shimizu 890ddd
		param.m_dpi.m_supported = false;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	//m_dpi.m_value = m_dpi.m_def;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
param.m_twainVersion = string(TTWAIN_GetTwainVersion());
Toshihiro Shimizu 890ddd
param.m_manufacturer = string(TTWAIN_GetManufacturer ());
Toshihiro Shimizu 890ddd
param.m_prodFamily = string(TTWAIN_GetProductFamily());
Toshihiro Shimizu 890ddd
param.m_productName = string(TTWAIN_GetProductName  ());
Toshihiro Shimizu 890ddd
param.m_version = string(TTWAIN_GetVersion());
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool bw = !!TTWAIN_SupportsPixelType(TTWAIN_BW) || !!TTWAIN_SupportsPixelType(TTWAIN_WB);
Toshihiro Shimizu 890ddd
	bool gray = !!TTWAIN_SupportsPixelType(TTWAIN_GRAY8);
Toshihiro Shimizu 890ddd
	bool rgb = !!TTWAIN_SupportsPixelType(TTWAIN_RGB24);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	param.setSupportedTypes(bw, gray, rgb);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TTWAIN_CloseAll(0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void setupParameters(const TScannerParameters ¶ms, bool isAreaSupported)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (isAreaSupported) {
Toshihiro Shimizu 890ddd
		TRectD scanArea = params.getScanArea();
Toshihiro Shimizu 890ddd
		float L = (float)(scanArea.getP00().x / 25.4);
Toshihiro Shimizu 890ddd
		float T = (float)(scanArea.getP00().y / 25.4);
Toshihiro Shimizu 890ddd
		float R = (float)(scanArea.getP11().x / 25.4);
Toshihiro Shimizu 890ddd
		float B = (float)(scanArea.getP11().y / 25.4);
Toshihiro Shimizu 890ddd
		TTWAIN_SetImageLayout(L, T, R, B);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TTWAIN_PIXTYPE pt;
Toshihiro Shimizu 890ddd
	switch (params.getScanType()) {
Toshihiro Shimizu 890ddd
	case TScannerParameters::BW:
Toshihiro Shimizu 890ddd
		pt = TTWAIN_BW;
Toshihiro Shimizu 890ddd
		break;
Toshihiro Shimizu 890ddd
	case TScannerParameters::GR8:
Toshihiro Shimizu 890ddd
		pt = TTWAIN_GRAY8;
Toshihiro Shimizu 890ddd
		break;
Toshihiro Shimizu 890ddd
	case TScannerParameters::RGB24:
Toshihiro Shimizu 890ddd
		pt = TTWAIN_RGB24;
Toshihiro Shimizu 890ddd
		break;
Toshihiro Shimizu 890ddd
	default:
Toshihiro Shimizu 890ddd
		/*      assert(0);*/
Toshihiro Shimizu 890ddd
		pt = TTWAIN_RGB24;
Toshihiro Shimizu 890ddd
		break;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TTWAIN_SetPixelType(pt);
Toshihiro Shimizu 890ddd
	if (params.m_dpi.m_supported)
Toshihiro Shimizu 890ddd
		TTWAIN_SetResolution(params.m_dpi.m_value);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (params.m_brightness.m_supported)
Toshihiro Shimizu 890ddd
		TTWAIN_SetBrightness(params.m_brightness.m_value);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (params.m_contrast.m_supported)
Toshihiro Shimizu 890ddd
		TTWAIN_SetContrast(params.m_contrast.m_value);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (params.m_threshold.m_supported)
Toshihiro Shimizu 890ddd
		TTWAIN_SetThreshold(params.m_threshold.m_value);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
void openAndSetupTwain()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int rc = TTWAIN_OpenDefaultSource();
Toshihiro Shimizu 890ddd
	if (rc) {
Toshihiro Shimizu 890ddd
		TTWAIN_SetTwainUsage(TTWAIN_MODE_UNLEASHED);
Toshihiro Shimizu 890ddd
		if (TTWAIN_IsCapDeviceOnLineSupported()) {
Toshihiro Shimizu 890ddd
			int status = TTWAIN_IsDeviceOnLine();
Toshihiro Shimizu 890ddd
			if (status == 0) {
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	TTWAIN_SetUIStatus(TRUE);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TScannerTwain::acquire(const TScannerParameters ¶ms, int paperCount)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	openAndSetupTwain();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//int feeder = TTWAIN_IsFeederLoaded();
Toshihiro Shimizu 890ddd
	int feeder = params.isPaperFeederEnabled();
Toshihiro Shimizu 890ddd
	m_paperLeft = paperCount;
Toshihiro Shimizu 890ddd
	int rc;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Toshihiro Shimizu 890ddd
	// pezza solo HP su MACOSX per gestire la scansione di piu' frame
Toshihiro Shimizu 890ddd
	bool ishp = !!(strcasestr(TTWAIN_GetProductName(), "hp"));
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
	bool ishp = false;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
	if (ishp) {
Toshihiro Shimizu 890ddd
		for (int i = 0; i < paperCount; ++i) {
Toshihiro Shimizu 890ddd
			printf("scanning %d/%d\n", i + 1, paperCount);
Toshihiro Shimizu 890ddd
			if (i == 0) {
Toshihiro Shimizu 890ddd
				setupParameters(params, isAreaSupported());
Toshihiro Shimizu 890ddd
				TTWAIN_SetOnDoneCallback(onDoneCB, this);
Toshihiro Shimizu 890ddd
				TTWAIN_SetOnErrorCallback(onErrorCB, this);
Toshihiro Shimizu 890ddd
			} else
Toshihiro Shimizu 890ddd
				openAndSetupTwain();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			rc = TTWAIN_SetXferMech(TTWAIN_TRANSFERMODE_MEMORY, 0, 0, 0, 0, 1);
Toshihiro Shimizu 890ddd
			int acq_rc = TTWAIN_AcquireMemory(0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			if (acq_rc == 0)
Toshihiro Shimizu 890ddd
				break; //error, or the user has closed the TWAIN UI
Toshihiro Shimizu 890ddd
			if (!feeder && ((paperCount - i) > 1))
Toshihiro Shimizu 890ddd
				notifyNextPaper();
Toshihiro Shimizu 890ddd
			TTWAIN_CloseAll(0);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		for (int i = 0; i < (feeder ? 1 : paperCount); ++i) {
Toshihiro Shimizu 890ddd
			printf("scanning %d/%d\n", i + 1, paperCount);
Toshihiro Shimizu 890ddd
			setupParameters(params, isAreaSupported());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			rc = TTWAIN_SetXferMech(TTWAIN_TRANSFERMODE_MEMORY, 0, 0, 0, 0, paperCount);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			TTWAIN_SetOnDoneCallback(onDoneCB, this);
Toshihiro Shimizu 890ddd
			TTWAIN_SetOnErrorCallback(onErrorCB, this);
Toshihiro Shimizu 890ddd
			int acq_rc = TTWAIN_AcquireMemory(0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			if (acq_rc == 0)
Toshihiro Shimizu 890ddd
				break; //error, or the user has closed the TWAIN UI
Toshihiro Shimizu 890ddd
			if (!feeder && ((paperCount - i) > 1))
Toshihiro Shimizu 890ddd
				notifyNextPaper();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		TTWAIN_CloseAll(0);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TScannerTwain::isAreaSupported()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
TTWAIN_IsCapPhysicalWidthSupported    (void);
Toshihiro Shimizu 890ddd
TTWAIN_IsCapPhysicalHeightSupported   (void);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
	return !!TTWAIN_IsCapImageLayoutSupported();
Toshihiro Shimizu 890ddd
}