QQBitmap.cpp
资源名称:CQQFind.rar [点击查看]
上传用户:cxh888fhc
上传日期:2017-07-08
资源大小:240k
文件大小:18k
源码类别:
钩子与API截获
开发平台:
Visual C++
- // QQBitmap.cpp: implementation of the CQQBitmap class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "CQQFind.h"
- #include "QQBitmap.h"
- #include <math.h>
- #include <winable.h>
- #include <winuser.h>
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CQQBitmap::CQQBitmap()
- {
- m_hWnd=(HWND)-1;
- }
- CQQBitmap::CQQBitmap(CString strFilePath)
- {
- //以一个数据文件作为初始化,供测试用
- #ifdef _DEBUG
- CFile file;
- if(GetFileAttributes(strFilePath)==-1)
- {
- return ;
- }
- if(!file.Open(strFilePath,CFile::modeRead))
- return ;
- BITMAPFILEHEADER bmfih;
- DWORD nFileLen;
- nFileLen=file.GetLength();
- if(file.Read((LPSTR)&bmfih,sizeof(bmfih))!=sizeof(bmfih))
- {
- file.Close();
- return;
- }
- if(bmfih.bfType!=((WORD)('M'<<8)|'B'))
- {
- MessageBox(NULL,"不是bmp文件!","错误",MB_ICONWARNING);
- file.Close();
- return ;
- }
- HGLOBAL hDIB=::GlobalAlloc(GMEM_FIXED,nFileLen);
- if(hDIB==NULL)
- {
- file.Close();
- return ;
- }
- if(file.ReadHuge((LPSTR)hDIB,nFileLen-sizeof(BITMAPFILEHEADER))!=
- nFileLen-sizeof(BITMAPFILEHEADER))
- {
- ::GlobalFree(hDIB);
- file.Close();
- return ;
- }
- BITMAPINFO &bmInfo=*(LPBITMAPINFO)::GlobalLock(hDIB);
- BYTE *pBmpPixelBuffer=(BYTE *)&bmInfo+bmfih.bfOffBits-
- sizeof(BITMAPFILEHEADER);
- CClientDC dc(NULL);
- HBITMAP hBitmap;
- hBitmap=CreateDIBitmap(dc.m_hDC,(BITMAPINFOHEADER *)&bmInfo,
- CBM_INIT,(VOID *)pBmpPixelBuffer,&bmInfo,DIB_RGB_COLORS);
- ::GlobalUnlock(hDIB);
- ::GlobalFree(hDIB);
- file.Close();
- m_bpAllPicture.Attach(hBitmap);
- CheckStyle();
- DividPicture();
- FindDifferent();
- #endif
- }
- CQQBitmap::~CQQBitmap()
- {
- m_hWnd=(HWND)-1;
- }
- CQQBitmap::CQQBitmap(HWND hWnd)
- {
- m_hWnd=hWnd;
- ::BringWindowToTop(hWnd);
- CClientDC dc(CWnd::FromHandle(hWnd));
- int BitPerPixel=dc.GetDeviceCaps(BITSPIXEL);
- CRect rcTemp;
- ::GetClientRect(hWnd,rcTemp);
- int Width=rcTemp.right;
- int Height=rcTemp.bottom;
- CDC memDC;
- memDC.CreateCompatibleDC(&dc);
- CBitmap *pOldmemBitmap;
- m_bpAllPicture.CreateCompatibleBitmap(&dc,Width,Height);
- pOldmemBitmap=memDC.SelectObject(&m_bpAllPicture);
- memDC.BitBlt(0,0,Width,Height,&dc,0,0,SRCCOPY);
- memDC.SelectObject(pOldmemBitmap);
- CheckStyle();
- DividPicture();
- FindDifferent();
- }
- BOOL CQQBitmap::SetCurrenthWnd(HWND hWnd)
- {
- if(hWnd!=(HWND)-1)
- {
- m_hWnd=hWnd;
- if(hWnd==NULL)
- {
- MessageBox(NULL,"没有开启QQ游戏!","错误",MB_ICONWARNING);
- return FALSE;
- }
- ::BringWindowToTop(hWnd);
- CClientDC dc(CWnd::FromHandle(hWnd));
- int BitPerPixel=dc.GetDeviceCaps(BITSPIXEL);
- CRect rcTemp;
- ::GetClientRect(hWnd,rcTemp);
- int Width=rcTemp.right;
- int Height=rcTemp.bottom;
- CDC memDC;
- memDC.CreateCompatibleDC(&dc);
- CBitmap *pOldmemBitmap;
- m_bpAllPicture.CreateCompatibleBitmap(&dc,Width,Height);
- pOldmemBitmap=memDC.SelectObject(&m_bpAllPicture);
- memDC.BitBlt(0,0,Width,Height,&dc,0,0,SRCCOPY);
- memDC.SelectObject(pOldmemBitmap);
- DividPicture();
- FindDifferent();
- return TRUE;
- }
- return FALSE;
- }
- BOOL CQQBitmap::DividPicture()
- {
- /////////////////////////////////////////////////
- DividPictureV();
- DividPictureH();
- //图片划分完毕.可以开始找数据了
- return TRUE;
- }
- void CQQBitmap::PrintBitmapToFile(CString strFilePath,BOOL bBitmapFormat)
- {
- #ifdef _DEBUG
- if(m_bpAllPicture.m_hObject==NULL)
- {
- return ;
- }
- BITMAP bmp;
- CClientDC dc(NULL);
- m_bpAllPicture.GetBitmap(&bmp);
- strFilePath.Insert(strFilePath.GetLength()-4,"All");
- CFile file(strFilePath,CFile::modeWrite|CFile::modeCreate);
- strFilePath.Delete(strFilePath.GetLength()-7,3);
- BITMAPINFOHEADER bih={0};
- bih.biBitCount=bmp.bmBitsPixel;
- bih.biCompression=BI_RGB;
- bih.biHeight=bmp.bmHeight;
- bih.biPlanes=1;
- bih.biSize=sizeof(BITMAPINFOHEADER);
- bih.biSizeImage=bmp.bmWidthBytes*bmp.bmHeight;
- bih.biWidth=bmp.bmWidth;
- BITMAPFILEHEADER bfh={0};
- bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
- bfh.bfSize=bfh.bfOffBits+bmp.bmWidthBytes*bmp.bmHeight;
- bfh.bfType=(WORD)(_T('M')<<8|_T('B'));
- file.Write(&bfh,sizeof(BITMAPFILEHEADER));
- file.Write(&bih,sizeof(BITMAPINFOHEADER));
- BYTE *p=new BYTE[bmp.bmWidthBytes * bmp.bmHeight];
- if(bBitmapFormat==TRUE)
- {
- GetDIBits( dc.m_hDC,(HBITMAP)m_bpAllPicture,0,bmp.bmHeight,p,
- (LPBITMAPINFO)&bih,DIB_RGB_COLORS);
- }
- else
- {
- m_bpAllPicture.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)p);
- }
- file.WriteHuge(p,bmp.bmWidthBytes * bmp.bmHeight);
- delete[] p;
- file.Close();
- if(m_bpPicture1.m_hObject==NULL)
- {
- return;
- }
- m_bpPicture1.GetBitmap(&bmp);
- strFilePath.Insert(strFilePath.GetLength()-4,"Prt1");
- CFile file1(strFilePath,CFile::modeWrite|CFile::modeCreate);
- strFilePath.Delete(strFilePath.GetLength()-8,4);
- memset(&bih,0,sizeof(BITMAPINFOHEADER));
- bih.biBitCount=bmp.bmBitsPixel;
- bih.biCompression=BI_RGB;
- bih.biHeight=bmp.bmHeight;
- bih.biPlanes=1;
- bih.biSize=sizeof(BITMAPINFOHEADER);
- bih.biSizeImage=bmp.bmWidthBytes*bmp.bmHeight;
- bih.biWidth=bmp.bmWidth;
- memset(&bfh,0,sizeof(BITMAPFILEHEADER));
- bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
- bfh.bfSize=bfh.bfOffBits+bmp.bmWidthBytes*bmp.bmHeight;
- bfh.bfType=(WORD)(_T('M')<<8|_T('B'));
- file1.Write(&bfh,sizeof(BITMAPFILEHEADER));
- file1.Write(&bih,sizeof(BITMAPINFOHEADER));
- BYTE *p1=new BYTE[bmp.bmWidthBytes * bmp.bmHeight];
- if(bBitmapFormat==TRUE)
- {
- GetDIBits( dc.m_hDC,(HBITMAP)m_bpPicture1,0,bmp.bmHeight,p1,
- (LPBITMAPINFO)&bih,DIB_RGB_COLORS);
- }
- else
- {
- m_bpPicture1.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)p1);
- }
- file1.WriteHuge(p1,bmp.bmWidthBytes * bmp.bmHeight);
- file1.Close();
- delete[] p1;
- if(m_bpPicture2.m_hObject==NULL)
- {
- return;
- }
- m_bpPicture2.GetBitmap(&bmp);
- strFilePath.Insert(strFilePath.GetLength()-4,"Prt2");
- CFile file2(strFilePath,CFile::modeWrite|CFile::modeCreate);
- strFilePath.Delete(strFilePath.GetLength()-8,4);
- memset(&bih,0,sizeof(BITMAPINFOHEADER));
- bih.biBitCount=bmp.bmBitsPixel;
- bih.biCompression=BI_RGB;
- bih.biHeight=bmp.bmHeight;
- bih.biPlanes=1;
- bih.biSize=sizeof(BITMAPINFOHEADER);
- bih.biSizeImage=bmp.bmWidthBytes*bmp.bmHeight;
- bih.biWidth=bmp.bmWidth;
- memset(&bfh,0,sizeof(BITMAPFILEHEADER));
- bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
- bfh.bfSize=bfh.bfOffBits+bmp.bmWidthBytes*bmp.bmHeight;
- bfh.bfType=(WORD)(_T('M')<<8|_T('B'));
- file2.Write(&bfh,sizeof(BITMAPFILEHEADER));
- file2.Write(&bih,sizeof(BITMAPINFOHEADER));
- BYTE *p2=new BYTE[bmp.bmWidthBytes * bmp.bmHeight];
- if(bBitmapFormat==TRUE)
- {
- GetDIBits( dc.m_hDC,(HBITMAP)m_bpPicture2,0,bmp.bmHeight,p2,
- (LPBITMAPINFO)&bih,DIB_RGB_COLORS);
- }
- else
- {
- m_bpPicture2.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)p2);
- }
- file2.WriteHuge(p2,bmp.bmWidthBytes * bmp.bmHeight);
- file2.Close();
- delete []p2;
- #endif
- }
- BOOL CQQBitmap::DividPictureV()
- {
- //垂直分割图片,以m_bpAllPicture为蓝本,结果保存到m_bpPicture1中
- BITMAP bmp;
- m_bpAllPicture.GetBitmap(&bmp);
- int nPosX=bmp.bmWidthBytes;
- int nPosY=bmp.bmHeight;
- BYTE *pData1=new BYTE[nPosX*nPosY];
- m_bpAllPicture.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)pData1);
- LONG *pData=(LONG*)pData1;
- ASSERT(nPosX%4==0);
- nPosX/=4;
- // int x,y;
- //
- // int nSameColorLineX=0;
- // BOOL bNewBegin=TRUE;
- // int nTop=-1,nBottom=-1;
- // //此标志为真,预示着当前正在经历非线条
- //
- // for(y=0;y<nPosY;y++)
- // {
- // LONG tempPre;
- //
- // int nDiff=0;
- // for(x=0;x<nPosX;x++)
- // {
- // LONG temp=pData[y*nPosX+x];
- // if(x==0)
- // {
- // tempPre=temp;
- // continue;
- // }
- //
- // BYTE /*t4,*/t3,t2,t1;
- //// t4=HIBYTE(HIWORD(temp)); //保留
- // t3=LOBYTE(HIWORD(temp)); //红色
- // t2=HIBYTE(LOWORD(temp)); //绿色
- // t1=LOBYTE(LOWORD(temp)); //蓝色
- // BYTE p1,p2,p3/*,p4*/;
- //// p4=HIBYTE(HIWORD(tempPre)); //保留
- // p3=LOBYTE(HIWORD(tempPre)); //红色
- // p2=HIBYTE(LOWORD(tempPre)); //绿色
- // p1=LOBYTE(LOWORD(tempPre)); //蓝色
- //
- // if(abs((UINT)t1-(UINT)p1)<=20&&abs((UINT)t2-(UINT)p2)<=20&&
- // abs((UINT)t3-(UINT)p3)<=20)
- // {
- // //do nothing;
- // }
- // else
- // {
- // //出现一行的颜色变化幅度非常大,则认为此行为非分割线条
- // nDiff++;
- // if(nDiff>=10)
- // {
- // if(nSameColorLineX==3&&nTop==-1)
- // {
- // //处于top位置
- // nTop=y;
- // }
- // bNewBegin=TRUE;
- // break;
- // //此行无需再比较,直接跳出;
- // }
- // }
- // tempPre=temp;
- // }
- //
- // if(x>=nPosX)
- // {
- // //刚刚经历了分割线条
- // if(bNewBegin==TRUE)
- // {
- // nSameColorLineX++;
- // if(nSameColorLineX==4&&nBottom==-1)
- // {
- // //记录下下限位置
- // nBottom=y-1;
- // }
- // bNewBegin=FALSE;
- // }
- // }
- // }
- //
- int nTop,nBottom;
- //卡通场的数据;
- if(m_bSmall==TRUE)
- {
- nTop=186;
- nBottom=471;
- }
- else
- {
- nTop=192;
- nBottom=639;
- }
- LONG *pData2=new LONG[nPosX*(nBottom-nTop+1)];
- memcpy(pData2,&pData[nTop*nPosX],nPosX*4*(nBottom-nTop+1));
- delete []pData1;
- m_nTop=nTop;
- m_nBottom=nBottom;
- BITMAPINFO bih={0};
- bih.bmiHeader.biBitCount=bmp.bmBitsPixel;
- bih.bmiHeader.biCompression=BI_RGB;
- bih.bmiHeader.biHeight=-nBottom+nTop-1;
- bih.bmiHeader.biPlanes=1;
- bih.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
- bih.bmiHeader.biWidth=nPosX;
- bih.bmiHeader.biSizeImage=bih.bmiHeader.biWidth*bih.bmiHeader.biHeight*4;
- CClientDC dc(NULL);
- HBITMAP hBitmap;
- hBitmap=CreateDIBitmap(dc.m_hDC,(BITMAPINFOHEADER *)&bih,
- CBM_INIT,(VOID *)pData2,&bih,DIB_RGB_COLORS);
- m_bpPicture1.Attach(hBitmap);
- delete []pData2;
- return TRUE;
- }
- BOOL CQQBitmap::DividPictureH()
- {
- //垂直分割图片,以m_bpPicture1为蓝本,结果保存到m_bpPicture1,2中
- int p1Left,p1Right,p2Left,p2Right;
- if(m_bSmall==FALSE)
- {
- p1Left=8;
- p1Right=504;
- p2Left=517;
- p2Right=1013;
- }
- else
- {
- p1Left=10;
- p1Right=390;
- p2Left=403;
- p2Right=783;
- }
- m_nP1Right=p1Right;
- m_nP1Left=p1Left;
- m_nP2Left=p2Left;
- BITMAP bmp;
- m_bpPicture1.GetBitmap(&bmp);
- int nPosX=bmp.bmWidthBytes;
- int nPosY=bmp.bmHeight;
- BYTE *pData1=new BYTE[nPosX*nPosY];
- m_bpPicture1.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)pData1);
- LONG *pData=(LONG*)pData1;
- ASSERT(nPosX%4==0);
- nPosX/=4;
- LONG *pTempData=new LONG[bmp.bmHeight*(p1Right-p1Left+1)];
- for(int j=0;j<bmp.bmHeight;j++)
- {
- for(int i=p1Left;i<=p1Right;i++)
- {
- pTempData[j*(p1Right-p1Left+1)+i-p1Left]=pData[j*nPosX+i];
- }
- }
- BITMAPINFO bih={0};
- bih.bmiHeader.biBitCount=bmp.bmBitsPixel;
- bih.bmiHeader.biCompression=BI_RGB;
- bih.bmiHeader.biHeight=-bmp.bmHeight;
- bih.bmiHeader.biPlanes=1;
- bih.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
- bih.bmiHeader.biWidth=p1Right-p1Left+1;
- bih.bmiHeader.biSizeImage=bih.bmiHeader.biWidth*bih.bmiHeader.biHeight*4;
- CClientDC dc(NULL);
- HBITMAP hBitmap;
- hBitmap=CreateDIBitmap(dc.m_hDC,(BITMAPINFOHEADER *)&bih,
- CBM_INIT,(VOID *)pTempData,&bih,DIB_RGB_COLORS);
- m_bpPicture1.Detach();
- m_bpPicture1.Attach(hBitmap);
- for(j=0;j<bmp.bmHeight;j++)
- {
- for(int i=p2Left;i<=p2Right;i++)
- {
- pTempData[j*(p2Right-p2Left+1)+i-p2Left]=pData[j*nPosX+i];
- }
- }
- bih.bmiHeader.biWidth=p2Right-p2Left+1;
- bih.bmiHeader.biSizeImage=bih.bmiHeader.biWidth*bih.bmiHeader.biHeight*4;
- hBitmap=CreateDIBitmap(dc.m_hDC,(BITMAPINFOHEADER *)&bih,
- CBM_INIT,(VOID *)pTempData,&bih,DIB_RGB_COLORS);
- m_bpPicture2.Attach(hBitmap);
- delete []pTempData;
- delete []pData1;
- return TRUE;
- }
- //void CQQBitmap::GetHLine(int &p1Left,int &p1Right,int &p2Left,int &p2Right)
- //{
- // BITMAP bmp;
- // m_bpPicture1.GetBitmap(&bmp);
- // int nPosX=bmp.bmWidthBytes;
- // int nPosY=bmp.bmHeight;
- // BYTE *pData1=new BYTE[nPosX*nPosY];
- // m_bpPicture1.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)pData1);
- //
- // LONG *pData=(LONG*)pData1;
- // ASSERT(nPosX%4==0);
- // nPosX/=4;
- //
- // for(int i=0;i<nPosY;i++)
- // {
- // for(int j=0;j<nPosX;j++)
- // {
- // LONG temp=pData[i*nPosX+j];
- // BYTE t4,t3,t2,t1;
- // t4=HIBYTE(HIWORD(temp)); //保留
- // t3=LOBYTE(HIWORD(temp)); //红色
- // t2=HIBYTE(LOWORD(temp)); //绿色
- // t1=LOBYTE(LOWORD(temp)); //蓝色
- //
- // if(t1>=110&&t2>=110&&t3>=110)
- // {
- // pData[i*nPosX+j]=255|255<<8|255<<16|255<<24;
- // }
- // else
- // {
- // pData[i*nPosX+j]=0|0<<8|0<<16|0<<24;
- // }
- // }
- // }
- //
- // m_bpPicture1.SetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,pData1);
- // PrintBitmapToFile("测试1.bmp",TRUE);
- //
- // int x,y;
- // int nGet=1;
- // BOOL bInGet=FALSE;
- // for(x=0;x<nPosX;x++)
- // {
- // int nBlack=0;
- // for(y=0;y<nPosY;y++)
- // {
- // LONG temp1=pData[y*nPosX+x];
- // if(temp1==(0|0<<8|0<<16|0<<24))
- // {
- // //出现黑色点超过十个,认为不是垂直线条区域,直接跳出
- // if(++nBlack>=10)
- // {
- // if(bInGet==TRUE)
- // {
- // bInGet=FALSE;
- // nGet++;
- // }
- // break;
- // }
- // }
- // }
- //
- // if(y>=nPosY)
- // {
- // //出现了第一条线全都是白色的列线条
- // if(nGet==1)
- // {
- // bInGet=TRUE;
- // p1Left=x;
- // }
- // else if(nGet==2)
- // {
- // //出现第二条白线
- // p1Right=x;
- // nGet++;
- // }
- // else if(nGet==3)
- // {
- // p2Left=x;
- // bInGet=TRUE;
- // }
- // else if(nGet==4)
- // {
- // p2Right=x;
- // break;
- // }
- // }
- // }
- //
- // delete []pData1;
- // p1Left++;
- // p1Right--;
- // p2Left++;
- // p2Right--;
- // ASSERT(p1Right-p1Left==p2Right-p2Left);
- //}
- void CQQBitmap::FindDifferent()
- {
- BITMAP bmp;
- m_bpPicture1.GetBitmap(&bmp);
- int nPosX=bmp.bmWidthBytes;
- int nPosY=bmp.bmHeight;
- BYTE *pDataX=new BYTE[nPosX*nPosY];
- m_bpPicture1.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)pDataX);
- LONG *pData1=(LONG*)pDataX;
- BYTE *pDataY=new BYTE[nPosX*nPosY];
- m_bpPicture2.GetBitmap(&bmp);
- ASSERT((nPosX==bmp.bmWidthBytes)&&(nPosY==bmp.bmHeight));
- m_bpPicture2.GetBitmapBits(bmp.bmWidthBytes * bmp.bmHeight,(LPVOID)pDataY);
- LONG *pData2=(LONG*)pDataY;
- ASSERT(nPosX%4==0);
- nPosX/=4;
- int x,y;
- for(y=0;y<nPosY;y++)
- {
- for(x=0;x<nPosX;x++)
- {
- int n=m_arrayDifRect.GetSize();
- POINT ptTemp;
- ptTemp.x=x;
- ptTemp.y=y;
- while(n)
- {
- n--;
- RECT rcTemp=m_arrayDifRect.GetAt(n);
- rcTemp.left=rcTemp.left-6>0?rcTemp.left-6:0;
- rcTemp.right+=6;
- rcTemp.top=rcTemp.top-6>0?rcTemp.top-6:0;;
- rcTemp.bottom+=6;
- if(PtInRect(&rcTemp,ptTemp)==TRUE)
- {
- break;
- }
- }
- if(n>0)
- {
- continue;
- }
- if(pData2[y*nPosX+x]!=pData1[y*nPosX+x])
- {
- //向右寻找,直到连续五个像素都相同,则认为为右边界
- int nRight,nBottom,nFlag=0;
- for(nRight=x+1;nRight<nPosX;nRight++)
- {
- if(pData2[y*nPosX+nRight]==pData1[y*nPosX+nRight])
- {
- nFlag++;
- if(nFlag>=5)
- {
- break;
- }
- }
- else
- {
- nFlag=0;
- }
- }
- if(nFlag<5)
- {
- //nRight到达右极限
- nRight=nPosX-1-nFlag;
- }
- else
- {
- //达到五个像素连续相同的条件
- nRight=nRight-5;
- }
- //向下寻找,知道连续个像素都相同,则认为为下边界
- nFlag=0;
- for(nBottom=y+1;nBottom<nPosY;nBottom++)
- {
- if(pData2[nBottom*nPosX+x]==pData1[nBottom*nPosX+x])
- {
- nFlag++;
- if(nFlag>=5)
- {
- break;
- }
- }
- else
- {
- nFlag=0;
- }
- }
- if(nFlag<5)
- {
- //nRight到达右极限
- nBottom=nPosY-1-nFlag;
- }
- else
- {
- //达到五个像素连续相同的条件
- nBottom=nBottom-5;
- }
- RECT rcTemp;
- rcTemp.left=x;
- rcTemp.top=y;
- rcTemp.right=nRight;
- rcTemp.bottom=nBottom;
- m_arrayDifRect.Add(rcTemp);
- x=nRight;
- }
- }
- }
- int nCount=m_arrayDifRect.GetSize();
- int i=0;
- //#ifdef _DEBUG
- // while(i<nCount)
- // {
- // //调整坐标位置为相对于窗体的位置
- // RECT rcTemp=m_arrayDifRect.GetAt(i);
- // rcTemp.left+=m_nP1Left;
- // rcTemp.right+=m_nP1Left;
- // rcTemp.top+=m_nTop;
- // rcTemp.bottom+=m_nTop;
- // m_arrayDifRect.RemoveAt(i);
- // m_arrayDifRect.InsertAt(i,rcTemp);
- // i++;
- // }
- //#endif
- while(i<nCount)
- {
- RECT rcTemp=m_arrayDifRect.GetAt(i);
- m_arrayDifRect.RemoveAt(i);
- if(rcTemp.right-rcTemp.left<=6||rcTemp.bottom-rcTemp.top<=6)
- {
- nCount--;
- }
- else
- {
- m_arrayDifRect.InsertAt(i,rcTemp);
- i++;
- }
- }
- HDC hdcMem;
- CDC MemDC;
- CClientDC dc(NULL);
- hdcMem=CreateCompatibleDC(dc.m_hDC); //?????hdc?????dc
- MemDC.Attach(hdcMem);//?hdcMem?pMemDC????
- m_bpAllPicture.GetBitmap(&bmp);
- nPosX=bmp.bmWidthBytes;
- nPosY=bmp.bmHeight;
- CBitmap *pOldBitmap=MemDC.SelectObject(&m_bpAllPicture); //?????hdcMem,???hdcMem???????????dc?.
- CBrush *pOldBrush=(CBrush *)MemDC.SelectStockObject(NULL_BRUSH);
- CPen pen;
- pen.CreatePen(PS_SOLID,3,RGB(255,0,0));
- CPen *pOldPen=(CPen *)MemDC.SelectObject(&pen);
- nCount=m_arrayDifRect.GetSize();
- i=0;
- while(i<nCount)
- {
- RECT rcTemp;
- rcTemp=m_arrayDifRect.GetAt(i);
- MemDC.Ellipse(&rcTemp);
- i++;
- }
- MemDC.SelectObject(pOldPen);
- MemDC.SelectObject(pOldBrush);
- MemDC.SelectObject(pOldBitmap);
- PrintBitmapToFile("QQ游戏.bmp",TRUE);
- delete []pDataX;
- delete []pDataY;
- }
- void CQQBitmap::CheckStyle()
- {
- BITMAP bmp;
- m_bpAllPicture.GetBitmap(&bmp);
- if(bmp.bmHeight>=700&&bmp.bmWidth>=1000)
- {
- //美女场
- m_bSmall=FALSE;
- }
- else
- {
- //卡通场
- m_bSmall=TRUE;
- }
- }
- void CQQBitmap::GetDiffRects(CArray<RECT,RECT> &array)
- {
- int nCount=m_arrayDifRect.GetSize();
- int i=0;
- for(i=0;i<nCount;i++)
- {
- RECT rcTemp;
- rcTemp=m_arrayDifRect.GetAt(i);
- array.Add(rcTemp);
- }
- }
- void CQQBitmap::GetPicture1Rect(RECT &rcP1)
- {
- rcP1.left=m_nP1Left;
- rcP1.right=m_nP1Right;
- rcP1.top=m_nTop;
- rcP1.bottom=m_nBottom;
- }