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 into RGB

GetPixel into RGB

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 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.
  • J Offline
    J Offline
    Johpoke
    wrote on last edited by
    #1

    Ive been using SetPixel alot, where i feed it seperate R G B values, but now im playing with GetPixel, but it only seems to return one big bitwise value, so how can i most cpu friendly wise convert this big number into 3 sperate ints? thanks

    /Johannes

    D 1 Reply Last reply
    0
    • J Johpoke

      Ive been using SetPixel alot, where i feed it seperate R G B values, but now im playing with GetPixel, but it only seems to return one big bitwise value, so how can i most cpu friendly wise convert this big number into 3 sperate ints? thanks

      /Johannes

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Johpoke wrote:

      so how can i most cpu friendly wise convert this big number into 3 sperate ints?

      Why not just use GetRValue(), GetGValue(), and GetBValue()?


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      J 1 Reply Last reply
      0
      • D David Crow

        Johpoke wrote:

        so how can i most cpu friendly wise convert this big number into 3 sperate ints?

        Why not just use GetRValue(), GetGValue(), and GetBValue()?


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        J Offline
        J Offline
        Johpoke
        wrote on last edited by
        #3

        That sounds right, but how do i connect them or use them correctly? i just get out weird characters, no numbers.. :/

        /Johannes

        D 1 Reply Last reply
        0
        • J Johpoke

          That sounds right, but how do i connect them or use them correctly? i just get out weird characters, no numbers.. :/

          /Johannes

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Johpoke wrote:

          ...but how do i connect them...

          Huh?

          Johpoke wrote:

          i just get out weird characters, no numbers..

          How are you using those functions?


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          J 1 Reply Last reply
          0
          • D David Crow

            Johpoke wrote:

            ...but how do i connect them...

            Huh?

            Johpoke wrote:

            i just get out weird characters, no numbers..

            How are you using those functions?


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

            J Offline
            J Offline
            Johpoke
            wrote on last edited by
            #5

            im not sure if im using them correctlt, msdn didnt explain alot, first i tried geting pixel, and sening the int to getrbvale, i also tried some other data types, and last i tied: cout</Johannes

            D 1 Reply Last reply
            0
            • J Johpoke

              im not sure if im using them correctlt, msdn didnt explain alot, first i tried geting pixel, and sening the int to getrbvale, i also tried some other data types, and last i tied: cout</Johannes

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Johpoke wrote:

              cout< This is doing exactly what it is supposed to (i.e., printing the character equivalent of the red value). Since your red value is likely not a printable character (e.g., some value less than 33 or greater than 127), that's why you're not seeing a number. Cast it to an int instead.

              Johpoke wrote:

              how do i get the Rvalue G and B for the pixel seperate??

              By using the three functions I mentioned earlier.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              J 1 Reply Last reply
              0
              • D David Crow

                Johpoke wrote:

                cout< This is doing exactly what it is supposed to (i.e., printing the character equivalent of the red value). Since your red value is likely not a printable character (e.g., some value less than 33 or greater than 127), that's why you're not seeing a number. Cast it to an int instead.

                Johpoke wrote:

                how do i get the Rvalue G and B for the pixel seperate??

                By using the three functions I mentioned earlier.


                "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                "Judge not by the eye but by the heart." - Native American Proverb

                J Offline
                J Offline
                Johpoke
                wrote on last edited by
                #7

                yep feeding it into int, or doing int(GetR... works great thanks for the help!

                /Johannes

                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