mirror of
https://github.com/soukoku/ntwain.git
synced 2025-04-05 20:59:23 +08:00
Fixed some warnings.
This commit is contained in:
parent
6fff04fc65
commit
54c7fc1d50
@ -181,10 +181,11 @@ namespace WinFormSample
|
||||
// there may be a better way...
|
||||
private string ReadTypedValue(CAP cap, TWTY type, bool forCurrent)
|
||||
{
|
||||
STS sts = default;
|
||||
switch (type)
|
||||
{
|
||||
case TWTY.UINT8:
|
||||
var sts = forCurrent ?
|
||||
sts = forCurrent ?
|
||||
twain.GetCapCurrent(cap, out byte ubval) :
|
||||
twain.GetCapDefault(cap, out ubval);
|
||||
return ubval.ToString();
|
||||
@ -251,6 +252,7 @@ namespace WinFormSample
|
||||
case TWTY.HANDLE:
|
||||
break;
|
||||
}
|
||||
Debug.WriteLine($"{nameof(ReadTypedValue)}({cap}, {type}, {forCurrent}) => {sts}");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ namespace NTwain.Data
|
||||
//}
|
||||
|
||||
// Set the Item...
|
||||
WriteRangeValues(memMgr, lockedPtr, itemType, value);
|
||||
WriteRangeValues(lockedPtr, itemType, value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -301,7 +301,7 @@ namespace NTwain.Data
|
||||
return twCap;
|
||||
}
|
||||
|
||||
static void WriteRangeValues<TValue>(IMemoryManager memMgr, IntPtr lockedPtr, TWTY itemType, Range<TValue> value) where TValue : struct
|
||||
static void WriteRangeValues<TValue>(IntPtr lockedPtr, TWTY itemType, Range<TValue> value) where TValue : struct
|
||||
{
|
||||
// TODO: reduce this later
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace NTwain.Native
|
||||
|
||||
public static unsafe byte[]? GetBitmapData(System.Buffers.ArrayPool<byte> xferMemPool, IntPtr data)
|
||||
{
|
||||
var infoHeader = (BITMAPINFOHEADER)Marshal.PtrToStructure(data, typeof(BITMAPINFOHEADER));
|
||||
var infoHeader = Marshal.PtrToStructure<BITMAPINFOHEADER>(data);
|
||||
if (infoHeader.Validate())
|
||||
{
|
||||
var fileHeaderSize = Marshal.SizeOf(typeof(BITMAPFILEHEADER));
|
||||
@ -75,7 +75,7 @@ namespace NTwain.Native
|
||||
for (int i = 0; i < 999; i++)
|
||||
{
|
||||
tagPtr += (tagSize * i);
|
||||
var tag = (TIFFTAG)Marshal.PtrToStructure((IntPtr)tagPtr, typeof(TIFFTAG));
|
||||
var tag = Marshal.PtrToStructure<TIFFTAG>((IntPtr)tagPtr);
|
||||
|
||||
switch (tag.u16Tag)
|
||||
{
|
||||
|
@ -98,7 +98,9 @@ namespace NTwain
|
||||
|
||||
internal IntPtr _hwnd;
|
||||
internal TW_USERINTERFACE _userInterface; // kept around for disable to use
|
||||
#if WINDOWS || NETFRAMEWORK
|
||||
TW_EVENT _procEvent; // kept here so the alloc/free only happens once
|
||||
#endif
|
||||
// test threads a bit
|
||||
readonly BlockingCollection<MSG> _bgPendingMsgs = new();
|
||||
private readonly IThreadMarshaller _uiThreadMarshaller;
|
||||
@ -165,7 +167,9 @@ namespace NTwain
|
||||
// this will end the bg thread
|
||||
_bgPendingMsgs.CompleteAdding();
|
||||
}
|
||||
#if WINDOWS || NETFRAMEWORK
|
||||
if (_procEvent.pEvent != IntPtr.Zero) Marshal.FreeHGlobal(_procEvent.pEvent);
|
||||
#endif
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
@ -249,7 +253,7 @@ namespace NTwain
|
||||
protected STS WrapInSTS(TWRC rc, bool dsmOnly = false)
|
||||
{
|
||||
if (rc != TWRC.FAILURE) return new STS { RC = rc };
|
||||
var sts = new STS { RC = rc, STATUS = GetLastStatus() };
|
||||
var sts = new STS { RC = rc, STATUS = GetLastStatus(dsmOnly) };
|
||||
if (sts.STATUS.ConditionCode == TWCC.BADDEST)
|
||||
{
|
||||
// TODO: the current ds is bad, should assume we're back in S3?
|
||||
|
Loading…
Reference in New Issue
Block a user