最近有个项目,需调用扫描仪。
我们这里使用微软wia组件,调用扫描仪,去扫描图像。
先引用这个组件,这个组件是个com组件。
调用扫描仪的代码,很简单,返回一个ImageFile接口。这个ImageFile就是扫描后的图像文件。
public ImageFile Scan()
{
ImageFile image;
try
{
CommonDialog dialog = new CommonDialog();
image = dialog.ShowAcquireImage(
WiaDeviceType.ScannerDeviceType,
WiaImageIntent.ColorIntent,
WiaImageBias.MaximizeQuality,
WIA.FormatID.wiaFormatJPEG,
false,
true,
false);
return image;
}
catch (COMException ex)
{
if (ex.ErrorCode == -2145320939)
{
throw new ScannerNotFoundException();
}
else

本文介绍了如何在C#项目中利用微软的WIA组件与扫描仪交互,进行图像扫描操作。通过引用COM组件,可以简洁地获取到扫描后的ImageFile对象,代表扫描图像文件。

3181

被折叠的 条评论
为什么被折叠?



