剪贴板相关

public const int WM_USER = 0x400;

public const int WM_CAP_EDIT_COPY = WM_USER + 30

[DllImport("User32.dll")]
        static extern bool SendMessage(IntPtr hWnd, int wMsg, short wParam, int lParam);

 

 

 

 

                ms = new MemoryStream();
                IDataObject data;
                Image bmap;
                //发送消息,将捕获到的数据复制到剪贴板中去
                SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0);
                data = Clipboard.GetDataObject();
                if (null != data)
                {
                    if (data.GetDataPresent(typeof(System.Drawing.Bitmap)))
                    {
                        //将剪贴板中的图像数据存到一个内存数据流中
                        bmap = ((Image)(data.GetData(typeof(System.Drawing.Bitmap))));
                        bmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        //将流转换为字节数组
                        byte[] datatosend = ms.GetBuffer();
                        //调用RTP的Send函数发送数据
                        rtpSenderVideo.Send(datatosend);
                    }
                }

阅读更多
文章标签: image user byte null
个人分类: C#笔记
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭