HP Scanjet 7000 (양면 & ADF 스캐너)과 HP Scanjet 5500c (ADF 만) 및 개발중인 스캐너 프로그램이 있습니다. Windows 7의 WIA 2.0입니다.자동 문서 공급기 (ADF)가있는 WIA는 특정 스캐너에서 한 페이지 만 다시 인쇄합니다.
문제는 코드가 이전 스캐너 모델에서 완벽하게 작동하지만 최신 버전에서는 코드가 첫 번째 페이지에서 제대로 실행 된 다음 두 번째 페이지에서 오류가 발생하는 것입니다. 다음 줄을 따라 코드를 실행하면; 다른 통화에 대한
image = (WIA.ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatTIFF, false);
오래된 스캐너 정지 및 대기는 동일한 참조에 만들었지 만, 새로운 하나 하나 개의 연속 운전에 공급 장치에서 모든 그것의 페이지를 실행합니다.
Windows 7에서 기본 검색 프로그램을 사용하는 경우 최신 버전은 모든 별도의 페이지가 들어있는 단일 .tif 파일을 반환합니다. 이전 버전에서는 별도의 .jpg 파일 (각 페이지마다 하나씩)이 반환됩니다.
이것은 이전 스캐너가 스캔 한 각 페이지 사이에 하나의 이미지를 반환하는 이미지 모음을 반환 할 준비가되기 전에 최신 스캐너가 전체 피더를 스캔하고 있음을 나타냅니다.
코드에서이 동작을 어떻게 지원합니까? 다음은 구형 스캐너 모델에서 작동하는 관련 코드의 일부입니다.
public static List<Image> Scan(string scannerId)
{
List<Image> images = new List<Image>();
List<String> tmp_imageList = new List<String>();
bool hasMorePages = true;
bool useAdf = true;
bool duplex = false;
int pages = 0;
string fileName = null;
string fileName_duplex = null;
WIA.DeviceManager manager = null;
WIA.Device device = null;
WIA.DeviceInfo device_infoHolder = null;
WIA.Item item = null;
WIA.ICommonDialog wiaCommonDialog = null;
manager = new WIA.DeviceManager();
// select the correct scanner using the provided scannerId parameter
foreach (WIA.DeviceInfo info in manager.DeviceInfos)
{
if (info.DeviceID == scannerId)
{
// Find scanner to connect to
device_infoHolder = info;
break;
}
}
while (hasMorePages)
{
wiaCommonDialog = new WIA.CommonDialog();
// Connect to scanner
device = device_infoHolder.Connect();
if (device.Items[1] != null)
{
item = device.Items[1] as WIA.Item;
try
{
if ((useAdf) || (duplex))
SetupADF(device, duplex); //Sets the right properties in WIA
WIA.ImageFile image = null;
WIA.ImageFile image_duplex = null;
// scan image
image = (WIA.ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatTIFF, false);
if (duplex)
{
image_duplex = (ImageFile)wiaCommonDialog.ShowTransfer(item, wiaFormatPNG, false);
}
// save (front) image to temp file
fileName = Path.GetTempFileName();
tmp_imageList.Add(fileName);
File.Delete(fileName);
image.SaveFile(fileName);
image = null;
// add file to images list
images.Add(Image.FromFile(fileName));
if (duplex)
{
fileName_duplex = Path.GetTempFileName();
tmp_imageList.Add(fileName_duplex);
File.Delete(fileName_duplex);
image_duplex.SaveFile(fileName_duplex);
image_duplex = null;
// add file_duplex to images list
images.Add(Image.FromFile(fileName_duplex));
}
if (useAdf || duplex)
{
hasMorePages = HasMorePages(device); //Returns true if the feeder has more pages
pages++;
}
}
catch (Exception exc)
{
throw exc;
}
finally
{
wiaCommonDialog = null;
manager = null;
item = null;
device = null;
}
}
}
device = null;
return images;
}
이 문제에 대한 도움은 매우 감사하겠습니다! 나는 웹상에서 작동하는 해결책을 찾지 못하고있다. 같은 문제를 가진 사람들의 답변이없는 포럼 게시물.
정말 "HasMorePages (device)"메서드를 볼 수 있었으면 좋겠습니다. 나는 그 조각과 고투하고있다. – JDPeckham