コード例 #1
0
ファイル: twainiface.cpp プロジェクト: UIKit0/digikam
/** Opens a Data Source */
bool KSaneWidgetPrivate::OpenSource(const QString &source)
{
    if (source.isEmpty()) {
        return false;
    }
    
    QStringList splited = source.split(';');
    if (splited.size() != 3) {
        return false;
    }

    // go thorough the list and check if the source is available
    bool ret_ok = CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, &m_Source);
    while (ret_ok) {
        //qDebug() << m_Source.Id << m_Source.Version.MajorNum << m_Source.Version.MinorNum;
        //qDebug() << m_Source.Manufacturer << m_Source.ProductFamily << m_Source.ProductName;
        if (QString(m_Source.ProductName) == splited[0]) break;
        ret_ok = CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETNEXT, &m_Source);
    }
    
    if (!ret_ok) {
        // CallTwainProc failed when reading beyond the last source
        return false;
    }
    
    // open the source
    if (m_hTwainDLL && m_pDSMProc && m_bDSMOpen) {
        m_bDSOpen = CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, (TW_MEMREF)&m_Source);
        //qDebug() << "OpenSource(qst..) m_bDSOpen" <<  m_bDSOpen;
    }

    SetImageCount(TWCPP_ANYCOUNT);

    return DSOpen();
}
コード例 #2
0
ファイル: TwainCpp.cpp プロジェクト: jf4210/src2-test
BOOL CTwain::Acquire(int numImages /*= 1*/, BOOL bShowUI)
{
	if (DSOpen() || OpenSource())
	{		
		TW_UINT16 nCut = 1;
		BOOL ret_value = SetCapability(ICAP_AUTOMATICBORDERDETECTION, nCut, TRUE);	//自动裁剪

		TW_UINT16 nRotate = 1;
		ret_value = SetCapability(ICAP_AUTOMATICDESKEW, nRotate, TRUE);		//自动纠偏
		
	#if 0
		TW_UINT16 nBright = (135 - 128) / 0.125;
		ret_value = SetCapability(ICAP_BRIGHTNESS, nBright, TRUE);		//亮度调节

		TW_UINT16 nContrast = (135 - 128) / 0.125;
		ret_value = SetCapability(ICAP_CONTRAST, nContrast, TRUE);		//对比度调节
	#endif

		if (SetImageCount(numImages))
		{
			if (EnableSource(bShowUI))
			{
				return TRUE;
			}
		}
	}
	return FALSE;
}
コード例 #3
0
ファイル: TwainCpp.cpp プロジェクト: jf4210/src2-test
BOOL CTwain::SetOneValueCapability(TW_UINT16 cap, TW_UINT16 Type, TW_UINT16 value/*,BOOL sign*/)
{
	if (DSOpen())
	{
		TW_CAPABILITY twCap;
		pTW_ONEVALUE pVal;
		BOOL ret_value = FALSE;
		twCap.Cap = cap;
		twCap.ConType = TWON_ONEVALUE;

		twCap.hContainer = GlobalAlloc(GHND, sizeof(TW_ONEVALUE));
		if (twCap.hContainer)
		{

			pVal = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
			pVal->ItemType = Type;
			pVal->Item = (TW_UINT32)value;
			ret_value = SetCapability(twCap);
			GlobalUnlock(twCap.hContainer);
			GlobalFree(twCap.hContainer);
		}
		else
		{
			//AfxMessageBox("twCap.hContainer false");
		}
		return ret_value;
	}

	return FALSE;
}
コード例 #4
0
/*
Sets the capability of the Twain Data Source
*/
BOOL CTwain::SetCapability(TW_UINT16 cap,TW_UINT16 value,BOOL sign)
{
	if(DSOpen())
	{
	TW_CAPABILITY twCap;
	pTW_ONEVALUE pVal;
	BOOL ret_value = FALSE;

		twCap.Cap = cap;
		twCap.ConType = TWON_ONEVALUE;
		
		twCap.hContainer = GlobalAlloc(GHND,sizeof(TW_ONEVALUE));
		if(twCap.hContainer)
		{
			pVal = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
			pVal->ItemType = sign ? TWTY_INT16 : TWTY_UINT16;
			pVal->Item = (TW_UINT32)value;
			GlobalUnlock(twCap.hContainer);
			ret_value = SetCapability(twCap);
			GlobalFree(twCap.hContainer);
		}
		return ret_value;
	}
	return FALSE;
}
コード例 #5
0
ファイル: twainiface.cpp プロジェクト: UIKit0/digikam
/** Sets the capability of the Twain Data Source */
bool KSaneWidgetPrivate::SetCapability(TW_CAPABILITY& cap)
{
    if(DSOpen()) {
        return CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                             DAT_CAPABILITY, MSG_SET, (TW_MEMREF)&cap);
    }
    return false;
}
コード例 #6
0
/*
Sets the capability of the Twain Data Source
*/
BOOL CTwain::SetCapability(TW_CAPABILITY& cap)
{
	if(DSOpen())
	{
		return CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_CAPABILITY,MSG_SET,(TW_MEMREF)&cap);
	}
	return FALSE;
}
コード例 #7
0
/*
Closes the Data Source
*/
void CTwain::CloseDS()
{
	if(DSOpen())
	{
		DisableSource();
		CallTwainProc(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_CLOSEDS,(TW_MEMREF)&m_Source);
		m_bDSOpen = FALSE;
	}
}
コード例 #8
0
ファイル: twainiface.cpp プロジェクト: UIKit0/digikam
/** Re-Opens a Data Source */
bool KSaneWidgetPrivate::ReOpenDialog()
{
    //qDebug() << "ReOpenSource:" << m_hTwainDLL << m_pDSMProc << m_bDSMOpen << m_bDSOpen;
    
    if (DSOpen()) {
        // already open
        return true;
    }
    // open the source
    if (m_hTwainDLL && m_pDSMProc && m_bDSMOpen) {
        m_bDSOpen = CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, (TW_MEMREF)&m_Source);
        //qDebug() << "ReOpenSource() m_bDSOpen" <<  m_bDSOpen;      
    }

    SetImageCount(TWCPP_ANYCOUNT);

    if (DSOpen()) {
        return EnableSource(true);
    }
    //else
    return false;
}
コード例 #9
0
/*
Called to acquire images from the source. parameter numImages i the
numberof images that you an handle concurrently
*/
BOOL CTwain::Acquire(int numImages)
{
	if(DSOpen() || OpenSource())
	{
		if(SetImageCount(numImages))
		{
			if(EnableSource())
			{
				return TRUE;
			}
		}
	}
	return FALSE;
}
コード例 #10
0
/*
Queries the capability of the Twain Data Source
*/
BOOL CTwain::GetCapability(TW_CAPABILITY& twCap,TW_UINT16 cap,TW_UINT16 conType)
{
	if(DSOpen())
	{
		twCap.Cap = cap;
		twCap.ConType = conType;
		twCap.hContainer = NULL;

		if(CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_CAPABILITY,MSG_GET,(TW_MEMREF)&twCap))
		{
			return TRUE;
		}
	}
	return FALSE;
}
コード例 #11
0
ファイル: twainiface.cpp プロジェクト: UIKit0/digikam
/** Closes the Data Source
 */
void KSaneWidgetPrivate::CloseDS()
{
    if(DSOpen()) {
        if(m_bSourceEnabled) {
            TW_USERINTERFACE twUI;
            if(CallTwainProc(&m_AppId, &m_Source, DG_CONTROL, 
                             DAT_USERINTERFACE, MSG_DISABLEDS, &twUI)) {
                m_bSourceEnabled = false;
            }
        }
        CallTwainProc(&m_AppId, NULL, DG_CONTROL,
                      DAT_IDENTITY, MSG_CLOSEDS, (TW_MEMREF)&m_Source);
        m_bDSOpen = false;
    }
}
コード例 #12
0
/*
Opens a Data Source supplied as the input parameter
*/
BOOL CTwain::OpenSource(TW_IDENTITY *pSource)
{
	if(pSource) 
	{
		m_Source = *pSource;
	}
	if(DSMOpen())
	{
		if(!SourceSelected())
		{
			SelectDefaultSource();
		}
		m_bDSOpen = CallTwainProc(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_OPENDS,(TW_MEMREF)&m_Source);
	}
	return DSOpen();
}
コード例 #13
0
ファイル: twainiface.cpp プロジェクト: UIKit0/digikam
/** Queries the capability of the Twain Data Source */
bool KSaneWidgetPrivate::GetCapability(TW_CAPABILITY& twCap, TW_UINT16 cap, TW_UINT16 conType)
{
    if(DSOpen())
    {
        twCap.Cap        = cap;
        twCap.ConType    = conType;
        twCap.hContainer = NULL;

        if(CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                         DAT_CAPABILITY, MSG_GET, (TW_MEMREF)&twCap))
        {
            return true;
        }
    }
    return false;
}
コード例 #14
0
ファイル: twainiface.cpp プロジェクト: ruphy/kipi-plugins
/** Called to acquire images from the source. parameter numImages is the
    number of images that you an handle concurrently
 */
bool TwainIface::Acquire(int numImages)
{
    if(DSOpen() || OpenSource())
    {
        if(SetImageCount(numImages))
        {
            if(EnableSource())
            {
                //ReleaseTwain();
                //TW_IMAGEINFO info;
                //GetImageInfo(info);
                //GetImage(info);
                return true;
            }
        }
    }
    return false;
}
コード例 #15
0
ファイル: TwainCpp.cpp プロジェクト: jf4210/src2-test
/*
Called to acquire images from the source. parameter numImages i the
numberof images that you an handle concurrently
*/
BOOL CTwain::Acquire(int numImages, TW_UINT16 duplex, TW_UINT16 size, TW_UINT16 pixel, TW_UINT16 resolution, BOOL bShowUI, int nAutoCut)
{
	if(DSOpen() || OpenSource())
	{
		_bTwainContinue = TRUE;
//		BOOL ret_value=SetCapability(CAP_DUPLEXENABLED,duplex,TRUE);
		if (duplex == 1)
			duplex = TRUE;
		else
			duplex = FALSE;	// CAP_DUPLEX
		BOOL ret_value = SetOneValueCapability(CAP_DUPLEXENABLED, TWTY_BOOL, duplex);	//单双面扫描控制	//duplex, TRUE


//		ret_value = SetCapability(CAP_DUPLEX, duplex, TRUE);

		ret_value=SetCapability(ICAP_SUPPORTEDSIZES,size,TRUE);
		ret_value=SetCapability(ICAP_PIXELTYPE,pixel,TRUE);
		ret_value=SetResolution(ICAP_XRESOLUTION,resolution);
		ret_value=SetResolution(ICAP_YRESOLUTION,resolution);
		
		ret_value = SetCapability(ICAP_AUTOMATICBORDERDETECTION, nAutoCut, TRUE);	//自动裁剪

		TW_UINT16 nRotate = 1;
		ret_value = SetCapability(ICAP_AUTOMATICDESKEW, nRotate, TRUE);		//自动纠偏

#if 0
		TW_UINT16 nBright = (135 - 128) / 0.125;
		ret_value = SetCapability(ICAP_BRIGHTNESS, nBright, TRUE);		//亮度调节

		TW_UINT16 nContrast = (135 - 128) / 0.125;
		ret_value = SetCapability(ICAP_CONTRAST, nContrast, TRUE);		//对比度调节
#endif

		if(SetImageCount(numImages))
		{
			if (EnableSource(bShowUI))
			{
				return TRUE;
			}
		}
	}
	return FALSE;
}
コード例 #16
0
ファイル: TwainCpp.cpp プロジェクト: jf4210/src2-test
/*
Called to enable the Twain Acquire Dialog. This too can be
overridden but is a helluva job . 
*/
BOOL CTwain::EnableSource(BOOL showUI)
{
	if(DSOpen() && !SourceEnabled())
	{
		twUI.ShowUI = showUI;	//FALSE
		twUI.hParent = (TW_HANDLE)m_hMessageWnd;
		if(CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_USERINTERFACE,MSG_ENABLEDS,(TW_MEMREF)&twUI))
		{
			m_bSourceEnabled = TRUE;
			m_bModalUI = twUI.ModalUI;
		}
		else
		{
			m_bSourceEnabled = FALSE;
			m_bModalUI = TRUE;
		}
		return m_bSourceEnabled;
	}
	return FALSE;
}
コード例 #17
0
ファイル: twainiface.cpp プロジェクト: UIKit0/digikam
/** Sets the capability of the Twain Data Source */
bool KSaneWidgetPrivate::SetCapability(TW_UINT16 cap, TW_UINT16 value, bool sign)
{
    if(DSOpen()) {
        TW_CAPABILITY twCap;
        pTW_ONEVALUE pVal;
        bool ret_value   = false;
        twCap.Cap        = cap;
        twCap.ConType    = TWON_ONEVALUE;
        twCap.hContainer = GlobalAlloc(GHND,sizeof(TW_ONEVALUE));

        if(twCap.hContainer) {
            pVal           = (pTW_ONEVALUE)GlobalLock(twCap.hContainer);
            pVal->ItemType = sign ? TWTY_INT16 : TWTY_UINT16;
            pVal->Item     = (TW_UINT32)value;
            GlobalUnlock(twCap.hContainer);
            ret_value      = SetCapability(twCap);
            GlobalFree(twCap.hContainer);
        }
        return ret_value;
    }
    return false;
}
コード例 #18
0
ファイル: twainiface.cpp プロジェクト: ruphy/kipi-plugins
/** Called to enable the Twain Acquire Dialog. This too can be
    overridden but is a helluva job .
 */
bool TwainIface::EnableSource(bool showUI)
{
    if(DSOpen() && !SourceEnabled())
    {
        TW_USERINTERFACE twUI;
        twUI.ShowUI  = showUI;
        twUI.hParent = (TW_HANDLE)m_hMessageWnd;

        if(CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                         DAT_USERINTERFACE, MSG_ENABLEDS, (TW_MEMREF)&twUI))
        {
            m_bSourceEnabled = true;
            m_bModalUI       = twUI.ModalUI;
        }
        else
        {
            m_bSourceEnabled = false;
            m_bModalUI       = true;
        }
        return m_bSourceEnabled;
    }
    return false;
}
コード例 #19
0
ファイル: twainiface.cpp プロジェクト: UIKit0/digikam
/** Called to enable the Twain Acquire Dialog. This too can be 
 * overridden but is a helluva job. */
bool KSaneWidgetPrivate::EnableSource(bool showUI)
{
    //qDebug() << "DSOpen() =" << DSOpen();
    if(DSOpen() && !m_bSourceEnabled) {
        TW_USERINTERFACE twUI;
        twUI.ShowUI  = showUI;
        twUI.hParent = (TW_HANDLE)m_hMessageWnd;

        if(CallTwainProc(&m_AppId, &m_Source, DG_CONTROL,
                         DAT_USERINTERFACE, MSG_ENABLEDS, (TW_MEMREF)&twUI))
        {
            m_bSourceEnabled = true;
            m_bModalUI       = twUI.ModalUI;
        }
        else {
            m_bSourceEnabled = false;
            m_bModalUI       = true;
        }
        //qDebug() << "EnableSource:ModalUI=" << twUI.ModalUI;
        return m_bSourceEnabled;
    }
    return false;
}