Twain扫描输出将intptr转换为图像



使用twain扫描仪扫描并在Mdi表单中显示代码输出我需要在图片框中显示它,这可能吗?我尝试了一些将intptr转换为图像或其他东西的方法,但没有找到正确的方法。

下面的代码;

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

您可以使用位图构造函数。更多信息请访问:http://msdn.microsoft.com/en-us/library/zy1a2d14.aspx

相关内容

  • 没有找到相关文章

最新更新