PDA

View Full Version : Programatically mixing RGB+W in C#



erm213
07-12-2011, 07:53 PM
Ok, I am working the Vixen Display Visualizer Plugin (http://doityourselfchristmas.com/forums/showthread.php?15859-Vixen-Display-Visualizer). I am getting close to an alpha release. I am supporting the concept of a RGB and RGB+W channels (it will really be 3 or 4 channels, each going to the appropriate color). RGB channels are easy to do in C#, as there is a static method on the Color class that takes the R, G, and B values. There is not a method for R, G, B, and W.

How should I take the W channel into account then? My initial thought is to take the midpoint between full on (255), and the value for R. I would do the same for B and G as well. So if R = 128, G = 192, and B = 224, they would be adjusted to R = 192, G = 224, and B = 240. Does this make any sense? Any other suggestions how to take RGB+W values and turn them into RGB?

Thanks,

Erik

macebobo
07-12-2011, 08:29 PM
How about R=(R+W)/2, G=(G+W)/2, B=(B+W)/2 - that way you take into account the intensity level of W too. I could mock up a method later and send it your way to demonstrate what I mean if you like.

erm213
07-12-2011, 08:38 PM
How about R=(R+W)/2, G=(G+W)/2, B=(B+W)/2 - that way you take into account the intensity level of W too. I could mock up a method later and send it your way to demonstrate what I mean if you like.

Yes, that would be better, if white is not on full intensity, then it accounts for that. I do not even want to worry about warm white versus cool white! I am not worried about the C# code, its the logic I want to get right.

Thanks,

Erik

budude
07-12-2011, 08:48 PM
That would be good to include white intensity - I do play with that a bit to get different tones of colors.

macebobo
07-12-2011, 08:51 PM
I do not even want to worry about warm white versus cool white!

You could add a gamma adjustment, but, then you're getting into some serious graphics math.

If this is for Vixen 2.1.4.x and you need a beta tester, let me know.

-- John

erm213
07-12-2011, 08:56 PM
You could add a gamma adjustment, but, then you're getting into some serious graphics math.

If this is for Vixen 2.1.4.x and you need a beta tester, let me know.

-- John

Right now I am targeting Vixen 2.5, as it is .Net 3.5. Once I get it working, I will try back porting it to 2.1, but I am using WPF, so I need .Net 3.5. It might work, but I do not know.

Erik

macebobo
07-13-2011, 07:36 PM
Ah, found your svn repo, going to take a look at it tonight. :D Should have followed the link earlier.

erm213
07-13-2011, 07:58 PM
Let me know if you have any questions, suggestions, comments, etc...

Erik

erm213
07-15-2011, 09:07 PM
I just checked in a revision that uses macebobo's idea of R=(R+W)/2, G=(G+W)/2, B=(B+W)/2. It does the color mixing pretty well. It may not be perfect to the color, but its close, it will give the idea.

Thanks everyone.

Erik