diff --git a/NTwain/Data/Types.cs b/NTwain/Data/Types.cs
index 6f7ec43..b45743c 100644
--- a/NTwain/Data/Types.cs
+++ b/NTwain/Data/Types.cs
@@ -83,10 +83,8 @@ namespace NTwain.Data
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
TWDecodeFunction[] _decode;
- // TODO: research jagged aray mapping (3x3).
- // maybe can only have 1-D
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
- TWFix32[][] _mix;
+ TWFix32[] _mix;
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
@@ -230,61 +228,58 @@ namespace NTwain.Data
TWInfo[] _info;
}
- [StructLayout(LayoutKind.Explicit, Pack = 2),
+ [StructLayout(LayoutKind.Sequential, Pack = 2),
BestFitMapping(false, ThrowOnUnmappableChar = true)]
partial class TWFileSystem
{
- // TODO: verify all field offset #s
-
- [FieldOffset(0)]
+ //[FieldOffset(0)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)]
string _inputName;
- [FieldOffset(TwainConst.String255)]
+ //[FieldOffset(TwainConst.String255)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)]
string _outputName;
- [FieldOffset(512)]
+ //[FieldOffset(512)]
TW_MEMREF _context;
- //TODO: verify this field offset in 64bit due to previous pointer
- [FieldOffset(520)]
- short _recursive;
- [FieldOffset(520)]
+ //[FieldOffset(520)]
+ //short _recursive;
+ //[FieldOffset(520)]
TW_BOOL _subdirectories;
- [FieldOffset(524)]
+ //[FieldOffset(524)]
TW_INT32 _fileType;
- [FieldOffset(524)]
- TW_UINT32 _fileSystemType;
+ //[FieldOffset(524)]
+ //TW_UINT32 _fileSystemType;
- [FieldOffset(528)]
+ //[FieldOffset(528)]
TW_UINT32 _size;
- [FieldOffset(532)]
+ //[FieldOffset(532)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)]
string _createTimeDate;
- [FieldOffset(566)]
+ //[FieldOffset(566)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String32)]
string _modifiedTimeDate;
- [FieldOffset(600)]
+ //[FieldOffset(600)]
TW_UINT32 _freeSpace;
- [FieldOffset(604)]
+ //[FieldOffset(604)]
TW_INT32 _newImageSize;
- [FieldOffset(608)]
+ //[FieldOffset(608)]
TW_UINT32 _numberOfFiles;
- [FieldOffset(612)]
+ //[FieldOffset(612)]
TW_UINT32 _numberOfSnippets;
- [FieldOffset(616)]
+ //[FieldOffset(616)]
TW_UINT32 _deviceGroupMask;
- [FieldOffset(620)]
+ //[FieldOffset(620)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 508)]
TW_INT8[] _reserved;
}
diff --git a/NTwain/Data/TypesExtended.cs b/NTwain/Data/TypesExtended.cs
index 25abb27..345604b 100644
--- a/NTwain/Data/TypesExtended.cs
+++ b/NTwain/Data/TypesExtended.cs
@@ -470,9 +470,21 @@ namespace NTwain.Data
///
public TWDecodeFunction[] Decode { get { return _decode; } set { _decode = value; } }
///
- /// 3x3 matrix that specifies how channels are mixed in.
+ /// Flattened 3x3 matrix that specifies how channels are mixed in.
///
- public TWFix32[][] Mix { get { return _mix; } set { _mix = value; } }
+ public TWFix32[] Mix { get { return _mix; } set { _mix = value; } }
+
+ ///
+ /// Gets the value as matrix.
+ ///
+ ///
+ public TWFix32[,] GetMixMatrix()
+ {
+ // from http://stackoverflow.com/questions/3845235/convert-array-to-matrix, haven't tested it
+ TWFix32[,] mat = new TWFix32[3, 3];
+ Buffer.BlockCopy(_mix, 0, mat, 0, _mix.Length * 4);
+ return mat;
+ }
}
///
@@ -1606,9 +1618,8 @@ namespace NTwain.Data
/// all subdirectories in the directory being deleted; or copies all
/// sub-directories in the directory being copied.
///
- public short Recursive { get { return _recursive; } set { _recursive = value; } }
- public bool Subdirectories { get { return _subdirectories == TwainConst.True; } }
-
+ public bool Recursive { get { return _subdirectories == TwainConst.True; } set { _subdirectories = value ? TwainConst.True : TwainConst.False; } }
+
///
/// Gets the type of the file.
///
@@ -1616,8 +1627,7 @@ namespace NTwain.Data
/// The type of the file.
///
public FileType FileType { get { return (FileType)_fileType; } set { _fileType = (int)value; } }
- public uint FileSystemType { get { return _fileSystemType; } set { _fileSystemType = value; } }
-
+
///
/// If , total size of media in bytes.
/// If , size of image in bytes.
diff --git a/NTwain/Triplets/DGControl/DGControl.XferGroup.cs b/NTwain/Triplets/DGControl/DGControl.XferGroup.cs
index f3a0e11..65fa674 100644
--- a/NTwain/Triplets/DGControl/DGControl.XferGroup.cs
+++ b/NTwain/Triplets/DGControl/DGControl.XferGroup.cs
@@ -17,7 +17,7 @@ namespace NTwain.Triplets
///
/// The value.
///
- public ReturnCode Get(ref uint value)
+ public ReturnCode Get(ref DataGroups value)
{
Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Get);
return PInvoke.DsmEntry(Session.GetAppId(), Session.SourceId, DataGroups.Control, DataArgumentType.XferGroup, Message.Get, ref value);
@@ -30,7 +30,7 @@ namespace NTwain.Triplets
///
/// The value.
///
- public ReturnCode Set(uint value)
+ public ReturnCode Set(DataGroups value)
{
Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Set);
return PInvoke.DsmEntry(Session.GetAppId(), Session.SourceId, DataGroups.Control, DataArgumentType.XferGroup, Message.Set, ref value);
diff --git a/NTwain/Triplets/PInvoke.Linux.cs b/NTwain/Triplets/PInvoke.Linux.cs
index 5e24741..80d386d 100644
--- a/NTwain/Triplets/PInvoke.Linux.cs
+++ b/NTwain/Triplets/PInvoke.Linux.cs
@@ -28,7 +28,7 @@ namespace NTwain.Triplets
// DataGroups dg,
// DataArgumentType dat,
// Message msg,
- // ref uint data);
+ // ref DataGroups data);
// [DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "#1")]
// public static extern ReturnCode DsmEntryLinux(
diff --git a/NTwain/Triplets/PInvoke.Win32.cs b/NTwain/Triplets/PInvoke.Win32.cs
index 52f7b67..1d8f049 100644
--- a/NTwain/Triplets/PInvoke.Win32.cs
+++ b/NTwain/Triplets/PInvoke.Win32.cs
@@ -25,7 +25,7 @@ namespace NTwain.Triplets
DataGroups dg,
DataArgumentType dat,
Message msg,
- ref uint data);
+ ref DataGroups data);
[DllImport("twain_32", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry32(
diff --git a/NTwain/Triplets/PInvoke.Win64.cs b/NTwain/Triplets/PInvoke.Win64.cs
index 0664a5f..a78cd2f 100644
--- a/NTwain/Triplets/PInvoke.Win64.cs
+++ b/NTwain/Triplets/PInvoke.Win64.cs
@@ -25,7 +25,7 @@ namespace NTwain.Triplets
DataGroups dg,
DataArgumentType dat,
Message msg,
- ref uint data);
+ ref DataGroups data);
[DllImport("twaindsm", EntryPoint = "#1")]
public static extern ReturnCode DsmEntry64(
diff --git a/NTwain/Triplets/PInvoke.cs b/NTwain/Triplets/PInvoke.cs
index 4e44162..1d5aa00 100644
--- a/NTwain/Triplets/PInvoke.cs
+++ b/NTwain/Triplets/PInvoke.cs
@@ -53,7 +53,7 @@ namespace NTwain.Triplets
DataGroups dg,
DataArgumentType dat,
Message msg,
- ref uint data)
+ ref DataGroups data)
{
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); }
else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); }
diff --git a/NTwain/TwainSession.cs b/NTwain/TwainSession.cs
index c36643a..01c2d8a 100644
--- a/NTwain/TwainSession.cs
+++ b/NTwain/TwainSession.cs
@@ -603,7 +603,7 @@ namespace NTwain
// My guess is the DS needs to see the Success return code first before letting transfer happen
// so this is an hack to make it happen.
- // TODO: find a better method.
+ // TODO: find a better method without needing a SynchronizationContext.
ThreadPool.QueueUserWorkItem(o =>
{
var ctx = o as SynchronizationContext;
@@ -669,12 +669,19 @@ namespace NTwain
///
protected virtual void DoTransferRoutine()
{
- // TODO: better way to determine what's being xfered?
- if ((SourceId.DataGroup & DataGroups.Image) == DataGroups.Image)
+ DataGroups xferGroup = DataGroups.None;
+
+ if (DGControl.XferGroup.Get(ref xferGroup) != ReturnCode.Success)
+ {
+ xferGroup = DataGroups.None;
+ }
+
+ // support one or the other or both?
+ if ((xferGroup & DataGroups.Image) == DataGroups.Image)
{
DoImageXfer();
}
- else if ((SourceId.DataGroup & DataGroups.Audio) == DataGroups.Audio)
+ else if ((xferGroup & DataGroups.Audio) == DataGroups.Audio)
{
DoAudioXfer();
}
@@ -725,8 +732,7 @@ namespace NTwain
rc = DGControl.PendingXfers.Reset(pending);
if (rc == ReturnCode.Success)
{
- // TODO: verify if audio exit directly?
- return;
+ break;
}
}
else if (!preXferArgs.CancelCurrent)
diff --git a/NTwain/TwainSessionOld.cs b/NTwain/TwainSessionOld.cs
index 82ebea7..741cc38 100644
--- a/NTwain/TwainSessionOld.cs
+++ b/NTwain/TwainSessionOld.cs
@@ -97,8 +97,6 @@ namespace NTwain
#region do xfer
- // TODO: expose all swallowed exceptions somehow later
-
IntPtr dataPtr = IntPtr.Zero;
IntPtr lockedPtr = IntPtr.Zero;
string file = null;