ken911629
一般會員
發表:7 回覆:4 積分:2 註冊:2005-11-10
發送簡訊給我
|
在BCB5中
TVideoCapture在儲存AVI文件時只能在Configure中先設定好檔案名稱
如果我想要要主畫面設定成每一次都能修改檔案名稱,程式上要如何設定
如果直接取用下列程式碼
config->CaptureFileName = avitext->Text;
並不能存成想要的檔案名稱
希望有大大能解答我的問題...謝謝
|
huwk
資深會員
發表:26 回覆:340 積分:323 註冊:2002-04-03
發送簡訊給我
|
若你中途都沒有再從CONFIG載入任何東西!
應是直接修改TVideoCapture->CaptureFileName = avitext->Text;
即可! 在呼叫StopCapture時.即會存到你指定的檔案!
------ 熊的學習 http://huwk.blogspot.com
|
ken911629
一般會員
發表:7 回覆:4 積分:2 註冊:2005-11-10
發送簡訊給我
|
根據上面大大的建議,程式會出現以下的錯誤
[C++ Error] MainForm.cpp(47): E2108 Improper use of typedef 'TVideoCapture' 以下附上我的程式碼 //-----------------------------------------------------------------------------
#include
#include
#include
#include "VCapStrings.hpp"
#include "VCap.hpp"
#pragma hdrstop // if u don't need to save graph u can delete #include
#include
#include "MainForm.h"
#include "GraphConfig.h"
#pragma package(smart_init)
#pragma link "VCap"
#pragma resource "*.dfm"
TFMain *FMain;
int A=0;
__fastcall TFMain::TFMain(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TFMain::FormShow(TObject *Sender)
{
if (!cap->Init()) {
ShowMessage("Can't init capture!");
Application->Terminate();
};
}
void __fastcall TFMain::capCaptureProgress(TObject *Sender)
{
StatusBar->SimpleText = "Frames Captured " IntToStr(cap->NotDropped)
". Frames Dropped " IntToStr(cap->FramesDropped)
". Capture time " IntToStr(cap->CapTime / 1000) '.'
IntToStr((cap->CapTime / 10) % 100);
btStart->Enabled = !cap->Capturing;
btStop->Enabled = !btStart->Enabled;
}
void __fastcall TFMain::btStartClick(TObject *Sender)
{
TVideoCapture->CaptureFileName = avitext->Text;//---------加入此行會錯誤
cap->StartCapture(true);
capCaptureProgress(this);
}
void __fastcall TFMain::btStopClick(TObject *Sender)
{
cap->StopCapture();
capCaptureProgress(this);
}
void __fastcall TFMain::btCaptureFrameClick(TObject *Sender)
{
A ;
if (!cap->CaptureFrame()) ShowMessage("Can't capture frame!");
}
void __fastcall TFMain::FormClose(TObject *Sender, TCloseAction &Action)
{
cap->StopPreview();
cap->StopCapture();
}
void __fastcall TFMain::capChangeDevice(TObject *Sender)
{
}
void __fastcall TFMain::cbVModesChange(TObject *Sender)
{
cap->StartPreview();
}
void __fastcall TFMain::cbAModesChange(TObject *Sender)
{
cap->StartPreview();
}
void __fastcall TFMain::lbDialogsClick(TObject *Sender)
{ }
void __fastcall TFMain::capStartPreview(TObject *Sender)
{
framecount = 0; }
void __fastcall TFMain::TimerTimer(TObject *Sender)
{
// make a delay to show form (let form get a handle)
Timer->Enabled = false;
cap->RestoreGraph(config);
}
void __fastcall TFMain::Button1Click(TObject *Sender)
{
if (cap->CaptureGraph==NULL) return;
CComPtr x;
if (x.CoCreateInstance(__uuidof(Xml2Dex))==S_OK)
x->WriteGrfFile(cap->CaptureGraph, L"graph.grf");
}
void __fastcall TFMain::FormCreate(TObject *Sender)
{
config = new TGraphConfig();
}
void __fastcall TFMain::FormDestroy(TObject *Sender)
{
delete config;
}
void __fastcall TFMain::Button2Click(TObject *Sender)
{
cap->SaveGraph(config);
if (EditGraphConfig(config)) cap->RestoreGraph(config);
}
void __fastcall TFMain::capBitmapGrabbed(TCapturedBitmap *CapturedImage)
{
CapturedImage->SaveToFile("TEMP.bmp");
Image->Picture->Assign(CapturedImage);
TJPEGImage *jpg = new TJPEGImage;
Graphics::TBitmap *bmp = new Graphics::TBitmap; bmp->LoadFromFile("TEMP.BMP");
jpg->Assign(bmp);
jpg->CompressionQuality = 50;
jpg->Compress();
jpg->PixelFormat = jf8Bit;
jpg->Assign(bmp);
jpg->SaveToFile(feBitmap->Text A ".JPG"); delete jpg;
delete bmp;
delete("TEMP.BMP");
}
void __fastcall TFMain::capFrameRendered(TObject *Sender)
{
}
void __fastcall TFMain::capStopPreview(TObject *Sender)
{
framecount = 0;
}
|
ken911629
一般會員
發表:7 回覆:4 積分:2 註冊:2005-11-10
發送簡訊給我
|
謝謝上面大大給我的建議...讓我找到新的方法...已經可以使用只要改成 cap->CaptureFileName = avitext->Text
就可以在主畫面隨時修改檔名
|
huwk
資深會員
發表:26 回覆:340 積分:323 註冊:2002-04-03
發送簡訊給我
|
不好意思.我原來的TVideoCapture即是指你實際的產生的物件
只是用CLASS名稱代表而已! ^^ 引言:
謝謝上面大大給我的建議...讓我找到新的方法...已經可以使用只要改成 cap->CaptureFileName = avitext->Text
就可以在主畫面隨時修改檔名
------ 熊的學習 http://huwk.blogspot.com
|