无法帮你什么,给你点代码吧!转自别人的加字
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DSPack,DirectShow9;
type
TForm1 = class(TForm)
FilterGraph: TFilterGraph;
VideoWindow: TVideoWindow;
SampleGrabber: TSampleGrabber;
OpenPlay: TButton;
Snapshot: TButton;
OpenDialog: TOpenDialog;
CallBack: TCheckBox;
Image: TImage;
Edit1: TEdit;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
ColorDialog1: TColorDialog;
Shape1: TShape;
Button1: TButton;
Edit4: TEdit;
Label1: TLabel;
Shape2: TShape;
Button2: TButton;
procedure OpenPlayClick(Sender: TObject);
procedure SnapshotClick(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure SampleGrabberBuffer(sender: TObject;
SampleTime:do
uble;
pBuffer: Pointer;
BufferLen: Integer);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ D閏larations priv閑s }
public
{ D閏larations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.OpenPlayClick(Sender: TObject);
begin
if OpenDialog.Execute then
begin
FilterGraph.Active := False;
FilterGraph.Active := true;
FilterGraph.RenderFile(OpenDialog.FileName);
FilterGraph.Play;
end;
end;
procedure TForm1.SnapshotClick(Sender: TObject);
begin
// SampleGrabber.GetBitmap(Image.Picture.Bitmap)
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
CallBack.Checked := false;
FilterGraph.ClearGraph;
FilterGraph.Active := false;
end;
procedure TForm1.SampleGrabberBuffer(sender: TObject;
SampleTime:do
uble;
pBuffer: Pointer;
BufferLen: Integer);
var
hr: HRESULT;
VideoInfo: PVideoInfo;
MediaType: TAMMediaType;
i, j: Integer;
P: PByteArray;
CurrectColor: TColor;
begin
if CallBack.Checked then
begin
hr:=SampleGrabber.SampleGrabber.GetConnectedMediaType(MediaType);
if hr <> S_OK then
Exit;
if IsEqualGUID(MediaType.majortype, MEDIATYPE_Video) then
VideoInfo:=MediaType.pbFormat;
Image.Picture.Bitmap.Width := VideoInfo.bmiHeader.biWidth;
Image.Picture.Bitmap.Height:= VideoInfo.bmiHeader.biHeight;
Image.Picture.Bitmap.Canvas.Lock;
Image.Picture.Bitmap.Canvas.Brush.Color:= Shape2.Brush.Color;
Image.Picture.Bitmap.Canvas.Rectangle(-1, -1,
Image.Picture.Bitmap.Width + 1, Image.Picture.Bitmap.Height + 1);
Image.Picture.Bitmap.Canvas.Brush.Style:=bsClear;
Image.Picture.Bitmap.Canvas.Font.Size:=strtoint(edit4.Text );
Image.Picture.Bitmap.PixelFormat:=pf24bit;
Image.Picture.Bitmap.Canvas.Font.Color:=Shape1.Brush.Color;
Image.Picture.Bitmap.Canvas.Font.Style :=[fsBold];
Image.Picture.Bitmap.Canvas.TextOut(strtoint(Edit1.text),
strtoint(Edit2.text),Edit3.text);
// to avoid flickering
for j := 0 to Image.Picture.Bitmap.Height - 1do
begin
P := Image.Picture.Bitmap.ScanLine[Image.Picture.Bitmap.Height - j - 1];
for i := 0 to Image.Picture.Bitmap.Width - 1do
begin
CurrectColor :=RGB(P[i*3], P[i*3 + 1], P[i*3 + 2]);
//P[i*3];
if CurrectColor <> Shape2.Brush.Color then
begin
// PByte(Integer(pBuffer) + j * Image.Picture.Bitmap.Width*3+i*3)^:=p[i*3];
PByte(Integer(pBuffer) + j * Image.Picture.Bitmap.Width*3 + i*3 )^ := P[i*3];
PByte(Integer(pBuffer) + j * Image.Picture.Bitmap.Width*3 + i*3 + 1)^ := P[i*3 +
1];
PByte(Integer(pBuffer) + j * Image.Picture.Bitmap.Width*3 + i*3 + 2)^ := P[i*3 +
2];
end;
end;
end;
Image.Picture.Bitmap.Canvas.Unlock;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ColorDialog1.Color:=clwhite;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ColorDialog1.Execute;
Shape1.Brush.Color:=ColorDialog1.Color;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ColorDialog1.Execute;
Shape2.Brush.Color:=ColorDialog1.Color;
end;
end.