您的位置:首页 > 其它

VC屏幕截图并保存为bmp、jpg、png等格式文件

2016-04-14 14:11 417 查看
int main()

{

HDC hdcSrc = GetDC(NULL);

int nBitPerPixel = GetDeviceCaps(hdcSrc, BITSPIXEL);

int nWidth = GetDeviceCaps(hdcSrc, HORZRES);

int nHeight = GetDeviceCaps(hdcSrc, VERTRES);

CImage image;

image.Create(nWidth, nHeight, nBitPerPixel);

BitBlt(image.GetDC(), 0, 0, nWidth, nHeight, hdcSrc, 0, 0, SRCCOPY);

ReleaseDC(NULL, hdcSrc);

image.ReleaseDC();

image.Save(L"1.png", Gdiplus::ImageFormatPNG);//ImageFormatJPEG

return 0;

}

/article/2024103.html

注意:HDC
hdcSrc = GetDC(NULL); 和 ReleaseDC(NULL, hdcSrc);语句中的NULL是替代参数,在此位置应根据需要提供要截屏的窗口DC。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: