如何实现字幕叠加?(高分急问)(300分)

将字符串直接叠加在帧画面上
 
textout(handle,int x,int y,const char,int length)可以,但是如何存储那在研究中
 
请试一下下面例程。另外,这个例程退出时有错误发生,请教大家是什么原因。[?]

unit Unit13f;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, VrControls, VrThreads, dspack, OleServer;

type
TBounceThread=class(TThread)
private
FDSVideoWindow: TDSVideoWindow;
procedure WriteDSVideoWindow;
protected
procedure Execute;
override;
public
constructor Create(Suspended: Boolean;
DSVideoWindow: TDSVideoWindow);
property DSVideoWindow: TDSVideoWindow read FDSVideoWindow;
end;


TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
FilterGraph1: TDSFilterGraph2;
DWin: TDSVideoWindow;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;
TimeStr: String;
WriteThread: TBounceThread;

implementation

{$R *.DFM}
procedure TBounceThread.WriteDSVideoWindow;
begin

with FDSVideoWindowdo

begin

Canvas.Font.Color:=clYellow;
Canvas.Font.Size:=12;
Canvas.TextOut(500,10,TimeStr);
end;

end;


procedure TBounceThread.Execute;
begin

while not Terminateddo

begin

Synchronize(WriteDSVideoWindow);
end;

end;


constructor TBounceThread.Create(Suspended: Boolean;
DSVideoWindow: TDSVideoWindow);
begin

inherited Create(Suspended);
FDSVideoWindow:=DSVideoWindow;
FreeOnTerminate:=True;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin

WriteThread:=TBounceThread.Create(False, DWin);
end;


procedure TForm1.Button2Click(Sender: TObject);
begin

if OpenDialog1.Execute then

begin

FilterGraph1.ClearGraph;
FilterGraph1.FilterGraph2.RenderFile(StringToOleStr(OpenDialog1.FileName),nil);
FilterGraph1.QueryInterfaces;
FilterGraph1.MediaControl.Run;
end;

end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin

TimeStr:=DateTimeToStr(Now);
end;


procedure TForm1.FormDestroy(Sender: TObject);
begin

WriteThread.Suspend;

WriteThread.Free;
end;


end.
 
用Overlay surface已经实现了
可是实现不了透明叠加??
 
我已经实现了透明叠加流动字幕,想知道吗,拿人民币来.
 
to:撒野
老兄要多少银子?
 
好了,我给一段代码,你自己好好研究,吧!:)
bmpp:=tbitmap.create;
(form1.activemdichild as tform2).bmp.canvas.CopyMode:=cmsrcand;
bmpp.canvas.Font.Name:='宋体';
bmpp.canvas.font.Color:=stringtocolor(form10.Table1.fieldbyname('hbys').asstring);
bmpp.canvas.font.size:=round(form10.table1.fieldbyname('cx').asinteger*form3.ttx);
a:=form10.table1.fieldbyname('san').asstring;
if (w<y)and(x<z) then

begin

bmpp.Width:=y-w;bmpp.Height:=z-x;
intrect:=rect(0,0,bmpp.width,bmpp.height);
bmpp.canvas.brush.color:=clwhite;
bmpp.canvas.fillrect(intrect);
bmpp.canvas.TextRect(intrect,5,5,a);
intrect:=rect(w,x,y,z);
(form1.ActiveMDIChild as tform2).bmp.canvas.CopyRect(intrect,bmpp.canvas,rect(0,0,bmpp.width,bmpp.height));
end

如果还有什么不懂的,请写信到swnumaochang#hotmail.com
 
to luket:
我有一个一个播放Mpg,Asf,dvd,wmv,dat 的例子程序(没有错就是这么多格式,当然你的机子有这些文件的解码引擎),
不但可以叠加透明的字幕,透明的图片也没问题,还可以截图,我只要200大富翁币.^_^.
 
最简单的方法:
放两个label控件位置成叠加状。
 
To MilkRoad, cfzme@public.info.fj.cn 给我例子,我给分235大富翁币[:D],如何?
 
To 天真:
你看懂需求了吗?
To MilkRoad:
我给你250大富翁币[:D],please..
 
晕,你把屏幕截下来,再把字写上去,不是OK了,上面的代码就是写透明字的
 
To 天真:
你以为屏幕是这么好截的呀:)
工作在DirectX全屏模式时form1.ActiveMDIChild根本就不是播放窗口的Handle..

 
To 天真:
1.得不到播放窗口的Handle和DC,就算得到,一次裁图马上会被图象盖住
2.这种方式显然需要用线程(每秒25次)不断截屏,占用资源
3.不适合大量随时变化的文字的叠加..
只能用DirectX的Surface操作
另外在WIN2000下用某些函数就很简单,但现在需要通用..
 
to luket:
你不给Email我怎样给你呀?
to IamWLJ888:
我给你,不过记得给分喔.^_^.
 
to IamWLJ888:
luketang@21cn.com,thanks!
 
to luket: 请MilkRoad给你邮, 或你在DSPack的Demos找一下Grabber &amp;
CallBack。
to MilkRoad: 到http://www.delphibbs.com/delphibbs/dispq.asp?lid=1107757领分。
 
to iamwlj888:
那儿有DS2.0下载呀?能告诉我吗?lujinhu@vip.sina.com
 
我找到了DSPack2.0Beta1版,安装后找SampleGrabber作了一下测试,OK!效果不错,大家
试一试。
 

Similar threads

顶部