提示:本地函数定义是非法的,有谁可以帮我看看吗?。 5
boolFindPic(intx,inty,intxx,intyy,CStringFileName,doubles,int&rex,int&rey){CBitmapbmp...
bool FindPic(int x,int y,int xx,int yy, CString FileName, double s, int &rex,int &rey)
{
CBitmap bmp;
BITMAP bm;
HBITMAP hBmp;
CDC bmpDC;
hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),FileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
bmp.DeleteObject();
bmp.Attach( hBmp );
bmp.GetObject(sizeof(BITMAP),&bm);
bmpDC.CreateCompatibleDC(NULL);
bmpDC.SelectObject(&bmp); //图片DC
HDC hScreenDC = ::GetDC(NULL); //屏幕DC
bool found = false;//是否匹配到
bool next = false;//是否找下一个点
int width = bm.bmWidth;
int height = bm.bmHeight;
int limit = (double)(width * height) * (1-s);
int count = 0;
for (int i = x; i < (xx - width) && !found ; i++)
{
for (int j = y ; j < (yy - height) && !found ; j++)
{
next = false;
count = 0;
for (int a = 0;a<width && !next;a++)
{
for (int b = 0;b<height &&!next;b++)
{
if(GetPixel(hScreenDC,i+a,j+b) != bmpDC.GetPixel(a, b))
{
//next = true;//找屏幕中下一个点
count ++;
}
if (count > limit)
{
next = true;
}
}
}
if (!next)//找到点
{
found = true;
rex = i;
rey = j;
return true;
break;
}
}
}
return false;
}
错误C2601:'FindPic':本地函数定义是非法的 展开
{
CBitmap bmp;
BITMAP bm;
HBITMAP hBmp;
CDC bmpDC;
hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),FileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
bmp.DeleteObject();
bmp.Attach( hBmp );
bmp.GetObject(sizeof(BITMAP),&bm);
bmpDC.CreateCompatibleDC(NULL);
bmpDC.SelectObject(&bmp); //图片DC
HDC hScreenDC = ::GetDC(NULL); //屏幕DC
bool found = false;//是否匹配到
bool next = false;//是否找下一个点
int width = bm.bmWidth;
int height = bm.bmHeight;
int limit = (double)(width * height) * (1-s);
int count = 0;
for (int i = x; i < (xx - width) && !found ; i++)
{
for (int j = y ; j < (yy - height) && !found ; j++)
{
next = false;
count = 0;
for (int a = 0;a<width && !next;a++)
{
for (int b = 0;b<height &&!next;b++)
{
if(GetPixel(hScreenDC,i+a,j+b) != bmpDC.GetPixel(a, b))
{
//next = true;//找屏幕中下一个点
count ++;
}
if (count > limit)
{
next = true;
}
}
}
if (!next)//找到点
{
found = true;
rex = i;
rey = j;
return true;
break;
}
}
}
return false;
}
错误C2601:'FindPic':本地函数定义是非法的 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询