mirror of
https://github.com/soukoku/ntwain.git
synced 2025-07-15 09:44:20 +08:00
Moved DetermineBufferSize() to TW_SETUPMEMXFER
This commit is contained in:
parent
830dc8cd9b
commit
633e8b1236
@ -2507,7 +2507,7 @@ namespace NTwain.Data
|
|||||||
/// Provides the application information about the Source’s requirements and preferences regarding allocation of transfer buffer(s).
|
/// Provides the application information about the Source’s requirements and preferences regarding allocation of transfer buffer(s).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||||
public struct TW_SETUPMEMXFER
|
public partial struct TW_SETUPMEMXFER
|
||||||
{
|
{
|
||||||
public uint MinBufSize;
|
public uint MinBufSize;
|
||||||
public uint MaxBufSize;
|
public uint MaxBufSize;
|
||||||
|
@ -762,6 +762,23 @@ namespace NTwain.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial struct TW_SETUPMEMXFER
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Determines the best buffer size from values
|
||||||
|
/// specified by source
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public uint DetermineBufferSize()
|
||||||
|
{
|
||||||
|
if (Preferred != TwainConst.TWON_DONTCARE32) return Preferred;
|
||||||
|
if (MaxBufSize != TwainConst.TWON_DONTCARE32) return MaxBufSize;
|
||||||
|
if (MinBufSize != TwainConst.TWON_DONTCARE32) return MinBufSize;
|
||||||
|
// default to 16 kb if source doesn't really want to say what it needs
|
||||||
|
return 1024 * 16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//partial struct TW_DEVICEEVENT
|
//partial struct TW_DEVICEEVENT
|
||||||
//{
|
//{
|
||||||
// public TWDE Event { get { return (TWDE)_event; } }
|
// public TWDE Event { get { return (TWDE)_event; } }
|
||||||
|
@ -275,7 +275,7 @@ namespace NTwain
|
|||||||
rc = DGControl.SetupMemXfer.Get(ref _appIdentity, ref _currentDS, out TW_SETUPMEMXFER memSetup);
|
rc = DGControl.SetupMemXfer.Get(ref _appIdentity, ref _currentDS, out TW_SETUPMEMXFER memSetup);
|
||||||
if (rc == TWRC.SUCCESS)
|
if (rc == TWRC.SUCCESS)
|
||||||
{
|
{
|
||||||
uint buffSize = DetermineBufferSize(memSetup);
|
uint buffSize = memSetup.DetermineBufferSize();
|
||||||
var memPtr = Alloc(buffSize);
|
var memPtr = Alloc(buffSize);
|
||||||
|
|
||||||
TW_IMAGEMEMXFER memXfer = new()
|
TW_IMAGEMEMXFER memXfer = new()
|
||||||
@ -357,20 +357,6 @@ namespace NTwain
|
|||||||
return WrapInSTS(rc);
|
return WrapInSTS(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static uint DetermineBufferSize(TW_SETUPMEMXFER memSetup)
|
|
||||||
{
|
|
||||||
// default to 16 kb if source doesn't really want to say what it needs
|
|
||||||
var buffSize = memSetup.Preferred;
|
|
||||||
if (buffSize != TwainConst.TWON_DONTCARE32) return buffSize;
|
|
||||||
|
|
||||||
buffSize = memSetup.MaxBufSize;
|
|
||||||
if (buffSize != TwainConst.TWON_DONTCARE32) return buffSize;
|
|
||||||
|
|
||||||
buffSize = memSetup.MinBufSize;
|
|
||||||
if (buffSize != TwainConst.TWON_DONTCARE32) return buffSize;
|
|
||||||
|
|
||||||
return 1024 * 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
private STS TransferFileImage(ref TW_PENDINGXFERS pending)
|
private STS TransferFileImage(ref TW_PENDINGXFERS pending)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user