问题描述
请问有谁会用.net实现视频叠加?就是在视频上添加文字等
解决方案
解决方案二:
冒泡帮顶接分
解决方案三:
你可以做一个自定义控件,把控件的形状挖成文字的形状.这样就作到了真正的透明.usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Drawing;usingSystem.Data;usingSystem.Text;usingSystem.Windows.Forms;namespaceTransparenceFont{publicpartialclassRealTransparentLabel:UserControl{privatestringtext;publicstring_Text{get{returntext;}set{text=value;OnTextChanged();}}publicRealTransparentLabel(){InitializeComponent();this._Text=this.Name;}privatevoidOnTextChanged(){if(text==null||text==""){this.Width=1;return;}//计算文字区域大小Bitmaptmp=newBitmap(1,1);Graphicsmeasure=Graphics.FromImage(tmp);SizeFsz=measure.MeasureString(text,Font);tmp.Dispose();measure.Dispose();Sizesize=newSize((int)sz.Width,(int)sz.Height);this.Size=size;//绘制文字Bitmapimg=newBitmap(size.Width,size.Height);Graphicsgph=Graphics.FromImage(img);gph.DrawString(text,Font,newSolidBrush(ForeColor),0,0);gph.Dispose();this.BackgroundImage=img;//除去控件多余区域Colortransp=img.GetPixel(0,0);Regionreg=newRegion();reg.MakeEmpty();for(inti=0;i<size.Width;i++){for(intj=0;j<size.Height;j++){if(img.GetPixel(i,j)!=transp){reg.Union(newRectangle(i,j,1,1));}}}this.Region=reg;}}}
效果如图下面的对比是普通Label控件用透明色做背景,其背景只是窗体的背景.而RealTransparentLabel完全透明了.