Dephi实现屏幕录像Word文档格式.docx

上传人:b****3 文档编号:7960138 上传时间:2023-05-09 格式:DOCX 页数:14 大小:17.03KB
下载 相关 举报
Dephi实现屏幕录像Word文档格式.docx_第1页
第1页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第2页
第2页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第3页
第3页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第4页
第4页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第5页
第5页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第6页
第6页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第7页
第7页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第8页
第8页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第9页
第9页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第10页
第10页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第11页
第11页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第12页
第12页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第13页
第13页 / 共14页
Dephi实现屏幕录像Word文档格式.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Dephi实现屏幕录像Word文档格式.docx

《Dephi实现屏幕录像Word文档格式.docx》由会员分享,可在线阅读,更多相关《Dephi实现屏幕录像Word文档格式.docx(14页珍藏版)》请在冰点文库上搜索。

Dephi实现屏幕录像Word文档格式.docx

//BMP文件存储路径procedureTForm

1.FormCreate(Sender:

TObject);

begin

PicIndex:

=0;

BmpFileName:

='

'

;

ScreenBmp:

=TBitmap.Create;

ScreenBmp.PixelFormat:

=pf24bit;

ScreenBmp.Width:

=Screen.Width;

ScreenBmp.Height:

=Screen.Height;

ScreenBmp.Canvas.Brush.Style:

=bsClear;

RecPause:

=False;

//不录制透明窗体

RecTransFlag:

=SRCCOPY;

//录制透明窗体

//RecTransFlag:

=SRCCOPYorCAPTUREBLT;

AppPath:

=ExtractFilePath(Application.ExeName);

TempPath:

=AppPath+'

Temp\'

ifnotDirectoryExists(TempPath)then

CreateDirectory(PAnsiChar(TempPath),nil);

end;

procedureTForm

1.DrawCursorToBmp(varScrBmp:

TBitmap);

hCur:

HICON;

MousePt:

TPoint;

ifnotAssigned(ScrBmp)then

Exit;

=GetCursor();

GetCursorPos(MousePt);

//画光标

DrawIcon(ScrBmp.canvas.handle,MousePt.x,MousePt.y,hCur);

1.Timer1Timer(Sender:

dc:

HDC;

DC:

=GetDC

(0);

try

BitBlt(ScreenBmp.Canvas.Handle,0,0,Screen.Width,Screen.Height,dc,0,0,Flag);

finally

ReleaseDC(0,dc);

//根据标记判断是否画上光标

DrawCursorToBmp(ScreenBmp);

=TempPath+IntToStr(PicIndex)+'

.bmp'

ScreenBmp.SaveToFile(BmpFileName);

Inc(PicIndex);

except

onEIntOverflowdo

1.Button1Click(Sender:

timer

1.Enabled:

=True;

2.取保存的bmp图片生成avi并添加声音.

usesVFW;

AviFileName:

//AVI文件存储路径Tempbmp:

//生成AVI前读出的BMPfunctionGetBitmapData(bmp:

TBitmap):

TImageData;

bmp.PixelFormat:

Result.Width:

=bmp.Width;

Result.Height:

=bmp.Height;

Result.Stride:

=Result.Widthshl2;

Result.Scan0:

=bmp.ScanLine[Result.Height-1];

Result.PixelFormat:

=-1;

//Windowsbitmapformatflag

Result.Reserved:

procedureCreateAVI;

hr:

Strhdr:

TAVIStreamInfo;

//AVI流信息

Wavehdr:

TWaveFormatEx;

Opts:

TAVICOMPRESSOPTIONS;

//压缩选项

POpts:

PAVICOMPRESSOPTIONS;

//压缩选项指针

Bi:

BITMAPINFOHEADER;

//BMP头信息

B:

Boolean;

P:

Pointer;

i:

bmpData:

nRet:

ifFileExists(AviFileName)then

DeleteFile(AviFileName);

AVIFileInit;

=AVIFileOpen(PFile,PChar(AviFileName),OF_CREATEorOF_WRITE,nil);

if(hr<

>

0)then

//设置AVI流信息

ZeroMemory(@Strhdr,SizeOf(TAVIStreamInfo));

strhdr.fccType:

=streamTypeVIDEO;

strhdr.fccHandler:

=mmioFOURCC('

D'

'

I'

V'

X'

);

strhdr.dwFlags:

strhdr.dwCaps:

strhdr.wPriority:

strhdr.wLanguage:

strhdr.dwScale:

=1;

strhdr.dwRate:

=5;

//pfs

strhdr.dwStart:

strhdr.dwLength:

strhdr.dwInitialFrames:

strhdr.dwSuggestedBufferSize:

=((Screen.Width*3+3)and$FFFC)*screen.Height;

//Screen.Height*screen.Width*3;

strhdr.dwQuality:

strhdr.dwSampleSize:

strhdr.rcFrame:

=Rect(0,0,Screen.Width,Screen.Height);

strhdr.dwEditCount:

strhdr.dwFormatChangeCount:

strhdr.szName[0]:

=#0;

strhdr.szName[1]:

//设置WAV流信息

ZeroMemory(@Wavehdr,SizeOf(TWaveFormatEx));

Wavehdr.cbSize:

Wavehdr.nChannels:

Wavehdr.wFormatTag:

Wavehdr.wBitsPerSample:

=16;

Wavehdr.nSamplesPerSec:

=8000;

Wavehdr.nBlockAlign:

=Wavehdr.wBitsPerSample*Wavehdr.nChannelsdiv8;

Wavehdr.nAvgBytesPerSec:

=Wavehdr.nBlockAlign*

Wavehdr.nSamplesPerSec;

ZeroMemory(@opts,SizeOf(TAVICOMPRESSOPTIONS));

//设置压缩信息

//Indeo?

Video

5.10

opts.fccType:

//vids

opts.fccHandler:

=9;

opts.dwKeyFrameEvery:

opts.dwQuality:

=8500;

opts.dwBytesPerSecond:

opts.dwFlags:

=8;

opts.lpFormat:

=nil;

opts.cbFormat:

opts.cbParms:

=48;

opts.dwInterleaveEvery:

//设置BMP头信息

ZeroMemory(@bi,SizeOf(BITMAPINFOHEADER));

bi.biSize:

=SizeOf(bi);

bi.biWidth:

bi.biHeight:

bi.biPlanes:

bi.biBitCount:

=24;

bi.biCompression:

bi.biSizeImage:

=((Screen.Width*3+3)and$FFFC)*screen.Height;

//(((bih.biWidth*3)+3)&

0xFFFC)*bih.biHeight//Screen.Height*screen.Width*3;

//_stride*_height;

bi.biXPelsPerMeter:

bi.biYPelsPerMeter:

bi.biClrUsed:

bi.biClrImportant:

hr:

=AVIFileCreateStream(PFile,PSrcStream,@strhdr);

=AVIMakeCompressedStream(PCompStream,PSrcStream,@opts,nil);

Abort;

=AVIStreamSetFormat(PCompStream,20,@bi,40);

Tempbmp:

Tempbmp.LoadFromFile(bmpFile);

bmpData:

=GetBitmapData(Tempbmp);

=AVIStreamWrite(PCompStream,

FrameCount,//存在第几帧

1,

bmpData.Scan0,

((Screen.Width*3+3)and$FFFC)*screen.Height,

0,

nil,

nil);

//添加声音

AddAVISound;

procedureAddAVISound;

wfx:

TWAVEFORMATEX;

buf:

arrayofchar;

wav:

PWavChunk;

hf:

HWND;

size:

DWORD;

numbytes,numsamps:

ZeroMemory(@wfx,sizeof(TWAVEFORMATEX));

hf:

=CreateFile(PChar(WavFileName),GENERIC_READ,FILE_SHARE_READ,nil,OPEN_EXISTING,0,0);

if(hf=0)then

size:

=GetFileSize(hf,nil);

SetLength(buf,size);

ReadFile(hf,buf[0],size,size,nil);

CloseHandle(hf);

wav:

=PWavChunk(buf);

wfx.wFormatTag:

=wav.fmt.wFormatTag;

wfx.cbSize:

wfx.nAvgBytesPerSec:

=wav.fmt.dwAvgBytesPerSec;

wfx.nBlockAlign:

=wav.fmt.wBlockAlign;

wfx.nChannels:

=wav.fmt.wChannels;

wfx.nSamplesPerSec:

=wav.fmt.dwSamplesPerSec;

wfx.wBitsPerSample:

=wav.fmt.wBitsPerSample;

Strhdr.fccType:

=streamtypeAUDIO;

Strhdr.dwScale:

=wfx.nBlockAlign;

Strhdr.dwRate:

=wfx.nSamplesPerSec*wfx.nBlockAlign;

Strhdr.dwSampleSize:

Strhdr.dwQuality:

=DWORD(-1);

=AVIFileCreateStream(PFile,PWavStream,@Strhdr);

if(buf<

nil)then

buf:

=AVIStreamSetFormat(PWavStream,0,@wfx,SizeOf(TWAVEFORMATEX));

//nowwecanwritethedata

numbytes:

=wav.dat.size;

ifwfx.wBitsPerSample<

0then

numsamps:

=numbytes*8divwfx.wBitsPerSample

else

=AVIStreamWrite(PWavStream,0,numsamps,wav,numbytes,0,nil,nil);

WavAddCompleted:

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2