public static extern ReturnCode DsmWin32( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_IMAGEMEMXFER data);
public STS DatImagememxfer(DG a_dg, MSG a_msg, ref TW_IMAGEMEMXFER a_twimagememxfer) { STS sts; // Submit the work to the TWAIN thread... if (this.m_runinuithreaddelegate == null) { if ((m_threadTwain != null) && (m_threadTwain.ManagedThreadId != Thread.CurrentThread.ManagedThreadId)) { lock (m_lockTwain) { // Set our command variables... ThreadData threaddata = default(ThreadData); threaddata.twimagememxfer = a_twimagememxfer; threaddata.dg = a_dg; threaddata.msg = a_msg; threaddata.dat = DAT.IMAGEMEMXFER; m_lIndexDatImagememxfer = m_twaincommand.Submit(threaddata); // Submit the command and wait for the reply... CallerToThreadSet(); ThreadToCallerWaitOne(); // Return the result... a_twimagememxfer = m_twaincommand.Get(m_lIndexDatImagememxfer).twimagememxfer; sts = m_twaincommand.Get(m_lIndexDatImagememxfer).sts; // Clear the command variables... m_twaincommand.Delete(m_lIndexDatImagememxfer); } return (sts); } } // Log it... if (Log.GetLevel() > 0) { Log.LogSendBefore(a_dg.ToString(), DAT.IMAGEMEMXFER.ToString(), a_msg.ToString(), ImagememferToCsv(a_twimagememxfer)); } // Windows... if (ms_platform == Platform.WINDOWS) { // Issue the command... try { if (this.m_runinuithreaddelegate == null) { if (m_blUseLegacyDSM) { sts = (STS)WindowsTwain32DsmEntryImagememxfer(ref m_twidentitylegacyApp, ref m_twidentitylegacyDs, a_dg, DAT.IMAGEMEMXFER, a_msg, ref a_twimagememxfer); } else { sts = (STS)WindowsTwaindsmDsmEntryImagememxfer(ref m_twidentitylegacyApp, ref m_twidentitylegacyDs, a_dg, DAT.IMAGEMEMXFER, a_msg, ref a_twimagememxfer); } } else { if (m_blUseLegacyDSM) { lock (m_lockTwain) { ThreadData threaddata = default(ThreadData); threaddata.twimagememxfer = a_twimagememxfer; threaddata.dg = a_dg; threaddata.msg = a_msg; threaddata.dat = DAT.IMAGEMEMXFER; m_lIndexDatImagememxfer = m_twaincommand.Submit(threaddata); RunInUiThread(DatImagememxferWindowsTwain32); a_twimagememxfer = m_twaincommand.Get(m_lIndexDatImagememxfer).twimagememxfer; sts = m_twaincommand.Get(m_lIndexDatImagememxfer).sts; m_twaincommand.Delete(m_lIndexDatImagememxfer); } } else { lock (m_lockTwain) { ThreadData threaddata = default(ThreadData); threaddata.twimagememxfer = a_twimagememxfer; threaddata.dg = a_dg; threaddata.msg = a_msg; threaddata.dat = DAT.IMAGEMEMXFER; m_lIndexDatImagememxfer = m_twaincommand.Submit(threaddata); RunInUiThread(DatImagememxferWindowsTwainDsm); a_twimagememxfer = m_twaincommand.Get(m_lIndexDatImagememxfer).twimagememxfer; sts = m_twaincommand.Get(m_lIndexDatImagememxfer).sts; m_twaincommand.Delete(m_lIndexDatImagememxfer); } } } } catch { // The driver crashed... Log.LogSendAfter(STS.BUMMER.ToString(), ""); return (STS.BUMMER); } } // Linux... else if (ms_platform == Platform.LINUX) { // Issue the command... try { if (TWAIN.GetMachineWordBitSize() == 32) { sts = (STS)LinuxDsmEntryImagememxfer(ref m_twidentitylegacyApp, ref m_twidentitylegacyDs, a_dg, DAT.IMAGEMEMXFER, a_msg, ref a_twimagememxfer); } else { TW_IMAGEMEMXFER_LINUX64 twimagememxferlinux64 = default(TW_IMAGEMEMXFER_LINUX64); twimagememxferlinux64.BytesPerRow = a_twimagememxfer.BytesPerRow; twimagememxferlinux64.BytesWritten = a_twimagememxfer.BytesWritten; twimagememxferlinux64.Columns = a_twimagememxfer.Columns; twimagememxferlinux64.Compression = a_twimagememxfer.Compression; twimagememxferlinux64.MemoryFlags = a_twimagememxfer.Memory.Flags; twimagememxferlinux64.MemoryLength = a_twimagememxfer.Memory.Length; twimagememxferlinux64.MemoryTheMem = a_twimagememxfer.Memory.TheMem; twimagememxferlinux64.Rows = a_twimagememxfer.Rows; twimagememxferlinux64.XOffset = a_twimagememxfer.XOffset; twimagememxferlinux64.YOffset = a_twimagememxfer.YOffset; sts = (STS)Linux64DsmEntryImagememxfer(ref m_twidentityApp, ref m_twidentityDs, a_dg, DAT.IMAGEMEMXFER, a_msg, ref twimagememxferlinux64); a_twimagememxfer.BytesPerRow = (uint)twimagememxferlinux64.BytesPerRow; a_twimagememxfer.BytesWritten = (uint)twimagememxferlinux64.BytesWritten; a_twimagememxfer.Columns = (uint)twimagememxferlinux64.Columns; a_twimagememxfer.Compression = (ushort)twimagememxferlinux64.Compression; a_twimagememxfer.Memory.Flags = (uint)twimagememxferlinux64.MemoryFlags; a_twimagememxfer.Memory.Length = (uint)twimagememxferlinux64.MemoryLength; a_twimagememxfer.Memory.TheMem = twimagememxferlinux64.MemoryTheMem; a_twimagememxfer.Rows = (uint)twimagememxferlinux64.Rows; a_twimagememxfer.XOffset = (uint)twimagememxferlinux64.XOffset; a_twimagememxfer.YOffset = (uint)twimagememxferlinux64.YOffset; } } catch { // The driver crashed... Log.LogSendAfter(STS.BUMMER.ToString(), ""); return (STS.BUMMER); } } // Mac OS X, which has to be different... else if (ms_platform == Platform.MACOSX) { // Issue the command... try { TW_IMAGEMEMXFER_MACOSX twimagememxfermacosx = default(TW_IMAGEMEMXFER_MACOSX); twimagememxfermacosx.BytesPerRow = a_twimagememxfer.BytesPerRow; twimagememxfermacosx.BytesWritten = a_twimagememxfer.BytesWritten; twimagememxfermacosx.Columns = a_twimagememxfer.Columns; twimagememxfermacosx.Compression = a_twimagememxfer.Compression; twimagememxfermacosx.Memory.Flags = a_twimagememxfer.Memory.Flags; twimagememxfermacosx.Memory.Length = a_twimagememxfer.Memory.Length; twimagememxfermacosx.Memory.TheMem = a_twimagememxfer.Memory.TheMem; twimagememxfermacosx.Rows = a_twimagememxfer.Rows; twimagememxfermacosx.XOffset = a_twimagememxfer.XOffset; twimagememxfermacosx.YOffset = a_twimagememxfer.YOffset; sts = (STS)MacosxDsmEntryImagememxfer(ref m_twidentitymacosxApp, ref m_twidentitymacosxDs, a_dg, DAT.IMAGEMEMXFER, a_msg, ref twimagememxfermacosx); a_twimagememxfer.BytesPerRow = twimagememxfermacosx.BytesPerRow; a_twimagememxfer.BytesWritten = twimagememxfermacosx.BytesWritten; a_twimagememxfer.Columns = twimagememxfermacosx.Columns; a_twimagememxfer.Compression = (ushort)twimagememxfermacosx.Compression; a_twimagememxfer.Memory.Flags = twimagememxfermacosx.Memory.Flags; a_twimagememxfer.Memory.Length = twimagememxfermacosx.Memory.Length; a_twimagememxfer.Memory.TheMem = twimagememxfermacosx.Memory.TheMem; a_twimagememxfer.Rows = twimagememxfermacosx.Rows; a_twimagememxfer.XOffset = twimagememxfermacosx.XOffset; a_twimagememxfer.YOffset = twimagememxfermacosx.YOffset; } catch { // The driver crashed... Log.LogSendAfter(STS.BUMMER.ToString(), ""); return (STS.BUMMER); } } // Uh-oh... else { Log.LogSendAfter(STS.BUMMER.ToString(), ""); return (STS.BUMMER); } // Log it... if (Log.GetLevel() > 0) { Log.LogSendAfter(sts.ToString(), ImagememferToCsv(a_twimagememxfer)); } // If we had a successful transfer, then change state... if (sts == STS.XFERDONE) { m_state = STATE.S7; } // All done... return (AutoDatStatus(sts)); }
private static extern UInt16 LinuxDsmEntryImagememxfer ( ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest, DG dg, DAT dat, MSG msg, ref TW_IMAGEMEMXFER twimagememxfer );
/// <summary> /// Convert the contents of an image mem xfer structure to a string that /// we can show in our simple GUI... /// </summary> /// <param name="a_twsetupfilexfer">A TWAIN structure</param> /// <returns>A CSV string of the TWAIN structure</returns> public string ImagememferToCsv(TW_IMAGEMEMXFER a_twimagememxfer) { try { CSV csv = new CSV(); csv.Add("TWCP_" + (TWCP)a_twimagememxfer.Compression); csv.Add(a_twimagememxfer.BytesPerRow.ToString()); csv.Add(a_twimagememxfer.Columns.ToString()); csv.Add(a_twimagememxfer.Rows.ToString()); csv.Add(a_twimagememxfer.XOffset.ToString()); csv.Add(a_twimagememxfer.YOffset.ToString()); csv.Add(a_twimagememxfer.BytesWritten.ToString()); csv.Add(a_twimagememxfer.Memory.Flags.ToString()); csv.Add(a_twimagememxfer.Memory.Length.ToString()); csv.Add(a_twimagememxfer.Memory.TheMem.ToString()); return (csv.Get()); } catch { return ("***error***"); } }
private static extern UInt16 WindowsTwaindsmDsmEntryImagememfilexfer ( ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest, DG dg, DAT dat, MSG msg, ref TW_IMAGEMEMXFER twimagememxfer );