/// <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()); } }
BrailleIOViewRange getMainScreenCenter2Region(int left, int top, int width, int height) { BrailleIOViewRange center2 = new BrailleIOViewRange(left, top, width, height); center2.SetZoom(-1); center2.SetBorder(0); center2.SetContrastThreshold(STANDARD_CONTRAST_THRESHOLD); center2.SetMargin(7, 0); return(center2); }
// string path = ""; private void showExample() { BrailleIOScreen s = new BrailleIOScreen(); #region Center Region #region screenshot Image bmp = captureScreen(); #endregion BrailleIOViewRange center = new BrailleIOViewRange(0, 7, 120, 46, new bool[120, 40]); //center.Move(1,1); center.SetBitmap(bmp); center.SetZoom(-1); center.SetBorder(0); center.SetContrastThreshold(150); center.ShowScrollbars = true; s.AddViewRange("center", center); #endregion #region Top Reagion BrailleIOViewRange top = new BrailleIOViewRange(0, 0, 120, 7); top.SetBorder(0, 0, 1); top.SetMargin(0, 0, 1); top.SetPadding(0, 0, 1); top.SetText("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nabcdefghijklmnopqrstuvwxyz\r\n0123456789!\"#$%&<=>?@©®\r\n*+-~:;[],.'^_`(){}/|\\r\nß\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n"); top.SetText("Tactile screen capture"); s.AddViewRange("top", top); #endregion #region Bottom Reagion BrailleIOViewRange bottom = new BrailleIOViewRange(0, 53, 120, 7); bottom.SetBorder(1, 0, 0); bottom.SetMargin(1, 0, 0); bottom.SetPadding(1, 0, 0); bottom.SetText("Detail area: status messages can be shown"); s.AddViewRange("bottom", bottom); #endregion io.AddView(BS_MAIN_NAME, s); io.ShowView(BS_MAIN_NAME); io.RenderDisplay(); }
/// <summary> /// Change contrast of the image to the given value. /// </summary> /// <param name="viewName">name of the view</param> /// <param name="viewRangeName">name of the view range</param> /// <param name="contrast">new contrast value (should be between 0 and 255)</param> private void setContrast(string viewName, string viewRangeName, int contrast) { if (io == null || io.GetView(viewName) as BrailleIOScreen == null) { return; } BrailleIOViewRange vr = ((BrailleIOScreen)io.GetView(viewName)).GetViewRange(viewRangeName); if (vr != null) { vr.SetContrastThreshold(contrast); } io.RefreshDisplay(true); }
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> /// Shows the center region in full screen (other regions are set invisible). /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <returns></returns> BrailleIOScreen buildFullScreen(int width, int height) { BrailleIOScreen fullScreen = new BrailleIOScreen(BS_FULLSCREEN_NAME); BrailleIOViewRange center = new BrailleIOViewRange(0, 0, width, height); center.SetZoom(-1); center.SetBorder(0); center.SetContrastThreshold(STANDARD_CONTRAST_THRESHOLD); center.ShowScrollbars = true; fullScreen.AddViewRange(VR_CENTER_NAME, center); if (io != null) { io.AddView(BS_FULLSCREEN_NAME, fullScreen); } fullScreen.SetVisibility(false); return(fullScreen); }
// string path = ""; private void showExample() { BrailleIOScreen s = new BrailleIOScreen(); #region Center Region #region screenshot Image bmp = captureScreen(); #endregion BrailleIOViewRange center = new BrailleIOViewRange(0, 0, 120, 60, new bool[120, 40]); center.SetMargin(7, 0, 0); center.Move(1, 1); center.SetBitmap(bmp); center.SetZoom(-1); center.SetBorder(0); center.SetContrastThreshold(150); s.AddViewRange("center", center); #endregion #region Top Region BrailleIOViewRange top = new BrailleIOViewRange(0, 0, 120, 7, new bool[0, 0]); top.SetBorder(0, 0, 1); top.SetMargin(0, 0, 1); top.SetPadding(0, 0, 1); top.SetText("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nabcdefghijklmnopqrstuvwxyz\r\n0123456789!\"#$%&<=>?@©®\r\n*+-~:;[],.'^_`(){}/|\\r\nß\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n"); top.SetText("Tactile screen capture"); s.AddViewRange("top", top); #endregion IO.AddView(BS_MAIN_NAME, s); IO.ShowView(BS_MAIN_NAME); IO.RenderDisplay(); }
BrailleIOViewRange getMainScreenCenter2Region(int left, int top, int width, int height) { BrailleIOViewRange center2 = new BrailleIOViewRange(left, top, width, height); center2.SetZoom(-1); center2.SetBorder(0); center2.SetContrastThreshold(STANDARD_CONTRAST_THRESHOLD); center2.SetMargin(7, 0); return center2; }
/// <summary> /// Shows the center region in full screen (other regions are set invisible). /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <returns></returns> BrailleIOScreen buildFullScreen(int width, int height) { BrailleIOScreen fullScreen = new BrailleIOScreen(BS_FULLSCREEN_NAME); BrailleIOViewRange center = new BrailleIOViewRange(0, 0, width, height); center.SetZoom(-1); center.SetBorder(0); center.SetContrastThreshold(STANDARD_CONTRAST_THRESHOLD); center.ShowScrollbars = true; fullScreen.AddViewRange(VR_CENTER_NAME, center); if (io != null) io.AddView(BS_FULLSCREEN_NAME, fullScreen); fullScreen.SetVisibility(false); return fullScreen; }