home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / dspack / DSPACK231.exe / {app} / Demos / D6-D7 / SampleGrabber / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2003-01-27  |  1.7 KB  |  75 lines

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