Unit1.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit Unit1;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, ExtCtrls, DSPack;
  6. type
  7.   TForm1 = class(TForm)
  8.     FilterGraph: TFilterGraph;
  9.     VideoWindow: TVideoWindow;
  10.     SampleGrabber: TSampleGrabber;
  11.     Image: TImage;
  12.     OpenPlay: TButton;
  13.     Snapshot: TButton;
  14.     OpenDialog: TOpenDialog;
  15.     CallBack: TCheckBox;
  16.     procedure OpenPlayClick(Sender: TObject);
  17.     procedure SnapshotClick(Sender: TObject);
  18.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19.     procedure SampleGrabberBuffer(sender: TObject; SampleTime: Double;
  20.       pBuffer: Pointer; BufferLen: Integer);
  21.   private
  22.     { D閏larations priv閑s }
  23.   public
  24.     { D閏larations publiques }
  25.   end;
  26. var
  27.   Form1: TForm1;
  28. implementation
  29. {$R *.dfm}
  30. procedure TForm1.OpenPlayClick(Sender: TObject);
  31. begin
  32.   if OpenDialog.Execute then
  33.   begin
  34.     FilterGraph.Active := false;
  35.     FilterGraph.Active := true;
  36.     FilterGraph.RenderFile(OpenDialog.FileName);
  37.     FilterGraph.Play;
  38.   end;
  39. end;
  40. procedure TForm1.SnapshotClick(Sender: TObject);
  41. begin
  42.   SampleGrabber.GetBitmap(Image.Picture.Bitmap)
  43. end;
  44. // procedure TForm1.SampleGrabberBuffer(sender: TObject; Buffer: TBufferCB);
  45. // begin
  46. // if CallBack.Checked then
  47. //    SampleGrabber.GetBitmap(Image.Picture.Bitmap, Buffer)
  48. // end;
  49. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  50. begin
  51.   CallBack.Checked := false;
  52.   FilterGraph.ClearGraph;
  53.   FilterGraph.Active := false;
  54. end;
  55. procedure TForm1.SampleGrabberBuffer(sender: TObject; SampleTime: Double;
  56.   pBuffer: Pointer; BufferLen: Integer);
  57. begin
  58.   Image.Picture.Bitmap.Canvas.Lock;
  59.   try
  60.     SampleGrabber.GetBitmap(Image.Picture.Bitmap, pBuffer, BufferLen);
  61.   finally
  62.     Image.Picture.Bitmap.Canvas.UnLock;
  63.   end;
  64. end;
  65. end.