Aforge.net摄像头旋转代码

最近有需求摄像头旋转,找了很多资料没有源代码,看了aforge.net源码,分析之后,实现了效果,分享个需要的童鞋。


public void videoSourcePlayer_NewFrame(object sender, ref Bitmap image)
        {
            if (image != null)
            {
                RotateFlipType pType = RotateFlipType.RotateNoneFlipNone;
                if (dAngle == 0)
                {
                    pType = RotateFlipType.RotateNoneFlipNone;
                }
                else if (dAngle == 90)
                {
                    pType = RotateFlipType.Rotate90FlipNone;
                }
                else if (dAngle == 180)
                {
                    pType = RotateFlipType.Rotate180FlipNone;
                }
                else if (dAngle == 270)
                {
                    pType = RotateFlipType.Rotate270FlipNone;
                }


                // 实时按角度绘制
                image.RotateFlip(pType);
            }
        }


        /// <summary>
        /// 旋转函数,外部调用触发
        /// </summary>
        public void Rotate()
        {
            // 计算角度,类变量
            dAngle = dAngle + 90;
            dAngle = dAngle % 360;
            
            // 事件绑定,实时绘制,达到效果,本来就是实时绘制的原理
            videoSourcePlayer.NewFrame -= new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer_NewFrame);
            videoSourcePlayer.NewFrame += new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer_NewFrame);
        }
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值