Unit1.pas 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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éclarations privées }
  23. public
  24. { Déclarations 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.