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