C#: How to avoid WIA-error when scanning documents with 2400dpi or more?

Posted by Stephan_W on Stack Overflow See other posts from Stack Overflow or by Stephan_W
Published on 2010-05-05T08:59:03Z Indexed on 2010/05/18 13:00 UTC
Read the original article Hit count: 1178

Filed under:
|
|
|

Hello,

when we scan a document with a resolution of 2400dpi or higher, we recieve (for example) the following error-message:

COMException: Ausnahme von HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED)

or

COMException: Ausnahme von HRESULT: 0x8021006F

in one of the following lines

            img = itm.Transfer(scanFormat.ScanFormat) as WIA.ImageFile;
            img = ip.Apply(img as WIA.ImageFile);

some screenshots for the mentioned errors:

http://www.amarant-it.de/TempDownload/WIA_Error01.png

or the same path with WIA_Error02.png and WIA_Error03.png

for scanning we use the following code:

            #region Image-Convert-Settings
            //IP.Filters.Add IP.FilterInfos("Convert").FilterID
            //IP.Filters(1).Properties("FormatID").Value = wiaFormatJPEG
            WIA.IImageProcess ip = new WIA.ImageProcessClass();
            object convert = "Convert";
            WIA.IFilterInfo fi = ip.FilterInfos.get_Item(ref convert);
            ip.Filters.Add(fi.FilterID, 0);
            convert = "FormatID";
            object formatstring = scanFormat.ScanFormat;
            WIA.IFilter filter;
            foreach (WIA.IFilter fTemp in ip.Filters)
            {
                filter = fTemp;
                WIA.IProperty prop = filter.Properties.get_Item(ref convert);
                prop.set_Value(ref formatstring);
            }
            #endregion
            #region Image-Scan + Convert
            img = itm.Transfer(scanFormat.ScanFormat) as WIA.ImageFile;
            img = ip.Apply(img as WIA.ImageFile);
            img.SaveFile("D:\\scan2." + img.FileExtension);
            Image image = Image.FromFile("D:\\scan2." + img.FileExtension);
            ilImages.Images.Add(image.ToString(), image);
            alImages.Add(image);
            if (ImageScanned != null)
            {
                ImageScanned(image);
            }
            #endregion

can anyone help us with this problem?

thanks

© Stack Overflow or respective owner

Related posts about wia

Related posts about c#