/// <summary> /// Reduce or increase contrast of the image with the given value. /// </summary> /// <param name="viewName">name of the view</param> /// <param name="viewRangeName">name of the view range</param> /// <param name="factor">factor that should be added to current contrast</param> /// <returns>true if threshold could be set to new value, false if it is already max or min value</returns> private bool updateContrast(string viewName, string viewRangeName, int factor) { if (io == null || io.GetView(viewName) as BrailleIOScreen == null) { return(false); } BrailleIOViewRange vr = ((BrailleIOScreen)io.GetView(viewName)).GetViewRange(viewRangeName); int oldThreshold = 0; int newThreshold = 0; if (vr != null) { oldThreshold = vr.GetContrastThreshold(); newThreshold = vr.SetContrastThreshold(oldThreshold + factor); } io.RefreshDisplay(); if ((oldThreshold >= 255 || oldThreshold <= 0) && (newThreshold >= 255 || newThreshold <= 0)) { return(false); } else { return(true); } }
/// <summary> /// Synchronize the contrastThreshold and InvertImage value. /// </summary> /// <param name="oldvr">ViewRange whose values should be used in the new ViewRange.</param> /// <param name="newvr">ViewRange that should get the values of the old ViewRange.</param> private void syncContrastSettings(BrailleIOViewRange oldvr, BrailleIOViewRange newvr) { if (oldvr != null && newvr != null) { newvr.InvertImage = oldvr.InvertImage; newvr.SetContrastThreshold(oldvr.GetContrastThreshold()); } }
private void updateContrast(string viewName, string viewRangeName, int factor) { if (IO == null && IO.GetView(viewName) as BrailleIOScreen != null) { return; } // zoom in BrailleIOViewRange vr = ((BrailleIOScreen)IO.GetView(viewName)).GetViewRange(viewRangeName); if (vr != null) { vr.SetContrastThreshold(vr.GetContrastThreshold() + factor); } IO.RenderDisplay(); }
/// <summary> /// Synchronize the contrastThreshold and InvertImage value. /// </summary> /// <param name="oldvr">ViewRange whose values should be used in the new ViewRange.</param> /// <param name="newvr">ViewRange that should get the values of the old ViewRange.</param> private void syncContrastSettings(BrailleIOViewRange oldvr, BrailleIOViewRange newvr) { if (oldvr != null && newvr != null) { newvr.InvertImage = oldvr.InvertImage; newvr.SetContrastThreshold(oldvr.GetContrastThreshold()); } }