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. Changing gamma with multiple display setup

Changing gamma with multiple display setup

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionworkspace
12 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.
  • V Offline
    V Offline
    Valentinor
    wrote on last edited by
    #1

    I made an app that used to works just fine to change gamma, and it still does, but with one condition, to have only one monitor connected. But the problem now is that I have 2 monitors, and the app doesn't work anymore, only if I disconnect one of them. Can anyone tell me what I need to change in order to make it work with multiple display setups? And if there is a way to change gamma on only one of them then that is a good bonus and will help with another idea that I have. This is what I'm using right now:

    WORD ramp\[256 \* 3\];
    for (int i = 0; i < 256; i++) {
    	ramp\[i\] = ramp\[i + 256\] = ramp\[i + 512\] =
    		(WORD)min(65535, max(0, pow((i + 1) / 256.0, ValueForLight) \* 65535 + 0.5));
    }
    SetDeviceGammaRamp(::GetDC(NULL), ramp);
    
    L 1 Reply Last reply
    0
    • V Valentinor

      I made an app that used to works just fine to change gamma, and it still does, but with one condition, to have only one monitor connected. But the problem now is that I have 2 monitors, and the app doesn't work anymore, only if I disconnect one of them. Can anyone tell me what I need to change in order to make it work with multiple display setups? And if there is a way to change gamma on only one of them then that is a good bonus and will help with another idea that I have. This is what I'm using right now:

      WORD ramp\[256 \* 3\];
      for (int i = 0; i < 256; i++) {
      	ramp\[i\] = ramp\[i + 256\] = ramp\[i + 512\] =
      		(WORD)min(65535, max(0, pow((i + 1) / 256.0, ValueForLight) \* 65535 + 0.5));
      }
      SetDeviceGammaRamp(::GetDC(NULL), ramp);
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      See the warnings at SetDeviceGammaRamp function (wingdi.h) - Win32 apps | Microsoft Docs[^].

      V 1 Reply Last reply
      0
      • L Lost User

        See the warnings at SetDeviceGammaRamp function (wingdi.h) - Win32 apps | Microsoft Docs[^].

        V Offline
        V Offline
        Valentinor
        wrote on last edited by
        #3

        I don't get it. I don't see anything there that may interfere with the app and the way I have my PC.

        L 1 Reply Last reply
        0
        • V Valentinor

          I don't get it. I don't see anything there that may interfere with the app and the way I have my PC.

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

          The first paragraph clearly states that you should not use it, and it may even fail without giving any indication, and indeed returning TRUE suggesting that it did not fail.

          V 1 Reply Last reply
          0
          • L Lost User

            The first paragraph clearly states that you should not use it, and it may even fail without giving any indication, and indeed returning TRUE suggesting that it did not fail.

            V Offline
            V Offline
            Valentinor
            wrote on last edited by
            #5

            The following statement is a personal opinion and is not addressed to you specifically! So take it as it is! These types of answers are actually more harmful then they are helpful. Not only that they don't actually help the person reach a solution but they may affect some, and actually will affect certain people by at least demoralizing them. We are not in school to say "I can't give you a straight answer because you are on a test" or by giving them a riddle which may lead that person on a wrong path that is even farther from the solution, we are here to learn from each other. So it is best to actually not to say anything then giving an answer that isn't helpful or by making fun of them for not knowing. Not everyone is good at searching on google for the answer, maybe they don't know exactly what to search for. Why is it so hard to tell someone, "Here you do it this way, use that and like that"?! This as a side note, because I saw in general, on other platforms as well, many answers that were so bad and actually harmful. I have a friend that tried to get into programing but quit it because he posted like only 2 questions on another popular website, and because the questions where really beginner level many started criticizing him for what he asked, like "How can you not know that?!", well he was just starting so how could he have know. As for what you said that, in that paragraph it says not to use it, yeah it is true, but it also says the following "Use of this API is subject to major limitations", so it's not like not to use it because it is bad, but because other reasons. As for the other part, it is actually a good thing in that situation that it doesn't uses what you give it, and it actually is telling you why in documentation, because it may lead to an unusable screen.

            D L 2 Replies Last reply
            0
            • V Valentinor

              The following statement is a personal opinion and is not addressed to you specifically! So take it as it is! These types of answers are actually more harmful then they are helpful. Not only that they don't actually help the person reach a solution but they may affect some, and actually will affect certain people by at least demoralizing them. We are not in school to say "I can't give you a straight answer because you are on a test" or by giving them a riddle which may lead that person on a wrong path that is even farther from the solution, we are here to learn from each other. So it is best to actually not to say anything then giving an answer that isn't helpful or by making fun of them for not knowing. Not everyone is good at searching on google for the answer, maybe they don't know exactly what to search for. Why is it so hard to tell someone, "Here you do it this way, use that and like that"?! This as a side note, because I saw in general, on other platforms as well, many answers that were so bad and actually harmful. I have a friend that tried to get into programing but quit it because he posted like only 2 questions on another popular website, and because the questions where really beginner level many started criticizing him for what he asked, like "How can you not know that?!", well he was just starting so how could he have know. As for what you said that, in that paragraph it says not to use it, yeah it is true, but it also says the following "Use of this API is subject to major limitations", so it's not like not to use it because it is bad, but because other reasons. As for the other part, it is actually a good thing in that situation that it doesn't uses what you give it, and it actually is telling you why in documentation, because it may lead to an unusable screen.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              :wtf: :wtf: :wtf: Richard posts a link to the documentation where it clearly says "We strongly recommend that you don't use this API" and then you complain that it isn't the kind of answer you wanted ????? :wtf: The documentation even goes so far as to tell you how to do what you want using a supported alternative method!! DID YOU EVEN READ IT!?!?

              Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
              Dave Kreskowiak

              V 1 Reply Last reply
              0
              • V Valentinor

                The following statement is a personal opinion and is not addressed to you specifically! So take it as it is! These types of answers are actually more harmful then they are helpful. Not only that they don't actually help the person reach a solution but they may affect some, and actually will affect certain people by at least demoralizing them. We are not in school to say "I can't give you a straight answer because you are on a test" or by giving them a riddle which may lead that person on a wrong path that is even farther from the solution, we are here to learn from each other. So it is best to actually not to say anything then giving an answer that isn't helpful or by making fun of them for not knowing. Not everyone is good at searching on google for the answer, maybe they don't know exactly what to search for. Why is it so hard to tell someone, "Here you do it this way, use that and like that"?! This as a side note, because I saw in general, on other platforms as well, many answers that were so bad and actually harmful. I have a friend that tried to get into programing but quit it because he posted like only 2 questions on another popular website, and because the questions where really beginner level many started criticizing him for what he asked, like "How can you not know that?!", well he was just starting so how could he have know. As for what you said that, in that paragraph it says not to use it, yeah it is true, but it also says the following "Use of this API is subject to major limitations", so it's not like not to use it because it is bad, but because other reasons. As for the other part, it is actually a good thing in that situation that it doesn't uses what you give it, and it actually is telling you why in documentation, because it may lead to an unusable screen.

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

                Valentinor wrote:

                will affect certain people by at least demoralizing them.

                So are you saying it is demoralizing to be given a link to the documentation?

                Valentinor wrote:

                Not everyone is good at searching on google for the answer

                I just Googled for the name of the API function that is in your question; why do you think that is difficult?

                Valentinor wrote:

                As for what you said that, in that paragraph it says not to use it, yeah it is true, but it also says the following "Use of this API is subject to major limitations", so it's not like not to use it because it is bad, but because other reasons. As for the other part, it is actually a good thing in that situation that it doesn't uses what you give it, and it actually is telling you why in documentation, because it may lead to an unusable screen.

                So you have the complete answer, why complain?

                V 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  :wtf: :wtf: :wtf: Richard posts a link to the documentation where it clearly says "We strongly recommend that you don't use this API" and then you complain that it isn't the kind of answer you wanted ????? :wtf: The documentation even goes so far as to tell you how to do what you want using a supported alternative method!! DID YOU EVEN READ IT!?!?

                  Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                  Dave Kreskowiak

                  V Offline
                  V Offline
                  Valentinor
                  wrote on last edited by
                  #8

                  First of, I wasn't talking about him giving a link to the documentation. That is a good replay when you don't know a solution, but you still want to try to help. I did seen it before posting my original questions, but it doesn't say anything about the problem I encountered. I even mentioned that it was a general opinion, and at the end of the statement I added something as a respond to what he said. So back to the matter, yes they do say not to use it, but they also give you reasons why not to, which none of them are bad for the use case the app I made is meant for. So by taking in consideration their warnings in the documentation, it was still a good option to use.

                  Quote:

                  The documentation even goes so far as to tell you how to do what you want using a supported alternative method!!

                  Yes, it does talk about some alternatives, but I don't need color calibration, or blue light filtering, or color adaptation.

                  Quote:

                  DID YOU EVEN READ IT!?!?

                  So based on what I just said, I can ask you the same, did you read everything I said?! But as I said in that statement, this type of behavior isn't helpful so why not try to avoid it, and actually try other means of expressing to get your point of view understood, as this is something optional to do, no one is forcing you to answer every question the users of this website are posting?! I even saw this article in which they talk about evolution of methods to do that, but there are a few problems with other methods they present, first and most important this:

                  Quote:

                  The Direct3D 9 and DXGI APIs are “write only”. You can't read the value of the hardware, modify it, and then set it. You can only set the ramp.

                  The problem with this is that my app is meant for general gamma change, which means when the user closes the app, he has an option to restore to the original gamma value, which with those 2 you can't. And also this problem:

                  Quote:

                  Furthermore, you can only set gamma when the app is full screen.

                  I need it to work in general not based on an app that is running in fullscreen mode.

                  D 1 Reply Last reply
                  0
                  • L Lost User

                    Valentinor wrote:

                    will affect certain people by at least demoralizing them.

                    So are you saying it is demoralizing to be given a link to the documentation?

                    Valentinor wrote:

                    Not everyone is good at searching on google for the answer

                    I just Googled for the name of the API function that is in your question; why do you think that is difficult?

                    Valentinor wrote:

                    As for what you said that, in that paragraph it says not to use it, yeah it is true, but it also says the following "Use of this API is subject to major limitations", so it's not like not to use it because it is bad, but because other reasons. As for the other part, it is actually a good thing in that situation that it doesn't uses what you give it, and it actually is telling you why in documentation, because it may lead to an unusable screen.

                    So you have the complete answer, why complain?

                    V Offline
                    V Offline
                    Valentinor
                    wrote on last edited by
                    #9

                    Quote:

                    So are you saying it is demoralizing to be given a link to the documentation?

                    I wasn't talking about that answer. Giving a link to documentation is a good start when you don't really know the answer, in hopes that the person who asked the question didn't checked it before.

                    Quote:

                    I just Googled for the name of the API function that is in your question; why do you think that is difficult?

                    So with that I wasn't talking about me, it was in general, everything in that statement beside the part at the end, was something I observed over the time.

                    Quote:

                    So you have the complete answer, why complain?

                    I didn't said the problem is solved. In the above message in responds to what Dave Kreskowiak said, I went into more details about the problem, as no one even tried to ask more question to understand the problem better, in case maybe it wasn't explained properly, which the founder of this website actually encourages to do so.

                    Quote:

                    If a question is poorly phrased then either ask for clarification...

                    I'm glad that you actually read the whole thing, even tho there were some misunderstandings about the message it was meant to deliver.

                    1 Reply Last reply
                    0
                    • V Valentinor

                      First of, I wasn't talking about him giving a link to the documentation. That is a good replay when you don't know a solution, but you still want to try to help. I did seen it before posting my original questions, but it doesn't say anything about the problem I encountered. I even mentioned that it was a general opinion, and at the end of the statement I added something as a respond to what he said. So back to the matter, yes they do say not to use it, but they also give you reasons why not to, which none of them are bad for the use case the app I made is meant for. So by taking in consideration their warnings in the documentation, it was still a good option to use.

                      Quote:

                      The documentation even goes so far as to tell you how to do what you want using a supported alternative method!!

                      Yes, it does talk about some alternatives, but I don't need color calibration, or blue light filtering, or color adaptation.

                      Quote:

                      DID YOU EVEN READ IT!?!?

                      So based on what I just said, I can ask you the same, did you read everything I said?! But as I said in that statement, this type of behavior isn't helpful so why not try to avoid it, and actually try other means of expressing to get your point of view understood, as this is something optional to do, no one is forcing you to answer every question the users of this website are posting?! I even saw this article in which they talk about evolution of methods to do that, but there are a few problems with other methods they present, first and most important this:

                      Quote:

                      The Direct3D 9 and DXGI APIs are “write only”. You can't read the value of the hardware, modify it, and then set it. You can only set the ramp.

                      The problem with this is that my app is meant for general gamma change, which means when the user closes the app, he has an option to restore to the original gamma value, which with those 2 you can't. And also this problem:

                      Quote:

                      Furthermore, you can only set gamma when the app is full screen.

                      I need it to work in general not based on an app that is running in fullscreen mode.

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #10

                      I'm sorry, did you want someone to click on the Windows Color System[^] link for you? That's what you're going to have to use.

                      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                      Dave Kreskowiak

                      V 1 Reply Last reply
                      0
                      • D Dave Kreskowiak

                        I'm sorry, did you want someone to click on the Windows Color System[^] link for you? That's what you're going to have to use.

                        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                        Dave Kreskowiak

                        V Offline
                        V Offline
                        Valentinor
                        wrote on last edited by
                        #11

                        I'm sorry but how is that theory goin to help someone who doesn't know what code to use? OK, I'm learning the theory behind it, but that isn't goin to help me write the code. I never said that I have a good knowledge when it comes to C/C++. Actually it is kinda bad, that is why this function is goin to be called as a native one. Just out of curiosity, have you ever thought that maybe there are some that understand better by seeing it in practice then reading about the theory behind certain things? And surely I'm not the only one, after all there is this saying "Practice makes perfect".

                        D 1 Reply Last reply
                        0
                        • V Valentinor

                          I'm sorry but how is that theory goin to help someone who doesn't know what code to use? OK, I'm learning the theory behind it, but that isn't goin to help me write the code. I never said that I have a good knowledge when it comes to C/C++. Actually it is kinda bad, that is why this function is goin to be called as a native one. Just out of curiosity, have you ever thought that maybe there are some that understand better by seeing it in practice then reading about the theory behind certain things? And surely I'm not the only one, after all there is this saying "Practice makes perfect".

                          D Offline
                          D Offline
                          Dave Kreskowiak
                          wrote on last edited by
                          #12

                          You apparently didn't look at the rest of the page, especially the navigation down the left side, and completely missed the link to "Reference", which gives you all of the functions involved with WCS and the documentation on each. If you're looking for someone to write the code for you, or to copy, I can't help you there. I have no need of color correction at all and don't have the time to the someone's research for them.

                          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                          Dave Kreskowiak

                          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