5 Replies - 5898 Views - Last Post: 17 January 2013 - 12:35 PM Rate Topic: -----

#1 rook21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-January 13

getPixel() with different resolutions

Posted 17 January 2013 - 09:28 AM

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?

Is This A Good Question/Topic? 0
  • +

Replies To: getPixel() with different resolutions

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3589
  • View blog
  • Posts: 11,161
  • Joined: 05-May 12

Re: getPixel() with different resolutions

Posted 17 January 2013 - 11:12 AM

Does your game change its window size based on the capabilities of display? Or are you guaranteed that you character health indicator will always be at pixel 200,200?
Was This Post Helpful? 0
  • +
  • -

#3 rook21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-January 13

Re: getPixel() with different resolutions

Posted 17 January 2013 - 11:34 AM

View PostSkydiver, on 17 January 2013 - 11:12 AM, said:

Does your game change its window size based on the capabilities of display? Or are you guaranteed that you character health indicator will always be at pixel 200,200?

It's actually in full screen and yes the pixel is at 200,200 on my desktop but not on my laptop because of the different resolution. Should I try to convert the coordinate based on the resolution?
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3589
  • View blog
  • Posts: 11,161
  • Joined: 05-May 12

Re: getPixel() with different resolutions

Posted 17 January 2013 - 12:05 PM

And does the game change screen layout depending on whether it's wide screen or 4:3 screen ratio?
Was This Post Helpful? 0
  • +
  • -

#5 rook21  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-January 13

Re: getPixel() with different resolutions

Posted 17 January 2013 - 12:17 PM

View PostSkydiver, on 17 January 2013 - 12:05 PM, said:

And does the game change screen layout depending on whether it's wide screen or 4:3 screen ratio?

Yes it does
Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg  Icon User is offline

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,682
  • Joined: 25-December 09

Re: getPixel() with different resolutions

Posted 17 January 2013 - 12:35 PM

Quote

Should I try to convert the coordinate based on the resolution?

Yes.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1