find x,y from pixel

This is a discussion on find x,y from pixel within the C++ Programming forums, part of the General Programming Boards category; ok I have the color of a pixel but I wont to find x,y of that pixl with out moving ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    43

    find x,y from pixel

    ok I have the color of a pixel but I wont to find x,y of that pixl with out moving the mouse over it. so far im thinking i need to use this.
    Code:
    COLORREF RGB(37, 124, 244);
    but I dont know what els to do.

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    I don't quite understand what you are asking, but what I think you are asking is this:

    "How can I find the RGB color value of a specific pixel on the screen at some coordinate (x,y)?"

    Is that correct? Or are you asking this question:

    "How can I find all pixels with coordinates (x,y) that have the specified RGB value which I know?"

    Whatever the case...I don't think COLORREF is what you want. It just stores some RGB value in memory as a "color". It has nothing to do with (x,y) coordinates.
    My Website

    "Circular logic is good because it is."

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> but I dont know what els to do.

    a book perhaps?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    43
    no thats not it but I think that i have figured it out thanks

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    If you are trying to get pixel x,y from pixel offset:

    Code:
    int pixel_x = offset &#37; (width);
    int pixel_y = offset / (width);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Find Dialog
    By Lithorien in forum Windows Programming
    Replies: 6
    Last Post: 04-25-2005, 05:28 PM
  3. Replies: 5
    Last Post: 04-16-2004, 01:29 AM
  4. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  5. how do u find 2nd largest number??
    By juancardenas in forum C Programming
    Replies: 8
    Last Post: 02-14-2003, 07:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21