WIA silverlight 扫描仪集成
我是 silverlight 的新手,我正在尝试使用 wia 扫描仪集成。我知道使用 WIA.CommonDialog 、 showacquireimage() 我可以从扫描仪检索图像。我试图直接访问设备并执行扫描命令以避免用户交互。
我能够连接到该设备。但扫描仪唯一可用的命令是同步。我正在尝试在设备对象上使用 ExecuteCommand,但我不确定要使用什么命令。任何方向将不胜感激。
using (dynamic DeviceManager1 = AutomationFactory.CreateObject("WIA.DeviceManager"))
{
var deviceInfos = DeviceManager1.DeviceInfos;
for(int i= 1;i<=deviceInfos.Count;i++)
{
//check if the device is a scanner
if (deviceInfos.Item(i).Type.ToString() == "1")
{
var IDevice = deviceInfos.Item(i).Connect();
deviceN.Text = IDevice.Properties("Name").Value.ToString();
var dv = IDevice.Commands;
for (int j = 0; j <= dv.Count; j++)
{
deviceN.Text += " " + dv.Item(i).CommandID.ToString() + " " + dv.Item(i).Description.ToString();
}
}
}
}
I am new to silverlight , and I am experimenting with wia scanner integration. I know usng WIA.CommonDialog , showacquireimage() I can retrieve an image from the scanner. I am trying to access the device directly and execute the scan command to avoid user interaction.
I am able to connect to the device. But the only command available from the scanner is synchronize. I am trying to use the ExecuteCommand on the device object, but I am not sure what command to use. Any direction will be appreciated.
using (dynamic DeviceManager1 = AutomationFactory.CreateObject("WIA.DeviceManager"))
{
var deviceInfos = DeviceManager1.DeviceInfos;
for(int i= 1;i<=deviceInfos.Count;i++)
{
//check if the device is a scanner
if (deviceInfos.Item(i).Type.ToString() == "1")
{
var IDevice = deviceInfos.Item(i).Connect();
deviceN.Text = IDevice.Properties("Name").Value.ToString();
var dv = IDevice.Commands;
for (int j = 0; j <= dv.Count; j++)
{
deviceN.Text += " " + dv.Item(i).CommandID.ToString() + " " + dv.Item(i).Description.ToString();
}
}
}
}
您实际上不需要处理设备命令来扫描文档。相反,您需要使用设备对象下的第一个设备项。这是一个本身有效的小示例,没有故障检查,以便于阅读。
在扫描之前(但在连接到设备项目之后),如果默认设置不足以满足您的需求,您可能需要设置各种设备属性来选择扫描分辨率、颜色深度和其他内容。
不久前,我制作了一个易于使用的类来操作 WIA 兼容的扫描仪,您可以从 此页...适用于.Net Framework 2.0,C#。也许它在您的项目中会派上用场,您只需几行代码即可完成,包括设置基本属性。 :)
You don't really need to deal with the device commands to scan the document. Instead you need to use the first device item under the device object. Here is a little example which works in itself, without failure checks for easier readability.
Before scanning (but after you connected to the device item), you probably need to set various device properties to select the scanning resolution, color depth and other things if the defaults are not good enough for your needs.
Not long ago I made an easy to use class to operate WIA-compatible scanners, you can download it from this page... It's for .Net Framework 2.0, C#. Maybe it could come handy in your project, you would be done with a few lines of code including setting the basic properties. :)