mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Try to fix range value reader.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!--change these in each release-->
|
<!--change these in each release-->
|
||||||
<VersionPrefix>4.0.0.0</VersionPrefix>
|
<VersionPrefix>4.0.0.0</VersionPrefix>
|
||||||
<VersionSuffix>alpha.10</VersionSuffix>
|
<VersionSuffix>alpha.11</VersionSuffix>
|
||||||
|
|
||||||
<!--keep it the same until major # changes-->
|
<!--keep it the same until major # changes-->
|
||||||
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
||||||
|
|||||||
@@ -259,79 +259,29 @@ namespace NTwain.Data
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TW_RANGE twrange = default;
|
TWTY itemType;
|
||||||
TW_RANGE_FIX32 twrangefix32 = default;
|
|
||||||
|
|
||||||
// Mac has a level of indirection and a different structure (ick)...
|
// Mac has a level of indirection and a different structure (ick)...
|
||||||
if (TWPlatform.IsMacOSX)
|
if (TWPlatform.IsMacOSX)
|
||||||
{
|
{
|
||||||
var twrangemacosx = MarshalTo<TW_RANGE_MACOSX>(lockedPtr);
|
itemType = (TWTY)Marshal.ReadInt32(lockedPtr);
|
||||||
var twrangefix32macosx = MarshalTo<TW_RANGE_FIX32_MACOSX>(lockedPtr);
|
lockedPtr += 4;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
// Windows or the 2.4+ Linux DSM...
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
twrange = MarshalTo<TW_RANGE>(lockedPtr);
|
// Windows or the 2.4+ Linux DSM...
|
||||||
twrangefix32 = MarshalTo<TW_RANGE_FIX32>(lockedPtr);
|
itemType = (TWTY)Marshal.ReadInt16(lockedPtr);
|
||||||
}
|
lockedPtr += 2;
|
||||||
// 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.");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
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;
|
return retVal;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
Reference in New Issue
Block a user