通过馈线WIA扫描 [英] WIA Scanning via Feeder

查看:335
本文介绍了通过馈线WIA扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过馈线WIA扫描

下面是我的设备属性:

Document Handling Select = 1 (2 is for flatbed, and 1 is for the feeder.)

这是我的项目(​​第)性能:

Here is my item (page) properties:

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))我得到的异常值没有在预期范围之内。

I got everything running smoothly if I set the "Document Handling Select" to "2". When I set it to "1", and ran it, just before I say item.Transfer() (or item.Transfer(bmp/jpeg/pngGuid)) I get the exception "Value does not fall within the expected range."

这是很讨厌,有什么价值?我用Google搜索网页,我只能找到一点点信息,但它没有太大的帮助。

This is so annoying, what value? I have googled the web, and I could only find a little information but it isn't much of help.

推荐答案

我觉得你必须设置为0的设备属性页面(ID 3096)为1,以防止例外。我花了一些时间来弄清楚这一点。最后,我通过之前和CommonDialogClass.ShowSelectItems一个电话后,比较器属性中找到此属性。

I think you have to set the device property "Pages" (ID 3096) from 0 to 1 to prevent the exception. It took me some time to figure this out. Finally, I found this property by comparing the device properties before and after a call to 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);
        }
    }

这篇关于通过馈线WIA扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆