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. Colors: How To?

Colors: How To?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsregextutorialquestion
7 Posts 3 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
    soup
    wrote on last edited by
    #1

    Hi, I have a vanilla SDI app with a scroll view in it. I have also created a CWnd derived window intended to be used as a child window in a dialog etc to pick colors from. It is populated with about 400 colors obtained from a 3rd party source. All drawing seems to be OK, apart from: I choose a color in my derived child window, then click in the SDI view to 'draw with it' and the colors don't match up. I'm not sure if the view or the child window is drawing the colors wrong (hopefully not both as the colors are different!). I did put the RGB value of one color into Paint SHop Pro and it corresponded to the view, so I think the view is right. Is there anything you have to do to get a window (my derived child window) to have the same color depth as the view? Or is something else amiss? Thanks in advance, Simon :confused:

    C S L 4 Replies Last reply
    0
    • S soup

      Hi, I have a vanilla SDI app with a scroll view in it. I have also created a CWnd derived window intended to be used as a child window in a dialog etc to pick colors from. It is populated with about 400 colors obtained from a 3rd party source. All drawing seems to be OK, apart from: I choose a color in my derived child window, then click in the SDI view to 'draw with it' and the colors don't match up. I'm not sure if the view or the child window is drawing the colors wrong (hopefully not both as the colors are different!). I did put the RGB value of one color into Paint SHop Pro and it corresponded to the view, so I think the view is right. Is there anything you have to do to get a window (my derived child window) to have the same color depth as the view? Or is something else amiss? Thanks in advance, Simon :confused:

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you've managed to make different parts of your screen the same colour depth then I salute you. You may have a DIBSection that you are drawing on, and it may be any colour depth, so check that first - if it's 8 bit then there's your problem right there. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

      S 1 Reply Last reply
      0
      • C Christian Graus

        If you've managed to make different parts of your screen the same colour depth then I salute you. You may have a DIBSection that you are drawing on, and it may be any colour depth, so check that first - if it's 8 bit then there's your problem right there. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

        S Offline
        S Offline
        soup
        wrote on last edited by
        #3

        Christian, Thanks for the response. To be honest, I think there is a problem with the CDC that I am given. I simply pass it to the render function that creates a compatible dc with a compatible bitmap attached to it. I do this because I am drawing the state off-screen for flicker-free drawing. I will try drawing direct to the given DC, but I don't feel this will help at all. Is there anywhere that you can influence the color depth of a window's DC at creation or after? Simon

        1 Reply Last reply
        0
        • S soup

          Hi, I have a vanilla SDI app with a scroll view in it. I have also created a CWnd derived window intended to be used as a child window in a dialog etc to pick colors from. It is populated with about 400 colors obtained from a 3rd party source. All drawing seems to be OK, apart from: I choose a color in my derived child window, then click in the SDI view to 'draw with it' and the colors don't match up. I'm not sure if the view or the child window is drawing the colors wrong (hopefully not both as the colors are different!). I did put the RGB value of one color into Paint SHop Pro and it corresponded to the view, so I think the view is right. Is there anything you have to do to get a window (my derived child window) to have the same color depth as the view? Or is something else amiss? Thanks in advance, Simon :confused:

          S Offline
          S Offline
          soup
          wrote on last edited by
          #4

          Hmmm, most interesting. In case anyone was interested, I have overcome the problem, but storing the color not as 3 bytes, but as a COLORREF structure. I am slightly confused, since I thought all the COLORREF structure was is 3 byte values, but if it works, I ain't going to kick it! :laugh: Simon

          C 1 Reply Last reply
          0
          • S soup

            Hmmm, most interesting. In case anyone was interested, I have overcome the problem, but storing the color not as 3 bytes, but as a COLORREF structure. I am slightly confused, since I thought all the COLORREF structure was is 3 byte values, but if it works, I ain't going to kick it! :laugh: Simon

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            The problem was obviously in converting the COLORREF to unsigned char values, because that is all they are in the COLORREF Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

            1 Reply Last reply
            0
            • S soup

              Hi, I have a vanilla SDI app with a scroll view in it. I have also created a CWnd derived window intended to be used as a child window in a dialog etc to pick colors from. It is populated with about 400 colors obtained from a 3rd party source. All drawing seems to be OK, apart from: I choose a color in my derived child window, then click in the SDI view to 'draw with it' and the colors don't match up. I'm not sure if the view or the child window is drawing the colors wrong (hopefully not both as the colors are different!). I did put the RGB value of one color into Paint SHop Pro and it corresponded to the view, so I think the view is right. Is there anything you have to do to get a window (my derived child window) to have the same color depth as the view? Or is something else amiss? Thanks in advance, Simon :confused:

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Soup, while not having an answer as to why the two colours don't match up I do have this link for you. Try Color Picker, it's free and will show the RGB values for any area of the screen that is under the cursor. Should make it a bit easier than copying into Paint Shop Pro. Michael Martin Australia mjm68@tpg.com.au "Don't belong. Never join. Think for yourself. Peace" - Victor Stone

              1 Reply Last reply
              0
              • S soup

                Hi, I have a vanilla SDI app with a scroll view in it. I have also created a CWnd derived window intended to be used as a child window in a dialog etc to pick colors from. It is populated with about 400 colors obtained from a 3rd party source. All drawing seems to be OK, apart from: I choose a color in my derived child window, then click in the SDI view to 'draw with it' and the colors don't match up. I'm not sure if the view or the child window is drawing the colors wrong (hopefully not both as the colors are different!). I did put the RGB value of one color into Paint SHop Pro and it corresponded to the view, so I think the view is right. Is there anything you have to do to get a window (my derived child window) to have the same color depth as the view? Or is something else amiss? Thanks in advance, Simon :confused:

                S Offline
                S Offline
                soup
                wrote on last edited by
                #7

                Thanks for the input guys. Everything is back on track now. Simon :-D

                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