mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-24 08:47:06 +08:00
Added format for image file xfer
This commit is contained in:
@@ -24,16 +24,18 @@ namespace NTwain
|
||||
ImageInfo = imageInfo;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataTransferredEventArgs" /> class.
|
||||
/// Initializes a new instance of the <see cref="DataTransferredEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <param name="fileDataPath">The file data path.</param>
|
||||
/// <param name="imageInfo">The image information.</param>
|
||||
public DataTransferredEventArgs(DataSource source, string fileDataPath, TWImageInfo imageInfo)
|
||||
/// <param name="imageFileFormat">The image file format.</param>
|
||||
public DataTransferredEventArgs(DataSource source, string fileDataPath, TWImageInfo imageInfo, FileFormat imageFileFormat)
|
||||
{
|
||||
DataSource = source;
|
||||
FileDataPath = fileDataPath;
|
||||
ImageInfo = imageInfo;
|
||||
ImageFileFormat = imageFileFormat;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataTransferredEventArgs" /> class.
|
||||
@@ -66,6 +68,14 @@ namespace NTwain
|
||||
/// </value>
|
||||
public string FileDataPath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file format if applicable.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The file format.
|
||||
/// </value>
|
||||
public FileFormat ImageFileFormat { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the raw memory data if the transfer was memory.
|
||||
/// Consumer application will need to do the parsing based on the values
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace NTwain.Internals
|
||||
var xrc = session.DGAudio.AudioFileXfer.Get();
|
||||
if (xrc == ReturnCode.XferDone)
|
||||
{
|
||||
session.SafeSyncableRaiseEvent(new DataTransferredEventArgs(session.CurrentSource, filePath, null));
|
||||
session.SafeSyncableRaiseEvent(new DataTransferredEventArgs(session.CurrentSource, filePath, null, (FileFormat)0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -202,7 +202,7 @@ namespace NTwain.Internals
|
||||
{
|
||||
lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr);
|
||||
}
|
||||
DoImageXferredEventRoutine(session, lockedPtr, null, null);
|
||||
DoImageXferredEventRoutine(session, lockedPtr, null, null, (FileFormat)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -243,7 +243,7 @@ namespace NTwain.Internals
|
||||
var xrc = session.DGImage.ImageFileXfer.Get();
|
||||
if (xrc == ReturnCode.XferDone)
|
||||
{
|
||||
DoImageXferredEventRoutine(session, IntPtr.Zero, null, filePath);
|
||||
DoImageXferredEventRoutine(session, IntPtr.Zero, null, filePath, setupInfo.Format);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -307,7 +307,7 @@ namespace NTwain.Internals
|
||||
|
||||
if (xrc == ReturnCode.XferDone)
|
||||
{
|
||||
DoImageXferredEventRoutine(session, IntPtr.Zero, xferredData.ToArray(), null);
|
||||
DoImageXferredEventRoutine(session, IntPtr.Zero, xferredData.ToArray(), null, (FileFormat)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -413,12 +413,12 @@ namespace NTwain.Internals
|
||||
|
||||
if (File.Exists(finalFile))
|
||||
{
|
||||
DoImageXferredEventRoutine(session, IntPtr.Zero, null, finalFile);
|
||||
DoImageXferredEventRoutine(session, IntPtr.Zero, null, finalFile, fileInfo.Format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DoImageXferredEventRoutine(ITwainSessionInternal session, IntPtr dataPtr, byte[] dataArray, string filePath)
|
||||
static void DoImageXferredEventRoutine(ITwainSessionInternal session, IntPtr dataPtr, byte[] dataArray, string filePath, FileFormat format)
|
||||
{
|
||||
DataTransferredEventArgs args = null;
|
||||
TWImageInfo imgInfo;
|
||||
@@ -437,7 +437,7 @@ namespace NTwain.Internals
|
||||
}
|
||||
else
|
||||
{
|
||||
args = new DataTransferredEventArgs(session.CurrentSource, filePath, imgInfo);
|
||||
args = new DataTransferredEventArgs(session.CurrentSource, filePath, imgInfo, format);
|
||||
}
|
||||
session.SafeSyncableRaiseEvent(args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user