private void ApplyRendererButton_Click(object sender, EventArgs e) { // Create the correct type of StretchParameters with the corresponding user inputs. StretchParameters stretchParameters = null; // See which type is selected and apply the corresponding input parameters to create the renderer. switch (_parameterInputTypeSpinner.SelectedItem.ToString()) { case "Min Max": // Read the minimum and maximum values for the red, green, and blue bands. double minRed = Convert.ToDouble(_minRedSpinner.SelectedItem); double minGreen = Convert.ToDouble(_minGreenSpinner.SelectedItem); double minBlue = Convert.ToDouble(_minBlueSpinner.SelectedItem); double maxRed = Convert.ToDouble(_maxRedSpinner.SelectedItem); double maxGreen = Convert.ToDouble(_maxGreenSpinner.SelectedItem); double maxBlue = Convert.ToDouble(_maxBlueSpinner.SelectedItem); // Create an array of the minimum and maximum values. double[] minValues = { minRed, minGreen, minBlue }; double[] maxValues = { maxRed, maxGreen, maxBlue }; // Create a new MinMaxStretchParameters with the values. stretchParameters = new MinMaxStretchParameters(minValues, maxValues); break; case "Percent Clip": // Get the percentile cutoff below which values in the raster dataset are to be clipped. double minimumPercent = Convert.ToDouble(_minPercentClipSlider.Progress); // Get the percentile cutoff above which pixel values in the raster dataset are to be clipped. double maximumPercent = Convert.ToDouble(_maxPercentClipSlider.Progress); // Create a new PercentClipStretchParameters with the inputs. stretchParameters = new PercentClipStretchParameters(minimumPercent, maximumPercent); break; case "Standard Deviation": // Read the standard deviation factor (the number of standard deviations used to define the range of pixel values). double standardDeviationFactor = Convert.ToDouble(_stdDeviationFactorSpinner.SelectedItem); // Create a new StandardDeviationStretchParameters with the selected number of standard deviations. stretchParameters = new StandardDeviationStretchParameters(standardDeviationFactor); break; } // Create an array to specify the raster bands (red, green, blue). int[] bands = { 0, 1, 2 }; // Create the RgbRenderer with the stretch parameters created above, then apply it to the raster layer. RgbRenderer rasterRenderer = new RgbRenderer(stretchParameters, bands, null, true); _rasterLayer.Renderer = rasterRenderer; }
private void UpdateRenderer(object sender, StretchParametersEventArgs e) { // Create an array to specify the raster bands (red, green, blue). int[] bands = { 0, 1, 2 }; // Create the RgbRenderer with the stretch parameters passed in, then apply it to the raster layer. RgbRenderer rasterRenderer = new RgbRenderer(e.StretchParams, bands, null, true); _rasterLayer.Renderer = rasterRenderer; // Remove the parameter input UI. _updateRendererUI.Hide(); _updateRendererUI = null; }
private void ApplyRgbRendererButton_Click(object sender, System.Windows.RoutedEventArgs e) { // Create the correct type of StretchParameters with the corresponding user inputs. StretchParameters stretchParameters = null; // See which type is selected and apply the corresponding input parameters to create the renderer. switch (StretchTypeComboBox.SelectedValue.ToString()) { case "Min Max": // Read the minimum and maximum values for the red, green, and blue bands. double minRed = Convert.ToDouble(MinRedComboBox.SelectedValue); double minGreen = Convert.ToDouble(MinGreenComboBox.SelectedValue); double minBlue = Convert.ToDouble(MinBlueComboBox.SelectedValue); double maxRed = Convert.ToDouble(MaxRedComboBox.SelectedValue); double maxGreen = Convert.ToDouble(MaxGreenComboBox.SelectedValue); double maxBlue = Convert.ToDouble(MaxBlueComboBox.SelectedValue); // Create an array of the minimum and maximum values. double[] minValues = { minRed, minGreen, minBlue }; double[] maxValues = { maxRed, maxGreen, maxBlue }; // Create a new MinMaxStretchParameters with the values. stretchParameters = new MinMaxStretchParameters(minValues, maxValues); break; case "Percent Clip": // Get the percentile cutoff below which values in the raster dataset are to be clipped. double minimumPercent = MinimumValueSlider.SelectedIndex; // Get the percentile cutoff above which pixel values in the raster dataset are to be clipped. double maximumPercent = MaximumValueSlider.SelectedIndex; // Create a new PercentClipStretchParameters with the inputs. stretchParameters = new PercentClipStretchParameters(minimumPercent, maximumPercent); break; case "Standard Deviation": // Read the standard deviation factor (the number of standard deviations used to define the range of pixel values). double standardDeviationFactor = Convert.ToDouble(StdDeviationFactorComboBox.SelectedValue); // Create a new StandardDeviationStretchParameters with the selected number of standard deviations. stretchParameters = new StandardDeviationStretchParameters(standardDeviationFactor); break; } // Create an array to specify the raster bands (red, green, blue). int[] bands = { 0, 1, 2 }; // Create the RgbRenderer with the stretch parameters created above, then apply it to the raster layer. RgbRenderer rgbRenderer; StretchRenderer stretchRenderer; if (stretchItem.IsEnabled == false) { rgbRenderer = new RgbRenderer(stretchParameters, bands, null, true); _rasterLayer.Renderer = rgbRenderer; } else if (stretchItem.IsEnabled == true) { PresetColorRampType pcrt; int colorType = Convert.ToInt32(ColorRampCsy.SelectedIndex - 1); switch (colorType) { case -1: pcrt = PresetColorRampType.Elevation; break; case 0: pcrt = PresetColorRampType.Elevation; break; case 1: pcrt = PresetColorRampType.DemScreen; break; case 2: pcrt = PresetColorRampType.DemScreen; break; default: pcrt = PresetColorRampType.DemScreen; break; } uint colorSize = Convert.ToUInt32(ColorRampSizeCsy.SelectedValue); stretchRenderer = new StretchRenderer(stretchParameters, null, true, ColorRamp.Create(pcrt, colorSize)); _rasterLayer.Renderer = stretchRenderer; } }