如何使用wia库从馈线读取

时间:2014-04-13 11:04:19

标签: c# image wia scanning

使用WIA Library读取进纸器中的所有页面时遇到问题。 我有一台扫描仪HP scanjet 5590,从平板扫描工作完美。如果进纸器中的页面只有一页,则从进纸器扫描可以完美地工作。

现在如果我在进纸器中有多个页面,它只扫描一页,并在尝试扫描下一页时停止。

我认为问题在于它只进行一次扫描功能。如果进纸器中有页面,如何继续读取扫描功能?

我使用了WIA库:

以下是我的进纸器扫描功能代码:

                if (this._deviceInfo != null)
                {
                    // Connect to the device
                    var device = this._deviceInfo.Connect();

                    //set _adf 
                    _adf = true; 

                    CommonDialog commonDialog = new CommonDialog();

                    var item = device.Items[1];
                    int dpi = 150;

                    // configure item
                    //SetItemIntProperty(ref item, 6146, 2); // greyscale
                    //SetItemIntProperty(ref item, 6147, dpi); // 150 dpi
                    //SetItemIntProperty(ref item, 6148, dpi); // 150 dpi
                    //SetItemIntProperty(ref item, 6151, (int)(dpi * _width)); // scan width
                    //SetItemIntProperty(ref item, 6152, (int)(dpi * _height)); // scan height
                    SetItemIntProperty(ref item, 4104, 8); // bit depth

                    //set Feeder Settings // 1 for ADF, 2 for flatbed
                    int deviceHandling = _adf ? int.Parse(DeviceDocumentHandling.Feeder.ToString()) : int.Parse(DeviceDocumentHandling.FlatBed.ToString()); 

                    // configure device
                    SetDeviceIntProperty(ref device, DEVICE_PROPERTY_DOCUMENT_HANDLING_SELECT_ID, deviceHandling);
                    int handlingStatus = GetDeviceIntProperty(ref device, DEVICE_PROPERTY_DOCUMENT_HANDLING_STATUS_ID);

                    if (handlingStatus == deviceHandling)
                    {
                        //I think I should add a loop here While(scanner had pages?) how to do it? 
                        {
                            //start scan
                            imageFile = commonDialog.ShowTransfer(item, MyFormatID.wiaFormatJPEG, true);

                            // save image to a file and add to arraylist 
                            var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
                            path = Path.Combine(path, Path.GetTempFileName());
                            path = System.IO.Path.ChangeExtension(path, "jpg");
                            imageFile.SaveFile(path);

                            _tempSavedImages.Add(path); //add to arraylist teh created images 
                        }

                    }

                }

0 个答案:

没有答案