⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vc实现卡拉ok字幕叠加_4.htm

📁 GDI编程的参考资料
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                    <TR>
                      <TD align=middle><SPAN id=pip></SPAN></TD></TR>
                    <TR>
                      <TD align=middle><IFRAME 
                        src="VC实现卡拉OK字幕叠加_4.files/y-soft-column-1.htm" 
                        frameBorder=0 width=360 scrolling=no 
                      height=50></IFRAME></TD></TR></TBODY></TABLE></TD>
                <TD width=5></TD>
                <TD vAlign=top width=220>
                  <TABLE cellSpacing=0 cellPadding=0 width=220 border=0>
                    <TBODY>
                    <TR>
                      <TD colSpan=2><FONT class=f21><B>[文章信息]</B></FONT></TD></TR>
                    <TR>
                      <TD colSpan=2 height=10></TD></TR>
                    <TR>
                      <TD vAlign=top width=62>作者:</TD>
                      <TD vAlign=top width=158><FONT 
                      color=#0e3e92>陆其明</FONT></TD></TR>
                    <TR>
                      <TD vAlign=top>时间:</TD>
                      <TD vAlign=top><FONT 
                    color=#0e3e92>2003-11-21</FONT></TD></TR>
                    <TR>
                      <TD vAlign=top>出处:</TD>
                      <TD vAlign=top><FONT color=#0e3e92>VCHelp</FONT></TD></TR>
                    <TR>
                      <TD vAlign=top>责任编辑:</TD>
                      <TD vAlign=top><FONT color=#0e3e92>方舟</FONT></TD></TR>
                    <TR>
                      <TD colSpan=2 height=10></TD></TR></TBODY></TABLE>
                  <TABLE cellSpacing=0 cellPadding=0 width=220 border=0>
                    <TBODY>
                    <TR>
                      <TD colSpan=2><FONT class=f21><B>[文章导读]</B></FONT></TD></TR>
                    <TR>
                      <TD colSpan=2 height=10></TD></TR>
                    <TR>
                      <TD vAlign=top colSpan=2><SPAN 
                        class=f14>本文介绍了卡拉OK字幕叠加的一般原理以及VC上使用GDI的一种简单实现</SPAN></TD></TR>
                    <TR>
                      <TD colSpan=2 height=10></TD></TR></TBODY></TABLE>
                  <SCRIPT 
                  language=JavaScript><!--var ad_id=1003//--></SCRIPT>

                  <SCRIPT language=JavaScript 
                  src="VC实现卡拉OK字幕叠加_4.files/10.js"></SCRIPT>
                </TD>
                <TD width=5></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
    <TD width=1 bgColor=#b9bebe rowSpan=13></TD>
    <TD vAlign=top align=middle width=170 bgColor=#ffffff rowSpan=13>
      <TABLE cellSpacing=5 cellPadding=0 width=165 border=0>
        <TBODY>
        <TR>
          <TD align=middle>
            <SCRIPT language=JavaScript><!--var ad_id=0403//--></SCRIPT>

            <SCRIPT language=JavaScript 
            src="VC实现卡拉OK字幕叠加_4.files/04.js"></SCRIPT>
          </TD></TR></TBODY></TABLE>
      <TABLE height=28 cellSpacing=0 cellPadding=0 width=160 
      background=VC实现卡拉OK字幕叠加_4.files/2004-30.gif border=0>
        <TBODY>
        <TR>
          <TD align=middle><B>advertisement</B></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
        <TBODY>
        <TR>
          <TD width=1 bgColor=#adadad></TD>
          <TD align=middle bgColor=#ffffff><SPAN id=sv></SPAN></TD>
          <TD width=1 bgColor=#adadad></TD></TR></TBODY></TABLE>
      <TABLE height=1 cellSpacing=0 cellPadding=0 width=160 bgColor=#adadad 
      border=0>
        <TBODY>
        <TR>
          <TD></TD></TR></TBODY></TABLE>
      <TABLE height=10 cellSpacing=0 cellPadding=0 width=160 border=0>
        <TBODY>
        <TR>
          <TD></TD></TR></TBODY></TABLE>
      <TABLE height=28 cellSpacing=0 cellPadding=0 width=160 
      background=VC实现卡拉OK字幕叠加_4.files/2004-30.gif border=0>
        <TBODY>
        <TR>
          <TD align=middle><B>热点推荐</B></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
        <TBODY>
        <TR>
          <TD width=1 bgColor=#adadad></TD>
          <TD align=middle bgColor=#ffffff>
            <TABLE cellSpacing=0 cellPadding=2 width=150 border=0>
              <TBODY>
              <TR>
                <TD width=7>· </TD>
                <TD width=143><A 
                  href="http://www.yesky.com/SoftChannel/72339069014638592/20041017/1864973.shtml" 
                  target=_blank>天极网软件频道改版调查</A></TD></TR>
              <TR>
                <TD width=7>· </TD>
                <TD width=143><A 
                  href="http://www.yesky.com/SoftChannel/72339069014638592/20041028/1869661.shtml" 
                  target=_blank>10.28软件精选 找乐还是赌钱</A></TD></TR>
              <TR>
                <TD width=7>· </TD>
                <TD width=143><A 
                  href="http://www.yesky.com/SoftChannel/72342389024358400/20041028/1869618.shtml" 
                  target=_blank>中国游戏业——被人们忽视的黑暗</A></TD></TR>
              <TR>
                <TD width=7>· </TD>
                <TD width=143><A 
                  href="http://www.yesky.com/SoftChannel/72356695560421376/20041028/1869602.shtml" 
                  target=_blank>Windows 2000密码破解不完全指南</A></TD></TR>
              <TR>
                <TD width=7>· </TD>
                <TD width=143><A 
                  href="http://www.yesky.com/SoftChannel/72350085605752832/20041028/1869596.shtml" 
                  target=_blank>解决XP SP2带来的网络故障(上)</A></TD></TR></TBODY></TABLE></TD>
          <TD width=1 bgColor=#adadad></TD></TR></TBODY></TABLE>
      <TABLE height=1 cellSpacing=0 cellPadding=0 width=160 bgColor=#adadad 
      border=0>
        <TBODY>
        <TR>
          <TD></TD></TR></TBODY></TABLE></TD>
    <TD width=1 bgColor=#b9bebe rowSpan=13></TD></TR>
  <TR>
    <TD vAlign=top bgColor=#f0f2fb height=5></TD></TR>
  <TR>
    <TD vAlign=top background=VC实现卡拉OK字幕叠加_4.files/newhard-040906_c_1.gif 
    bgColor=#f0f2fb height=1></TD></TR>
  <TR>
    <TD vAlign=top bgColor=#dee2f5>
      <TABLE height=25 cellSpacing=0 cellPadding=0 width=590 align=center 
      border=0>
        <TBODY>
        <TR>
          <TD width=90><FONT class=f21><B>[正文]</B></FONT></TD>
          <TD align=right width=480>
            <P align=right><FONT color=red><A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826_2.shtml">上一页</A>&nbsp;&nbsp;<A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826.shtml">1</A> 
            <A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826_1.shtml">2</A> 
            <A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826_2.shtml">3</A> 
            4 &nbsp;</FONT></P></TD>
          <TD align=middle width=20></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD vAlign=top background=VC实现卡拉OK字幕叠加_4.files/newhard-040906_c_1.gif 
    bgColor=#f0f2fb height=1></TD></TR>
  <TR>
    <TD vAlign=top bgColor=#f0f2fb height=10></TD></TR>
  <TR>
    <TD vAlign=top bgColor=#f0f2fb>
      <TABLE cellSpacing=0 cellPadding=0 width=590 align=center border=0>
        <TBODY>
        <TR>
          <TD><SPAN class=f14>  <STRONG>四. 
            性能优化<BR></STRONG><BR>  我们在演示中发现,频繁地直接在窗口DC中画图会带来一定的闪烁感。对此,我们可以进行一下优化,即首先创建一个与目标窗口DC兼容的内存DC,在这个内存DC中画好字幕后,再将字幕位图从内存DC拷贝到目标窗口DC中去。<BR><BR>  我们可以参考CSubtitleController类的DrawSubtitle2函数的实现:<BR><BR>BOOL 
            CSubtitleController::DrawSubtitle2(DWORD 
            inStreamTime)<BR>{<BR>ASSERT(mClientDC);<BR><BR>RECT 
            bounds;<BR>mTargetWnd-&gt;GetClientRect(&amp;bounds);<BR>int 
            wndWidth = bounds.right - bounds.left;<BR>int wndHeight = 
            bounds.bottom - bounds.top;<BR><BR>CDC memDC;<BR>// 
            创建与目标窗口DC兼容的内存DC<BR>memDC.CreateCompatibleDC(mClientDC);<BR>// 
            创建与目标窗口DC兼容的位图<BR>HBITMAP membmp = 
            CreateCompatibleBitmap(mClientDC-&gt;GetSafeHdc(),wndWidth,wndHeight);<BR>// 
            将位图选入内存DC<BR>HBITMAP oldbmp = (HBITMAP) 
            memDC.SelectObject(membmp);<BR>FillRect(memDC.GetSafeHdc(), 
            &amp;bounds, 
            (HBRUSH)GetStockObject(LTGRAY_BRUSH));<BR><BR>/*----------------- 
            以下字幕操作都在内存DC中进行 ----------------*/<BR>DWORD timeInChar = 0; <BR>LONG 
            sungLength = 0;<BR>int currentChar = LocateChar(inStreamTime, 
            timeInChar);<BR>if (currentChar != -1)<BR>{<BR>sungLength = 
            mFromToArray[currentChar].size.cx * timeInChar;<BR>sungLength = 
            sungLength / mFromToArray[currentChar].duration; <BR>for (int i = 0; 
            i &lt; currentChar; i++)<BR>{<BR>sungLength += 
            mFromToArray[i].size.cx;<BR>}<BR>}<BR>else<BR>{<BR>sungLength = 
            mTotalWidth;<BR>}<BR><BR>CFont * pOldFont = (CFont *) 
            memDC.SelectObject(&amp;mTextFont);<BR>memDC.SetBkMode(TRANSPARENT);<BR><BR>mSungRegion.CreateRectRgn(mStartPoint.x, 
            mStartPoint.y, <BR>mStartPoint.x + sungLength, mStartPoint.y + 
            mFromToArray[0].size.cy);<BR>mSingingRegion.CreateRectRgn(mStartPoint.x 
            + sungLength, mStartPoint.y, <BR>mStartPoint.x + mTotalWidth, 
            mStartPoint.y + mFromToArray[0].size.cy);<BR><BR>// Draw the first 
            part which has been sung<BR>int ret = 
            memDC.SelectClipRgn(&amp;mSungRegion, RGN_COPY); 
            <BR>memDC.SetPolyFillMode(WINDING);<BR>HPEN pOldPen = (HPEN) 
            memDC.SelectObject(mSungBoundaryPen);<BR>HBRUSH pOldBrush = (HBRUSH) 
            memDC.SelectObject(mSungTextBrush);<BR>memDC.BeginPath(); 
            <BR>memDC.TextOut(mStartPoint.x, mStartPoint.y, mSubtitleLine); 
            <BR>memDC.EndPath(); 
            <BR>memDC.StrokeAndFillPath();<BR>memDC.SelectClipPath(RGN_AND);<BR>memDC.SelectObject(pOldPen);<BR>memDC.SelectObject(pOldBrush);<BR><BR>// 
            Draw the second part which is waiting for being sung<BR>pOldPen = 
            (HPEN) memDC.SelectObject(mSingingBoundaryPen);<BR>pOldBrush = 
            (HBRUSH) 
            memDC.SelectObject(mSingingTextBrush);<BR>memDC.SelectClipRgn(&amp;mSingingRegion, 
            RGN_COPY); <BR>memDC.BeginPath(); <BR>memDC.TextOut(mStartPoint.x, 
            mStartPoint.y, mSubtitleLine); 
            <BR>memDC.EndPath();<BR>memDC.StrokePath();<BR>memDC.SelectClipPath(RGN_AND);<BR>memDC.SelectObject(pOldBrush);<BR>memDC.SelectObject(pOldPen);<BR>mSungRegion.DeleteObject();<BR>mSingingRegion.DeleteObject();<BR><BR>memDC.SelectObject(pOldFont);<BR>// 
            将内存DC中的位图拷贝到目标窗口DC中<BR>mClientDC-&gt;BitBlt(0, 0, wndWidth, 
            wndHeight, &amp;memDC, 0, 0, SRCCOPY);<BR>// 
            删除内存DC及使用的资源<BR>memDC.SelectObject(oldbmp);<BR>DeleteObject(membmp);<BR>memDC.DeleteDC();<BR><BR>return 
            (currentChar != -1);<BR>}<BR><BR>  <STRONG>五. 
            结束语<BR></STRONG><BR>  本文介绍了卡拉OK字幕叠加的一般原理以及VC上使用GDI的一种简单实现,并且提供了完整的示例源代码,希望能够对读者朋友们有所启示。<BR><BR>  <A 
            href="ftp://ftp1.mydown.com/home1/soft34/kf1051.zip" 
            target=_blank>下载本文源代码</A>  <BR><BR><BR><BR></SPAN><BR></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD vAlign=top bgColor=#f0f2fb height=10></TD></TR>
  <TR>
    <TD vAlign=top background=VC实现卡拉OK字幕叠加_4.files/newhard-040906_c_1.gif 
    bgColor=#f0f2fb height=1></TD></TR>
  <TR>
    <TD vAlign=top bgColor=#dee2f5>
      <TABLE height=25 cellSpacing=0 cellPadding=0 width=590 align=center 
      border=0>
        <TBODY>
        <TR>
          <TD width=90></TD>
          <TD align=right width=480>
            <P align=right><FONT color=red><A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826_2.shtml">上一页</A>&nbsp;&nbsp;<A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826.shtml">1</A> 
            <A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826_1.shtml">2</A> 
            <A 
            href="http://www.yesky.com/SoftChannel/72342371928702976/20031121/1746826_2.shtml">3</A> 
            4 &nbsp;</FONT></P></TD>
          <TD align=middle width=20></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD vAlign=top background=VC实现卡拉OK字幕叠加_4.files/newhard-040906_c_1.gif 
    bgColor=#f0f2fb height=1></TD></TR>
  <TR>
    <TD vAlign=top width=603 bgColor=#f0f2fb>
      <TABLE cellSpacing=0 cellPadding=0 width=580 align=center border=0>
        <TBODY>
        <TR>
          <TD height=26><FONT color=#ff0000>·</FONT><A 
            href="http://www.my5757.com/webwap/zt/itnews/index.jsp" 
            target=_blank><FONT 
            color=#ff0000>"WAP天极之IT新闻资讯,50万元等你拿"</FONT></A>&nbsp;&nbsp;&nbsp;&nbsp;<FONT 
            color=#ff0000>·</FONT><A 
            href="http://www.my5757.com/webwap/zt/gameinfo/index.jsp" 
            target=_blank><FONT 
        color=#ff0000>天极WAP之游戏狂图,50万元等你下载</FONT></A></TD></TR></TBODY></TABLE><BR>
      <SCRIPT language=JavaScript 
src="VC实现卡拉OK字幕叠加_4.files/channel.js"></SCRIPT>

      <SCRIPT language=JavaScript><!--var path = location.pathname;var aid = 0;var cid = 0;var channelid = 0;reg = /\/(\w+)\/(\d+)\/(\d+)\/(\d+)/;if(reg.test(path)) {    reg.exec(path);    aid = RegExp.$4;    cid = RegExp.$2;    var ename = RegExp.$1;    channelid = getChannelID(ename);}//--></SCRIPT>
      <SPAN id=commentsSpanText></SPAN>
      <TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=3 width="100%" 
      align=center bgColor=#eef8fd borderColorLight=#666666 border=0>
        <TBODY>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -