开发者

Windows Image Acquisition: How to hide scanner setup window

开发者 https://www.devze.com 2023-01-16 06:42 出处:网络
I use WIA library to scan images in my app. Can I set scanner settings (colorfull, grayscell, dpi....) programmaticaly in my app and not show every time scanning settings to end user?

I use WIA library to scan images in my app. Can I set scanner settings (colorfull, grayscell, dpi....) programmaticaly in my app and not show every time scanning settings to end user?

I use next code to get an image from scanner

        public ImageFile Scan()
        {
        try
        {
            CommonDialog dialog = new CommonDialog();

            ImageFile image = dialog.ShowAcquireImage(
                WiaDeviceType.ScannerDeviceType,
                WiaImageIntent.ColorIntent,
                WiaImageBias.MaximizeQuality,
                WIA.FormatID.wiaFormatJPEG,false,false,false);

            return image;
        }
        catch (COMException ex)
        {
            if (ex.Err开发者_C百科orCode == -2145320939)
            {
                throw new ScannerNotFoundException();
            }
            else
            {
                throw new ScannerException("COM Exception", ex);
            }
        }
    }


Yes, but you'll have to write a bunch of code. Start with DeviceManager.DeviceInfos to enumerate the devices that are available. You'll need some guidance from the user to select the specific device she intends to use. That produces a DeviceInfo from DeviceInfos.Item, call its Connect method. That produces a Device, call its ExecuteCommand method. That produces an Item, call its Transfer method. That produces the ImageFile you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号