
























wia
代码
private ImageFile imageFile = null;
private string ScanTemp = ConfigurationSettings.AppSettings["ScanTemp"].ToString().Trim();
private string imgType = "jpg";
private DeviceManager manager = null;
private Device device = null;
private List<System.Drawing.Image> imgs = new List<System.Drawing.Image>();private List<System.Drawing.Image> StartScan()
{
manager = new DeviceManagerClass();
foreach( DeviceInfo info in manager.DeviceInfos )
{
if( info.Type != WiaDeviceType.ScannerDeviceType ) continue;
device = info.Connect();
break;
}if( device == null )
{
throw new Exception("扫描仪没连接!");
}
Item item
= device.Items[1];Kodak
代码
try
{
int k = axImgScan1.ShowSelectScanner();//选择扫描仪
int ll_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;
string pathGen = ScanTemp + ScanPageName();// @"c:\abc.tif";
axImgScan1.Image = pathGen;
axImgScan1.FileType = FileTypeConstants.TIFF;//设置文件类型
//axImgScan1.GetPageTypeCompressionInfo( ImageTypeConstants.BlackAndWhite1Bit );
//axImgScan1.GetPageTypeCompressionType( ImageTypeConstants.BlackAndWhite1Bit ); // axImgScan1.CompressionType = 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( "扫描仪没有正确连接,请重新设置!", "系统提示" );
}
}
else if( ll_rtn == 9219 )
{
MessageBox.Show( "系统没有安装扫描仪或扫描仪没有正确连接!", "系统提示" );
}
}
catch( Exception ex )
{
MessageBox.Show( ex.Message );
}
IMGADMIN.OCX
代码
//选择图片显示 axImgAdmin1用法
axImgAdmin1.Image = "";
axImgAdmin1.DialogTitle = "选择一张图片";
axImgAdmin1.Filter = "All Image Files |*.bmp; *.jpg; *.tif|Bitmap Files(*.bmp)|*. bmp|JPG Files (*.jpg)|*.jpg|TIFF Files (*.tif)|*.tif|All Files (*.*)|*.*|";
axImgAdmin1.FilterIndex
= 4; //选择默认文件类型,对应Filter}
else此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。