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。
{
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。
相关文章推荐
- IOS-UI学习笔记(超级猜图)
- Android合并两个APP的具体做法(掌握)
- bug管理工具为开发者工作带来哪些改变?
- 160413、生成随机校验码
- $0返回值的含义
- FPGA低级建模---按键去抖动
- android:configChanges
- Linux监控子进程实现
- Hive外部分区表加载flume打到hdfs上文件,读不到.tmp文件
- SQL的更新语句update(更新表中数据)
- MySQL数据库时区配置
- JVM1
- Java编译后生成带$符号的class
- 如何确定函数依赖和其作用
- PIL使用示例
- 在 eclipse 上安装 genymotion 插件不成功的解决办法
- Java Web项目如何读取.properties配置文件
- JNDI初探之tomcat的datasource配置
- 函数-从进程名获得进程ID、从进程ID获得进程路径
- 文件的自定义包发送接收