EVC实现WIN CE下截屏
来源:互联网 发布:linux用户权限777回退 编辑:程序博客网 时间:2024/04/27 21:40
只转了代码,原贴心得未转
//======================================================================
void 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);
}
//测试代码:
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
const char filename[] = "screen.bmp";
OnScreenSave(filename);
return 0;
}
- EVC实现WIN CE下截屏
- EVC实现WIN CE下截屏
- EVC实现WIN CE下截屏
- EVC实现WIN CE下截屏并且保存到文件
- EVC实现WIN CE下截屏并且保存到文件
- EVC实现WIN CE下截屏并且保存到文件[By Erran]
- WIN CE 实现透明控件
- 实现WIN CE下截屏并且保存到文件
- Win CE 实现web访问快捷方式解决方案
- Win CE串口通讯
- Win CE版本研究
- Win CE 内存管理
- win ce右键消息
- Win CE 电源管理
- WIN CE 电源管理
- WIN CE 长按键
- Win CE历史简介
- Win CE 电源管理
- 手把手struts2.0+hibernate3.1+spring2.0环境配置和实验指导
- [Linux DMA]DMA-mapping.txt
- 超酷方式检验网站Alexa排名作弊
- Win32 二进制资源格式
- [原创]汇编实现大数乘除运算的雏形
- EVC实现WIN CE下截屏
- Struts 和 Tiles 辅助基于组件的开发(4)
- 部署最简单的三层结构--三层架构示例
- [Linux DMA]DMA-API.txt
- 各种数据库使用JDBC连接的方式
- Struts 和 Tiles 辅助基于组件的开发(1)
- Struts 和 Tiles 辅助基于组件的开发(2)
- 教育部、财政部全面启动“高等学校本科教学质量与教学改革工程”
- JSTL的c:out问题解决