雖然是非常簡單的程式, 但是我發現還是有許多人問這個問題。
我也在論壇search過"擷取畫面", 但幾乎都是CCD的問題。而不是單純的擷取畫面。
所以在這裡po一篇。
![]()
從 class="code">
void CaptureScreen(const TSavePictureDialog *SavPicDlg, const TImage *IMGdes, const TImage *IMGsur)
{
String lc_strNewFilePath,lc_strFileType;
TJPEGImage *lc_jpgJpegBuf = NULL; // 擷取畫面
IMGdes->Canvas->CopyRect(IMGdes->BoundsRect,From1->Canvas,IMGsur->BoundsRect); // 存檔
SavPicDlg->InitialDir = GetCurrentDir();
if(SavPicDlg->Execute())
{ lc_strFileType = ExtractFileExt(Form1->SavPicDlg->FileName);
lc_strNewFilePath = SavPicDlg->FileName; if(lc_strFileType == "")
{ lc_strNewFilePath = Form1->SavPicDlg->FileName ".bmp";
lc_strFileType = ".bmp"; } if(lc_strFileType == ".jpg" || lc_strFileType == ".jpeg" || lc_strFileType == ".JPG" || lc_strFileType == ".JPEG")
{ lc_jpgJpegBuf = new TJPEGImage () ;
lc_jpgJpegBuf->Assign(IMGdes->Picture->Bitmap);
lc_jpgJpegBuf->CompressionQuality=90;
lc_jpgJpegBuf->SaveToFile(lc_strNewFilePath);
delete lc_jpgJpegBuf ;
lc_jpgJpegBuf = NULL; }
else if(lc_strFileType == ".bmp" || lc_strFileType == ".BMP")
{
IMGdes->Picture->Bitmap->SaveToFile(lc_strNewFilePath); }
else
{ Application->MessageBox("This file type is not allow.", "Load File", MB_OK);
} }
} -------------------------------
數學系是內功很強(邏輯/分析) 資工系是招式很多(程式技巧) 就像令狐沖VS東方不敗:D
Programmers Guide
http://anpino.begin.8d8d.com 發表人 - anpino 於 2004/01/10 13:21:32