?? framegrabber_.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "sysutils.hpp"
#include "FrameGrabber_.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "AMovie"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
//---------------------------------------------------------------------------
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
//---------------------------------------------------------------------------
{
FFrameCount = 0;
StatusBar1->Panels->Items[0]->Text = " storage path: " + ActiveMovie1->StoragePath;
if (! ActiveMovie1->IsDirectX8installed) {
ShowMessage ("DirectX8 is not installed on this platform. Please download it from www.microsoft.com");
}
Edit5->Text = ActiveMovie1->StoragePath;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
//---------------------------------------------------------------------------
{
OpenDialog1->Filter = "video clips";
OpenDialog1->FileName = "*.mpg;*.mpeg;*.avi;*.wav;*.mp3;*.asf;*.wmv";
if (OpenDialog1->Execute()) {
Edit1->Text = OpenDialog1->FileName;
ActiveMovie1->FileName = Edit1->Text;
ActiveMovie1->Open();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
//---------------------------------------------------------------------------
{
ActiveMovie1->FileName = Edit1->Text;
ActiveMovie1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
//---------------------------------------------------------------------------
{
Edit1->Text = "http://www.Datastead.com/amovie/demo.mpeg";
ActiveMovie1->FileName = Edit1->Text;
ActiveMovie1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
//---------------------------------------------------------------------------
{
ActiveMovie1->FGrabber_BurstCount = 0;
ActiveMovie1->FGrabber_BurstMode = True;
ActiveMovie1->FGrabber_BurstInterval = StrToIntDef (Edit4->Text, 1);
ActiveMovie1->FGrabber_CaptureFrameTo (fcTBitmap);
// the captured frames are returned by the OnFGrabberFrameCaptureCompleted event
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ActiveMovie1FGrabberCaptureCompleted(
TObject *Sender, Pointer Bitmap, TFrameCapture_Dest DestType,
AnsiString FileName, WordBool Success)
//---------------------------------------------------------------------------
{
switch (DestType) {
case fcBmpFile:
StatusBar1->Panels->Items[1]->Text = "File " + FileName + " created";
break;
case fcJpegFile:
StatusBar1->Panels->Items[1]->Text = "File " + FileName + " created";
break;
case fcTBitmap:
Image1->Width = ((Graphics::TBitmap*) Bitmap)->Width;
Image1->Height = ((Graphics::TBitmap*) Bitmap)->Height;
Image1->Picture->Assign ((Graphics::TBitmap*) Bitmap);
FFrameCount ++;
Edit2->Text = " " + IntToStr (FFrameCount);
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ActiveMovie1OpenStateChange(TObject *Sender,
int OldState, int NewState)
//---------------------------------------------------------------------------
{
if (NewState == nsOpen) {
Button1->Enabled = True;
Button2->Enabled = True;
Button3->Enabled = True;
Button4->Enabled = True;
Button6->Enabled = True;
Button7->Enabled = True;
}
else {
Button1->Enabled = False;
Button2->Enabled = False;
Button3->Enabled = False;
Button4->Enabled = False;
Button6->Enabled = False;
Button7->Enabled = False;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
//---------------------------------------------------------------------------
{
ActiveMovie1->FGrabber_BurstMode = False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
//---------------------------------------------------------------------------
{
ActiveMovie1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
//------------------------------------------------------------------------------
// when FGrabber_Enabled is true, CaptureFrameToBitmap, CaptureFrameToImage,
// CaptureFrameToJPegFile and CaptureFrameToBmpFile uses the frame grabber
// synchronously (when the function returns, the capture is done, the
// OnFGrabberCaptureCompleted event is not used.
//------------------------------------------------------------------------------
{
ActiveMovie1->CaptureFrameToImage (Image1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
//---------------------------------------------------------------------------
{
ActiveMovie1->FGrabber_BurstMode = True;
ActiveMovie1->FGrabber_BurstCount = StrToIntDef (Edit3->Text, 1);
ActiveMovie1->FGrabber_BurstInterval = StrToIntDef (Edit4->Text, 1);
ActiveMovie1->FGrabber_CaptureFrameTo (fcJpegFile);
// the captured file is returned by the OnFrameCaptureCompleted event->
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
//---------------------------------------------------------------------------
{
ActiveMovie1->FGrabber_BurstMode = True;
ActiveMovie1->FGrabber_BurstCount = StrToIntDef (Edit3->Text, 1);
ActiveMovie1->FGrabber_BurstInterval = StrToIntDef (Edit4->Text, 1);
ActiveMovie1->FGrabber_CaptureFrameTo (fcBmpFile);
// the captured file is returned by the OnFrameCaptureCompleted event->
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender)
//---------------------------------------------------------------------------
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit5Change(TObject *Sender)
//---------------------------------------------------------------------------
{
ActiveMovie1->StoragePath = Edit5->Text;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -