|
From: <mi...@us...> - 2009-12-22 20:59:47
|
Revision: 66
http://twain-samples.svn.sourceforge.net/twain-samples/?rev=66&view=rev
Author: mihailm
Date: 2009-12-22 20:59:37 +0000 (Tue, 22 Dec 2009)
Log Message:
-----------
QT UI
Modified Paths:
--------------
trunk/TWAIN-Samples/Twain_DS_sample01/ChangeLog.txt
trunk/TWAIN-Samples/Twain_DS_sample01/README.txt
trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_FreeImage.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_FreeImage.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Sample1.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/CommonDS.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/DSMInterface.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainer.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainer.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerBool.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerBool.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerFix32.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerFix32.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerFrame.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerFrame.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerInt.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerInt.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/src.pro
trunk/TWAIN-Samples/Twain_DS_sample01/visual_studio/TWAINDS_GUI.rc
trunk/TWAIN-Samples/Twain_DS_sample01/visual_studio/TWAINDS_VS2003.vcproj
trunk/TWAIN-Samples/Twain_DS_sample01/visual_studio/TWAINDS_VS2005.vcproj
trunk/TWAIN-Samples/Twain_DS_sample01/visual_studio/TWAINDS_VS2008.vcproj
trunk/TWAIN-Samples/Twain_DS_sample01/visual_studio/resource.h
Added Paths:
-----------
trunk/TWAIN-Samples/Twain_DS_sample01/src/About.ui
trunk/TWAIN-Samples/Twain_DS_sample01/src/MainForm.ui
trunk/TWAIN-Samples/Twain_DS_sample01/src/NoUI.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/ProfileName.ui
trunk/TWAIN-Samples/Twain_DS_sample01/src/QT_UI.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/QT_UI.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/Qt_About.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/Qt_About.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/Qt_MainForm.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/Qt_MainForm.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/Qt_ProfileName.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/Qt_ProfileName.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerFix32Range.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerFix32Range.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerString.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAINContainerString.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAIN_UI.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWAIN_UI.h
trunk/TWAIN-Samples/Twain_DS_sample01/src/TWG-Logo.png
trunk/TWAIN-Samples/Twain_DS_sample01/src/qtresources.qrc
Removed Paths:
-------------
trunk/TWAIN-Samples/Twain_DS_sample01/visual_studio/TWAINDS_SampleDlg.cpp
trunk/TWAIN-Samples/Twain_DS_sample01/visual_studio/TWAINDS_SampleDlg.h
Modified: trunk/TWAIN-Samples/Twain_DS_sample01/ChangeLog.txt
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/ChangeLog.txt 2009-12-22 19:40:56 UTC (rev 65)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/ChangeLog.txt 2009-12-22 20:59:37 UTC (rev 66)
@@ -1,3 +1,11 @@
+2009-12-22 JFL Peripheral Solutions mi...@jf...
+
+ * UI added - QT based
+ * bug fixing
+ * Custom DS support
+ * New capabilities added
+
+
2009-07-16 JFL Peripheral Solutions ji...@jf...
* Update installer to use newest DSM merge module
@@ -56,3 +64,4 @@
DS was not being updated to proper state when the App is using callback to get image after receiving XferReady.
CTWAINDS_Base.cpp
CTWAINDS_FreeeImage.cpp
+
Modified: trunk/TWAIN-Samples/Twain_DS_sample01/README.txt
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/README.txt 2009-12-22 19:40:56 UTC (rev 65)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/README.txt 2009-12-22 20:59:37 UTC (rev 66)
@@ -31,17 +31,17 @@
------------
[Linux]
-- install qmake then run it to generate makefiles
+- install QT 4.5.3 then run it to generate makefiles
- make
-- copy images/TWAIN_logo.png to /usr/local/lib/twain
-- copy src/TWAINDS_Sample01.ds to /usr/local/lib/twain
+- copy images/TWAIN_logo.png to /usr/local/lib/twain/sample2
+- copy src/TWAINDS_Sample01.ds to /usr/local/lib/twain/sample2
notes: it is a future goal to have "make install" do the above copies.
[Windows]
- QMake is used to generate the makefiles. You can get a copy of this free in any
QT Open Source distribution. Please see http://www.trolltech.com for more info.
-- copy the TWAIN_logo.png and TWAINDS_Sample[32|64].ds to /Windows/twain_[32|64]
+- copy the TWAIN_logo.png and TWAINDS_Sample[32|64].ds to /Windows/twain_[32|64]/sample2
directory.
- Or use the provided Visual Studio project files.
@@ -50,3 +50,4 @@
- original: fr...@jf..., May 14, 2005
- updated: fr...@jf..., Nov 23, 2007
- updated: ji...@jf..., Dec 10, 2007
+- updated: mi...@jf..., Dec 23, 2009
\ No newline at end of file
Added: trunk/TWAIN-Samples/Twain_DS_sample01/src/About.ui
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/src/About.ui (rev 0)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/src/About.ui 2009-12-22 20:59:37 UTC (rev 66)
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>About</class>
+ <widget class="QDialog" name="About">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>577</width>
+ <height>292</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>577</width>
+ <height>292</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>577</width>
+ <height>292</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>About</string>
+ </property>
+ <widget class="QLabel" name="pLabel_QtGraphic">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>231</width>
+ <height>271</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap resource="qtresources.qrc">:/images/TWG-Logo.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="pLabel_TWG_Title">
+ <property name="geometry">
+ <rect>
+ <x>250</x>
+ <y>10</y>
+ <width>321</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">TWAIN Working Group</span></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Sample Data Source Implementation</span></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.TWAIN.org"><span style=" text-decoration: underline; color:#0000ff;">http://www.TWAIN.org</span></a></p></body></html></string>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="pLabel_TWG_AboutUs">
+ <property name="geometry">
+ <rect>
+ <x>250</x>
+ <y>70</y>
+ <width>321</width>
+ <height>111</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">The </span><span style=" font-size:8pt; font-weight:600;">TWAIN Working Group</span><span style=" font-size:8pt;"> is a not-for-profit organization which represents the imaging industry. </span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">TWAIN’s purpose is to provide and foster a universal public standard which links applications and image acquisition devices. </span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">The ongoing mission of this organization is to continue to enhance the standard to accommodate future technologies.</span></p></body></html></string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="pLabel_MoreInfo">
+ <property name="geometry">
+ <rect>
+ <x>250</x>
+ <y>210</y>
+ <width>321</width>
+ <height>71</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This Source code is BSD Licensed and available here:</span></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sf.net/projects/twain-samples/"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">http://sf.net/projects/twain-samples</span></a></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt; text-decoration: underline; color:#0000ff;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Questions? Visit the TWAIN Discussion Forum:</span></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.twainforum.org/"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">http://www.TWAINForum.org</span></a></p></body></html></string>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </widget>
+ <resources>
+ <include location="qtresources.qrc"/>
+ </resources>
+ <connections/>
+</ui>
Modified: trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.cpp
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.cpp 2009-12-22 19:40:56 UTC (rev 65)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.cpp 2009-12-22 20:59:37 UTC (rev 66)
@@ -67,6 +67,8 @@
extern HINSTANCE g_hinstance;
#endif
+#define kTWAIN_DS_DIR "/usr/local/lib/twain/sample2"
+
//////////////////////////////////////////////////////////////////////////////
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message)
{
@@ -141,7 +143,7 @@
m_nScanLine = 0;
m_nDestBytesPerRow = 0;
- m_nDocCount = getDocumentCount();// Reloaded the scanner with paper
+ m_nDocCount = m_nMaxDocCount = getDocumentCount();// Reloaded the scanner with paper
m_nPixelType = TWPT_RGB;
m_nPaperSource = SFI_PAPERSOURCE_ADF;
m_bDuplex = false;
@@ -175,6 +177,7 @@
m_nHeight = settings.m_nHeight;
m_fXResolution = settings.m_fXResolution;
m_fYResolution = settings.m_fYResolution;
+ m_nDocCount = m_nMaxDocCount;
}
//////////////////////////////////////////////////////////////////////////////
@@ -427,7 +430,7 @@
if(m_nDocCount<=0)
{
rtn = false;
- m_nDocCount = getDocumentCount();// Reloaded the scanner with paper
+ m_nDocCount = m_nMaxDocCount;// Reloaded the scanner with paper
}
return rtn;
}
Modified: trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.h
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.h 2009-12-22 19:40:56 UTC (rev 65)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/src/CScanner_FreeImage.h 2009-12-22 20:59:37 UTC (rev 66)
@@ -194,8 +194,10 @@
* @return true if online.
*/
bool getDeviceOnline() const;
+
+ short GetMaxPagesInADF(void){return m_nMaxDocCount;}
+ void SetMaxPagesInADF(short nVal){m_nMaxDocCount = nVal;};
-
protected:
/**
* Return the number of documents sitting in the feeder.
@@ -221,6 +223,7 @@
bool m_bReadOnly; /**< current mode */
DWORD m_nDestBytesPerRow; /**< number of bytes needed for a row of data */
short m_nDocCount; /**< number of documents waiting to transfer */
+ short m_nMaxDocCount; /**< Max number of documents waiting to transfer */
WORD m_nSourceWidth; /**< Width of image in FreeImage */
WORD m_nSourceHeight; /**< Height of image in FreeImage */
char m_szSourceImagePath[PATH_MAX]; /**< image used with FreeImage */
Modified: trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.cpp
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.cpp 2009-12-22 19:40:56 UTC (rev 65)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.cpp 2009-12-22 20:59:37 UTC (rev 66)
@@ -44,6 +44,7 @@
#include <fcntl.h>
#include <sys/stat.h>
+#include <sstream>
//////////////////////////////////////////////////////////////////////////////
CTWAINDS_Base::CTWAINDS_Base() :
@@ -149,6 +150,10 @@
twrc = dat_xfergroup(_MSG, (pTW_UINT32)_pData);
break;
+ case DAT_CUSTOMDSDATA:
+ twrc = dat_customdsdata(_MSG, (pTW_CUSTOMDSDATA)_pData);
+ break;
+
default:
setConditionCode(TWCC_BADPROTOCOL);
//assert(0);
@@ -368,6 +373,10 @@
twrc = enableDS(_pData);
break;
+ case MSG_ENABLEDSUIONLY:
+ twrc = enableDSOnly();
+ break;
+
case MSG_DISABLEDS:
twrc = disableDS(_pData);
break;
@@ -482,6 +491,36 @@
}
//////////////////////////////////////////////////////////////////////////////
+TW_INT16 CTWAINDS_Base::dat_customdsdata(TW_UINT16 _MSG, pTW_CUSTOMDSDATA _pDSData)
+{
+ TW_INT16 twrc = TWRC_SUCCESS;
+ if(m_CurrentState != dsState_Open)
+ {
+ setConditionCode(TWCC_SEQERROR);
+ return TWRC_FAILURE;
+ }
+
+ switch(_MSG)
+ {
+ case MSG_GET:
+ twrc = GetGustomDSData(_pDSData);
+ break;
+
+ case MSG_SET:
+ twrc = SetGustomDSData(_pDSData);
+ break;
+
+ default:
+ setConditionCode(TWCC_BADPROTOCOL);
+ //assert(0);
+ twrc = TWRC_FAILURE;
+ break;
+ }
+
+ return twrc;
+}
+
+//////////////////////////////////////////////////////////////////////////////
TW_INT16 CTWAINDS_Base::dat_imagememxfer(TW_UINT16 _MSG,
pTW_IMAGEMEMXFER _pData)
{
@@ -811,13 +850,10 @@
case TWTY_BOOL:
case TWTY_FIX32:
case TWTY_FRAME:
-/// @todo impliment str types
-// case TWTY_STR32:
-// case TWTY_STR64:
-// case TWTY_STR128:
-// case TWTY_STR255:
-// case TWTY_STR1024:
-// case TWTY_UNI512:
+ case TWTY_STR32:
+ case TWTY_STR64:
+ case TWTY_STR128:
+ case TWTY_STR255:
twrc = TWRC_SUCCESS; // so far so good
break;
@@ -847,7 +883,7 @@
case MSG_GETCURRENT:
case MSG_GETDEFAULT:
case MSG_GET:
- _pCap->ConType = (MSG_GET==_MSG)?_pContainer->GetGetType():TWON_ONEVALUE;
+ _pCap->ConType = _pContainer->GetGetType(_MSG);
twrc = updatePreDependencies(_pContainer);
if(twrc != TWRC_SUCCESS)
{
@@ -872,7 +908,15 @@
break;
}
- twrc = validateCapabilitySet(_pCap);
+ BYTE * pContainer = (BYTE*)_DSM_LockMemory(_pCap->hContainer);
+ if(pContainer==0)
+ {
+ setConditionCode(TWCC_LOWMEMORY);
+ twrc = TWRC_FAILURE;
+ break;
+ }
+ twrc = validateCapabilitySet(_pCap->Cap,_pCap->ConType, pContainer);
+ _DSM_UnlockMemory(_pCap->hContainer);
if(twrc != TWRC_SUCCESS)
{
setConditionCode(TWCC_BADVALUE);
@@ -906,18 +950,18 @@
}
//////////////////////////////////////////////////////////////////////////////
-TW_INT16 CTWAINDS_Base::validateCapabilitySet(pTW_CAPABILITY _pCap)
+TW_INT16 CTWAINDS_Base::validateCapabilitySet(TW_UINT16 _Cap, TW_UINT16 _ConType, BYTE* _pContainer)
{
TW_INT16 twrc = TWRC_SUCCESS;
- switch(_pCap->Cap)
+ switch(_Cap)
{
case CAP_XFERCOUNT:
{
twrc = TWRC_FAILURE;
- if(TWON_ONEVALUE == _pCap->ConType)
+ if(TWON_ONEVALUE == _ConType)
{
- pTW_ONEVALUE pCap = (pTW_ONEVALUE)_DSM_LockMemory(_pCap->hContainer);
+ pTW_ONEVALUE pCap = (pTW_ONEVALUE)_pContainer;
if(pCap)
{
@@ -925,11 +969,27 @@
{
twrc = TWRC_SUCCESS;
}
- _DSM_UnlockMemory(_pCap->hContainer);
}
}
break;
}
+ case ICAP_GAMMA:
+ {
+ twrc = TWRC_FAILURE;
+ if(TWON_ONEVALUE == _ConType)
+ {
+ pTW_ONEVALUE_FIX32 pCap = (pTW_ONEVALUE_FIX32)_pContainer;
+ if(pCap)
+ {
+ float flVal = FIX32ToFloat(pCap->Item);
+ if( flVal>0 )
+ {
+ twrc = TWRC_SUCCESS;
+ }
+ }
+ }
+ break;
+ }
case ICAP_FRAMES:
{
int unit = TWUN_PIXELS;
@@ -937,9 +997,9 @@
float Yres = 100;
twrc = getCurrentUnits(unit, Xres, Yres);
- if(TWON_ONEVALUE == _pCap->ConType)
+ if(TWON_ONEVALUE == _ConType)
{
- pTW_ONEVALUE_FRAME pCap = (pTW_ONEVALUE_FRAME)_DSM_LockMemory(_pCap->hContainer);
+ pTW_ONEVALUE_FRAME pCap = (pTW_ONEVALUE_FRAME)_pContainer;
if(pCap && pCap->ItemType == TWTY_FRAME)
{
@@ -949,39 +1009,53 @@
pCap->Item = frame.AsTW_FRAME(unit, Xres, Yres);
twrc = TWRC_CHECKSTATUS;
}
- _DSM_UnlockMemory(_pCap->hContainer);
}
}
- else if(TWON_ENUMERATION == _pCap->ConType)
+ else if(TWON_ENUMERATION == _ConType)
{
- pTW_ENUMERATION_FRAME pCap = (pTW_ENUMERATION_FRAME)_DSM_LockMemory(_pCap->hContainer);
-
- if(pCap && pCap->ItemType == TWTY_FRAME)
+ CTWAINContainerInt *pDepCapMax = dynamic_cast<CTWAINContainerInt*>(findCapability(ICAP_MAXFRAMES));
+ if(pDepCapMax==0)
{
- for(TW_UINT32 x = 0; x < pCap->NumItems; ++x)
+ setConditionCode(TWCC_BUMMER);
+ twrc = TWRC_FAILURE;
+ }
+ else
+ {
+ pTW_ENUMERATION_FRAME pCap = (pTW_ENUMERATION_FRAME)_pContainer;
+ int nMax;
+ if(!pDepCapMax->GetCurrent(nMax) || pCap->NumItems>(TW_UINT32)nMax)
{
- InternalFrame frame(pCap->ItemList[x], unit, Xres, Yres);
- if(ConstrainFrameToScanner(frame))
+ setConditionCode(TWCC_BADVALUE);
+ twrc = TWRC_FAILURE;
+ }
+ else
+ {
+ if(pCap && pCap->ItemType == TWTY_FRAME)
{
- pCap->ItemList[x] = frame.AsTW_FRAME(unit, Xres, Yres);
- twrc = TWRC_CHECKSTATUS;
+ for(TW_UINT32 x = 0; x < pCap->NumItems; ++x)
+ {
+ InternalFrame frame(pCap->ItemList[x], unit, Xres, Yres);
+ if(ConstrainFrameToScanner(frame))
+ {
+ pCap->ItemList[x] = frame.AsTW_FRAME(unit, Xres, Yres);
+ twrc = TWRC_CHECKSTATUS;
+ }
+ }
}
}
- _DSM_UnlockMemory(_pCap->hContainer);
}
}
break;
}
case CAP_FEEDERENABLED:
- if(TWON_ONEVALUE == _pCap->ConType)
+ if(TWON_ONEVALUE == _ConType)
{
- TW_ONEVALUE *pCap = (TW_ONEVALUE*)_DSM_LockMemory(_pCap->hContainer);
+ TW_ONEVALUE *pCap = (TW_ONEVALUE*)_pContainer;
- if(!pCap || pCap->ItemType != TWTY_BOOL || pCap->Item==0)
+ if(!pCap || pCap->ItemType != TWTY_BOOL)// || pCap->Item==0)
{
twrc = TWRC_FAILURE;
}
- _DSM_UnlockMemory(_pCap->hContainer);
}
else
{
@@ -990,15 +1064,14 @@
}
break;
case ICAP_MAXFRAMES:
- if(TWON_ONEVALUE == _pCap->ConType)
+ if(TWON_ONEVALUE == _ConType)
{
- TW_ONEVALUE *pCap = (TW_ONEVALUE*)_DSM_LockMemory(_pCap->hContainer);
+ TW_ONEVALUE *pCap = (TW_ONEVALUE*)_pContainer;
if(!pCap || pCap->ItemType != TWTY_UINT16 || pCap->Item!=1)
{
twrc = TWRC_FAILURE;
}
- _DSM_UnlockMemory(_pCap->hContainer);
}
else
{
@@ -1123,7 +1196,11 @@
// No match found
if(x >= nSize)
{
- pDepCapSS->SetCurrent(TWSS_NONE);
+ if(!pDepCapSS->SetCurrent(TWSS_NONE))
+ {
+ pDepCapSS->Add(TWSS_NONE);
+ pDepCapSS->SetCurrent(TWSS_NONE);
+ }
}
}
}
@@ -1154,7 +1231,9 @@
}
}
break;
-
+ case CAP_FEEDERENABLED:
+ //TODO add routine here if CAP_DUPLEXENABLED supports TRUE
+ break;
default:
break;
}
@@ -1440,7 +1519,7 @@
break;
/*
- Untill compression is implimented we don't support Jpeg
+ Untill compression is implimented we support Jpeg
case TWFF_JFIF:
break;
*/
@@ -1497,7 +1576,7 @@
// write the received image data to the image file
if( m_ImageInfo.BitsPerPixel < 24 // BW or Gray
- || m_ImageInfo.BitsPerPixel > 24 && !bSwitch) //Color but don't have to switch between RGB and BGR
+ || m_ImageInfo.BitsPerPixel > 24 && !bSwitch) //Color but have to switch between RGB and BGR
{
if(!pTifImg->WriteTIFFData(reinterpret_cast<char*>(pImage), nBPL*nHeight))
{
@@ -1785,6 +1864,109 @@
}
//////////////////////////////////////////////////////////////////////////////
+TW_INT16 CTWAINDS_Base::getTIFFImage(TW_MEMREF* _pTIFFImage)
+{
+ if(0 == m_hImageData || 0 == _pTIFFImage )
+ {
+ setConditionCode(TWCC_BADVALUE);
+ return TWRC_FAILURE;
+ }
+
+ *_pTIFFImage = 0;
+ BYTE *pImage = (BYTE *)_DSM_LockMemory(m_hImageData);
+ if(pImage == NULL)
+ {
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ TW_INT32 nWidth = m_ImageInfo.ImageWidth;
+ TW_INT32 nHeight = m_ImageInfo.ImageLength;
+ TW_INT16 nBPP = m_ImageInfo.BitsPerPixel;
+ TW_INT32 nBPL = BYTES_PERLINE(nWidth, nBPP);
+ CTiffWriter *pTifImg = new CTiffWriter("", nWidth, nHeight, nBPP, nBPL);
+ if(!pTifImg)
+ {
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ pTifImg->setXResolution(m_ImageInfo.XResolution.Whole, 1);
+ pTifImg->setYResolution(m_ImageInfo.YResolution.Whole, 1);
+
+ stringstream Header;
+ pTifImg->GetImageHeader(Header);
+ Header.seekp(0, ios_base::end);
+ DWORD dwSize =(DWORD) Header.tellp();
+ Header.seekg(0, ios_base::beg);
+ TW_HANDLE hTiff = _DSM_Alloc(dwSize+nBPL*nHeight); //create a buffer as large as the bitmap
+ if(hTiff==0)
+ {
+ setConditionCode(TWCC_LOWMEMORY);
+ delete pTifImg;
+ return TWRC_FAILURE;
+ }
+ char *pData = (char*)_DSM_LockMemory(hTiff);
+ if(pData==0)
+ {
+ _DSM_Free(hTiff);
+ setConditionCode(TWCC_LOWMEMORY);
+ delete pTifImg;
+ return TWRC_FAILURE;
+ }
+
+ Header.read(pData,dwSize);
+ pData +=dwSize;
+
+ bool bSwitch = true;
+ CTWAINContainerInt *pnCap = dynamic_cast<CTWAINContainerInt*>(findCapability(ICAP_BITORDER));
+ if(pnCap)
+ {
+ int nVal;
+ if(pnCap->GetCurrent(nVal))
+ {
+ bSwitch = nVal==TWBO_LSBFIRST? true:false;
+ }
+ }
+
+ // write the received image data to the image file
+ if( m_ImageInfo.BitsPerPixel < 24 // BW or Gray
+ || m_ImageInfo.BitsPerPixel > 24 && !bSwitch) //Color but have to switch between RGB and BGR
+ {
+ memcpy(pData,pImage,nBPL*nHeight);
+ }
+ else // color
+ {
+ BYTE *pSource = pImage;
+ BYTE *pDest = NULL;
+
+
+ for(TW_INT32 row=0; row<nHeight; row++)
+ {
+ pSource = pImage;
+ pDest = (BYTE*)pData;
+
+ // need to switch from BGR to RGB
+ for(TW_INT32 nCol=0; nCol<nWidth; nCol++)
+ {
+ *pDest++ = pSource[2];
+ *pDest++ = pSource[1];
+ *pDest++ = pSource[0];
+ pSource += 3;
+ }
+ pData += nBPL;
+ pImage += nBPL;
+ }
+ }
+
+ delete pTifImg;
+ _DSM_UnlockMemory(m_hImageData);
+ _DSM_UnlockMemory(hTiff);
+ *_pTIFFImage = hTiff;
+
+ return TWRC_SUCCESS;
+}
+//////////////////////////////////////////////////////////////////////////////
TW_INT16 CTWAINDS_Base::transferMemoryBuffers(pTW_IMAGEMEMXFER _ImageXfer)
{
TW_INT16 twrc = TWRC_SUCCESS;
@@ -1942,16 +2124,13 @@
{
// Native is basicaly an image file transfered by memory
// Windows is a Device independent BMP
- // Mac is a PICT
+ // Mac is a PICT - !!!!
// Linux is a TIFF
-#ifdef TWH_CMP_MSC
+#ifdef TWNDS_OS_LINUX
+ twrc = getTIFFImage(_pData);
+#else
twrc = getDIBImage(_pData);
-#elif defined(TWH_CMP_GNU)
- //On Linux, we need to do TIFF transfers in native mode
- //TODO: this needs to be implemented
- //twrc = getTIFFImage(_pData);
#endif
-
if( TWRC_SUCCESS == twrc )
{
twrc = TWRC_XFERDONE;
@@ -1961,3 +2140,17 @@
return twrc;
}
+
+//////////////////////////////////////////////////////////////////////////////
+TW_INT16 CTWAINDS_Base::GetGustomDSData(pTW_CUSTOMDSDATA _pDSData)
+{
+ setConditionCode(TWCC_BADPROTOCOL);
+ return TWRC_FAILURE;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+TW_INT16 CTWAINDS_Base::SetGustomDSData(pTW_CUSTOMDSDATA _pDSData)
+{
+ setConditionCode(TWCC_BADPROTOCOL);
+ return TWRC_FAILURE;
+}
\ No newline at end of file
Modified: trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.h
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.h 2009-12-22 19:40:56 UTC (rev 65)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_Base.h 2009-12-22 20:59:37 UTC (rev 66)
@@ -230,7 +230,16 @@
virtual TW_INT16 dat_xfergroup(TW_UINT16 _MSG,
pTW_UINT32 _pXferGroup);
+ /**
+ * Figures out what to do with the DAT_CUSTOMDSDATA request.
+ * @param[in] _MSG the message to handle.
+ * @param[in] _pDSData a pointer to a TW_CUSTOMDSDATA structure.
+ * @return a valid TWRC_xxxx return code.
+ */
+ virtual TW_INT16 dat_customdsdata(TW_UINT16 _MSG,
+ pTW_CUSTOMDSDATA _pDSData);
+
//////////////////////////////////////////////////////////////////////////////
/**
* @name Pure Virtuals
@@ -260,6 +269,13 @@
virtual TW_INT16 enableDS(pTW_USERINTERFACE _pData) = 0;
/**
+ * Enable the Data Source in setup mode.
+ * Called when a DG_CONTROL / DAT_USERINTERFACE / MSG_ENABLEDS op is sent.
+ * @return a valid TWRC_xxxx return code.
+ */
+ virtual TW_INT16 enableDSOnly() = 0;
+
+ /**
* Disable the Data Source.
* Called when a DG_CONTROL / DAT_USERINTERFACE / MSG_DISABLEDS op is sent.
* @param[in] _pData a pointer to a TW_USERINTERFACE structure.
@@ -452,6 +468,15 @@
*/
virtual bool DoDeviceEvent();
+ /**
+ * get the Internal Image format. For Linux Only
+ * Called when a DG_IMAGE / DAT_IMAGENATIVEXFER / MSG_GET op is sent.
+ * also used when creating a BMP for saving when DG_IMAGE / DAT_IMAGEFILEXFER / MSG_GET op is sent.
+ * @param[out] _pImage a pointer to store the image locaton.
+ * @return a valid TWRC_xxxx return code.
+ */
+ TW_INT16 getTIFFImage(TW_MEMREF* _pImage);
+
// END Capabilities
/**
* @}
@@ -523,10 +548,12 @@
* Validate the value being used to set a capability. Ranges and enums can be tested
* by the capability but OneValues might have only some values that are acceptable.
* Override this function in base class to support more capabilities
- * @param[in] _pCap a pointer to TW_CAPABILITY structure.
+ * @param[in] Cap the Capability ID
+ * @param[in] ConType the container type
+ * @param[in] _pCap a pointer to BYTE. Pointer to Cap container
* @return a valid TWRC_xxxx return code.
*/
- virtual TW_INT16 validateCapabilitySet(pTW_CAPABILITY _pCap);
+ virtual TW_INT16 validateCapabilitySet(TW_UINT16 _Cap, TW_UINT16 _ConType, BYTE* _pContainer);
/**
* if the CTWAINContainer is dependend on another Capabiltiy.
@@ -554,6 +581,20 @@
*/
TW_INT16 getCurrentUnits(int &Unit, float &Xres, float &Yres);
+ /**
+ * Get Gustom DS data
+ * @param[out] _pDSData a pointer to a TW_CUSTOMDSDATA structure.
+ * @return a valid TWRC_xxxx return code, TWRC_SUCCESS on success.
+ */
+ virtual TW_INT16 GetGustomDSData(pTW_CUSTOMDSDATA _pDSData);
+
+ /**
+ * Set Gustom DS data
+ * @param[in] _pDSData a pointer to a TW_CUSTOMDSDATA structure.
+ * @return a valid TWRC_xxxx return code, TWRC_SUCCESS on success.
+ */
+ virtual TW_INT16 SetGustomDSData(pTW_CUSTOMDSDATA _pDSData);
+
// END Accessors
/**
* @}
Modified: trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_FreeImage.cpp
===================================================================
--- trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_FreeImage.cpp 2009-12-22 19:40:56 UTC (rev 65)
+++ trunk/TWAIN-Samples/Twain_DS_sample01/src/CTWAINDS_FreeImage.cpp 2009-12-22 20:59:37 UTC (rev 66)
@@ -36,14 +36,16 @@
* @author TWAIN Working Group
* @date April 2007
*/
-
#include "CTWAINDS_FreeImage.h"
+#include "TWAIN_UI.h"
#include "FreeImage.h"
+#include <sstream>
#include <iostream>
#include <cstdlib>
#include <assert.h>
#include <signal.h>
+#include <typeinfo>
#ifdef TWH_CMP_MSC
#include <Winbase.h>
@@ -69,7 +71,7 @@
1, // TW_UINT16 MinorNum; Incremental revision number of the software
TWLG_ENGLISH, // TW_UINT16 Language; e.g. TWLG_SWISSFRENCH
TWCY_USA, // TW_UINT16 Country; e.g. TWCY_SWITZERLAND
- "2.1 sample" // TW_STR32 Info; e.g. "1.0b3 Beta release"
+ "2.1.1 sample" // TW_STR32 Info; e.g. "1.0b3 Beta release"
#ifdef _DEBUG
" debug"
#else
@@ -82,7 +84,7 @@
#endif
},
2, // TW_UINT16 ProtocolMajor; Application and DS must set to TWON_PROTOCOLMAJOR
- 0, // TW_UINT16 ProtocolMinor; Application and DS must set to TWON_PROTOCOLMINOR
+ 1, // TW_UINT16 ProtocolMinor; Application and DS must set to TWON_PROTOCOLMINOR
DG_IMAGE | DG_CONTROL | DF_DS2, // TW_UINT32 SupportedGroups; Bit field OR combination of DG_ constants
"TWAIN Working Group", // TW_STR32 Manufacturer; Manufacturer name, e.g. "Hewlett-Packard"
"Software Scan", // TW_STR32 ProductFamily; Product family name, e.g. "ScanJet"
@@ -96,9 +98,264 @@
m_AppID = AppID;
// Setup our identity
fillIdentityStructure(*getIdentity());
+ m_pGUI = CreateUI(this);
return;
}
+bool CTWAINDS_FreeImage::StoreCapInStream(stringstream &_DsData, TW_UINT16 _unCapID, TW_UINT16 _unCapIdx, TW_UINT16 unContType)
+{
+ CUST_DS_DATA_ELEMENT *pCapCon =(CUST_DS_DATA_ELEMENT*) new BYTE[sizeof(CUST_DS_DATA_ELEMENT)];
+ CTWAINContainer *pCap = findCapability(_unCapID);
+ TW_UINT16 unType = pCap->GetItemType();
+ pCapCon->unItemType = unType;
+ pCapCon->unCapID = _unCapID;
+ pCapCon->unCapIdx=_unCapIdx;
+ pCapCon->unContType = unContType;
+ pCapCon->dwSize = sizeof(CUST_DS_DATA_ELEMENT);
+
+ if(unContType!=TWON_ONEVALUE)//currentlly storing a single value
+ {
+ delete []pCapCon;
+ return false;
+ }
+
+ if(typeid(*pCap) == typeid(CTWAINContainerBool))
+ {
+
+ CTWAINContainerBool *pfBoolCap = (CTWAINContainerBool*)pCap;
+ bool bVal;
+ if(!pfBoolCap->GetCurrent(bVal))
+ {
+ delete []pCapCon;
+ return false;
+ }
+ pCapCon->dwVal[0] = bVal?1:0;
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerInt))
+ {
+ CTWAINContainerInt *pfIntCap = (CTWAINContainerInt*)pCap;
+ int nVal;
+ if(!pfIntCap->GetCurrent(nVal))
+ {
+ delete []pCapCon;
+ return false;
+ }
+ pCapCon->dwVal[0] = nVal;
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerFix32))
+ {
+ CTWAINContainerFix32 *pfFix32Cap = (CTWAINContainerFix32*)pCap;
+ float fVal;
+ if(!pfFix32Cap->GetCurrent(fVal))
+ {
+ delete []pCapCon;
+ return false;
+ }
+ *((float*)pCapCon->dwVal) = fVal;
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerFix32Range))
+ {
+ CTWAINContainerFix32Range *pfFix32Cap = (CTWAINContainerFix32Range*)pCap;
+ float fVal;
+ if(!pfFix32Cap->GetCurrent(fVal))
+ {
+ delete []pCapCon;
+ return false;
+ }
+ *((float*)pCapCon->dwVal) = fVal;
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerFrame))
+ {
+
+ CTWAINContainerFrame *pfFrameCap = (CTWAINContainerFrame*)pCap;
+ InternalFrame frmVal;
+ if(!pfFrameCap->GetCurrent(frmVal))
+ {
+ delete []pCapCon;
+ return false;
+ }
+ CUST_DS_DATA_ELEMENT *pCapCon1 =(CUST_DS_DATA_ELEMENT*) new BYTE[sizeof(CUST_DS_DATA_ELEMENT) + (4*sizeof(int)-sizeof(DWORD))];
+ *pCapCon1=*pCapCon;
+ delete []pCapCon;
+ pCapCon=pCapCon1;
+ pCapCon->dwSize +=(4*sizeof(int)-sizeof(DWORD));
+ pCapCon->dwVal[0] = frmVal.nBottom;
+ pCapCon->dwVal[1] = frmVal.nLeft;
+ pCapCon->dwVal[2] = frmVal.nRight;
+ pCapCon->dwVal[3] = frmVal.nTop;
+ }
+ else
+ {
+ delete []pCapCon;
+ return false;
+ }
+
+ _DsData.write((char*)pCapCon,pCapCon->dwSize);
+ delete []pCapCon;
+ return true;
+}
+
+bool CTWAINDS_FreeImage::ReadCapFromStream(stringstream &_DsData, TW_UINT16 _unCapID, TW_UINT16 _unCapIdx)
+{
+ _DsData.seekg(0, ios_base::beg);
+ DWORD dwSize = sizeof(CUST_DS_DATA_ELEMENT);
+ CUST_DS_DATA_ELEMENT *pCapCon =(CUST_DS_DATA_ELEMENT*) new BYTE[dwSize];
+ pCapCon->unCapID=-1;
+ pCapCon->unCapIdx=-1;
+ pCapCon->dwSize = 0;
+ while(!_DsData.eof() && (pCapCon->unCapID!=_unCapID || pCapCon->unCapIdx!=_unCapIdx))
+ {
+ _DsData.read((char*)pCapCon,sizeof(CUST_DS_DATA_ELEMENT));
+ if(!_DsData.eof() && pCapCon->dwSize>sizeof(CUST_DS_DATA_ELEMENT))
+ {
+ if(pCapCon->dwSize>dwSize)
+ {
+ BYTE *pTemp = new BYTE[pCapCon->dwSize];
+ memcpy(pTemp,pCapCon,sizeof(CUST_DS_DATA_ELEMENT));
+ delete []pCapCon;
+ pCapCon = (CUST_DS_DATA_ELEMENT*) pTemp;
+ dwSize = pCapCon->dwSize;
+ }
+ _DsData.read((char*)pCapCon+sizeof(CUST_DS_DATA_ELEMENT),pCapCon->dwSize-sizeof(CUST_DS_DATA_ELEMENT));
+ }
+ }
+
+ if(pCapCon->unCapID!=_unCapID || pCapCon->unCapIdx!=_unCapIdx)
+ {
+ delete []pCapCon;
+ return false;
+ }
+ CTWAINContainer *pCap = findCapability(_unCapID);
+ TW_UINT16 unType = pCap->GetItemType();
+ if(unType !=pCapCon->unItemType)
+ {
+ delete []pCapCon;
+ return false;
+ }
+
+ if(pCapCon->unContType!=TWON_ONEVALUE)//currentlly storing a single value
+ {
+ delete []pCapCon;
+ return false;
+ }
+
+ bool bRes =true;
+ TW_ONEVALUE conVal;
+ conVal.ItemType = pCapCon->unItemType;
+ conVal.Item =pCapCon->dwVal[0];
+ if(typeid(*pCap) == typeid(CTWAINContainerBool))
+ {
+ bRes = validateCapabilitySet(_unCapID,TWON_ONEVALUE,(BYTE*)&conVal)!=TWRC_FAILURE;
+ if(bRes)
+ {
+ CTWAINContainerBool *pfBoolCap = (CTWAINContainerBool*)pCap;
+ bRes = pfBoolCap->SetCurrent(pCapCon->dwVal[0]!=0);
+ }
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerInt))
+ {
+ bRes = validateCapabilitySet(_unCapID,TWON_ONEVALUE,(BYTE*)&conVal)!=TWRC_FAILURE;
+ if(bRes)
+ {
+ CTWAINContainerInt *pfIntCap = (CTWAINContainerInt*)pCap;
+ bRes = pfIntCap->SetCurrent(pCapCon->dwVal[0]);
+ }
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerFix32))
+ {
+ bRes = validateCapabilitySet(_unCapID,TWON_ONEVALUE,(BYTE*)&conVal)!=TWRC_FAILURE;
+ if(bRes)
+ {
+ CTWAINContainerFix32 *pfFix32Cap = (CTWAINContainerFix32*)pCap;
+ bRes = pfFix32Cap->SetCurrent(*(float*)pCapCon->dwVal);
+ }
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerFix32Range))
+ {
+ bRes = validateCapabilitySet(_unCapID,TWON_ONEVALUE,(BYTE*)&conVal)!=TWRC_FAILURE;
+ if(bRes)
+ {
+ CTWAINContainerFix32Range *pfFix32Cap = (CTWAINContainerFix32Range*)pCap;
+ bRes=pfFix32Cap->SetCurrent(*(float*)pCapCon->dwVal);
+ }
+ }
+ else if(typeid(*pCap) == typeid(CTWAINContainerFrame))
+ {
+ InternalFrame frmVal;
+ frmVal.nBottom = pCapCon->dwVal[0];
+ frmVal.nLeft = pCapCon->dwVal[1];
+ frmVal.nRight = pCapCon->dwVal[2];
+ frmVal.nTop = pCapCon->dwVal[3];
+ ConstrainFrameToScanner(frmVal);
+ CTWAINContainerFrame *pfFrameCap = (CTWAINContainerFrame*)pCap;
+ bRes = pfFrameCap->Set(frmVal);
+ }
+ else
+ {
+ bRes = false;
+ }
+
+ delete []pCapCon;
+ return bRes;
+}
+
+bool CTWAINDS_FreeImage::StoreCustomDSdata(stringstream &DsData)
+{
+ bool bResult = true;
+ bResult = bResult && StoreCapInStream(DsData,CAP_FEEDERENABLED,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,CAP_DUPLEXENABLED,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,CAP_AUTOFEED,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_BITDEPTH,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_BITORDER,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_COMPRESSION,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_FRAMES,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_IMAGEFILEFORMAT,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_PIXELFLAVOR,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_PIXELTYPE,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_PLANARCHUNKY,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_SUPPORTEDSIZES,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_ORIENTATION,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_UNITS,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_XRESOLUTION,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_YRESOLUTION,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_THRESHOLD,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_CONTRAST,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_BRIGHTNESS,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,ICAP_GAMMA,0,TWON_ONEVALUE);
+ bResult = bResult && StoreCapInStream(DsData,CUSTCAP_LONGDOCUMENT,0,TWON_ONEVALUE);
+ return bResult;
+}
+
+bool CTWAINDS_FreeImage::ReadCustomDSdata(stringstream &DsData)
+{
+ // When adding to Capabiltiy remember the order of operations
+ // Some capabilities are dependent on others.
+ // see: http://www.twain.org/docs/CapOrderForWeb.PDF
+ bool bResult = true;
+ bResult = bResult && ReadCapFromStream(DsData,CUSTCAP_LONGDOCUMENT,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_BITORDER,0);
+ bResult = bResult && ReadCapFromStream(DsData,CAP_FEEDERENABLED,0);
+ bResult = bResult && ReadCapFromStream(DsData,CAP_DUPLEXENABLED,0);
+ bResult = bResult && ReadCapFromStream(DsData,CAP_AUTOFEED,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_UNITS,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_PIXELTYPE,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_BITDEPTH,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_XRESOLUTION,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_YRESOLUTION,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_PIXELFLAVOR,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_PLANARCHUNKY,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_THRESHOLD,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_IMAGEFILEFORMAT,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_COMPRESSION,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_CONTRAST,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_BRIGHTNESS,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_GAMMA,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_SUPPORTEDSIZES,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_ORIENTATION,0);
+ bResult = bResult && ReadCapFromStream(DsData,ICAP_FRAMES,0);
+ return bResult;
+}
+
//////////////////////////////////////////////////////////////////////////////
TW_INT16 CTWAINDS_FreeImage::Initialize()
{
@@ -109,14 +366,19 @@
// setup the supported independant caps
CTWAINContainerInt* pnCap = 0;
CTWAINContainerBool* pbCap = 0;
+ CTWAINContainerString* pstrCap = 0;
+ CTWAINContainerFix32* pfixCap = 0;
m_IndependantCapMap[CAP_SUPPORTEDCAPS] = new CTWAINContainerInt(CAP_SUPPORTEDCAPS, TWTY_UINT16, TWON_ARRAY, TWQC_GETS);
if( NULL == (pnCap = dynamic_cast<CTWAINContainerInt*>(m_IndependantCapMap[CAP_SUPPORTEDCAPS]))
|| !pnCap->Add(CAP_DEVICEONLINE)
|| !pnCap->Add(CAP_INDICATORS)
+ || !pnCap->Add(CAP_ENABLEDSUIONLY)
|| !pnCap->Add(CAP_PAPERDETECTABLE)
|| !pnCap->Add(CAP_FEEDERENABLED)
|| !pnCap->Add(CAP_FEEDERLOADED)
+ || !pnCap->Add(CAP_DUPLEX)
+ || !pnCap->Add(CAP_DUPLEXENABLED)
|| !pnCap->Add(CAP_AUTOFEED)
|| !pnCap->Add(CAP_SUPPORTEDCAPS)
|| !pnCap->Add(CAP_UICONTROLLABLE)
@@ -133,10 +395,20 @@
|| !pnCap->Add(ICAP_PIXELTYPE)
|| !pnCap->Add(ICAP_PLANARCHUNKY)
|| !pnCap->Add(ICAP_SUPPORTEDSIZES)
+ || !pnCap->Add(ICAP_ORIENTATION)
|| !pnCap->Add(ICAP_UNITS)
|| !pnCap->Add(ICAP_XFERMECH)
|| !pnCap->Add(ICAP_XRESOLUTION)
- || !pnCap->Add(ICAP_YRESOLUTION) )
+ || !pnCap->Add(ICAP_YRESOLUTION)
+ || !pnCap->Add(ICAP_THRESHOLD)
+ || !pnCap->Add(ICAP_CONTRAST)
+ || !pnCap->Add(ICAP_BRIGHTNESS)
+ || !pnCap->Add(ICAP_GAMMA)
+ || !pnCap->Add(CAP_CUSTOMINTERFACEGUID)
+ || !pnCap->Add(CUSTCAP_LONGDOCUMENT)
+ || !pnCap->Add(CUSTCAP_DOCS_IN_ADF)
+ || !pnCap->Add(CAP_CUSTOMDSDATA)
+ )
{
cerr << "Could not create CAP_SUPPORTEDCAPS" << endl;
setConditionCode(TWCC_LOWMEMORY);
@@ -209,6 +481,15 @@
return TWRC_FAILURE;
}
+ m_IndependantCapMap[CAP_ENABLEDSUIONLY] = new CTWAINContainerBool(CAP_ENABLEDSUIONLY, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_GETS);
+ if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CAP_ENABLEDSUIONLY]))
+ || !pbCap->Add(TRUE, true) )
+ {
+ cerr << "Could not create CAP_ENABLEDSUIONLY" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
m_IndependantCapMap[CAP_XFERCOUNT] = new CTWAINContainerInt(CAP_XFERCOUNT, TWTY_INT16, TWON_ONEVALUE);
if( NULL == (pnCap = dynamic_cast<CTWAINContainerInt*>(m_IndependantCapMap[CAP_XFERCOUNT]))
|| !pnCap->Add(TWON_DONTCARE32, true) )
@@ -260,6 +541,15 @@
return TWRC_FAILURE;
}
+ m_IndependantCapMap[ICAP_ORIENTATION] = new CTWAINContainerInt(ICAP_ORIENTATION, TWTY_UINT16, TWON_ENUMERATION);
+ if( NULL == (pnCap = dynamic_cast<CTWAINContainerInt*>(m_IndependantCapMap[ICAP_ORIENTATION]))
+ || !pnCap->Add(TWOR_PORTRAIT, true))
+ {
+ cerr << "Could not create ICAP_ORIENTATION" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
m_IndependantCapMap[CAP_DEVICEONLINE] = new CTWAINContainerBool(CAP_DEVICEONLINE, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_GETS);
if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CAP_DEVICEONLINE]))
|| !pbCap->Add(TRUE, true)
@@ -272,9 +562,8 @@
m_IndependantCapMap[CAP_INDICATORS] = new CTWAINContainerBool(CAP_INDICATORS, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_ALL);
if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CAP_INDICATORS]))
- || !pbCap->Add(FALSE, true))
- /// @todo add UI
- // || !pnCap->Add(TRUE, true))//Default has to be TRUE if it is supported
+ || !pbCap->Add(TRUE, true)
+ || !pbCap->Add(FALSE))
{
cerr << "Could not create CAP_INDICATORS" << endl;
setConditionCode(TWCC_LOWMEMORY);
@@ -291,8 +580,8 @@
}
m_IndependantCapMap[CAP_FEEDERENABLED] = new CTWAINContainerBool(CAP_FEEDERENABLED, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_ALL);
- /// @todo to add support for flatbed set to TWQC_ALL and add False as posible value.
if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CAP_FEEDERENABLED]))
+ || !pbCap->Add(FALSE)
|| !pbCap->Add(TRUE, true) )
{
cerr << "Could not create CAP_FEEDERENABLED" << endl;
@@ -300,6 +589,23 @@
return TWRC_FAILURE;
}
+ m_IndependantCapMap[CAP_DUPLEX] = new CTWAINContainerInt(CAP_DUPLEX, TWTY_UINT16, TWON_ONEVALUE, TWQC_GETS);
+ if( NULL == (pnCap = dynamic_cast<CTWAINContainerInt*>(m_IndependantCapMap[CAP_DUPLEX]))
+ || !pnCap->Add(TWDX_NONE, true) )
+ {
+ cerr << "Could not create CAP_DUPLEX" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ m_IndependantCapMap[CAP_DUPLEXENABLED] = new CTWAINContainerBool(CAP_DUPLEXENABLED, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_ALL);
+ if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CAP_DUPLEXENABLED]))
+ || !pbCap->Add(FALSE, true))
+ {
+ cerr << "Could not create CAP_DUPLEXENABLED" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
m_IndependantCapMap[CAP_FEEDERLOADED] = new CTWAINContainerBool(CAP_FEEDERLOADED, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_GETS);
if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CAP_FEEDERLOADED]))
|| !pbCap->Add(TRUE)
@@ -329,6 +635,34 @@
return TWRC_FAILURE;
}
+ m_IndependantCapMap[CUSTCAP_LONGDOCUMENT] = new CTWAINContainerBool(CUSTCAP_LONGDOCUMENT, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_ALL);
+ if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CUSTCAP_LONGDOCUMENT]))
+ || !pbCap->Add(TRUE)
+ || !pbCap->Add(FALSE, true) )
+ {
+ cerr << "Could not create CUSTCAP_LONGDOCUMENT" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ m_IndependantCapMap[CUSTCAP_DOCS_IN_ADF] = new CTWAINContainerInt(CUSTCAP_DOCS_IN_ADF, TWTY_UINT16, TWON_ONEVALUE, TWQC_ALL);
+ if( NULL == (pnCap = dynamic_cast<CTWAINContainerInt*>(m_IndependantCapMap[CUSTCAP_DOCS_IN_ADF]))
+ || !pnCap->Add(m_Scanner.GetMaxPagesInADF()))
+ {
+ cerr << "Could not create CUSTCAP_DOCS_IN_ADF" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ m_IndependantCapMap[CAP_CUSTOMDSDATA] = new CTWAINContainerBool(CAP_CUSTOMDSDATA, (m_AppID.SupportedGroups&DF_APP2)!=0, TWQC_GETS);
+ if( NULL == (pbCap = dynamic_cast<CTWAINContainerBool*>(m_IndependantCapMap[CAP_CUSTOMDSDATA]))
+ || !pbCap->Add(TRUE, true) )
+ {
+ cerr << "Could not create CAP_CUSTOMDSDATA" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
// setup dependant caps
if( NULL == (m_BitDepthMap[TWPT_BW] = new CTWAINContainerInt(ICAP_BITDEPTH, TWTY_UINT16, TWON_ENUMERATION))
|| !m_BitDepthMap[TWPT_BW]->Add(1, true) )
@@ -354,8 +688,61 @@
return TWRC_FAILURE;
}
+ m_IndependantCapMap[CAP_CUSTOMINTERFACEGUID] = new CTWAINContainerString(CAP_CUSTOMINTERFACEGUID,TWTY_STR255,TWON_ONEVALUE, TWQC_GETS);
+ if( NULL == (pstrCap = dynamic_cast<CTWAINContainerString*>(m_IndependantCapMap[CAP_CUSTOMINTERFACEGUID]))
+ || !pstrCap->Add(kCUSTOMDSGUI, true))
+ {
+ cerr << "Could not create CAP_CUSTOMINTERFACEGUID" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ m_IndependantCapMap[ICAP_GAMMA] = new CTWAINContainerFix32(ICAP_GAMMA,TWON_ONEVALUE, TWQC_ALL);
+ if( NULL == (pfixCap = dynamic_cast<CTWAINContainerFix32*>(m_IndependantCapMap[ICAP_GAMMA]))
+ || !pfixCap->Add(1, true))
+ {
+ cerr << "Could not create ICAP_GAMMA" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+ FLOAT_RANGE fRange;
+ fRange.fCurrentValue = 128.0f;
+ fRange.fMaxValue = 255.0f;
+ fRange.fMinValue = 0.0f;
+ fRange.fStepSize = 1.0f;
+ m_IndependantCapMap[ICAP_THRESHOLD] = new CTWAINContainerFix32Range(ICAP_THRESHOLD,fRange, TWQC_ALL);
+ if( NULL == dynamic_cast<CTWAINContainerFix32Range*>(m_IndependantCapMap[ICAP_THRESHOLD]))
+ {
+ cerr << "Could not create ICAP_THRESHOLD" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ fRange.fCurrentValue = 0.0f;
+ fRange.fMaxValue = 1000.0f;
+ fRange.fMinValue = -1000.0f;
+ fRange.fStepSize = 1.0f;
+ m_IndependantCapMap[ICAP_CONTRAST] = new CTWAINContainerFix32Range(ICAP_CONTRAST,fRange, TWQC_ALL);
+ if( NULL == dynamic_cast<CTWAINContainerFix32Range*>(m_IndependantCapMap[ICAP_CONTRAST]))
+ {
+ cerr << "Could not create ICAP_CONTRAST" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
+
+ fRange.fCurrentValue = 0.0f;
+ fRange.fMaxValue = 1000.0f;
+ fRange.fMinValue = -1000.0f;
+ fRange.fStepSize = 1.0f;
+ m_IndependantCapMap[ICAP_BRIGHTNESS] = new CTWAINContainerFix32Range(ICAP_BRIGHTNESS,fRange, TWQC_ALL);
+ if( NULL == dynamic_cast<CTWAINContainerFix32Range*>(m_IndependantCapMap[ICAP_BRIGHTNESS]))
+ {
+ cerr << "Could not create ICAP_BRIGHTNESS" << endl;
+ setConditionCode(TWCC_LOWMEMORY);
+ return TWRC_FAILURE;
+ }
// expressed internally as pixels per inch
- if( NULL == (m_ICAP_UNIT_Dependant[ICAP_XRESOLUTION] = new CTWAINContainerFix32(ICAP_XRESOLUTION, TWTY_FIX32, TWON_ENUMERATION, TWQC_ALL))
+ if( NULL == (m_ICAP_UNIT_Dependant[ICAP_XRESOLUTION] = new CTWAINContainerFix32(ICAP_XRESOLUTION, TWON_ENUMERATION, TWQC_ALL))
|| !m_ICAP_UNIT_Dependant[ICAP_XRESOLUTION]->Add(50)
|| !m_ICAP_UNIT_Dependant[ICAP_XRESOLUTION]->Add(100)
|| !m_ICAP_UNIT_Dependant[ICAP_XRESOLUTION]->Add(150)
@@ -371,7 +758,7 @@
}
// expressed internally as pixels per inch
- if( NULL == (m_ICAP_UNIT_Dependant[ICAP_YRESOLUTION] = new CTWAINContainerFix32(ICAP_YRESOLUTION, TWTY_FIX32, TWON_ENUMERATION, TWQC_ALL))
+ if( NULL == (m_ICAP_UNIT_Dependant[ICAP_YRESOLUTION] = new CTWAINContainerFix32(ICAP_YRESOLUTION, TWON_ENUMERATION, TWQC_ALL))
|| !m_ICAP_UNIT_Dependant[ICAP_YRESOLUTION]->Add(50)
|| !m_ICAP_UNIT_Dependant[ICAP_YRESOLUTION]->Add(100)
|| !m_ICAP_UNIT_Dependant[ICAP_YRESOLUTION]->Add(150)
@@ -392,7 +779,7 @@
// Flatbed - A4 letter paper
// ConvertUnits(29.7f, TWUN_CENTIMETERS, TWUN_INCHES, 1000);
// ConvertUnits(21.0f, TWUN_CENTIMETERS, TWUN_INCHES, 1000);
- if( NULL == (m_ICAP_UNIT_Dependant[ICAP_PHYSICALWIDTH] = new CTWAINContainerFix32(ICAP_PHYSICALWIDTH, TWTY_FIX32, TWON_ONEVALUE, TWQC_GETS))
+ if( NULL == (m_ICAP_UNIT_Dependant[ICAP_PHYSICALWIDTH] = new CTWAINContainerFix32(ICAP_PHYSICALWIDTH, TWON_ONEVALUE, TWQC_GETS))
|| !m_ICAP_UNIT_Dependant[ICAP_PHYSICALWIDTH]->Add(8.5, true) )
{
cerr << "Could not create ICAP_PHYSICALWIDTH" << endl;
@@ -400,7 +787,7 @@
return TWRC_FAILURE;
}
- if( NULL == (m_ICAP_UNIT_Dependant[ICAP_PHYSICALHEIGHT] = new CTWAINContainerFix32(ICAP_PHYSICALHEIGHT, TWTY_FIX32, TWON_ONEVALUE, TWQC_GETS))
+ if( NULL == (m_ICAP_UNIT_Dependant[ICAP_PHYSICALHEIGHT] = new CTWAINContainerFix32(ICAP_PHYSICALHEIGHT, TWON_ONEVALUE, TWQC_GETS))
|| !m_ICAP_UNIT_Dependant[ICAP_PHYSICALHEIGHT]->Add(14.0, true) )
{
cerr << "Could not create ICAP_PHYSICALHEIGHT" << endl;
@@ -411,7 +798,7 @@
// setup the ICAP_FRAMES
// expressed internally as 1000 pixels per inch
// Currently only supports one frame see: ICAP_MAXFRAMES
- if( NULL == (m_pICAP_FRAMES = new CTWAINContainerFrame(ICAP_FRAMES, TWTY_FRAME, TWON_ENUMERATION, TWQC_ALL))
+ if( NULL == (m_pICAP_FRAMES = new CTWAINContainerFrame(ICAP_FRAMES, TWON_ENUMERATION, TWQC_ALL))
|| !m_pICAP_FRAMES->Add(0, 0, 8500, 11000, true) )
{
cerr << "Could not create ICAP_FRAMES" << endl;
@@ -439,6 +826,8 @@
//////////////////////////////////////////////////////////////////////////////
CTWAINDS_FreeImage::~CTWAINDS_FreeImage()
{
+ DestroyUI(m_pGUI);
+
// free all resources belonging to m_IndependantCapMap
TWAINCapabilitiesMap_int::iterator cur_int = m_BitDepthMap.begin();
while(cur_int != m_BitDepthMap.end())
@@ -459,6 +848,7 @@
delete m_pICAP_FRAMES;
}
m_pICAP_FRAMES = 0;
+ return;
}
//////////////////////////////////////////////////////////////////////////////
@@ -526,7 +916,6 @@
TW_INT16 CTWAINDS_FreeImage::openDS(pTW_IDENTITY _pOrigin)
{
TW_INT16 ret = TWRC_SUCCESS;
-
// this basic version of the DS only supports one connection from the DSM
if( m_App.Id != 0 )
{
@@ -583,12 +972,29 @@
setConditionCode(TWCC_SEQERROR);
return TWRC_FAILURE;
}
+ m_CurrentState = dsState_Enabled;
+ m_bCanceled = false;
- // @todo Impliment UI in the DS
- if(1)//FALSE == _pData->ShowUI)
+
+ //set pending xfers to whatever the user configured for XferCount
+ int Count = TWON_DONTCARE32;
+ CTWAINContainerInt *pnCap = dynamic_cast<CTWAINContainerInt*>(findCapability(CAP_XFERCOUNT));
+ if(pnCap)
{
- m_CurrentState = dsState_Enabled;
+ pnCap->GetCurrent(Count);
+ }
+ m_Xfers.Count = Count;
+ // Indicate we have not transferred any images yet
+ m_DocumentNumber = 0;
+ m_PageNumber = 0;
+
+ // The application will move to state 5 after this triplet which means that
+ // no more capabilities can be set until we are brought back to state 4.
+ m_Scanner.Lock();
+
+ if(FALSE == _pData->ShowUI)
+ {
// Update the scanner with the latest negotiated caps
if(!updateScannerFromCaps())
{
@@ -596,24 +1002,9 @@
setConditionCode(TWCC_BADVALUE);
return TWRC_FAILURE;
}
-
- //set pending xfers to whatever the user configured for XferCount
- int Count = TWON_DONTCARE32;
- CTWAINContainerInt *pnCap = dynamic_cast<CTWAINContainerInt*>(findCapability(CAP_XFERCOUNT));
- if(pnCap)
- {
- pnCap->GetCurrent(Count);
- }
- m_Xfers.Count = Count;
-
- // Indicate we have not transferred any images yet
- m_DocumentNumber = 0;
- m_PageNumber = 0;
-
// The application will move to state 5 after this triplet which means that
// no more capabilities can be set until we are brought back to state 4.
m_Scanner.Lock();
-
// Because there is no user interface, there isn't anything to show here.
// But, at this point, the application is not allowed to set any more
// capabilities. This means that we can do any initializations we
@@ -633,37 +1024,50 @@
setConditionCode(TWCC_SEQERROR);
return TWRC_FAILURE;
}
-
- // @todo remove this when UI is working
- if(TRUE == _pData->ShowUI)
- {
- setConditionCode(TWCC_BADPROTOCOL);
- return TWRC_CHECKSTATUS;
- }
}
- else
+ CTWAINContainerBool *pbCap = dynamic_cast<CTWAINContainerBool*>(findCapability(CAP_INDICATORS));
+ bool bIndicators = FALSE;
+ if(pbCap)
{
- /// @todo Hook up the GUI
- /*
- if(!DisplayTWAINGUI(*_pData))
- {
- // A user interface is not supported as of right now because we are
- // in text mode.
- setConditionCode(TWCC_OPERATIONERROR);
- twrc = TWRC_FAILURE;
- }
- else
- {
- m_CurrentState = dsState_Enabled;
- }
- */
- return TWRC_FAILURE;
+ pbCap->GetCurrent(bIndicators);
+ }
+ if(m_pGUI->DisplayTWAINGUI(*_pData,false,bIndicators)!=TWRC_SUCCESS)
+ {
+ // A user interface is not supported as of right now because we are
+ // in text mode.
+ m_CurrentState = dsState_Open;
+ setConditionCode(TWCC_OPERATIONERROR);
+ return TWRC_FAILURE;
+ }
+ return TWRC_SUCCESS;
+}
+//////////////////////////////////////////////////////////////////////////////
+TW_INT16 CTWAINDS_FreeImage::enableDSOnly()
+{
+ if( dsState_Open != m_CurrentState )
+ {
+ setConditionCode(TWCC_SEQERROR);
+ return TWRC_FAILURE;
}
+ m_CurrentState = dsState_Enabled;
+ TW_USERINTERFACE Data;
+ memset(&Data,0,sizeof(TW_USERINTERFACE));
+ Data.ShowUI = 1;
+
+
+ if(m_pGUI->DisplayTWAINGUI(Data,true,false)!=TWRC_SUCCESS)
+ {
+ // A user interface is not supported as of right now because we are
+ // in text mode.
+ m_CurrentState = dsState_Open;
+ setConditionCode(TWCC_OPERATIONERROR);
+ return TWRC_FAILURE;
+ }
+
return TWRC_SUCCESS;
}
-
//////////////////////////////////////////////////////////////////////////////
TW_INT16 CTWAINDS_FreeImage::disableDS(pTW_USERINTERFACE _pData)
{
@@ -672,23 +1076,18 @@
setConditionCode(TWCC_SEQERROR);
return TWRC_FAILURE;
}
+ m_pGUI->DestroyTWAINGUI();
// allow the scanners caps to be writeable again because we are moving back
// to state 4. If this source had a UI, it would be lowered at this time.
m_Scanner.Unlock();
- if(TRUE == _...
[truncated message content] |