Added format for image file xfer

This commit is contained in:
soukoku
2015-01-12 19:23:56 -05:00
parent 5fad8b3c02
commit 1170b2d6ef
2 changed files with 19 additions and 9 deletions

View File

@@ -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

View File

@@ -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);
}