实现WIN CE下截屏并且保存到文件
本文为转载,原文地址丢失,sorry
##################################################################################################################
找了一些WinCE下的截图软件,但大都是ARM平台下的,可怜俺用的是Intel,还是自己写吧。
// this function create a bmp file to save the current screen;
// supported eVC++ 4.0 (wince 4.0) and vc++ 6.0 , test pass;
void CSnapDlg::OnScreenSave(const char *filename)
{
HDC hScrDC, hMemDC;
int width, height;
//the pointer will save all pixel point's color value
BYTE *lpBitmapBits = NULL;
//creates a device context for the screen device
hScrDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
//get the screen point size
width = GetDeviceCaps(hScrDC, HORZRES);
height = GetDeviceCaps(hScrDC, VERTRES);
//creates a memory device context (DC) compatible with the screen device(hScrDC)
hMemDC = CreateCompatibleDC(hScrDC);
//initialise the struct BITMAPINFO for the bimap infomation,
//in order to use the function CreateDIBSection
// on wince os, each pixel stored by 24 bits(biBitCount=24)
//and no compressing(biCompression=0)
BITMAPINFO RGB24BitsBITMAPINFO;
ZeroMemory(&RGB24BitsBITMAPINFO, sizeof(BITMAPINFO));
RGB24BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
RGB24BitsBITMAPINFO.bmiHeader.biWidth = width;
RGB24BitsBITMAPINFO.bmiHeader.biHeight = height;
RGB24BitsBITMAPINFO.bmiHeader.biPlanes = 1;
RGB24BitsBITMAPINFO.bmiHeader.biBitCount = 24;
//use the function CreateDIBSection and SelectObject
//in order to get the bimap pointer : lpBitmapBits
HBITMAP directBmp = CreateDIBSection(hMemDC, (BITMAPINFO*)&RGB24BitsBITMAPINFO,
DIB_RGB_COLORS, (void **)&lpBitmapBits, NULL, 0);
HGDIOBJ previousObject = SelectObject(hMemDC, directBmp);
// copy the screen dc to the memory dc
BitBlt(hMemDC, 0, 0, width, height, hScrDC, 0, 0, SRCCOPY);
//if you only want to get the every pixel color value,
//you can begin here and the following part of this function will be unuseful;
//the following part is in order to write file;
//bimap file header in order to write bmp file
BITMAPFILEHEADER bmBITMAPFILEHEADER;
ZeroMemory(&bmBITMAPFILEHEADER, sizeof(BITMAPFILEHEADER));
bmBITMAPFILEHEADER.bfType = 0x4d42; //bmp
bmBITMAPFILEHEADER.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bmBITMAPFILEHEADER.bfSize = bmBITMAPFILEHEADER.bfOffBits + ((width*height)*3); ///3=(24 / 8)
//write into file
FILE *mStream = NULL;
if((mStream = fopen(filename, "wb")))
{
//write bitmap file header
fwrite(&bmBITMAPFILEHEADER, sizeof(BITMAPFILEHEADER), 1, mStream);
//write bitmap info
fwrite(&(RGB24BitsBITMAPINFO.bmiHeader), sizeof(BITMAPINFOHEADER), 1, mStream);
//write bitmap pixels data
fwrite(lpBitmapBits, 3*width*height, 1, mStream);
//close file
fclose(mStream);
}
//delete
DeleteObject(hMemDC);
DeleteObject(hScrDC);
DeleteObject(directBmp);
DeleteObject(previousObject);
}
实现WIN CE下截屏并且保存到文件相关推荐
- EVC实现WIN CE下截屏
这几天在看老大写的博客(http://blog.csdn.net/norains ,八卦一下我老大在CSDN上小有名气已经成为了专家), 虽然跟着老大一年多了学到不少的东西但是发现自己要学的东西还有很 ...
- w ndows默认截图工具,浅谈Win10系统下截屏方式
前言 虽然近年来Windows式微的言论从不间断,微软也不再将Windows系统作为核心业务而是转向"AI为先·云为先"的战略,但Windows依然占据着全球88.5%的电脑桌面, ...
- 服务器双系统快捷键,Mac/Win7双系统下截屏快捷键介绍
由于苹果电脑采用的是mac系统,使用的用户相对较少,不少购买苹果电脑的朋友经常会遇到一些截图困扰,接下来是小编为大家收集的Mac/Win7双系统下截屏快捷键介绍,希望能帮到大家. Mac/Win7双系 ...
- 苹果xr如何截屏_iphone敲两下截屏如何操作 苹果手机触控截屏方法【教程步骤】...
iphone敲两下截屏如何操作?相信小伙伴们一定很好奇,下面小编为大家带来了苹果手机触控截屏方法教程详解,感兴趣的小伙伴赶紧跟着小编一起来看看吧 iphone敲两下截屏怎么设置 轻点两下进行截屏其实是 ...
- Windows CE/Moblie截屏工具及实现源码
Windows CE/Moblie截屏工具及实现源码 [img]http://dl2.iteye.com/upload/attachment/0084/6997/c72941f2-b86e-3683- ...
- UEFI开发探索99 – UEFI Shell下截屏工具
(请保留-> 作者: 罗冰 https://blog.csdn.net/luobing4365) UEFI Shell下截屏工具 1 PrintScreenLogger的代码结构 1)Print ...
- Ubuntu系统下截屏快捷键
Ubuntu系统下截屏快捷键 常用的: fn+print: 全屏截图 ctrl+alt+print:截取当前窗口 参考链接:https://blog.csdn.net/sunshine_lyn/art ...
- 苹果笔记本装windows10后,如何一键截屏并保存到onedrive中?
苹果macbook pro,为了工作方便装了win10. 前几天在开线上会的时候,有些内容需要记录下,突然发现不会使用苹果本截屏快捷键,于是用QQ截屏凑合用了. 晚上回到家,终于找到了苹果本在win1 ...
- Linux下截屏方法!
一.最便捷的方法 1.按下印屏幕键,截取整个桌面: 2.按下Alt+屏幕键,截取当前窗口: 二.命令行截屏 1.import screenshot.jp ...
最新文章
- 云炬Android开发教程 Android Studio自带的AVD模拟器安装教程
- Fast R-CNN 个人理解
- mysql 数据库 额外_Manager额外参数怎么学?mysql数据库学习
- java双缓存机制_详解JVM类加载机制及类缓存问题的处理方法
- mysql数据库栏目_MySQL的一些小技巧(持续更新) - mysql数据库栏目
- p2p-如何拯救k8s镜像分发的阿喀琉斯之踵?
- ModelCoder中的超密时间模型
- 招商:笔试题(数组统计重复次数,面包累计问题)
- Android开源项目汇总
- Choerodon 的微服务之路(二):Choerodon 的微服务网关
- 【论文阅读】EMNLP 2018 基于自适应的多轮解码机制的神经机器翻译模型
- Redis详解(七)——Redis主从同步高可用架构
- 杭电多校HDU 6601 Keen On Everything But Triangle(主席树)题解
- MSP430开发笔记之五:硬件IO中断与IR红外接收
- 【重要】股票收益互换
- pano2vr输出的HTML手机可以看吗,Pano2VR怎么导出手机可看_ Pano2VR导出手机查看教程...
- 计算机打代码的技巧,工作超实用的电脑技巧
- 通过网线实现两台PC相互通信(并实现访问公网)
- Minimum supported Gradle version is 5.4.1. Current version is 4.10.1. If using the gradle wrapper
- flink-cdc 同步 Postgre SQL 基本配置【1】