获取 WIA 扫描仪功能

发布于 2024-11-16 13:45:22 字数 46 浏览 1 评论 0原文

如何获取扫描仪的可用分辨率和/或 dpi。另外,如何获取它有自动送稿器等信息?

How do you get a scanner's available resolutions and/or dpi. Also, how to get the information that it has an automatic document feeder, etc?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

‘画卷フ 2024-11-23 13:45:22

您可以像 Matthias 向您建议的那样,通过导航属性对象来检索扫描仪可用的功能。
以下是我使用的所有属性及其 ID 的枚举:

public enum WiaProperty
{
    DeviceId = 2,
    Manufacturer = 3,
    Description = 4,
    Type = 5,
    Port = 6,
    Name = 7,
    Server = 8,
    RemoteDevId = 9,
    UIClassId = 10,
    FirmwareVersion = 1026,
    ConnectStatus = 1027,
    DeviceTime = 1028,
    PicturesTaken = 2050,
    PicturesRemaining = 2051,
    ExposureMode = 2052,
    ExposureCompensation = 2053,
    ExposureTime = 2054,
    FNumber = 2055,
    FlashMode = 2056,
    FocusMode = 2057,
    FocusManualDist = 2058,
    ZoomPosition = 2059,
    PanPosition = 2060,
    TiltPostion = 2061,
    TimerMode = 2062,
    TimerValue = 2063,
    PowerMode = 2064,
    BatteryStatus = 2065,
    Dimension = 2070,
    HorizontalBedSize = 3074,
    VerticalBedSize = 3075,
    HorizontalSheetFeedSize = 3076,
    VerticalSheetFeedSize = 3077,
    SheetFeederRegistration = 3078,         // 0 = LEFT_JUSTIFIED, 1 = CENTERED, 2 = RIGHT_JUSTIFIED
    HorizontalBedRegistration = 3079,       // 0 = LEFT_JUSTIFIED, 1 = CENTERED, 2 = RIGHT_JUSTIFIED
    VerticalBedRegistraion = 3080,          // 0 = TOP_JUSTIFIED, 1 = CENTERED, 2 = BOTTOM_JUSTIFIED
    PlatenColor = 3081,
    PadColor = 3082,
    FilterSelect = 3083,
    DitherSelect = 3084,
    DitherPatternData = 3085,

    DocumentHandlingCapabilities = 3086,    // FEED = 0x01, FLAT = 0x02, DUP = 0x04, DETECT_FLAT = 0x08, 
                                            // DETECT_SCAN = 0x10, DETECT_FEED = 0x20, DETECT_DUP = 0x40, 
                                            // DETECT_FEED_AVAIL = 0x80, DETECT_DUP_AVAIL = 0x100
    DocumentHandlingStatus = 3087,          // FEED_READY = 0x01, FLAT_READY = 0x02, DUP_READY = 0x04, 
                                            // FLAT_COVER_UP = 0x08, PATH_COVER_UP = 0x10, PAPER_JAM = 0x20
    DocumentHandlingSelect = 3088,          // FEEDER = 0x001, FLATBED = 0x002, DUPLEX = 0x004, FRONT_FIRST = 0x008
                                            // BACK_FIRST = 0x010, FRONT_ONLY = 0x020, BACK_ONLY = 0x040
                                            // NEXT_PAGE = 0x080, PREFEED = 0x100, AUTO_ADVANCE = 0x200
    DocumentHandlingCapacity = 3089, 
    HorizontalOpticalResolution = 3090,
    VerticalOpticalResolution = 3091,
    EndorserCharacters = 3092,
    EndorserString = 3093,
    ScanAheadPages = 3094,                  // ALL_PAGES = 0
    MaxScanTime = 3095,
    Pages = 3096,                           // ALL_PAGES = 0
    PageSize = 3097,                        // A4 = 0, LETTER = 1, CUSTOM = 2
    PageWidth = 3098,
    PageHeight = 3099,
    Preview = 3100,                         // FINAL_SCAN = 0, PREVIEW = 1
    TransparencyAdapter = 3101,
    TransparecnyAdapterSelect = 3102,
    ItemName = 4098,
    FullItemName = 4099,
    ItemTimeStamp = 4100,
    ItemFlags = 4101,
    AccessRights = 4102,
    DataType = 4103,
    BitsPerPixel = 4104,
    PreferredFormat = 4105,
    Format = 4106,
    Compression = 4107,                     // 0 = NONE, JPG = 5, PNG = 8
    MediaType = 4108,
    ChannelsPerPixel = 4109,
    BitsPerChannel = 4110,
    Planar = 4111,
    PixelsPerLine = 4112,
    BytesPerLine = 4113,
    NumberOfLines = 4114,
    GammaCurves = 4115,
    ItemSize = 4116,
    ColorProfiles = 4117,
    BufferSize = 4118,
    RegionType = 4119,
    ColorProfileName = 4120,
    ApplicationAppliesColorMapping = 4121,
    StreamCompatibilityId = 4122,
    ThumbData = 5122,
    ThumbWidth = 5123,
    ThumbHeight = 5124,
    AudioAvailable = 5125,
    AudioFormat = 5126,
    AudioData = 5127,
    PicturesPerRow = 5128,
    SequenceNumber = 5129,
    TimeDelay = 5130,
    CurrentIntent = 6146,
    HorizontalResolution = 6147,
    VerticalResolution = 6148,
    HorizontalStartPosition = 6149,
    VerticalStartPosition = 6150,
    HorizontalExtent = 6151,
    VerticalExtent = 6152,
    PhotometricInterpretation = 6153,
    Brightness = 6154,
    Contrast = 6155,
    Orientation = 6156, // 0 = PORTRAIT, 1 = LANDSCAPE, 2 = 180°, 3 = 270°
    Rotation = 6157, // 0 = PORTRAIT, 1 = LANDSCAPE, 2 = 180°, 3 = 270°
    Mirror = 6158,
    Threshold = 6159,
    Invert = 6160,
    LampWarmUpTime = 6161,
}

对于每个属性的可能值,您可以阅读 MSDN 文档:

MSDN WIA 文档

或者如果您想更深入,您可以分析标头原始SDK的文件。

You can retrieve the features available for your scanner by navigating through the Properties object like Matthias suggested to you.
Here is an enum I use with all the properties and their IDs:

public enum WiaProperty
{
    DeviceId = 2,
    Manufacturer = 3,
    Description = 4,
    Type = 5,
    Port = 6,
    Name = 7,
    Server = 8,
    RemoteDevId = 9,
    UIClassId = 10,
    FirmwareVersion = 1026,
    ConnectStatus = 1027,
    DeviceTime = 1028,
    PicturesTaken = 2050,
    PicturesRemaining = 2051,
    ExposureMode = 2052,
    ExposureCompensation = 2053,
    ExposureTime = 2054,
    FNumber = 2055,
    FlashMode = 2056,
    FocusMode = 2057,
    FocusManualDist = 2058,
    ZoomPosition = 2059,
    PanPosition = 2060,
    TiltPostion = 2061,
    TimerMode = 2062,
    TimerValue = 2063,
    PowerMode = 2064,
    BatteryStatus = 2065,
    Dimension = 2070,
    HorizontalBedSize = 3074,
    VerticalBedSize = 3075,
    HorizontalSheetFeedSize = 3076,
    VerticalSheetFeedSize = 3077,
    SheetFeederRegistration = 3078,         // 0 = LEFT_JUSTIFIED, 1 = CENTERED, 2 = RIGHT_JUSTIFIED
    HorizontalBedRegistration = 3079,       // 0 = LEFT_JUSTIFIED, 1 = CENTERED, 2 = RIGHT_JUSTIFIED
    VerticalBedRegistraion = 3080,          // 0 = TOP_JUSTIFIED, 1 = CENTERED, 2 = BOTTOM_JUSTIFIED
    PlatenColor = 3081,
    PadColor = 3082,
    FilterSelect = 3083,
    DitherSelect = 3084,
    DitherPatternData = 3085,

    DocumentHandlingCapabilities = 3086,    // FEED = 0x01, FLAT = 0x02, DUP = 0x04, DETECT_FLAT = 0x08, 
                                            // DETECT_SCAN = 0x10, DETECT_FEED = 0x20, DETECT_DUP = 0x40, 
                                            // DETECT_FEED_AVAIL = 0x80, DETECT_DUP_AVAIL = 0x100
    DocumentHandlingStatus = 3087,          // FEED_READY = 0x01, FLAT_READY = 0x02, DUP_READY = 0x04, 
                                            // FLAT_COVER_UP = 0x08, PATH_COVER_UP = 0x10, PAPER_JAM = 0x20
    DocumentHandlingSelect = 3088,          // FEEDER = 0x001, FLATBED = 0x002, DUPLEX = 0x004, FRONT_FIRST = 0x008
                                            // BACK_FIRST = 0x010, FRONT_ONLY = 0x020, BACK_ONLY = 0x040
                                            // NEXT_PAGE = 0x080, PREFEED = 0x100, AUTO_ADVANCE = 0x200
    DocumentHandlingCapacity = 3089, 
    HorizontalOpticalResolution = 3090,
    VerticalOpticalResolution = 3091,
    EndorserCharacters = 3092,
    EndorserString = 3093,
    ScanAheadPages = 3094,                  // ALL_PAGES = 0
    MaxScanTime = 3095,
    Pages = 3096,                           // ALL_PAGES = 0
    PageSize = 3097,                        // A4 = 0, LETTER = 1, CUSTOM = 2
    PageWidth = 3098,
    PageHeight = 3099,
    Preview = 3100,                         // FINAL_SCAN = 0, PREVIEW = 1
    TransparencyAdapter = 3101,
    TransparecnyAdapterSelect = 3102,
    ItemName = 4098,
    FullItemName = 4099,
    ItemTimeStamp = 4100,
    ItemFlags = 4101,
    AccessRights = 4102,
    DataType = 4103,
    BitsPerPixel = 4104,
    PreferredFormat = 4105,
    Format = 4106,
    Compression = 4107,                     // 0 = NONE, JPG = 5, PNG = 8
    MediaType = 4108,
    ChannelsPerPixel = 4109,
    BitsPerChannel = 4110,
    Planar = 4111,
    PixelsPerLine = 4112,
    BytesPerLine = 4113,
    NumberOfLines = 4114,
    GammaCurves = 4115,
    ItemSize = 4116,
    ColorProfiles = 4117,
    BufferSize = 4118,
    RegionType = 4119,
    ColorProfileName = 4120,
    ApplicationAppliesColorMapping = 4121,
    StreamCompatibilityId = 4122,
    ThumbData = 5122,
    ThumbWidth = 5123,
    ThumbHeight = 5124,
    AudioAvailable = 5125,
    AudioFormat = 5126,
    AudioData = 5127,
    PicturesPerRow = 5128,
    SequenceNumber = 5129,
    TimeDelay = 5130,
    CurrentIntent = 6146,
    HorizontalResolution = 6147,
    VerticalResolution = 6148,
    HorizontalStartPosition = 6149,
    VerticalStartPosition = 6150,
    HorizontalExtent = 6151,
    VerticalExtent = 6152,
    PhotometricInterpretation = 6153,
    Brightness = 6154,
    Contrast = 6155,
    Orientation = 6156, // 0 = PORTRAIT, 1 = LANDSCAPE, 2 = 180°, 3 = 270°
    Rotation = 6157, // 0 = PORTRAIT, 1 = LANDSCAPE, 2 = 180°, 3 = 270°
    Mirror = 6158,
    Threshold = 6159,
    Invert = 6160,
    LampWarmUpTime = 6161,
}

For the possible values of every single property you can read the MSDN documentation:

MSDN WIA Documentation

or if you want to get deeper, you can analyze the header files of the original SDK.

岁月苍老的讽刺 2024-11-23 13:45:22

您可以使用包含属性列表的 Properties 对象。使用Device 对象的Properties 对象访问扫描仪属性(文档进纸器),使用Item 对象的Properties 对象访问页面属性(分辨率)。

这是一些代码:

        DeviceManager manager = new DeviceManagerClass();
        DeviceInfo scannerInfo = WiaHelper.FindFirstScanner(manager);
        Device device = scannerInfo.Connect();
        Item item = device.Items[1];

    public static DeviceInfo FindFirstScanner(DeviceManager manager)
    {
        DeviceInfos infos = manager.DeviceInfos;
        foreach (DeviceInfo info in infos)
            if (info.Type == WiaDeviceType.ScannerDeviceType)
                return info;
        return null;
    }

    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 object GetItemProperty(Item item, int propertyId)
    {
        Property property = FindProperty(item.Properties, propertyId);
        return property != null ? property.get_Value() : null;
    }

    public static void SetItemProperty(Item item, int propertyId, object value)
    {
        Property property = FindProperty(item.Properties, propertyId);
        if (property != null)
            property.set_Value(value);
    }

You can use the Properties object containing a list of properties. Use the Properties object of the Device object to access scanner properties (document feeder), use the Properties object of the Item object to access page properties (resolution).

Here is some code:

        DeviceManager manager = new DeviceManagerClass();
        DeviceInfo scannerInfo = WiaHelper.FindFirstScanner(manager);
        Device device = scannerInfo.Connect();
        Item item = device.Items[1];

    public static DeviceInfo FindFirstScanner(DeviceManager manager)
    {
        DeviceInfos infos = manager.DeviceInfos;
        foreach (DeviceInfo info in infos)
            if (info.Type == WiaDeviceType.ScannerDeviceType)
                return info;
        return null;
    }

    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 object GetItemProperty(Item item, int propertyId)
    {
        Property property = FindProperty(item.Properties, propertyId);
        return property != null ? property.get_Value() : null;
    }

    public static void SetItemProperty(Item item, int propertyId, object value)
    {
        Property property = FindProperty(item.Properties, propertyId);
        if (property != null)
            property.set_Value(value);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文