2015-02-11 171 views
1

在我的應用程序中,我正在使用TwainDotNet庫,並且正在從平板掃描特定區域。TwainDotNet特定區域掃描

public Prasymas scanForm(Prasymas prasymas, bool isItFirstScan) 
    { 

     Enabled = false; 

     _settings = new ScanSettings(); 
     _settings.UseDocumentFeeder = false; 
     _settings.ShowTwainUI = false; 
     _settings.ShowProgressIndicatorUI = true; 
     _settings.UseDuplex = false; 
     _settings.Resolution = 
      false 
      ? ResolutionSettings.Fax : ResolutionSettings.ColourPhotocopier; 
     _settings.Page = PageSettings.Default; 

     if (!isItFirstScan) 
     { 
      _prasymas = prasymas; 
      AreaSettings = new AreaSettings(Units.Centimeters, 0.0f, 0.0f, (float)(_prasymas.maxScanAukstis), 0.0f);     
     } 
     else 
     { 
      _settings.Area = !false ? null : AreaSettings; 
     } 
     _settings.ShouldTransferAllPages = true; 


     _settings.Rotation = new RotationSettings() 
     { 
      AutomaticRotate = false, 
      AutomaticBorderDetection = false 
     }; 

     try 
     { 
      _twain.SelectSource(); 
      _twain.StartScanning(_settings); 
     } 
     catch (TwainException ex) 
     { 
      if (ex.Message == "Error opening data source") 
      { 
       _twain.SelectSource(); 
       scanForm(_prasymas, isItFirstScan); 
       Enabled = true; 
      } 
      else 
       throw ex; 

     } 
     catch (Exception exc) 
     { 
      if (exc.Message == "Pasiuto skeneris") 
      { 
       scanForm(_prasymas, true);      
      } 
      else 
       throw exc; 

     } 

     Enabled = true; 
     return prasymas; 
    } 

但開始掃描和掃描源時的結果是Twain驅動程序,它會掃描整個頁面,但如果讓我選擇WIA驅動程序我得到特別選定的區域。 主要想法是應用程序第一次啓動時會掃描整個頁面,下次只掃描頁面的特定高度。

回答

0

閱讀文檔後,我發現只需要註釋旋轉部分,一切都開始工作。我可以掃描選定的區域。

相關問題