【问题标题】:Twain scan output convert intptr to imageTwain 扫描输出将 intptr 转换为图像
【发布时间】:2014-05-21 05:04:32
【问题描述】:

使用 twain 扫描仪扫描并在 Mdi 表单内显示代码显示输出我需要将其显示在图片框内,可以吗?我尝试了一些关于将 intptr 转换为 image 或 somethnig 的方法,但没有找到正确的方法。

下面的代码;

                        case TwainCommand.TransferReady:
                        {
                        ArrayList pics = tw.TransferPictures();
                        EndingScan();
                        tw.CloseSrc();
                        picnumber++;
                        for (int i = 0; i < pics.Count; i++)
                        {
                          IntPtr img = (IntPtr)pics[i];
                          PicForm newpic = new PicForm(img);
                          newpic.MdiParent = this;
                          int picnum = i + 1;
                          newpic.Text = "ScanPass" + picnumber.ToString() + "_Pic" +                picnum.ToString();
                         newpic.Show();
                        }
                        break;

            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;
        }

【问题讨论】:

    标签: c# twain image-scanner


    【解决方案1】:

    您可以使用位图构造函数。更多信息可以在以下位置找到: http://msdn.microsoft.com/en-us/library/zy1a2d14.aspx

    【讨论】:

      猜你喜欢
      • 2015-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多