基本信息
源码名称:WPF写的显示实时视频和帧率的库(源码+示例)
源码大小:0.33M
文件格式:.zip
开发语言:C#
更新时间:2018-01-18
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using System.Windows.Media;
using System.Runtime.InteropServices;
using System.Windows.Media.Animation;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Data;

namespace WpfCap
{
    public class CapPlayer : Image,IDisposable
    {
        public CapPlayer()
        {
            initBitmap();
            Application.Current.Exit  = new ExitEventHandler(Current_Exit);

            
        }

        void Current_Exit(object sender, ExitEventArgs e)
        {
            this.Dispose();
        }
        void initBitmap()
        {
            
            if (_device == null)
            {
                _device = new CapDevice();
                _device.OnNewBitmapReady  = new EventHandler(_device_OnNewBitmapReady);
            }
            else
            {
                _device.Start();
            }
        }

        void _device_OnNewBitmapReady(object sender, EventArgs e)
        {
            Binding b = new Binding();
            b.Source = _device;
            b.Path = new PropertyPath(CapDevice.FramerateProperty);
            this.SetBinding(CapPlayer.FramerateProperty, b);

            this.Source = _device.BitmapSource;
        }

        
        CapDevice _device;


        public float Framerate
        {
            get { return (float)GetValue(FramerateProperty); }
            set { SetValue(FramerateProperty, value); }
        }
        public static readonly DependencyProperty FramerateProperty =
            DependencyProperty.Register("Framerate", typeof(float), typeof(CapPlayer), new UIPropertyMetadata(default(float)));








        #region IDisposable Members

        public void Dispose()
        {
            if (_device != null)
                _device.Dispose();
        }

        #endregion
    }
}