EasyPlayerPro Windows播放器电子放大/局部放大播放功能实现

来源:互联网 发布:缓存服务器软件 编辑:程序博客网 时间:2024/05/16 04:28

背景描述

在视频监控软件中,我们看到很多的软件都有电子放大功能, 按住鼠标左键不放,框选一个区域,再松开鼠标左键,即对选中的区域进行放大显示, 且可以重复该操作,逐步放大所需显示的区域, 有没有觉得,这个功能在视频监控软件中还是有他的用武地. 今天我们就来实现该功能;

EasyPlayerPro

实现流程

//设置电子放大起起始点int     SetElectronicZoomStartPoint(int channelId, float fXPercent, float fYPercent, unsigned char showBox);//设置电子放大结束点(在鼠标移动过程中可一直调用该函数)int     SetElectronicZoomEndPoint(int channelId, float fXPercent, float fYPercent);//设置是否放大显示int     SetElectronicZoom(int channelId, int zoomIn);//复位void    ResetElectronicZoom(int channelId);//直接设置显示区域,用于电子放大, 在某些场合, 需要直接进行缩放显示, 即可调用该函数实现int     SetRenderRect(int channelId, LPRECT lpSrcRect);

EasyPlayerPro

代码实现

int ChannelManager::ElectronicZoomProcess(MEDIA_VIDEO_CHANNEL_OBJ_T *pMediaChannel, EASY_FRAME_INFO *frameInfo){if (NULL == pMediaChannel)              return 0;if (NULL == frameInfo)                  return 0;ELECTRONIC_ZOOM_T *pElectoricZoom = pMediaChannel->pElectoricZoom;if (NULL == pElectoricZoom)             return 0;int nLeft = 0, nTop = 0, nRight = 0, nBottom = 0;if (pElectoricZoom->zoomIn >= 0x01){    RECT rcClient;    GetClientRect(pMediaChannel->mediaDisplay.hWnd, &rcClient);    float fLeftPercent =    pElectoricZoom->fStartPointX;    float fTopPercent  =    pElectoricZoom->fStartPointY;    float fRightPercent =   pElectoricZoom->fEndPointX;    float fBottomPercent  = pElectoricZoom->fEndPointY;    if (fRightPercent > fLeftPercent && fBottomPercent > fTopPercent)               //逐步放大    {        if (pElectoricZoom->fVideoWidth > 0)        {            int video_width = (int)pElectoricZoom->fVideoWidth;            int video_height= (int)pElectoricZoom->fVideoHeight;            nLeft = (int)((float)video_width / 100.0f * fLeftPercent);            nTop  = (int)((float)video_height/ 100.0f * fTopPercent);            nRight = (int)((float)video_width / 100.0f * fRightPercent);            nBottom  = (int)((float)video_height/ 100.0f * fBottomPercent);            if (nRight > nLeft && nBottom > nTop)            {                pElectoricZoom->fVideoWidth = (float)(nRight - nLeft);                pElectoricZoom->fVideoHeight = (float)(nBottom - nTop);                nLeft = pElectoricZoom->startVideoLeft + nLeft;                nTop = pElectoricZoom->startVideoTop + nTop;                nRight = pElectoricZoom->startVideoLeft + nRight;                nBottom = pElectoricZoom->startVideoTop + nBottom;                pElectoricZoom->startVideoLeft = nLeft;                pElectoricZoom->startVideoTop = nTop;                if (pElectoricZoom->zoomIndex + 1 <MAX_ZOOM_IN_TIMES)                {                    SetRect(&pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].rect, nLeft, nTop, nRight, nBottom);                    pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].fVideoWidth = pElectoricZoom->fVideoWidth;                    pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].fVideoHeight = pElectoricZoom->fVideoHeight;                    pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].startVideoLeft = pElectoricZoom->startVideoLeft;                    pElectoricZoom->zoomParam[pElectoricZoom->zoomIndex].startVideoTop = pElectoricZoom->startVideoTop;                    pElectoricZoom->zoomIndex ++;                }            }            else            {                int idx = pElectoricZoom->zoomIndex-2;                if (idx > 0)                {                    nLeft = pElectoricZoom->zoomParam[idx].rect.left;                    nTop = pElectoricZoom->zoomParam[idx].rect.top;                    nRight = pElectoricZoom->zoomParam[idx].rect.right;                    nBottom = pElectoricZoom->zoomParam[idx].rect.bottom;                    pElectoricZoom->fVideoWidth = pElectoricZoom->zoomParam[idx].fVideoWidth;                    pElectoricZoom->fVideoHeight = pElectoricZoom->zoomParam[idx].fVideoHeight;                    pElectoricZoom->startVideoLeft = pElectoricZoom->zoomParam[idx].startVideoLeft;                    pElectoricZoom->startVideoTop = pElectoricZoom->zoomParam[idx].startVideoTop;                }            }        }        else        {            int video_width = frameInfo->width;            int video_height= frameInfo->height;            nLeft = (int)((float)video_width / 100.0f * fLeftPercent);            nTop  = (int)((float)video_height/ 100.0f * fTopPercent);            nRight = (int)((float)video_width / 100.0f * fRightPercent);            nBottom  = (int)((float)video_height/ 100.0f * fBottomPercent);            pElectoricZoom->startVideoLeft = nLeft;            pElectoricZoom->startVideoTop = nTop;            pElectoricZoom->fVideoWidth = (float)(nRight - nLeft);            pElectoricZoom->fVideoHeight = (float)(nBottom - nTop);            SetRect(&pElectoricZoom->zoomParam[0].rect, nLeft, nTop, nRight, nBottom);            pElectoricZoom->zoomParam[0].fVideoWidth = pElectoricZoom->fVideoWidth;            pElectoricZoom->zoomParam[0].fVideoHeight = pElectoricZoom->fVideoHeight;            pElectoricZoom->zoomParam[0].startVideoLeft = pElectoricZoom->startVideoLeft;            pElectoricZoom->zoomParam[0].startVideoTop = pElectoricZoom->startVideoTop;            pElectoricZoom->zoomIndex ++;        }    }    else    {        if (pElectoricZoom->zoomIndex > 1)        {            int idx = pElectoricZoom->zoomIndex-2;            nLeft = pElectoricZoom->zoomParam[idx].rect.left;            nTop = pElectoricZoom->zoomParam[idx].rect.top;            nRight = pElectoricZoom->zoomParam[idx].rect.right;            nBottom = pElectoricZoom->zoomParam[idx].rect.bottom;            pElectoricZoom->fVideoWidth = pElectoricZoom->zoomParam[idx].fVideoWidth;            pElectoricZoom->fVideoHeight = pElectoricZoom->zoomParam[idx].fVideoHeight;            pElectoricZoom->startVideoLeft = pElectoricZoom->zoomParam[idx].startVideoLeft;            pElectoricZoom->startVideoTop = pElectoricZoom->zoomParam[idx].startVideoTop;            pElectoricZoom->zoomIndex --;        }        else        {            pElectoricZoom->fVideoWidth = 0.0f;            nLeft = 0;            nTop = 0;            nRight = frameInfo->width;            nBottom = frameInfo->height;            pElectoricZoom->zoomIndex = 0;        }    }    RECT rcSrc;    SetRect(&rcSrc, nLeft, nTop, nRight, nBottom);    CopyRect(&pMediaChannel->mediaDisplay.rcSrcRender, &rcSrc);    pElectoricZoom->zoomIn --;}return 0;}

关于EasyPlayerPro

EasyPlayerPro是一款全功能的流媒体播放器,支持RTSP、RTMP、HTTP、HLS、UDP、RTP、File等多种流媒体协议播放、支持本地文件播放,支持本地抓拍、本地录像、播放旋转、多屏播放、倍数播放等多种功能特性,核心基于ffmpeg,稳定、高效、可靠、可控,支持Windows、Android、iOS三个平台,目前在多家教育、安防、行业型公司,都得到的应用,广受好评!

EasyPlayerPro:https://github.com/EasyDSS/EasyPlayerPro

点击链接加入群【EasyPlayer & EasyPlayerPro】:544917793

技术支持

  • 邮件:support@easydarwin.org

  • Tel:13718530929

  • QQ交流群:544917793

EasyPlayerPro是一款非常稳定的全协议/全功能播放器组件,各平台版本需要经过授权才能商业使用,商业授权方案可以通过以上渠道进行更深入的技术与合作咨询;

获取更多信息

EasyDarwin开源流媒体服务器:www.EasyDarwin.org

EasyDSS商用流媒体解决方案:www.EasyDSS.com

EasyNVR无插件直播方案:www.EasyNVR.com

Copyright © EasyDarwin Team 2012-2017

EasyDarwin

阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 洋酒杯图片 红酒杯子 葡萄酒杯分类 高档洋酒瓶 洋酒瓶生产厂家 洋酒瓶 洋酒瓶价格 回收洋酒瓶报价 洋酒瓶回收价格 洋酒包装 秦洋酒 洋酒英文 洋酒网站 洋酒批发市场 高档洋酒价格表 洋钱借款 洋钱 洋钱灌 洋钱图片 洋钱罐借款app下载 洋钱罐逾期 2018洋钱罐借款多少利息 洋钱罐逾期会怎么样 洋钱罐贷10000还13500 洋钱罐下载 类似洋钱罐的借款 洋钱罐借款怎么样 洋钱罐现金借款上征信吗 洋钱罐安全吗 洋钱罐理财安全吗 洋钱罐现金借款上征信么 洋钱罐怎么借钱 洋钱罐理财 洋钱罐怎么样 洋钱罐有借款成功的吗 洋钱罐查征信吗 洋钱罐贷款 洋钱罐借钱 洋钱罐吧 洋鸡蛋价格 洋姜为什么不能和鸡蛋一起吃