예제 #1
0
        public ArrayList TransferPictures()
        {
            ArrayList pics = new ArrayList();

            if (srcds.Id == IntPtr.Zero)
            {
                return(pics);
            }

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

            do
            {
                pxfr.Count = 0;
                hbitmap    = IntPtr.Zero;

                TwImageInfo iinf = new TwImageInfo();
                rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf);
                if (rc != TwRC.Success)
                {
                    CloseSrc();
                    return(pics);
                }

                rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
                if (rc != TwRC.XferDone)
                {
                    CloseSrc();
                    return(pics);
                }

                rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr);
                if (rc != TwRC.Success)
                {
                    CloseSrc();
                    return(pics);
                }

                pics.Add(hbitmap);
            }while (pxfr.Count != 0);

            rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pxfr);
            return(pics);
        }
 private static extern TwRC DSiinf([In, Out] TwIdentity origin, [In] TwIdentity dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TwImageInfo imginf);
        public void TransferPictures()
        {
            ArrayList pics = new ArrayList();

            if (srcds.Id == IntPtr.Zero)
            {
                return;
            }

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

            do
            {
                pxfr.Count = 0;
                hbitmap    = IntPtr.Zero;

                TwImageInfo iinf = new TwImageInfo();
                rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf);
                if (rc != TwRC.Success)
                {
                    CloseSrc();
                    return;
                }

                //verificar

                /*
                 * var guid = Guid.NewGuid();
                 * TwSetupFileXFfer tw_setfilexfer = new TwSetupFileXFfer(@"c:\temp\acs\"+guid.ToString()+".tiff", 0);//0=tif
                 *
                 * rc = DScap(appid, srcds, TwDG.Control, TwDAT.SetupFileXfer, TwMSG.Set, tw_setfilexfer);
                 * if (rc != TwRC.Success)
                 * {
                 *  CloseSrc();
                 *  return;
                 * }
                 */
                //rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageFileXfer, TwMSG.Get, ref hbitmap);
                rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
                if (rc != TwRC.XferDone)
                {
                    CloseSrc();
                    return;
                }

                rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr);
                if (rc != TwRC.Success)
                {
                    CloseSrc();
                    return;
                }

                if (TransferPictureEvent != null && hbitmap != IntPtr.Zero)
                {
                    var bmp = TwainBitmapConvertor.ToBitmap(hbitmap);
                    TransferPictureEvent(ref bmp);
                }
            }while (pxfr.Count != 0);

            rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pxfr);
            return;
        }
예제 #4
0
파일: Twain.cs 프로젝트: code-mtnit/WPFSM
        public ArrayList TransferPictures()
        {
            ArrayList arrayList = new ArrayList();
            ArrayList result;

            if (this.srcds.Id == IntPtr.Zero)
            {
                result = arrayList;
            }
            else
            {
                IntPtr         zero           = IntPtr.Zero;
                TwPendingXfers twPendingXfers = new TwPendingXfers();
                TwRC           twRC;
                while (true)
                {
                    twPendingXfers.Count = 0;
                    zero = IntPtr.Zero;
                    TwImageInfo imginf = new TwImageInfo();
                    twRC = Twain.DSiinf(this.appid, this.srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, imginf);
                    if (twRC != TwRC.Success)
                    {
                        break;
                    }
                    twRC = Twain.DSixfer(this.appid, this.srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref zero);
                    if (twRC != TwRC.XferDone)
                    {
                        goto Block_3;
                    }
                    twRC = Twain.DSpxfer(this.appid, this.srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, twPendingXfers);
                    if (twRC != TwRC.Success)
                    {
                        goto Block_4;
                    }
                    arrayList.Add(zero);
                    if (this.ScanedImage != null)
                    {
                        this.ScanedImage(zero, new ImageEvent());
                    }
                    if (twPendingXfers.Count == 0)
                    {
                        goto Block_6;
                    }
                }
                result = arrayList;
                return(result);

Block_3:
                result = arrayList;
                return(result);

Block_4:
                result = arrayList;
                return(result);

Block_6:
                twRC   = Twain.DSpxfer(this.appid, this.srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, twPendingXfers);
                result = arrayList;
            }
            return(result);
        }
예제 #5
0
        public System.Collections.Generic.List <string> TransferePicturesSaveImmediate(string ScanPath, string ScanTitle)
        {
            System.Collections.Generic.List <string> pics = new System.Collections.Generic.List <string>();
            if (srcds.Id == IntPtr.Zero)
            {
                return(pics);
            }

            TwRC           rc;
            IntPtr         hbitmap      = IntPtr.Zero;
            TwPendingXfers pxfr         = new TwPendingXfers();
            bool           boolEven     = false;
            string         LastFileName = "";

            #region do while
            do
            {
                pxfr.Count = 0;
                hbitmap    = IntPtr.Zero;

                TwImageInfo iinf = new TwImageInfo();
                rc = DSiinf(appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf);
                if (rc != TwRC.Success)
                {
                    CloseSrc();
                    return(pics);
                }

                rc = DSixfer(appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap);
                if (rc != TwRC.XferDone)
                {
                    CloseSrc();
                    return(pics);
                }

                rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr);
                if (rc != TwRC.Success)
                {
                    CloseSrc();
                    return(pics);
                }

                #region add ab file end
                string desFileName;
                if (boolEven)
                {
                    desFileName = ScanPath + ScanTitle + LastFileName + "_B";
                }
                else
                {
                    LastFileName = DateTime.Now.ToString("_yyMMddHHmmssffff");
                    System.Threading.Thread.Sleep(1);
                    desFileName = ScanPath + ScanTitle + LastFileName + "_A";
                }
                boolEven = !boolEven;
                #endregion

                DJScan.PicForm newpic = new DJScan.PicForm(hbitmap);
                newpic.Text = desFileName;
                pics.Add(desFileName + ".bmp");
                newpic.Show();
                newpic.saveImg();
                newpic.Close();
            }while (pxfr.Count != 0);
            #endregion



            rc = DSpxfer(appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pxfr);
            return(pics);
        }
예제 #6
0
        public ArrayList TransferPictures()
        {
            ArrayList pics = new ArrayList();
            if( srcds.Id == IntPtr.Zero )
            return pics;

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

            do
            {
            pxfr.Count = 0;
            hbitmap = IntPtr.Zero;

            TwImageInfo	iinf = new TwImageInfo();
            rc = DSiinf( appid, srcds, TwDG.Image, TwDAT.ImageInfo, TwMSG.Get, iinf );
            if( rc != TwRC.Success )
                {
                CloseSrc();
                return pics;
                }

            rc = DSixfer( appid, srcds, TwDG.Image, TwDAT.ImageNativeXfer, TwMSG.Get, ref hbitmap );
            if( rc != TwRC.XferDone )
                {
                CloseSrc();
                return pics;
                }

            rc = DSpxfer( appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.EndXfer, pxfr );
            if( rc != TwRC.Success )
                {
                CloseSrc();
                return pics;
                }

            pics.Add( hbitmap );
            }
            while( pxfr.Count != 0 );

            rc = DSpxfer( appid, srcds, TwDG.Control, TwDAT.PendingXfers, TwMSG.Reset, pxfr );
            return pics;
        }