HDC hdcScreen = GetDC(NULL); // 获取屏幕图像
HDC hdcDC = CreateCompatibleDC(hdcScreen); // 图形存入创建的内存上
HBITMAP hBitMap = CreateCompatibleBitmap(hdcScreen, fwx2, fwy2);//创建兼容位图
SelectObject(hdcDC, hBitMap);//将位图选入DC,并保存返回值
BitBlt(hdcDC, 0, 0, fwx2, fwy2, hdcScreen, 0, 0, SRCCOPY);//将屏幕DC的图象复制到内存DC中
int pmR, pmG, pmB;
Bitmap* pmbmp = Bitmap::FromHBITMAP(hBitMap, NULL);
for (int pmy = fwy1 + 25; pmy < fwy2; pmy++)//屏幕的
{
for (int pmx = fwx1; pmx < fwx2 ; pmx++)
{
pmbmp->GetPixel(pmx, pmy, &color);
pmR = (int)color.GetRed();
pmG = (int)color.GetGreen();
pmB = (int)color.GetBlue();
////对颜色进行比较
if (232 == pmR && 232 == pmG && 104 == pmB)
{
pmbmp->GetPixel(pmx - 10, pmy + 10, &color);
pmR = (int)color.GetRed();
pmG = (int)color.GetGreen();
pmB = (int)color.GetBlue();
if (232 == pmR && 232 == pmG && 104 == pmB)
{
ret.intX = pmx - 20, ret.intY = pmy - 9;
return ;
}
}
}
}
HDC hdcDC = CreateCompatibleDC(hdcScreen); // 图形存入创建的内存上
HBITMAP hBitMap = CreateCompatibleBitmap(hdcScreen, fwx2, fwy2);//创建兼容位图
SelectObject(hdcDC, hBitMap);//将位图选入DC,并保存返回值
BitBlt(hdcDC, 0, 0, fwx2, fwy2, hdcScreen, 0, 0, SRCCOPY);//将屏幕DC的图象复制到内存DC中
int pmR, pmG, pmB;
Bitmap* pmbmp = Bitmap::FromHBITMAP(hBitMap, NULL);
for (int pmy = fwy1 + 25; pmy < fwy2; pmy++)//屏幕的
{
for (int pmx = fwx1; pmx < fwx2 ; pmx++)
{
pmbmp->GetPixel(pmx, pmy, &color);
pmR = (int)color.GetRed();
pmG = (int)color.GetGreen();
pmB = (int)color.GetBlue();
////对颜色进行比较
if (232 == pmR && 232 == pmG && 104 == pmB)
{
pmbmp->GetPixel(pmx - 10, pmy + 10, &color);
pmR = (int)color.GetRed();
pmG = (int)color.GetGreen();
pmB = (int)color.GetBlue();
if (232 == pmR && 232 == pmG && 104 == pmB)
{
ret.intX = pmx - 20, ret.intY = pmy - 9;
return ;
}
}
}
}