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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetPixel() help

GetPixel() help

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++javacss
12 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.
  • A Offline
    A Offline
    arunforce
    wrote on last edited by
    #1

    I am trying to retrieve the RGB code of GetPixel() and I have a slight bit of understanding of C++, I'm pretty fluent in Java and VB.net, but the first parameter for the GetPixel function has to be some sort of HDC thing, how would I return it as RGB or hexadecimal, like using it as this: GetPixel(0,50,50); returns a number that is too large for an integer 42929... Can anyone help me? Please don't write a bunch of classes and constructors and stuff, just simple non-OOP code, best if its just one word, it's less confusing. Thanks alot.

    E 1 Reply Last reply
    0
    • A arunforce

      I am trying to retrieve the RGB code of GetPixel() and I have a slight bit of understanding of C++, I'm pretty fluent in Java and VB.net, but the first parameter for the GetPixel function has to be some sort of HDC thing, how would I return it as RGB or hexadecimal, like using it as this: GetPixel(0,50,50); returns a number that is too large for an integer 42929... Can anyone help me? Please don't write a bunch of classes and constructors and stuff, just simple non-OOP code, best if its just one word, it's less confusing. Thanks alot.

      E Offline
      E Offline
      Eytukan
      wrote on last edited by
      #2

      It returns a COLORREF (a DWORD in nature!), You must use GetRValue, GetGValue, and GetBValue to extract individual RGB values.


      Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

      A 1 Reply Last reply
      0
      • E Eytukan

        It returns a COLORREF (a DWORD in nature!), You must use GetRValue, GetGValue, and GetBValue to extract individual RGB values.


        Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

        A Offline
        A Offline
        arunforce
        wrote on last edited by
        #3

        Thanks, I sorta understand what you mean, but can you tell me what additional code I need to use it/how to set it up?

        E 1 Reply Last reply
        0
        • A arunforce

          Thanks, I sorta understand what you mean, but can you tell me what additional code I need to use it/how to set it up?

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          For eg:

          BYTE redValue;
          BYTE greenValue;
          BYTE blueValue;

          redValue = GetRValue(GetPixel(hdc,50,50));
          greenalue = GetGValue(GetPixel(hdc,50,50));
          blueValue = GetBValue(GetPixel(hdc,50,50));


          Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

          A 1 Reply Last reply
          0
          • E Eytukan

            For eg:

            BYTE redValue;
            BYTE greenValue;
            BYTE blueValue;

            redValue = GetRValue(GetPixel(hdc,50,50));
            greenalue = GetGValue(GetPixel(hdc,50,50));
            blueValue = GetBValue(GetPixel(hdc,50,50));


            Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

            A Offline
            A Offline
            arunforce
            wrote on last edited by
            #5

            hdc = undeclared identifier.

            E M A 4 Replies Last reply
            0
            • A arunforce

              hdc = undeclared identifier.

              E Offline
              E Offline
              Eytukan
              wrote on last edited by
              #6

              arunforce wrote:

              undeclared identifier.

              Weird exception!;P But is it not good you learn something before asking questions? I help you out : HDC[^]


              Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

              H 1 Reply Last reply
              0
              • A arunforce

                hdc = undeclared identifier.

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Are you trying to get the color of a pixel on the screen? In a bitmap? If a bitmap, what form of bitmap...Windows device independent, Windows device dependent?

                "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                1 Reply Last reply
                0
                • A arunforce

                  hdc = undeclared identifier.

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  You only wanted one word, but for Windows graphics programming, DCs are an essential concept, regardless of classes and OOP stuff. If you decide you want to learn it, here's some free info: Device Contexts[^]

                  "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                  1 Reply Last reply
                  0
                  • A arunforce

                    hdc = undeclared identifier.

                    A Offline
                    A Offline
                    arunforce
                    wrote on last edited by
                    #9

                    Sorry, I should of specified. It's just to get the pixel color of the pixel on the entire screen, doesn't matter what application or whatever, I could probably code it in VB or Java easier, but I want to make it professional. It's been a good 2 years since I've even touched C++, and it's a bit troubling. C++'s keywords and stuff throw me off, I find that it has no relation to a similar structure, and it's a bit confusing. I probably need more experience, but then again, I'm just 17. :/

                    M E 2 Replies Last reply
                    0
                    • A arunforce

                      Sorry, I should of specified. It's just to get the pixel color of the pixel on the entire screen, doesn't matter what application or whatever, I could probably code it in VB or Java easier, but I want to make it professional. It's been a good 2 years since I've even touched C++, and it's a bit troubling. C++'s keywords and stuff throw me off, I find that it has no relation to a similar structure, and it's a bit confusing. I probably need more experience, but then again, I'm just 17. :/

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #10

                      arunforce wrote:

                      It's just to get the pixel color of the pixel on the entire screen

                      In that case, as Vunic suggested, the GetDC(NULL) API will get you a screen DC. Don't forget to free it when you are finished with it (ReleaseDC()). Mark

                      "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                      1 Reply Last reply
                      0
                      • A arunforce

                        Sorry, I should of specified. It's just to get the pixel color of the pixel on the entire screen, doesn't matter what application or whatever, I could probably code it in VB or Java easier, but I want to make it professional. It's been a good 2 years since I've even touched C++, and it's a bit troubling. C++'s keywords and stuff throw me off, I find that it has no relation to a similar structure, and it's a bit confusing. I probably need more experience, but then again, I'm just 17. :/

                        E Offline
                        E Offline
                        Eytukan
                        wrote on last edited by
                        #11

                        arunforce wrote:

                        I could probably code it in VB or Java easier

                        Yup it is, when you opt for the Ignorance is bliss thinge. Just 17? Great, you are trying something good. At your age I never managed to install an IDE in my pc. The only user-made directory in my pc was "GAMES". C:\CD GAMES. :-D lol.. it was all games.


                        Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

                        1 Reply Last reply
                        0
                        • E Eytukan

                          arunforce wrote:

                          undeclared identifier.

                          Weird exception!;P But is it not good you learn something before asking questions? I help you out : HDC[^]


                          Press: 1500 to 2,200 messages in just 6 days? How's that possible sir? **Dr.Brad :**Well,I just replied to everything Graus did and then argued with Negus for a bit.

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

                          "undeclared identifier" Your code has an error maybe compiler has an internal error;P;)


                          WhiteSky


                          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