Beispiel #1
0
/** Sets the number of images which can be accpeted by the application at one time
 */
bool TwainIface::SetImageCount(TW_INT16 nCount)
{
    if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,true))
    {
        m_nImageCount = nCount;
        return true;
    }
    else
    {
        if(GetRC() == TWRC_CHECKSTATUS)
        {
            TW_UINT32 count;

            if(GetCapability(CAP_XFERCOUNT, count))
            {
                nCount = (TW_INT16)count;

                if(SetCapability(CAP_XFERCOUNT, nCount))
                {
                    m_nImageCount = nCount;
                    return true;
                }
            }
        }
    }
    return false;
}
Beispiel #2
0
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;
}
/*
Sets the number of images which can be accpeted by the application at one time
*/
BOOL CTwain::SetImageCount(TW_INT16 nCount)
{
	if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,TRUE))
	{
		m_nImageCount = nCount;
		return TRUE;
	}
	else
	{
		if(GetRC() == TWRC_CHECKSTATUS)
		{
		TW_UINT32 count;
			if(GetCapability(CAP_XFERCOUNT,count))
			{
				nCount = (TW_INT16)count;
				if(SetCapability(CAP_XFERCOUNT,nCount))
				{
					m_nImageCount = nCount;
					return TRUE;
				}
			}
		}
	}
	return FALSE;
}
/*
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;
}
Beispiel #5
0
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;
}
    void ProtocolModuleTaiga::ExtractCapabilitiesFromXml(std::string xml)
    {
        const std::string key = "<key>";
        const std::string key_end = "</key>";
        const std::string str = "<string>";
        const std::string str_end = "</string>";
        size_t key_pos = 0, key_end_pos = 0, str_pos = 0, str_end_pos = 0;
        bool proceed = true;

        while(proceed)
        {
            std::string name, url;

            key_pos = xml.find(key, str_end_pos);
            key_end_pos = xml.find(key_end, key_pos);
            name = xml.substr(key_pos + key.length(), key_end_pos - key_pos - key.length());

            str_pos = xml.find(str, key_end_pos);
            str_end_pos = xml.find(str_end, str_pos);
            url = xml.substr(str_pos + str.length(), str_end_pos - str_pos - str.length());

            SetCapability(name, url);

            if ((xml.find(key, str_end_pos) > xml.length()) ||
                (xml.find(key, str_end_pos) == std::string::npos))
                proceed = false;
        }
    }
Beispiel #7
0
/** Sets the number of images which can be accpeted by the application at one time */
bool KSaneWidgetPrivate::SetImageCount(TW_INT16 nCount)
{
    if(SetCapability(CAP_XFERCOUNT,(TW_UINT16)nCount,true)) {
        m_nImageCount = nCount;
        return true;
    }
    else {
        if(m_returnCode == TWRC_CHECKSTATUS) {
            TW_UINT32 count;

            if(GetCapability(CAP_XFERCOUNT, count)) {
                nCount = (TW_INT16)count;

                if(SetCapability(CAP_XFERCOUNT, nCount)) {
                    m_nImageCount = nCount;
                    return true;
                }
            }
        }
    }
    return false;
}
Beispiel #8
0
static bool MakeWellKnownSIDAttributes(std::vector<SID_AND_ATTRIBUTES> &capabilities,std::vector<SHARED_SID> &capabilitiesSidList)
{

    const WELL_KNOWN_SID_TYPE capabilitiyTypeList[] = {
        WinCapabilityInternetClientSid, WinCapabilityInternetClientServerSid, WinCapabilityPrivateNetworkClientServerSid,
        WinCapabilityPicturesLibrarySid, WinCapabilityVideosLibrarySid, WinCapabilityMusicLibrarySid,
        WinCapabilityDocumentsLibrarySid, WinCapabilitySharedUserCertificatesSid, WinCapabilityEnterpriseAuthenticationSid,
        WinCapabilityRemovableStorageSid,
    };
    for(auto type:capabilitiyTypeList) {
        if (!SetCapability(type, capabilities, capabilitiesSidList)) {
            return false;
        }
    }
    return true;
}
Beispiel #9
0
/** 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;
}
Beispiel #10
0
/*
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;
}