aforge视频录像,对界面进行重绘

由于项目需要,需要录像的时候在界面加多一个圆圈,并且一起录制下来。

只需要在NewFrame增加以下代码

   private void videoSourcePlayer1_NewFrame(object sender, ref Bitmap image)
        {
            //加个圆圈
            GraphicsPath buttonPath = new GraphicsPath();
            int pHeight = panel1.Height;
            int pWidth = panel1.Width;
            int lX = (pWidth - pHeight) / 2;
            int lY = 0;
            //矩阵
            Rectangle newRectangleOrigin = videoSourcePlayer.ClientRectangle;// new Rectangle(new System.Drawing.Point(lX, lY),new System.Drawing.Size(pHeight, pHeight)); //new Rectangle(videoSourcePlayer.Location, image.Size);
            //圆形
            Rectangle newRectangle = new Rectangle(new System.Drawing.Point(lX-300, lY), new System.Drawing.Size(pHeight+50, pHeight-170));// new Rectangle(new System.Drawing.Point(videoSourcePlayer.ClientRectangle.X, videoSourcePlayer.ClientRectangle.Y), image.Size);//  picturePreview.ClientRectangle;
            newRectangle.Inflate(videoWidth, videoHeight);
            g.DrawEllipse(Pens.Black, newRectangle);
            buttonPath.AddEllipse(newRectangle);
            Region rg = new Region(newRectangleOrigin);//要填充的区域
          
            rg.Exclude(buttonPath);//除去掉的区域
            g.FillRegion(Brushes.Black, rg);
            
        }

  

posted @ 2020-02-27 22:29  博客小莫  阅读(498)  评论(0编辑  收藏  举报