mirror of
https://github.com/soukoku/ntwain.git
synced 2025-09-19 01:57:56 +08:00
Example of setting file xfer in wpf.
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user