예제 #1
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;
}
예제 #2
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;
}
예제 #3
0
/** 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;
}
예제 #4
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;
}
예제 #5
0
int CTwain::BeginAcquire(HWND hwnd)
{
	nStartState = State();
	hwnd = DefWnd(hwnd);

	if (State() >= SOURCE_MANAGER_OPEN || OpenSourceManager(hwnd)) {
		if (State() >= SOURCE_OPEN || (OpenDefaultSource() && NegotiateCapabilities())) {
			if (State() >= SOURCE_ENABLED || EnableSource(hwnd)) {
				return TRUE;
			} else {
				ATLTRACE_ERROR(TWERR_ENABLE_SOURCE);
			}
		} else {
			ATLTRACE_ERROR(TWERR_OPEN_SOURCE);
		}
	} else {
		ATLTRACE_ERROR(TWERR_OPEN_DSM);
	}
	DropToState(nStartState);
	return FALSE;
} // BeginAcquire
예제 #6
0
/** 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;
}
예제 #7
0
/** Called to enable the Twain Acquire Dialog. This too can be 
 * overridden but is a helluva job. */
bool KSaneWidgetPrivate::OpenDialog()
{
    EnableSource(true);
	return true;
}