7

フィーダーを介した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.),
Vertical Extent = 500
Bits Per Pixel = 8
Current Intent = 4

「ドキュメント処理選択」を「2」に設定すると、すべてがスムーズに実行されました。「1」に設定して実行すると、item.Transfer()(またはitem.Transfer(bmp / jpeg / pngGuid))と言う直前に、「値が期待される範囲内にありません」という例外が発生します。

これはとても迷惑です、どのような価値がありますか?私はウェブをグーグルで検索しました、そして私はほんの少しの情報を見つけることができました、しかしそれはあまり助けにはなりません。

4

1 に答える 1

10

例外を防ぐために、デバイスプロパティ「ページ」(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);
        }
    }
于 2011-09-29T10:21:34.053 に答える