Created
August 13, 2016 04:43
-
-
Save CVertex/0133d4b208d62a5e93a093f44672991b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // srcColor:Color, destColor:Color | |
| // We're converting everything to doubles [0,1.0], then performing multiply | |
| // then converting back to byte | |
| // These conversions are slow | |
| var sr = Convert.ToDouble(srcColor.R) / 255.0; | |
| var sg = Convert.ToDouble(srcColor.G) / 255.0; | |
| var sb = Convert.ToDouble(srcColor.B) / 255.0; | |
| var dr = Convert.ToDouble(destColor.R) / 255.0; | |
| var dg = Convert.ToDouble(destColor.G) / 255.0; | |
| var db = Convert.ToDouble(destColor.B) / 255.0; | |
| var rr = sr * dr; | |
| var rg = sg * dg; | |
| var rb = sb * db; | |
| // Ignore alpha for now, keep it at 1.0 | |
| var ba = 255; | |
| var br = Convert.ToByte(rr * 255.0); | |
| var bg = Convert.ToByte(rg * 255.0); | |
| var bb = Convert.ToByte(rb * 255.0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment