//抓取全屏並保存
TCanvas *dtCanvas=new TCanvas;
Graphics::TBitmap *bitmap=new Graphics::TBitmap;
dtCanvas->Handle=GetDC(0);
bitmap->Width=Screen->Width;
bitmap->Height=Screen->Height;
TRect src=Screen->DesktopRect;
TRect dest=Rect(0,0,Screen->Width,Screen->Height);
bitmap->Canvas->CopyRect(dest,dtCanvas,src);
bitmap->SaveToFile("C://Desktop.bmp");
delete bitmap;
delete dtCanvas;
//附:在圖片上畫方格
TCanvas *pcanvas=bitmap->Canvas;
pcanvas->Brush->Style=bsDiagCross;
pcanvas->Brush->Color=clBlack;
pcanvas->Rectangle(-1,-1,bitmap->Width+1,bitmap->Height+1);
该博客展示了用C语言实现的功能。一是抓取全屏并保存为图片,通过创建画布和位图对象,获取屏幕信息,复制屏幕内容到位图并保存,最后释放对象;二是在图片上绘制方格,设置画笔样式和颜色后绘制矩形。


被折叠的 条评论
为什么被折叠?



