Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

getPixel() with different resolutions

$
0
0
I am trying to print out the color of a pixel (200,200). Ultimately I am trying to check the health of my player in a game based on the color of the pixel. However I have different resolutions on my laptop and desktop and I want the code to be able to find the right pixel.

This is what I have so far:
    HDC hdcScreen = GetDC(0);
    COLORREF color = GetPixel(hdcScreen, 200, 200);
    ReleaseDC(NULL, hdcScreen);
    int iRed = GetRValue(color);
    int iBlue = GetBValue(color);
    int iGreen = GetGValue(color);
    cout << iRed << "\n";
    cout << iBlue << "\n";
    cout << iGreen << "\n";

It doesn't get the same pixel on my laptop because of the resolution difference. What should I do?

Viewing all articles
Browse latest Browse all 51036

Trending Articles