Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do I access the pixels on the screen to read them?

How do I access the pixels on the screen to read them?

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicsgame-devdata-structurestutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sbscb
    wrote on last edited by
    #1

    I wanted to write some code or use a library to take the screen as an array of pixels and to locate a specific pixel by x-y axis of the screen, so for example I am running a program on the side which displays its output as graphics, like a card game, now I want to read the cards, in order to do this I will have to read the pixel at a specific location and see if it matches with a different array to "figure" out which card was displayed, and then have the program take the appropriate action. For example if it is poker and the cards are good to press a button to call/raise instead of folding and vice versa. Basically I need to read the screen, or a window and interpret the visual state.

    H L 2 Replies Last reply
    0
    • S sbscb

      I wanted to write some code or use a library to take the screen as an array of pixels and to locate a specific pixel by x-y axis of the screen, so for example I am running a program on the side which displays its output as graphics, like a card game, now I want to read the cards, in order to do this I will have to read the pixel at a specific location and see if it matches with a different array to "figure" out which card was displayed, and then have the program take the appropriate action. For example if it is poker and the cards are good to press a button to call/raise instead of folding and vice versa. Basically I need to read the screen, or a window and interpret the visual state.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Im not sure do you need to GetPixel ?


      WhiteSky


      1 Reply Last reply
      0
      • S sbscb

        I wanted to write some code or use a library to take the screen as an array of pixels and to locate a specific pixel by x-y axis of the screen, so for example I am running a program on the side which displays its output as graphics, like a card game, now I want to read the cards, in order to do this I will have to read the pixel at a specific location and see if it matches with a different array to "figure" out which card was displayed, and then have the program take the appropriate action. For example if it is poker and the cards are good to press a button to call/raise instead of folding and vice versa. Basically I need to read the screen, or a window and interpret the visual state.

        L Offline
        L Offline
        Llasus
        wrote on last edited by
        #3

        Just a suggestion. You can start by studying all about CDC. CWnd* MyDlg; CDC* MyDC; MyDlg = GetDlgItem(IDC_DISPLAYPANEL); //get the CDC of the display panel(ex. picture box) MyDC = MyDlg->GetDC(); From here by getting the CDC of your dialog, you can obtain it's bitmap by using CreateCompatibleBitmap() and obtain the data you'll need from your Bitmap object. Haven't tried it yet, though I am sure that these are the ones you will be needing for your application. :) Hope that helps.

        P 1 Reply Last reply
        0
        • L Llasus

          Just a suggestion. You can start by studying all about CDC. CWnd* MyDlg; CDC* MyDC; MyDlg = GetDlgItem(IDC_DISPLAYPANEL); //get the CDC of the display panel(ex. picture box) MyDC = MyDlg->GetDC(); From here by getting the CDC of your dialog, you can obtain it's bitmap by using CreateCompatibleBitmap() and obtain the data you'll need from your Bitmap object. Haven't tried it yet, though I am sure that these are the ones you will be needing for your application. :) Hope that helps.

          P Offline
          P Offline
          Perspx
          wrote on last edited by
          #4

          I'm not sure about the above two methods.. And I'm sure they work fine :) but I think that getting pixel values is quite intensive on the CPU/GPU, especially if you are getting a lot of pixel values at the same time.. --PerspX

          "Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates

          L 1 Reply Last reply
          0
          • P Perspx

            I'm not sure about the above two methods.. And I'm sure they work fine :) but I think that getting pixel values is quite intensive on the CPU/GPU, especially if you are getting a lot of pixel values at the same time.. --PerspX

            "Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates

            L Offline
            L Offline
            Llasus
            wrote on last edited by
            #5

            Yup, I was thinking about the heavy processing that it will require, specially the comparison. But if it is what was required of his application then it will be tough. Maybe he can just do the computation and comparison by using variables inside the program, instead of capturing the image outside. :)

            P 1 Reply Last reply
            0
            • L Llasus

              Yup, I was thinking about the heavy processing that it will require, specially the comparison. But if it is what was required of his application then it will be tough. Maybe he can just do the computation and comparison by using variables inside the program, instead of capturing the image outside. :)

              P Offline
              P Offline
              Perspx
              wrote on last edited by
              #6

              Llasus wrote:

              Yup, I was thinking about the heavy processing that it will require

              Yes it would :sigh:.. another thing to do would be to inject a DLL into the application and then monitor the messages to and from the window.. With this he could then send messages to the window to do certain tasks (if this is supported), and if, for example, there are custom messages, to get the numbers on certain cards. Hope this helps! --PerspX

              "Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups