抓取全屏并保存 (附:在图片上画方格)

版权声明:原创文章转载时请附上原文链接 https://blog.csdn.net/aniven/article/details/556324

//抓取全屏並保存
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);

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页