case TwainCapabilityValue.TransferMechanismFile:
{
//RasterImageFormat format = RasterImageFormat.Tif;
TwainFileFormat format1=new TwainFileFormat();
string destfilename = string.Empty;
CreateDerectory();
if (_scanCount == 0)
_scanCount++;
switch (_scanSet.SaveFileFormat)
{
case "TIF":
{
//format = RasterImageFormat.Tif;
destfilename=Path.Combine(_tempFilePath, (_scanCount++).ToString() + ".tif");
format1=TwainFileFormat.Tiff;
break;
}
case "bmp":
{
//format = RasterImageFormat.Bmp;
destfilename = Path.Combine(_tempFilePath, (_scanCount++).ToString() + ".bmp");
format1=TwainFileFormat.Bmp;
break;
}
case "jpeg":
{
//format = RasterImageFormat.Jpeg;
destfilename = Path.Combine(_tempFilePath, (_scanCount++).ToString() + ".jpg");
format1=TwainFileFormat.Pict;
break;
}
}
try
{
/* ICAP_IMAGEFILEFORMAT */
MySetCapability(TwainCapabilityType.ImageImageFileFormat, TwainItemType.Uint16, (UInt16)format1);
}
catch
{
return;
}
try
{
TwainProperties twnProps = _twainSession.Properties;
TwainDataTransferProperties dataTransfer = twnProps.DataTransfer;
dataTransfer.MemoryBufferSize = 1024;
dataTransfer.SaveToOneFile = true;
dataTransfer.AppendToFile = false;
dataTransfer.DumpMemoryBuffersToFile = true;
//dataTransfer.SaveToOneFile = true;
dataTransfer.FileName = destfilename;
dataTransfer.BufferedMemoryCompression = TwainCompressionMode.Group4;
dataTransfer.ScanFileFormat = format1;
twnProps.DataTransfer = dataTransfer;
_twainSession.Properties = twnProps;
}
catch
{
}
break;
} |