各位大虾如何获得我抓取的屏幕里显示的文本,谢谢
解决方案 »
- 为什么的我写的截图程序总是运行到LocalFree就停了?
- 请教IP/TCP协议实现对服务端进程管理?
- 关于VC的方向(进者有分)
- 我想模糊的比较两个颜色是否相等,想找一些相关的资料。
- 基于SDI的应用程序中的Dialog或FormView中创建的工具条使能问题
- 请大家帮忙思考模拟示波器的问题
- 未知数据类型的情况下,如何把lParam转成CString呢?
- 串口
- 你有这种心态吗?
- 如何在DialogBox中用ToolBar?
- 有一组YUV矩阵(400*320)数据矩阵,怎样以最快的速度显示到屏幕上?(Y:U:V=4:1:1)
- VC+SQL SERVER如何实现C/S模式的数据库应用程序(在线等待,参予者有分)?
void CCaptureView::OnCaptureScreen()
{
// TODO: Add your command handler code here
CDC dc;
dc.CreateDC("DISPLAY",NULL,NULL,NULL);
int SrcWidth=GetSystemMetrics(SM_CXSCREEN);
int SrcHeight=GetSystemMetrics(SM_CYSCREEN);
// int Width=384,Height=288;
int Width=SrcWidth,Height=SrcHeight;
/* CDC memdc;
memdc.CreateCompatibleDC(&dc);
memdc.StretchBlt(0,0,Width,Height,&dc,0,0,SrcWidth,SrcHeight,SRCCOPY);
*/
CBitmap bm;
bm.CreateCompatibleBitmap(&dc,Width,Height);
CDC tdc;
tdc.CreateCompatibleDC(&dc);
CBitmap*pOld=tdc.SelectObject(&bm);
tdc.SetStretchBltMode(STRETCH_HALFTONE);
tdc.StretchBlt(0,0,Width,Height,&dc,0,0,SrcWidth,SrcHeight,SRCCOPY);
// tdc.BitBlt(0,0,Width,Height,&dc,0,0,SRCCOPY);
tdc.SelectObject(pOld);
BITMAP btm;
bm.GetBitmap(&btm);
DWORD size=btm.bmWidthBytes*btm.bmHeight;
LPSTR lpData=(LPSTR)GlobalAllocPtr(GPTR,size);
/////////////////////////////////////////////
BITMAPINFOHEADER bih;
bih.biBitCount=btm.bmBitsPixel;
bih.biClrImportant=0;
bih.biClrUsed=0;
bih.biCompression=0;
bih.biHeight=btm.bmHeight;
bih.biWidth=btm.bmWidth;
bih.biPlanes=1;
bih.biSize=sizeof(BITMAPINFOHEADER);
bih.biSizeImage=size;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
///////////////////////////////////
GetDIBits(dc,bm,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
// bm.GetBitmapBits(size,lpData); //此函数在处理5-5-5模式的16位色下会出现颜色混乱
//////////////////////////////
static int filecount=0;
BITMAPFILEHEADER bfh;
bfh.bfReserved1=bfh.bfReserved2=0;
bfh.bfType=((WORD)('M'<< 8)|'B');
bfh.bfSize=54+size;
bfh.bfOffBits=54;
CFile bf;
if(bf.Open("capture.bmp",CFile::modeCreate|CFile::modeWrite)){
bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
bf.WriteHuge(lpData,size);
bf.Close();
// nCount++;
}
GlobalFreePtr(lpData);
UpdateData(FALSE);
}
{
// TODO: Add your command handler code here
CDC dc;
dc.CreateDC("DISPLAY",NULL,NULL,NULL);
int SrcWidth=GetSystemMetrics(SM_CXSCREEN);
int SrcHeight=GetSystemMetrics(SM_CYSCREEN);
// int Width=384,Height=288;
int Width=SrcWidth,Height=SrcHeight;
/* CDC memdc;
memdc.CreateCompatibleDC(&dc);
memdc.StretchBlt(0,0,Width,Height,&dc,0,0,SrcWidth,SrcHeight,SRCCOPY);
*/
CBitmap bm;
bm.CreateCompatibleBitmap(&dc,Width,Height);
CDC tdc;
tdc.CreateCompatibleDC(&dc);
CBitmap*pOld=tdc.SelectObject(&bm);
tdc.SetStretchBltMode(STRETCH_HALFTONE);
tdc.StretchBlt(0,0,Width,Height,&dc,0,0,SrcWidth,SrcHeight,SRCCOPY);
// tdc.BitBlt(0,0,Width,Height,&dc,0,0,SRCCOPY);
tdc.SelectObject(pOld);
BITMAP btm;
bm.GetBitmap(&btm);
DWORD size=btm.bmWidthBytes*btm.bmHeight;
LPSTR lpData=(LPSTR)GlobalAllocPtr(GPTR,size);
/////////////////////////////////////////////
BITMAPINFOHEADER bih;
bih.biBitCount=btm.bmBitsPixel;
bih.biClrImportant=0;
bih.biClrUsed=0;
bih.biCompression=0;
bih.biHeight=btm.bmHeight;
bih.biWidth=btm.bmWidth;
bih.biPlanes=1;
bih.biSize=sizeof(BITMAPINFOHEADER);
bih.biSizeImage=size;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
///////////////////////////////////
GetDIBits(dc,bm,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
// bm.GetBitmapBits(size,lpData); //此函数在处理5-5-5模式的16位色下会出现颜色混乱
//////////////////////////////
static int filecount=0;
BITMAPFILEHEADER bfh;
bfh.bfReserved1=bfh.bfReserved2=0;
bfh.bfType=((WORD)('M'<< 8)|'B');
bfh.bfSize=54+size;
bfh.bfOffBits=54;
CFile bf;
if(bf.Open("capture.bmp",CFile::modeCreate|CFile::modeWrite)){
bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
bf.WriteHuge(lpData,size);
bf.Close();
// nCount++;
}
GlobalFreePtr(lpData);
UpdateData(FALSE);
}
{
// TODO: Add your command handler code here
CDC dc;
dc.CreateDC("DISPLAY",NULL,NULL,NULL);
int SrcWidth=GetSystemMetrics(SM_CXSCREEN);
int SrcHeight=GetSystemMetrics(SM_CYSCREEN);
// int Width=384,Height=288;
int Width=SrcWidth,Height=SrcHeight;
/* CDC memdc;
memdc.CreateCompatibleDC(&dc);
memdc.StretchBlt(0,0,Width,Height,&dc,0,0,SrcWidth,SrcHeight,SRCCOPY);
*/
CBitmap bm;
bm.CreateCompatibleBitmap(&dc,Width,Height);
CDC tdc;
tdc.CreateCompatibleDC(&dc);
CBitmap*pOld=tdc.SelectObject(&bm);
tdc.SetStretchBltMode(STRETCH_HALFTONE);
tdc.StretchBlt(0,0,Width,Height,&dc,0,0,SrcWidth,SrcHeight,SRCCOPY);
// tdc.BitBlt(0,0,Width,Height,&dc,0,0,SRCCOPY);
tdc.SelectObject(pOld);
BITMAP btm;
bm.GetBitmap(&btm);
DWORD size=btm.bmWidthBytes*btm.bmHeight;
LPSTR lpData=(LPSTR)GlobalAllocPtr(GPTR,size);
/////////////////////////////////////////////
BITMAPINFOHEADER bih;
bih.biBitCount=btm.bmBitsPixel;
bih.biClrImportant=0;
bih.biClrUsed=0;
bih.biCompression=0;
bih.biHeight=btm.bmHeight;
bih.biWidth=btm.bmWidth;
bih.biPlanes=1;
bih.biSize=sizeof(BITMAPINFOHEADER);
bih.biSizeImage=size;
bih.biXPelsPerMeter=0;
bih.biYPelsPerMeter=0;
///////////////////////////////////
GetDIBits(dc,bm,0,bih.biHeight,lpData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);
// bm.GetBitmapBits(size,lpData); //此函数在处理5-5-5模式的16位色下会出现颜色混乱
//////////////////////////////
static int filecount=0;
BITMAPFILEHEADER bfh;
bfh.bfReserved1=bfh.bfReserved2=0;
bfh.bfType=((WORD)('M'<< 8)|'B');
bfh.bfSize=54+size;
bfh.bfOffBits=54;
CFile bf;
if(bf.Open("capture.bmp",CFile::modeCreate|CFile::modeWrite)){
bf.WriteHuge(&bfh,sizeof(BITMAPFILEHEADER));
bf.WriteHuge(&bih,sizeof(BITMAPINFOHEADER));
bf.WriteHuge(lpData,size);
bf.Close();
// nCount++;
}
GlobalFreePtr(lpData);
UpdateData(FALSE);
}