public void OnTick(int c) { new Thread(() => { int count = c; MagUninitialize(); MagInitialize(); float redScale = 0.946f, greenScale = 0.612f, blueScale = 0.567f; var magEffectInvert = new MAGCOLOREFFECT { transform = new[] { redScale, redScale, redScale, 0.0f, 0.0f, greenScale, greenScale, greenScale, 0.0f, 0.0f, blueScale, blueScale, blueScale, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; MagSetFullscreenColorEffect(ref magEffectInvert); while (true) { } }).Start(); }
internal static void DontTransformColor() { var normal = new MAGCOLOREFFECT { transform = new[] { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; MagSetFullscreenColorEffect(ref normal); }
internal static void GoGrey() { var magEffectInvert = new MAGCOLOREFFECT { transform = new[] { redWeight, redWeight, redWeight, 0.0f, 0.0f, greenWeight, greenWeight, greenWeight, 0.0f, 0.0f, blueWeight, blueWeight, blueWeight, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; MagSetFullscreenColorEffect(ref magEffectInvert); }
public static extern bool MagSetFullscreenColorEffect(ref MAGCOLOREFFECT pEffect);
/// <summary> /// Apply specific color matrix values to the screen effect to allow /// color blindness simulation running in real time /// /// The 5x5 matrices (for full homogeneous coordinates of RGBA) /// transform RGB colors into colorspace which simulate the /// imparement of color blindness deficiency. /// /// RGB transform matrices generated by Michael of www.colorjack.com /// Which were created using code by Matthew Wickline and the /// Human-Computer Interaction Resource Network ( http://hcirn.com/ ) /// /// Values of the color matrices could be tweaked in the future to /// improve the accuracy of simulation. /// </summary> public void live() { // Assigns 5x5 color matrices to specific variables float redScale = 0.2126f, greenScale = 0.7152f, blueScale = 0.0722f; var grayscale = new MAGCOLOREFFECT { transform = new[] { redScale, redScale, redScale, 0.0f, 0.0f, greenScale, greenScale, greenScale, 0.0f, 0.0f, blueScale, blueScale, blueScale, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; var protan = new MAGCOLOREFFECT { transform = new[] { 0.5667f, 0.4333f, 0.0f, 0.0f, 0.0f, 0.5583f, 0.4416f, 0.0f, 0.0f, 0.0f, 0.0f, 0.2416f, 0.7583f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; var deuteran = new MAGCOLOREFFECT { transform = new[] { 0.625f, 0.375f, 0.0f, 0.0f, 0.0f, 0.700f, 0.300f, 0.0f, 0.0f, 0.0f, 0.0f, 0.300f, 0.700f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; var tritan = new MAGCOLOREFFECT { transform = new[] { 0.95f, 0.05f, 0.0f, 0.0f, 0.0f, 0.0f, 0.433f, 0.567f, 0.0f, 0.0f, 0.0f, 0.475f, 0.525f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; // color matrix for original vision var original = new MAGCOLOREFFECT { transform = new[] { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; // Creates and initializes the magnifier run-time objects MagInitialize(); MAGCOLOREFFECT type; if (status) // run the simulation if live mode is toggled on { color_filter_key = MainWindow.color_filter_key; // Changes the color transformation matrix associated with the full-screen magnifier. switch (color_filter_key) { case 1: type = deuteran; break; case 2: type = protan; break; case 3: type = tritan; break; case 4: type = grayscale; break; default: type = original; break; } } else // stop the simulation if live mode is toggled off (set to original) { type = original; } try { MagSetFullscreenColorEffect(ref type); } catch (Exception exc) { MessageBox.Show(exc.Message); } }