1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > wia Kodak 扫描仪应用 winform

wia Kodak 扫描仪应用 winform

时间:2023-03-27 19:02:56

相关推荐

wia  Kodak 扫描仪应用 winform

wia

代码 privateImageFileimageFile=null;

privatestringScanTemp=ConfigurationSettings.AppSettings["ScanTemp"].ToString().Trim();

privatestringimgType="jpg";

privateDeviceManagermanager=null;

privateDevicedevice=null;

privateList<System.Drawing.Image>imgs=newList<System.Drawing.Image>();

privateList<System.Drawing.Image>StartScan()

{

manager=newDeviceManagerClass();

foreach(DeviceInfoinfoinmanager.DeviceInfos)

{

if(info.Type!=WiaDeviceType.ScannerDeviceType)continue;

device=info.Connect();

break;

}

if(device==null)

{

thrownewException("扫描仪没连接!");

}

Itemitem=device.Items[1];

CommonDialogClasscdc=monDialogClass();

//stringformatID=this.GetWiaFormat();

try

{

imageFile=cdc.ShowAcquireImage(WiaDeviceType.ScannerDeviceType,WiaImageIntent.UnspecifiedIntent,

WiaImageBias.MinimizeSize,"{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}",true,false,false);

}

catch(System.Exceptionex)

{

imageFile=null;

//thrownewException(ex.Message);

}

while(imageFile!=null)

{

varbuffer=imageFile.FileData.get_BinaryData()asbyte[];

using(MemoryStreamms=newMemoryStream())

{

ms.Write(buffer,0,buffer.Length);

imgs.Add(System.Drawing.Image.FromStream(ms));

}

imageFile=null;

try

{

imageFile=cdc.ShowTransfer(item,"{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}",false)asImageFile;

}

catch(Exceptionex)

{

returnimgs;

//thrownewException(ex.Message);

}

}

returnimgs;

}

Kodak

代码 try

{

intk=axImgScan1.ShowSelectScanner();//选择扫描仪

intll_rtn=axImgScan1.OpenScanner();//打开扫描仪

if(ll_rtn==0)

{

if(axImgScan1.ScannerAvailable()==true)//判断扫描仪是否可用

{

//axImgScan1.PageOption=PageOptionConstants.AppendPages;

//axImgScan1.PageType=PageTypeConstants.BlackAndWhite;

//axImgScan1.PageCount=0;

axImgScan1.MultiPage=true;//是否多页

//axImgScan1.PageCount=axImgScan1.PageCount+1;

stringpathGen=ScanTemp+ScanPageName();//@"c:\abc.tif";

axImgScan1.Image=pathGen;

axImgScan1.FileType=FileTypeConstants.TIFF;//设置文件类型

//axImgScan1.GetPageTypeCompressionInfo(ImageTypeConstants.BlackAndWhite1Bit);

//axImgScan1.GetPageTypeCompressionType(ImageTypeConstants.BlackAndWhite1Bit);

//pressionType=CompressionTypeConstants.JPEG;

axImgScan1.ScanTo=ScanToConstants.FileOnly;//.DisplayAndUseFileTemplate;

//axImgScan1.ShowSetupBeforeScan=false;//是否在扫描前显示设置界面

axImgScan1.SetPageTypeCompressionOpts(CompPreferenceConstants.CustomSettings,ImageTypeConstants.TrueColor24bitRGB,CompTypeConstants.Uncompressed,CompInfoConstants.NoCompInfo);

axImgScan1.StopScanBox=false;

axImgScan1.Show();

//axImgScan1.GetCompressionPreference()=CompPreferenceConstants.SmallestFile;

ll_rtn=axImgScan1.StartScan();//开始扫描

if(ll_rtn==0)

{

Byte[]filebyte=GetScanFileByte(axImgScan1.Image);

axImgScan1.CloseScanner();//关闭扫描仪

//axImgEdit1.Image=axImgScan1.Image;

//axImgEdit1.SaveAs(axImgScan1.Image,FileTypeConstants.TIFF,PageTypeConstants.BlackAndWhite,CompressionTypeConstants.NoCompression,CompInfoConstants.NoCompInfo,true);

}

else

{

MessageBox.Show("扫描仪没有正确连接或扫描控件已破坏,请检查!","系统提示");

}

axImgScan1.CloseScanner();//关闭扫描仪

}

else

{

MessageBox.Show("扫描仪没有正确连接,请重新设置!","系统提示");

}

}

elseif(ll_rtn==9219)

{

MessageBox.Show("系统没有安装扫描仪或扫描仪没有正确连接!","系统提示");

}

}

catch(Exceptionex)

{

MessageBox.Show(ex.Message);

}

IMGADMIN.OCX

代码 //选择图片显示axImgAdmin1用法

axImgAdmin1.Image="";

axImgAdmin1.DialogTitle="选择一张图片";

axImgAdmin1.Filter="AllImageFiles|*.bmp;*.jpg;*.tif|BitmapFiles(*.bmp)|*.bmp|JPGFiles(*.jpg)|*.jpg|TIFFFiles(*.tif)|*.tif|AllFiles(*.*)|*.*|";

axImgAdmin1.FilterIndex=4;//选择默认文件类型,对应Filter

axImgAdmin1.InitDir="c:\\";//选择的默认路径

axImgAdmin1.CancelError=false;

axImgAdmin1.ShowFileDialog(AdminLibCtl.DlgOptionValue.OpenDlg);

if(axImgAdmin1.Image=="")

{

}

else

{

axImgEdit1.Image=axImgAdmin1.Image;

axImgThumbnail1.Image=axImgAdmin1.Image;

axImgEdit1.Display();

//MessageBox.Show(axImgEdit1.PageCount.ToString());

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。