• 大小: 70.14MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2022-07-05
  • 语言: C#
  • 标签: c#  Twain  扫描仪  

资源简介

本个demo是c#使用Twain 直接调用扫描仪,使用vs2008以上可以直接运行。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Drawing.Imaging;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using Twain;
using ICSharpCode.SharpZipLib.Zip;
using System.Net;

namespace TwainDemo
{

    public partial class FrmDemo : Form
    {
        List lstImgPath = new List();//当前文件夹所有的图片信息
        public FrmDemo()
        {
            InitializeComponent();
        }
        private int mImageIndex = 1;
        private string mRunPath = ““;
        private string mImagePath = ““;
        private Twain32 mTwain = new Twain32();
        private int index = -1;

        private void twEndXfer(object sender Twain32.EndXferEventArgs e)
        {
            string filename = string.Empty;
            //if (mImageIndex == 1)
            //{
            //    filename = “core“;
            //}
            //else
            //{
            //    filename = Guid.NewGuid().ToString();
            //}
            filename = Guid.NewGuid().ToString();
            string FileNm = mImagePath + filename + “.png“;
            e.Image.Save(FileNm ImageFormat.Png);
            //mImageIndex++;
        }
        private void FrmDemo_Load(object sender EventArgs e)
        {
            mRunPath = System.IO.Directory.GetCurrentDirectory() + “\\“;
            mImagePath = mRunPath + “Image\\“;

            if (Directory.Exists(mImagePath) == false)
            {
                Directory.CreateDirectory(mImagePath);
            }

            mTwain.Language = TwLanguage.CHINESE_SINGAPORE;
            mTwain.IsTwain2Enable = false;
            mTwain.OpenDSM();
            List srclst = new List();
            for (int i = 0; i < mTwain.SourcesCount; i++)
            {
                srclst.Add(mTwain.GetSourceProductName(i));
            }
            combo_Dev.DataSource = srclst;
            mTwain.EndXfer += twEndXfer;
        }

        private void btnScan_Click(object sender EventArgs e)
        {
            if (MessageBox.Show(“您要删除之前的扫描文件吗?“ “提示信息“ MessageBoxButtons.YesNo MessageBoxIcon.Information) == DialogResult.Yes)
            {
                #region 初始化删除所有文件
                foreach (Panel c in pnlImage.Controls)
                {
                    foreach (PictureBox pic in c.Controls)
                    {
                        pic.Image.Dispose();
                        pic.Image = null;
                    }
                }
                DirectoryInfo dir = new DirectoryInfo(mImagePath);
                FileInfo[] inf = dir.GetFiles();
                foreach (FileInfo finf in inf)
                {
                    finf.Delete();
                }
                #endregion
            }
            float val = 150;// Convert.ToSingle(combo_DPI.Sel

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     93696  2018-11-08 17:08  CSharpTwainDemo\.vs\TwainDemo\v14\.suo

    ..A..H.    109056  2018-09-12 12:17  CSharpTwainDemo\.vs\TwainDemo\v15\.suo

     文件          0  2018-09-12 11:44  CSharpTwainDemo\.vs\TwainDemo\v15\Server\sqlite3\db.lock

     文件       4096  2018-09-12 11:44  CSharpTwainDemo\.vs\TwainDemo\v15\Server\sqlite3\storage.ide

     文件      32768  2018-09-12 11:44  CSharpTwainDemo\.vs\TwainDemo\v15\Server\sqlite3\storage.ide-shm

     文件    1042392  2018-09-12 11:44  CSharpTwainDemo\.vs\TwainDemo\v15\Server\sqlite3\storage.ide-wal

     文件         16  2018-09-12 13:54  CSharpTwainDemo\Readme.txt

     文件        187  2016-06-28 14:04  CSharpTwainDemo\TwainDemo\App.config

     文件     155648  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\bin\Debug\app.publish\TwainDemo.exe

     文件    2465771  2016-10-14 18:01  CSharpTwainDemo\TwainDemo\bin\Debug\BakZip\201610152158301585.zip

     文件      21440  2016-10-15 21:58  CSharpTwainDemo\TwainDemo\bin\Debug\BakZip\201809121146322110.zip

     文件      47491  2018-09-12 11:46  CSharpTwainDemo\TwainDemo\bin\Debug\BakZip\201810220921433900.zip

     文件      49917  2018-10-22 09:21  CSharpTwainDemo\TwainDemo\bin\Debug\BakZip\201811050912085420.zip

     文件     200704  2010-05-25 12:55  CSharpTwainDemo\TwainDemo\bin\Debug\ICSharpCode.SharpZipLib.dll

     文件   70087104  2016-10-14 18:35  CSharpTwainDemo\TwainDemo\bin\Debug\NDP451-KB2858728-x86-x64.3505182529.exe

     文件       1829  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.application

     文件     155648  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.exe

     文件        187  2016-06-28 14:04  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.exe.config

     文件       5374  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.exe.manifest

     文件     278016  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.pdb

     文件       1829  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.vshost.application

     文件      22696  2018-11-12 18:54  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.vshost.exe

     文件        187  2016-06-28 14:04  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.vshost.exe.config

     文件       5374  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\bin\Debug\TwainDemo.vshost.exe.manifest

     文件      99204  2018-11-05 09:12  CSharpTwainDemo\TwainDemo\bin\Debug\Zip\Image.zip

     文件         60  2016-10-12 15:28  CSharpTwainDemo\TwainDemo\ClassDiagram1.cd

     文件      22840  2018-11-12 18:53  CSharpTwainDemo\TwainDemo\FrmDemo.cs

     文件      13047  2016-10-15 21:58  CSharpTwainDemo\TwainDemo\FrmDemo.Designer.cs

     文件       6022  2016-10-15 21:58  CSharpTwainDemo\TwainDemo\FrmDemo.resx

     文件       1452  2018-11-05 08:28  CSharpTwainDemo\TwainDemo\obj\Debug\DesignTimeResolveAssemblyReferences.cache

............此处省略58个文件信息

评论

共有 条评论