扫描代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
bool blnNamingOnly = false;
string strFullPathFileName = "";
bool bl = axImgScan1.ScannerAvailable();
gstrWindowsTempDirectory = "D:\\";
if (axImgScan1.ScannerAvailable() == true)//判断扫描仪是否可用
{
sPath = createFolder(); //创建文件夹
//检查文件夹是否存在文件,如文件存在,检测最后一个文件名,提取文件数字
DirectoryInfo dir = new DirectoryInfo(sPath);
FileInfo[] finfo = dir.GetFiles();
string fnames = "";
for (int i = 0; i < finfo.Length; i++)
{
fnames = finfo[i].Name.Substring(20, 3);//截取文件名中的最后3为字符
if (int.Parse(fnames) > intNum)
intNum = int.Parse(fnames);
}
intNum = intNum + 1;
tooloptimizeBtn.Text = intNum.ToString();
axImgScan1.PageOption =
ScanLibCtl.PageOptionConstants.AppendPages;//axImgScan1.PageOption =
ScanLibCtl.PageOptionConstants.PromptToCreateNewFile;
axImgScan1.OpenScanner();//打开扫描仪
axImgScan1.ScanTo = ScanLibCtl.ScanToConstants.DisplayAndFile;//以何种形式扫描,如仅文件、仅显示、或显示加文件
axImgScan1.MultiPage = true;//扫描多页
axImgScan1.FileType = ScanLibCtl.FileTypeConstants.TIFF;//被扫描后的文件存储格式类型
axImgScan1.Page = axImgScan1.PageCount + 1;//新添加
axImgScan1.Scroll = true;
axImgScan1.SetPageTypeCompressionOpts(pPreferenceConstants.GoodDisplay, ScanLibCtl.ImageTypeConstants.ColorPal4Bit, pTypeConstants.TIFFPackbits, pInfoConstants.TIFFPackbitsInfo);//.G31DFaxRBO)
axImgScan1.Image = @sPath + "\\"+ label171.Text + "-"+ intNum.ToString("000") + ".tif";//保存文件 + "*"
axImgScan1.StartScan();
//axImgScan1.DestImageControl = "axImgEdit1";
//axImgThumbnail1.Image = axImgScan1.Image;
//axImgThumbnail1.DisplayThumbs();
//sum = axImgThumbnail1.ThumbCount;
axImgScan1.StopScan();
axImgScan1.CloseScanner();
}
else
{
MessageBox.Show("扫描仪没有正确连接,请重新设置!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
strFullPathFileName = axImgScan1.Image;
PerformFileOpen(blnNamingOnly, strFullPathFileName, 1);
return;
//在扫描结束后,弹出提示对话框
sum = axImgThumbnail1.ThumbCount;
frmMain.isSavePic = 1;
frmMain.strFileDesc = label230.Text;
frmFileDescribe frmFileDescribe = new frmFileDescribe();
frmFileDescribe.ShowDialog();
//saveAllPicture();//存储全部扫描的图片
函数: PerformFileOpen
public void PerformFileOpen(bool blnNamingOnly, string strFullPathFileName,int lngPageNo)
{
axImgAdmin1.Image = strFullPathFileName;
axImgEdit1.Image = strFullPathFileName;
axImgThumbnail1.Image = strFullPathFileName;
gintFileType = axImgAdmin1.FileType.ToString();
axImgAdmin1.PageNumber = lngPageNo;
axImgEdit1.Page = lngPageNo;
axImgThumbnail1.set_ThumbSelected(lngPageNo,true);
}