C# 通过馈线的WIA扫描
通过馈线的WIA扫描 以下是我的设备属性:C# 通过馈线的WIA扫描,c#,wia,scanning,C#,Wia,Scanning,通过馈线的WIA扫描 以下是我的设备属性: Document Handling Select = 1 (2 is for flatbed, and 1 is for the feeder.) Horizontal Resolution = 150 Vertical Resolution = 150 Horizontal Extent = 500 (I want to get it first to work, then I'll play with the extents.), Vertica
Document Handling Select = 1 (2 is for flatbed, and 1 is for the feeder.)
Horizontal Resolution = 150
Vertical Resolution = 150
Horizontal Extent = 500 (I want to get it first to work, then I'll play with the extents.),
Vertical Extent = 500
Bits Per Pixel = 8
Current Intent = 4
以下是我的项目(页面)属性:
Document Handling Select = 1 (2 is for flatbed, and 1 is for the feeder.)
Horizontal Resolution = 150
Vertical Resolution = 150
Horizontal Extent = 500 (I want to get it first to work, then I'll play with the extents.),
Vertical Extent = 500
Bits Per Pixel = 8
Current Intent = 4
如果我将“文档处理选择”设置为“2”,我会使一切顺利进行。当我将其设置为“1”并运行它时,就在我说item.Transfer()(或item.Transfer(bmp/jpeg/pngGuid))之前,我得到一个异常“值不在预期范围内”
这太烦人了,有什么价值?我在网上搜索过,只能找到一点信息,但没有多大帮助。我认为必须将设备属性“Pages”(ID 3096)从0设置为1,以防止出现异常。我花了一些时间才弄明白。最后,我通过比较调用CommonDialogClass.ShowSelectItems前后的设备属性找到了这个属性 下面是一些代码:
public enum DeviceDocumentHandling : int
{
Feeder = 1,
FlatBed = 2
}
const int DEVICE_PROPERTY_DOCUMENT_HANDLING_CAPABILITIES_ID = 3086;
const int DEVICE_PROPERTY_DOCUMENT_HANDLING_STATUS_ID = 3087;
const int DEVICE_PROPERTY_DOCUMENT_HANDLING_SELECT_ID = 3088;
const int DEVICE_PROPERTY_PAGES_ID = 3096;
public static Property FindProperty(WIA.Properties properties,
int propertyId)
{
foreach (Property property in properties)
if (property.PropertyID == propertyId)
return property;
return null;
}
public static void SetDeviceProperty(Device device, int propertyId,
object value)
{
Property property = FindProperty(device.Properties, propertyId);
if (property != null)
property.set_Value(value);
}
public static object GetDeviceProperty(Device device, int propertyId)
{
Property property = FindProperty(device.Properties, propertyId);
return property != null ? property.get_Value() : null;
}
public static void SelectDeviceDocumentHandling(Device device,
DeviceDocumentHandling handling)
{
int requested = (int)handling;
int supported = (int)GetDeviceProperty(device,
DEVICE_PROPERTY_DOCUMENT_HANDLING_CAPABILITIES_ID);
if ((requested & supported) != 0)
{
if ((requested & (int)DeviceDocumentHandling.Feeder) != 0)
SetDeviceProperty(device, DEVICE_PROPERTY_PAGES_ID, 1);
SetDeviceProperty(device,
DEVICE_PROPERTY_DOCUMENT_HANDLING_SELECT_ID, requested);
}
}
我对它做了更多的研究,我发现使用feeder的唯一方法是打开公共对话框询问“item”。对话框中的方法请求设备。它设置设备和项目中的属性。我瞥了一眼这些属性,它看起来和我的问题一样。它是有效的。一定有什么我没看到的……我也有同样的问题-(我假设必须修改另一个设备属性。我已经尝试了上面的代码,但是当设置下面的行时,我得到一个异常“值不在范围内”.object objValue=FEEDER | WIA_DPS_DOCUMENT_HANDLING_SELECT.DUPLEX;documentHandlingSelect.set_Value(参考objValue);