[在Windows 7上使用WIA扫描多个页面

问题描述 投票:0回答:1

我正在尝试从进纸器扫描几页,尽管当我调用ShowTransfer函数(不使用循环)时扫描仪会自动扫描所有页面,但我只返回了第一页。

我在做什么错?

这是我的代码:

  WIA.Item item = device.Items[1] as WIA.Item;

            if (pages > 1)
            {
                // Set to feeder
                SetWIAProperty(device.Properties, 44, 1);
            }

            SetWIAProperty(device.Properties, WIA_DEVICE_PROPERTY_PAGES_ID, 1);

            AdjustScannerSettings(item, 150, 0, 0, 1250, 1700, 0, 0, 1);
            try
            {

                // scan image
                WIA.ICommonDialog wiaCommonDialog = new WIA.CommonDialog();
                WIA.ImageFile image = (WIA.ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatBMP, false);

                // save to temp file
                string fileName = Path.GetTempFileName();
                File.Delete(fileName);
                image.SaveFile(fileName);
                image = null;
                // add file to output list
                images.Add(Image.FromFile(fileName));
            }
            catch (Exception exc)
            {
                throw exc;
            }
c# windows-7 scanning wia
1个回答
0
投票

我认为此链接正在执行您想做的事情

http://forums.codeguru.com/showthread.php?439027-Windows-Image-Acquisition-(WIA)-Code

基本上,您需要在保存每页之后进行检查,以查看是否还有更多页面并继续循环播放

                hasMorePages = false; //assume there are no more pages
                if (documentHandlingSelect != null)
                    //may not exist on flatbed scanner but required for feeder
                {
                    //check for document feeder
                    if ((Convert.ToUInt32(documentHandlingSelect.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_SELECT.FEEDER) != 0)
                    {
                        hasMorePages = ((Convert.ToUInt32(documentHandlingStatus.get_Value()) & WIA_DPS_DOCUMENT_HANDLING_STATUS.FEED_READY) != 0);
                    }
                }
© www.soinside.com 2019 - 2024. All rights reserved.