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; }
/** 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(); }
/* 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; }
/** * \brief Assign a set of MythImages to the widget for animation. * Use is strongly discouraged, use SetFilepattern() instead. * */ void MythUIImage::SetImages(QVector<MythImage *> &images) { Clear(); QWriteLocker updateLocker(&d->m_UpdateLock); QSize aSize = GetArea().size(); QVector<MythImage *>::iterator it; for (it = images.begin(); it != images.end(); ++it) { MythImage *im = (*it); if (!im) { QMutexLocker locker(&m_ImagesLock); m_Images[m_Images.size()] = im; continue; } im->UpRef(); if (!m_ForceSize.isNull()) { int w = (m_ForceSize.width() <= 0) ? im->width() : m_ForceSize.width(); int h = (m_ForceSize.height() <= 0) ? im->height() : m_ForceSize.height(); im->Resize(QSize(w, h), m_preserveAspect); } if (m_isReflected && !im->IsReflected()) im->Reflect(m_reflectAxis, m_reflectShear, m_reflectScale, m_reflectLength, m_reflectSpacing); if (m_isGreyscale && !im->isGrayscale()) im->ToGreyscale(); m_ImagesLock.lock(); m_Images[m_Images.size()] = im; m_ImagesLock.unlock(); aSize = aSize.expandedTo(im->size()); } SetImageCount(1, m_Images.size()); if (m_ForceSize.isNull()) SetSize(aSize); m_CurPos = 0; SetRedraw(); }
/** 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; }
/* 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; }
/** 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; }
/** * \brief Assign a set of MythImages to the widget for animation. * Use is strongly discouraged, use SetFilepattern() instead. * */ void MythUIImage::SetImages(QVector<MythImage *> *images) { Clear(); QWriteLocker updateLocker(&d->m_UpdateLock); QSize aSize = GetFullArea().size(); m_imageProperties.isThemeImage = false; QVector<MythImage *>::iterator it; for (it = images->begin(); it != images->end(); ++it) { MythImage *im = (*it); if (!im) { QMutexLocker locker(&m_ImagesLock); m_Images[m_Images.size()] = im; continue; } im->IncrRef(); QSize forceSize = m_imageProperties.forceSize; if (!forceSize.isNull()) { int w = (forceSize.width() <= 0) ? im->width() : forceSize.width(); int h = (forceSize.height() <= 0) ? im->height() : forceSize.height(); im->Resize(QSize(w, h), m_imageProperties.preserveAspect); } if (m_imageProperties.isReflected && !im->IsReflected()) im->Reflect(m_imageProperties.reflectAxis, m_imageProperties.reflectShear, m_imageProperties.reflectScale, m_imageProperties.reflectLength, m_imageProperties.reflectSpacing); if (m_imageProperties.isGreyscale && !im->isGrayscale()) im->ToGreyscale(); if (m_imageProperties.isOriented && !im->IsOriented() && (m_imageProperties.orientation >= 1 && m_imageProperties.orientation <= 8)) im->Orientation(m_imageProperties.orientation); m_ImagesLock.lock(); m_Images[m_Images.size()] = im; m_ImagesLock.unlock(); aSize = aSize.expandedTo(im->size()); } SetImageCount(1, m_Images.size()); if (m_imageProperties.forceSize.isNull()) SetSize(aSize); MythRect rect(GetFullArea()); rect.setSize(aSize); SetMinArea(rect); m_CurPos = 0; m_animatedImage = true; m_Initiator = m_EnableInitiator; SetRedraw(); }