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#
  4. graphics.Clear(color) - Incorrect color!

graphics.Clear(color) - Incorrect color!

Scheduled Pinned Locked Moved C#
graphicshelptutorialquestion
6 Posts 5 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.
  • R Offline
    R Offline
    redact207
    wrote on last edited by
    #1

    I have the following code, however it paints a different color :S Color blueColor = Color.FromArgb(41, 22, 111); g.clear(blueColor); It displays Ok on a display with a 32bit color depth, however when I change it to 16bit, it appears lighter than it should. I'm guessing this is because of the unused alpha value, or maybe it's doing something strange with the gamma - beats me? Does anyone know how to fix this so it displays the correct value on a 16bit display?? Thanks!

    D 1 Reply Last reply
    0
    • R redact207

      I have the following code, however it paints a different color :S Color blueColor = Color.FromArgb(41, 22, 111); g.clear(blueColor); It displays Ok on a display with a 32bit color depth, however when I change it to 16bit, it appears lighter than it should. I'm guessing this is because of the unused alpha value, or maybe it's doing something strange with the gamma - beats me? Does anyone know how to fix this so it displays the correct value on a 16bit display?? Thanks!

      D Offline
      D Offline
      Daniel Monzert
      wrote on last edited by
      #2

      It doesn't sound strange to me, since RGB is a 24 bit value, even if computers like powers of 2. If no color table is used, then the 24 bit value needs to be encoded as a 16 bit color which is 5 bits for each color (red, green blue), 1 bit unused. I may be not completely right with that. E.g. a 16 bit color can be converted to a 32 bit value with: Color32 = ( (((Color16 >> 10) & 0x1F) * 0xFF / 0x1F) | ((((Color16 >> 5) & 0x1F) * 0xFF / 0x1F) << 8) | ((( Color16 & 0x1F) * 0xFF / 0x1F) << 16)); Looks weird. A 16 bit color may look like tihs. 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 <- Bits U R R R R R G G G G G B B B B B <- Color U = Unused R = Red ...

      R D 2 Replies Last reply
      0
      • D Daniel Monzert

        It doesn't sound strange to me, since RGB is a 24 bit value, even if computers like powers of 2. If no color table is used, then the 24 bit value needs to be encoded as a 16 bit color which is 5 bits for each color (red, green blue), 1 bit unused. I may be not completely right with that. E.g. a 16 bit color can be converted to a 32 bit value with: Color32 = ( (((Color16 >> 10) & 0x1F) * 0xFF / 0x1F) | ((((Color16 >> 5) & 0x1F) * 0xFF / 0x1F) << 8) | ((( Color16 & 0x1F) * 0xFF / 0x1F) << 16)); Looks weird. A 16 bit color may look like tihs. 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 <- Bits U R R R R R G G G G G B B B B B <- Color U = Unused R = Red ...

        R Offline
        R Offline
        redact207
        wrote on last edited by
        #3

        thanks for the explaination - i kinda get what you mean. One thing i don't understand, however, is the color16 and how to get the final value into a "Color" obj?? cheers!

        1 Reply Last reply
        0
        • D Daniel Monzert

          It doesn't sound strange to me, since RGB is a 24 bit value, even if computers like powers of 2. If no color table is used, then the 24 bit value needs to be encoded as a 16 bit color which is 5 bits for each color (red, green blue), 1 bit unused. I may be not completely right with that. E.g. a 16 bit color can be converted to a 32 bit value with: Color32 = ( (((Color16 >> 10) & 0x1F) * 0xFF / 0x1F) | ((((Color16 >> 5) & 0x1F) * 0xFF / 0x1F) << 8) | ((( Color16 & 0x1F) * 0xFF / 0x1F) << 16)); Looks weird. A 16 bit color may look like tihs. 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 <- Bits U R R R R R G G G G G B B B B B <- Color U = Unused R = Red ...

          D Offline
          D Offline
          Dan Neely
          wrote on last edited by
          #4

          IIRC rather than wasting a bit the green channel has 6 bits instead of 5 like the red/blue. I've no idea what makes green special.

          R A 2 Replies Last reply
          0
          • D Dan Neely

            IIRC rather than wasting a bit the green channel has 6 bits instead of 5 like the red/blue. I've no idea what makes green special.

            R Offline
            R Offline
            Roger Alsing 0
            wrote on last edited by
            #5

            yepp you are correct about the extra green bit.. because the human eye is more sensitive to see variations of green (i guess since our tree climbing/plains crawling days) //Roger

            1 Reply Last reply
            0
            • D Dan Neely

              IIRC rather than wasting a bit the green channel has 6 bits instead of 5 like the red/blue. I've no idea what makes green special.

              A Offline
              A Offline
              Anthony Baraff
              wrote on last edited by
              #6

              The human eye is more sensitive to differences in green.

              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