tags:

views:

40

answers:

1

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.ErrorCode == -2145320939)
            {
                throw new ScannerNotFoundException();
            }
            else
            {
                throw new ScannerException("COM Exception", ex);
            }
        }
    }
+1  A: 

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.

Hans Passant
Can I show show setting window when required and then save all information. In which form Can I save this data about settings?
Polaris
There are a bunch of dialogs in CommonDialog. They'll set the properties of the object you pass. You can read those properties back after the dialog completes.
Hans Passant
can you give me a little peace of code like example?
Polaris
The SDK docs are filled with little pieces of code, use them to your advantage. http://msdn.microsoft.com/en-us/library/ms630826%28VS.85%29.aspx
Hans Passant
Thank you for useful link. Can I serialize CommonDialog class to drive and after use it ?
Polaris
COM objects cannot be serialized. Please start a new thread if you have any additional questions, this is not a forum.
Hans Passant