mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-24 08:47:06 +08:00
Try to fix range value reader.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--change these in each release-->
|
||||
<VersionPrefix>4.0.0.0</VersionPrefix>
|
||||
<VersionSuffix>alpha.10</VersionSuffix>
|
||||
<VersionSuffix>alpha.11</VersionSuffix>
|
||||
|
||||
<!--keep it the same until major # changes-->
|
||||
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
||||
|
||||
@@ -259,79 +259,29 @@ namespace NTwain.Data
|
||||
|
||||
try
|
||||
{
|
||||
TW_RANGE twrange = default;
|
||||
TW_RANGE_FIX32 twrangefix32 = default;
|
||||
|
||||
TWTY itemType;
|
||||
// Mac has a level of indirection and a different structure (ick)...
|
||||
if (TWPlatform.IsMacOSX)
|
||||
{
|
||||
var twrangemacosx = MarshalTo<TW_RANGE_MACOSX>(lockedPtr);
|
||||
var twrangefix32macosx = MarshalTo<TW_RANGE_FIX32_MACOSX>(lockedPtr);
|
||||
twrange.ItemType = (TWTY)twrangemacosx.ItemType;
|
||||
twrange.MinValue = twrangemacosx.MinValue;
|
||||
twrange.MaxValue = twrangemacosx.MaxValue;
|
||||
twrange.StepSize = twrangemacosx.StepSize;
|
||||
twrange.DefaultValue = twrangemacosx.DefaultValue;
|
||||
twrange.CurrentValue = twrangemacosx.CurrentValue;
|
||||
twrangefix32.ItemType = (TWTY)twrangefix32macosx.ItemType;
|
||||
twrangefix32.MinValue = twrangefix32macosx.MinValue;
|
||||
twrangefix32.MaxValue = twrangefix32macosx.MaxValue;
|
||||
twrangefix32.StepSize = twrangefix32macosx.StepSize;
|
||||
twrangefix32.DefaultValue = twrangefix32macosx.DefaultValue;
|
||||
twrangefix32.CurrentValue = twrangefix32macosx.CurrentValue;
|
||||
itemType = (TWTY)Marshal.ReadInt32(lockedPtr);
|
||||
lockedPtr += 4;
|
||||
}
|
||||
// Windows or the 2.4+ Linux DSM...
|
||||
else
|
||||
{
|
||||
twrange = MarshalTo<TW_RANGE>(lockedPtr);
|
||||
twrangefix32 = MarshalTo<TW_RANGE_FIX32>(lockedPtr);
|
||||
}
|
||||
// The -2.3 Linux DSM...
|
||||
//else
|
||||
//{
|
||||
// var twrangelinux64 = MarshalTo<TW_RANGE_LINUX64>(lockedPtr);
|
||||
// var twrangefix32macosx = MarshalTo<TW_RANGE_FIX32_MACOSX>(lockedPtr);
|
||||
// twrange.ItemType = twrangelinux64.ItemType;
|
||||
// twrange.MinValue = (uint)twrangelinux64.MinValue;
|
||||
// twrange.MaxValue = (uint)twrangelinux64.MaxValue;
|
||||
// twrange.StepSize = (uint)twrangelinux64.StepSize;
|
||||
// twrange.DefaultValue = (uint)twrangelinux64.DefaultValue;
|
||||
// twrange.CurrentValue = (uint)twrangelinux64.CurrentValue;
|
||||
// twrangefix32.ItemType = (TWTY)twrangefix32macosx.ItemType;
|
||||
// twrangefix32.MinValue = twrangefix32macosx.MinValue;
|
||||
// twrangefix32.MaxValue = twrangefix32macosx.MaxValue;
|
||||
// twrangefix32.StepSize = twrangefix32macosx.StepSize;
|
||||
// twrangefix32.DefaultValue = twrangefix32macosx.DefaultValue;
|
||||
// twrangefix32.CurrentValue = twrangefix32macosx.CurrentValue;
|
||||
//}
|
||||
|
||||
switch (twrange.ItemType)
|
||||
{
|
||||
// use dynamic since I know they fit the type.
|
||||
case TWTY.FIX32:
|
||||
retVal.MinValue = (dynamic)twrangefix32.MinValue;
|
||||
retVal.MaxValue = (dynamic)twrangefix32.MaxValue;
|
||||
retVal.StepSize = (dynamic)twrangefix32.StepSize;
|
||||
retVal.CurrentValue = (dynamic)twrangefix32.CurrentValue;
|
||||
retVal.DefaultValue = (dynamic)twrangefix32.DefaultValue;
|
||||
break;
|
||||
case TWTY.INT8:
|
||||
case TWTY.UINT8:
|
||||
case TWTY.INT16:
|
||||
case TWTY.BOOL:
|
||||
case TWTY.UINT16:
|
||||
case TWTY.INT32:
|
||||
case TWTY.UINT32:
|
||||
retVal.MinValue = (dynamic)twrange.MinValue;
|
||||
retVal.MaxValue = (dynamic)twrange.MaxValue;
|
||||
retVal.StepSize = (dynamic)twrange.StepSize;
|
||||
retVal.CurrentValue = (dynamic)twrange.CurrentValue;
|
||||
retVal.DefaultValue = (dynamic)twrange.DefaultValue;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException($"The value type {twrange.ItemType} is not supported as range.");
|
||||
|
||||
// Windows or the 2.4+ Linux DSM...
|
||||
itemType = (TWTY)Marshal.ReadInt16(lockedPtr);
|
||||
lockedPtr += 2;
|
||||
}
|
||||
retVal.MinValue = ReadTWTYData<TValue>(lockedPtr, itemType, 0);
|
||||
lockedPtr += 4;
|
||||
retVal.MaxValue = ReadTWTYData<TValue>(lockedPtr, itemType, 0);
|
||||
lockedPtr += 4;
|
||||
retVal.StepSize = ReadTWTYData<TValue>(lockedPtr, itemType, 0);
|
||||
lockedPtr += 4;
|
||||
retVal.CurrentValue = ReadTWTYData<TValue>(lockedPtr, itemType, 0);
|
||||
lockedPtr += 4;
|
||||
retVal.DefaultValue = ReadTWTYData<TValue>(lockedPtr, itemType, 0);
|
||||
lockedPtr += 4;
|
||||
return retVal;
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user