gpt4 book ai didi

c# - 通过 Feeder 进行 WIA 扫描

转载 作者:太空狗 更新时间:2023-10-29 20:14:35 26 4
gpt4 key购买 nike

WIA 通过 Feeder 扫描

这是我的设备属性:

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”设置为“2”,一切都会顺利进行。当我将它设置为“1”并运行它时,就在我说 item.Transfer()(或 item.Transfer(bmp/jpeg/pngGuid))之前,我收到异常“值不在预期范围内”。

这太烦人了,有什么值(value)?我在网上搜索了一下,只找到了一点信息,但帮助不大。

最佳答案

我认为您必须将设备属性“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);
}
}

关于c# - 通过 Feeder 进行 WIA 扫描,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7077020/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com