C # calls Twain to get scanner picture data using Kodak components

Source: Internet
Author: User

One of these is the official Microsoft-launched WIA interface call scanner, which is currently up-to-date. In fact, this way is easy to write,

But it does not store information such as the resolution the user needs to scan, but this method is easy and quick to install the WIA control to

Windows, written directly in C # code, can be called directly, without having to edit the control's properties and so on, it is easy to use.

Another way is the traditional Twian, because many scanner manufacturers are adhering to the rules of TWAIN, so this method

Also get a lot of programming enthusiasts welcome, this interface can directly call scanner manufacturers have written a scan window, can be implemented in the drive

The dynamic layer gets the picture information, and the advantage of this method is that it can be scanned in batches, and after the Kodak scan control is added, batch scanning can also be achieved.

function, but also provides image editing and other functions.

System components required by the Kodak method:
Imgadmin.ocx Imgcmn.dll imgedit.ocx Imgscan.ocx Xiffr3_0.dll
Imgshl.dll imgthumb.ocx Imm32.dll Jpeg1x32.dll Tifflt.dll
Jpeg2x32.dll Oieng400.dll Oiprt400.dll Oislb400.dll Oiui400.dll
Oissq400.dll Oitwa400.dll Run Kodak.bat
There are only two real spaces to use. However, during the scanning process, in order to ensure that the image editing and other operations are not affected, it is recommended that all

Install, run Kodak.bat to register all the components.

In Kodak's scanning component, we need the Imgscan.ocx, Imgadmin.ocx, ImgEdit.ocx Three as the main control, where

Imgscan.ocx is the main scanning component of Kodak.

After all the scanning components have been installed, the next step is to add a call to the scan component in C # to manipulate and retrieve the data in the scanner

。 In project Engineering, adding WIA references and applications for Kodak components, Kodak is a tool class, so you need to add a Kodak group in the Toolbox

Tool.

Using Kodak Scan, you need to drag and drop the Kodak Scan control into the window program
To add the Kodak namespace:

using Scanlibctl;

The following is the code in the button time:

Sealpicture.image =NULL; stringpaths =@"E:\img"; Try{file.delete (paths); }            Catch { }            intLl_rtn = Aximgscan.openscanner ();//Open Scanner            if(Ll_rtn = =0)            {                if(aximgscan.scanneravailable () = =true)//determine if the scanner is available{aximgscan.multipage=true;//is multiple pagesAximgscan.pagecount = Aximgscan.pagecount +1; Aximgscan.image=paths; Aximgscan.filetype= ScanLibCtl.FileTypeConstants.TIFF;//Set File typeAximgscan.compressiontype =Compressiontypeconstants.jpeg; Aximgscan.scanto=scantoconstants.fileonly; Aximgscan.setpagetypecompressionopts (Comppreferenceconstants.gooddisplay,imagetypeconstants.colorpal4bit, Comptypeconstants.jpegcompression,compinfoconstants.jpeghighhigh);//. G31dfaxrbo);Aximgscan.stopscanbox =false; Aximgscan.showsetupbeforescan=true;//whether to display the Setup interface before scanningaximgscan.show (); Ll_rtn= Aximgscan.startscan ();//Start Scanning//read the picture file as a file stream and release it so that the file is deleted before the next sweep                    Try{FileStream Files=NewFileStream (paths, FileMode.Open); Image Picture=Image.fromstream (Files); Sealpicture.image=Picture ;                    Files.close (); }                    Catch { }                    if(Ll_rtn = =9254|| Ll_rtn = =0) { }                    Else{MessageBox.Show ("the scanner is not properly connected or the scan control is broken, please check!","system prompt ...", MessageBoxButtons.OK, messageboxicon.stop); } aximgscan.closescanner (); //turn off the scanner                }                Else{MessageBox.Show ("the scanner is not properly connected, please reset it!","system prompt ...", MessageBoxButtons.OK, messageboxicon.exclamation); }            }            Else if(Ll_rtn = =9219) {MessageBox.Show ("The system does not have a scanner installed or the scanner is not properly connected! ","system prompt ...", MessageBoxButtons.OK, messageboxicon.exclamation); }

The completion of this code can also be done by invoking the WIA and Kodak two scanning components of the scanning call, to get the scanner

The image data.

The following is in the project code:

C # calls Twain to get scanner picture data using Kodak components

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.