Difference between revisions of "Scanner csharp"

From Ilianko
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Програмен достъп до скенер==
 
==Програмен достъп до скенер==
 +
 +
 +
 
===TWAIN===
 
===TWAIN===
 
TWAIN е програмен интерфейс (API) и комуникционен протокол за управление на комуникацията между софтуeрни приложения и устройства за въвеждане на графична информация ( изображения от скенери, цифрови фотопарати и др.)   
 
TWAIN е програмен интерфейс (API) и комуникционен протокол за управление на комуникацията между софтуeрни приложения и устройства за въвеждане на графична информация ( изображения от скенери, цифрови фотопарати и др.)   
Line 13: Line 16:
 
=== Windows Image Acquisition (WIA)===
 
=== Windows Image Acquisition (WIA)===
  
 +
WIA се разрботва от Microsoft с цел създаване на драйвери и програмен интерфейс за устройства за въвеждане на графична информацияdriver model and application programming interface (API). Разработва се за Windows ME, наличен е като допълнителна библиотека за Windows XP, a в следващите версии е стандартно вграден.
  
 +
===Scanner Access Now Easy (SANE)===
 +
SANE е програмен интерфейс, който осигурява стандартизиран достъп до всякакви растерни устраойства - плоски и ръчни скенери, камери и др. SANE API се разработва свободни с отворен лиценз и най-често се използва в Linux.
  
Windows Image Acquisition (WIA; sometimes also called Windows Imaging Architecture) is a proprietary Microsoft driver model and application programming interface (API) for Microsoft Windows Me and later Windows operating systems that enables graphics software to communicate with imaging hardware such as scanners, digital cameras and Digital Video-equipment. It was first introduced in 2000 as part of Windows Me, and continues to be the standard imaging device and API model through successive Windows versions. It is implemented as an on-demand service in Windows XP and later Windows operating systems.[1]
+
http://en.wikipedia.org/wiki/Scanner_Access_Now_Easy
 
 
Contents
 
 
 
    1 Overview
 
    2 Additional information
 
    3 Applications that use WIA
 
    4 See also
 
    5 References
 
    6 External links
 
 
 
Overview
 
 
 
WIA is a very significant superset of the support for digital still imaging drivers that was provided by the Still Image Architecture (STI) in Windows 98. Whereas STI only provided a low-level interface for doing basic transfers of data to and from the device (as well as the invocation of an image scan process on the Windows machine through the external device), WIA provides a framework through which a device can present its unique capabilities to the operating system, and applications can invoke those features. According to Microsoft, WIA drivers are made up of a user interface (UI) component and a driver core component, loaded into two different process spaces: UI in the application space and the driver core in the WIA service space.
 
 
 
Many scanners support WIA.[2][3][citation needed]
 
Additional information
 
 
 
In 2002, Microsoft released the Windows Image Acquisition Automation Library Tool, which provides access to WIA functionality through programming languages and scripting environments that support OLE Automation.
 
 
 
In Windows XP, WIA runs in the LocalSystem context. Because of the security ramifications of running a service as LocalSystem whereby a buggy driver or malicious person would have unrestricted access to the system, the WIA service in Windows Server 2003 and Windows Vista operates in the LocalService context. This can result in compatibility issues when using a driver designed for Windows XP.[4]
 
 
 
In Windows XP, support was added for automatic document feeder scanners, scroll-feed scanners without preview capabilities and multi-page TIFF generation.[5] For WIA video, a snapshot filter driver is introduced that allows still frames to be captured from the video stream.
 
 
 
Windows Vista has the WIA Automation library built-in. Also, WIA supports push scanning and multi-image scanning. Push scanning allows initiating scans and adjusting scanning parameters directly from the scanner control panel. Multi-image scanning allows one to scan several images at once and save them directly as separate files. However, video content support is removed from WIA for Windows Vista.[6] Microsoft recommends using the newer Windows Portable Devices API.[citation needed]
 
  
===Scanner Access Now Easy (SANE)===
+
http://www.sane-project.org/
  
 +
== Saraff.Twain.Net ==
  
 +
Сваляне на библиотеките -> https://sarafftwain.codeplex.com/
  
xxx
+
Добавяне на twain контролер към toolbox-a:
 +
Десен бутон върху ToolBox менюто -> choose Items -> Browse -> Saraff.Twain.dll
  
// _twain
+
Добавяне на контролера към приложенито
//
 
this.components = new System.ComponentModel.Container();
 
this.twain = new Saraff.Twain.Twain32(this.components);
 
this.twain.AppProductName = "Saraff.Twain, Version=1.0.0.0";
 
this.twain.Parent = this;
 
this.twain.AcquireCompleted += new System.EventHandler(this.getScan);
 
  
private Saraff.Twain.Twain32 twain;
 
  
 +
Добавяне на бутон за избор на сканиращо устройство:
 
  private void scanner_Click(object sender, EventArgs e)
 
  private void scanner_Click(object sender, EventArgs e)
 
  {
 
  {
     this.twain.CloseDataSource();
+
     this.twain321.CloseDataSource();
     this.twain.SelectSource();
+
     this.twain321.SelectSource();
 
  }
 
  }
  
 +
Добавяне на бутон за сканиране:
 
  private void scanButton_Click(object sender, EventArgs e)
 
  private void scanButton_Click(object sender, EventArgs e)
 
  {
 
  {
   this.twain.Acquire();
+
   this.twain321.Acquire();
 
  }
 
  }
  
  private void getScan(object sender, EventArgs e)
+
Да се добави Panel
 +
properties->autoscroll->true
 +
 
 +
Да се добави  PictureBox в панела
 +
properties->size->autosize
 +
 
 +
Добавяне на събитие при завършване на сканирането
 +
  private void twain321_AcquireCompleted(object sender, EventArgs e)
 
  {
 
  {
   if ( twain.ImageCount > 0)
+
   if (twain321.ImageCount > 0)
 
   {
 
   {
    pictureBox1.Image = twain.GetImage(0);
+
      pictureBox1.Image = twain321.GetImage(0);
 
   }
 
   }
 
  }
 
  }

Latest revision as of 13:09, 9 February 2016

Програмен достъп до скенер

TWAIN

TWAIN е програмен интерфейс (API) и комуникционен протокол за управление на комуникацията между софтуeрни приложения и устройства за въвеждане на графична информация ( изображения от скенери, цифрови фотопарати и др.)

TWAIN се разработва от TWAIN Working Group с цел:

  • Осигуряване на съвместимост между графичен софтуер и хардуер
  • Многоплатформена поддръжка (примерно Windows, Mac OS, and Linux)
  • Безплатна поддръжка и разпространение на инструменти за разработчици
  • Насърчаване на употребата на TWAIN
  • и др.


Windows Image Acquisition (WIA)

WIA се разрботва от Microsoft с цел създаване на драйвери и програмен интерфейс за устройства за въвеждане на графична информацияdriver model and application programming interface (API). Разработва се за Windows ME, наличен е като допълнителна библиотека за Windows XP, a в следващите версии е стандартно вграден.

Scanner Access Now Easy (SANE)

SANE е програмен интерфейс, който осигурява стандартизиран достъп до всякакви растерни устраойства - плоски и ръчни скенери, камери и др. SANE API се разработва свободни с отворен лиценз и най-често се използва в Linux.

http://en.wikipedia.org/wiki/Scanner_Access_Now_Easy

http://www.sane-project.org/

Saraff.Twain.Net

Сваляне на библиотеките -> https://sarafftwain.codeplex.com/

Добавяне на twain контролер към toolbox-a:

Десен бутон върху ToolBox менюто -> choose Items -> Browse -> Saraff.Twain.dll

Добавяне на контролера към приложенито


Добавяне на бутон за избор на сканиращо устройство:

private void scanner_Click(object sender, EventArgs e)
{
   this.twain321.CloseDataSource();
   this.twain321.SelectSource();
}

Добавяне на бутон за сканиране:

private void scanButton_Click(object sender, EventArgs e)
{
  this.twain321.Acquire();
}

Да се добави Panel

properties->autoscroll->true

Да се добави PictureBox в панела

properties->size->autosize

Добавяне на събитие при завършване на сканирането

private void twain321_AcquireCompleted(object sender, EventArgs e)
{
  if (twain321.ImageCount > 0)
  {
     pictureBox1.Image = twain321.GetImage(0);
  }
}