随笔 - 1936  文章 - 0  评论 - 8  阅读 - 44万

TSINGSEE青犀视频H265编码流媒体播放器EasyPlayer-RTMP自定义OSD字体颜色修改开发

EasyPlayer播放器系列项目可以说是目前市面中一款非常开放的播放器项目,用户可以根据自己的需求调用接口或者进行开发,实用性强,稳定性也足够优越。

 

上一篇我们讲了《EasyPlayer-RTMP定制窗体开发》,对于其中OSD的功能仍然有可以继续完善的点,比如用户希望可以自己定义OSD内容的颜色。

默认的是红色字体,如下图:

 

接下来介绍下OSD实现的过程,就可以方便大家自己来修改叠加内容的位置、颜色等信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/// <summary>
        /// 附加信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddScreenFontTSMenuItem_Click(object sender, EventArgs e)
        {
            int ret = -1;
            var rect = new Rect { X = 10, Y = 10, Width = panel1.Width, Height = panel1.Height };
            var panelSize = this.panel1.ClientSize;
  
            PlayerSdk.EASY_PALYER_OSD fontInfo = new PlayerSdk.EASY_PALYER_OSD
            {
                alpha = 255,
                size = 35,
                color = (uint)ToArgb(Color.Red),
                shadowcolor = (uint)ToArgb(Color.Black),
                stOSD = XMLOperate.BYCSB,
                rect = new PlayerSdk.tagRECT { left = (int)rect.X, top = (int)rect.Y, right = (int)rect.Width, bottom = (int)rect.Height }
            };
  
            var checkState = (sender as ToolStripMenuItem).CheckState;
  
            if (checkState == CheckState.Unchecked)
            {
                ret = PlayerSdk.EasyPlayer_ShowOSD(channelID, fontInfo);
                (sender as ToolStripMenuItem).CheckState = CheckState.Checked;
            }
            if (checkState == CheckState.Checked)
            {
                ret = PlayerSdk.EasyPlayer_ShowOSD(channelID, fontInfo, false);
                (sender as ToolStripMenuItem).CheckState = CheckState.Unchecked;
            }
        }
  
OSD有定义一个结构体如下:color可以修改颜色,stOSD传参是需要显示的内容,tagRECT也是一个结构体,可以自己定义显示位置。
/// <summary>
        /// OSD 信息集合
        /// </summary>
        [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public struct EASY_PALYER_OSD
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
            public string stOSD;
            public uint alpha;        //0-255
            public uint color;        //RGB(0xf9,0xf9,0xf9)
            public uint shadowcolor;      //RGB(0x4d,0x4d,0x4d) 全为0背景透明
            public tagRECT rect;      //OSD基于图像右上角显示区域
            public int size;       //just D3D Support
        }
  
/// <summary>
        /// 像素信息
        /// </summary>
        [StructLayoutAttribute(LayoutKind.Sequential)]
        public struct tagRECT
        {
            public int left;
            public int top;
            public int right;
            public int bottom;
        }

我们将color赋值为 (uint)ToArgb(Color.Yellow),如下效果:

 

 其他颜色也可以通过此种方式进行赋值。

 

 

posted on   TSINGSEE  阅读(104)  评论(0编辑  收藏  举报
< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示