Пример #1
0
 private static extern TwRC DSiinf([In, Out] TwIdentity origin, [In] TwIdentity dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TwImageInfo imginf);
Пример #2
0
        /// <summary>
        /// Transfers images from the scanner. Starts image processing by processing delegate chains.
        /// </summary>
        /// <param name="siteId"></param>
        /// <returns></returns>
        public bool TransferPictures(Voucher voucherData)
        {
            if (m_srcDs.Id == IntPtr.Zero)
            {
                return(false);
            }

            TwRC           rc;
            IntPtr         hbitmap = IntPtr.Zero;
            TwPendingXfers pxfr    = new TwPendingXfers();

            do
            {
                pxfr.Count = 0;

                try
                {
                    //Acquirs image from scanner
                    TwImageInfo iinf = new TwImageInfo();
                    rc = DSiinf(m_appId, m_srcDs, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf);
                    if (rc != TwRC.Success)
                    {
                        return(false);
                    }

                    rc = DSixfer(m_appId, m_srcDs, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
                    if (rc != TwRC.XferDone)
                    {
                        return(false);
                    }

                    rc = DSpxfer(m_appId, m_srcDs, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr);
                    if (rc != TwRC.Success)
                    {
                        return(false);
                    }

                    //Reads voucher data from common context
                    if (voucherData == null)
                    {
                        voucherData = ScanAppContext.FillFromScanContext(new Voucher());
                    }

                    //Creates temporary state object
                    StateObj stateObj = new StateObj()
                    {
                        Main = MainForm,
                        Scan = ScanForm,
                        Dib  = hbitmap,
                    };

                    //Creates processing delegate chain. Start processing the image.
                    var del = DelegateUtils.GetProcessDelegateChain();
                    del.FireAndForget(voucherData, stateObj);
                    voucherData = null;
                }
                finally
                {
                    DSpxfer(m_appId, m_srcDs, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pxfr);
                }
            }while (pxfr.Count != 0 && !UseImprinter);
            return(true);
        }