Get color of screen pixel

Discussion in 'Mac Programming' started by SeMig, Dec 7, 2010.

  1. SeMig macrumors newbie

    Joined:
    Dec 7, 2010
    #1
    Hi!

    I'm writing an application for automating certain tasks.
    I'm using the ApplicationServices framework for moving the mouse and so on.

    I need to know how to get the color of a specific screen pixel.
    And what would be the faster way if i have to scan through multiple screen pixels? Using the above several times or is there a better way? (Maybe taking a screenshot?)

    I'm writing in C++.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    A basic way (not necessarily fastest) is to use the CGWindow API to grab an image of the screen and then you can extract what you need from it.

    The other method is to use OpenGL's glReadPixel() function.
     
  3. SeMig thread starter macrumors newbie

    Joined:
    Dec 7, 2010
    #3
    Somehow i think the CGWindow API is the fastest. Anyway i'll try it out. Thanks!
     

Share This Page