Example of setting file xfer in wpf.

This commit is contained in:
soukoku
2014-04-07 19:46:03 -04:00
parent 2820cf7a8d
commit e915f6753b
2 changed files with 77 additions and 11 deletions

View File

@@ -79,17 +79,18 @@ namespace Tester.WPF
};
twain.TransferReady += (s, te) =>
{
//var type = twain.GetCurrentCap<PixelType>(CapabilityId.ICapPixelType);
//if (type == PixelType.BlackWhite)
//{
// te.ImageFormat = ImageFileFormat.Tiff;
// te.ImageCompression = Compression.Group31D;
// te.OutputFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.tif");
//}
//else
//{
//te.OutputFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.bmp");
//}
if (twain.GetCurrentCap<XferMech>(CapabilityId.ICapXferMech) == XferMech.File)
{
var formats = twain.CapGetImageFileFormat();
var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp;
var fileSetup = new TWSetupFileXfer
{
Format = wantFormat,
FileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.tif")
};
var rc = twain.DGControl.SetupFileXfer.Set(fileSetup);
}
};
}
@@ -133,6 +134,11 @@ namespace Tester.WPF
twain.CapSetPixelType(PixelType.BlackWhite);
}
if (twain.CapGetImageXferMechs().Contains(XferMech.File))
{
twain.CapSetImageXferMech(XferMech.File);
}
step = "Enable DS";
rc = twain.EnableSource(SourceEnableMode.NoUI, false, hand, SynchronizationContext.Current);
return;