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

Delphi控件源码

开发平台:

Delphi

  1. unit main;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, DSPack, ExtCtrls, DirectShow9, jpeg, ImgList, ComCtrls;
  6. type
  7.   TForm1 = class(TForm)
  8.     VideoWindow: TVideoWindow;
  9.     FilterGraph: TFilterGraph;
  10.     Button2: TButton;
  11.     SnapShot: TImage;
  12.     Button1: TButton;
  13.     OpenDialog: TOpenDialog;
  14.     Label1: TLabel;
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  17.     procedure Button2Click(Sender: TObject);
  18.   private
  19.     { D閏larations priv閑s }
  20.   public
  21.   end;
  22. var
  23.   Form1: TForm1;
  24. implementation
  25. uses activex;
  26. {$R *.dfm}
  27. procedure TForm1.Button1Click(Sender: TObject);
  28. begin
  29.   if OpenDialog.Execute then
  30.   begin
  31.     FilterGraph.ClearGraph;
  32.     FilterGraph.RenderFile(OpenDialog.FileName);
  33.     FilterGraph.Play;
  34.   end;
  35. end;
  36. procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  37. begin
  38.   FilterGraph.ClearGraph;
  39.   FilterGraph.Active := false;
  40. end;
  41. procedure TForm1.Button2Click(Sender: TObject);
  42. var
  43.   Stream: TMemoryStream;
  44. begin
  45.   Stream:= TMemoryStream.Create;
  46.   try
  47.     if VideoWindow.VMRGetBitmap(Stream) then
  48.       SnapShot.Picture.bitmap.LoadFromStream(Stream);
  49.   finally
  50.     Stream.Free;
  51.   end;
  52. end;
  53. end.