private Tuple <Point, Color> ComputeColor(Point p, int max, ColorRamp colorRamp) { var current = _hitPlot.GetHitsForPoint(p); var ratio = Gamma(1.0 - Math.Pow(Math.E, -10.0 * current / max)); return(Tuple.Create(p, colorRamp.GetColor(ratio).ToColor())); }
private void RenderButton_Click(object sender, System.Windows.RoutedEventArgs e) { ObservableCollection <ColorRamp> colorRamps = new ObservableCollection <ColorRamp>(); colorRamp = new ColorRamp() { From = ((StartColorListBox.SelectedItem as ListBoxItem).Background as SolidColorBrush).Color, To = ((EndColorListBox.SelectedItem as ListBoxItem).Background as SolidColorBrush).Color, Algorithm = (Algorithm)AlgorithmListBox.SelectedItem, }; colorRamps.Add(colorRamp); generateClassesParameters.ClassificationDefinition = new ClassBreaksDefinition() { BaseSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol() { Fill = (ColorRampListBox.SelectedItem as ListBoxItem).Background }, ClassificationField = ((ClassificationFieldListBox.SelectedItem) as Field).Name, ClassificationMethod = (ClassificationMethod)ClassificationMethodListBox.SelectedItem, BreakCount = int.Parse(BreakCountTB.Text.Trim()), ColorRamps = colorRamps, }; ClassBreaksDefinition classBreakDef = generateClassesParameters.ClassificationDefinition as ClassBreaksDefinition; if (classBreakDef.ClassificationMethod == ClassificationMethod.StandardDeviation) { classBreakDef.StandardDeviationInterval = (StandardDeviationInterval)IntervalListBox.SelectedItem; } if (NormalizationTypeListBox.SelectedItem != null) { classBreakDef.NormalizationType = (NormalizationType)NormalizationTypeListBox.SelectedItem; if (classBreakDef.NormalizationType == NormalizationType.Field) { if (NormalizationFieldListBox.SelectedItem != null) { classBreakDef.NormalizationField = ((NormalizationFieldListBox.SelectedItem) as Field).Name; } else { MessageBox.Show("Normalization Field must be selected"); return; } } } if (generateRendererTask.IsBusy) { generateRendererTask.CancelAsync(); } generateRendererTask.ExecuteAsync(generateClassesParameters); ThematicPropertiesPage.IsOpen = false; }
private BitmapSource GeneratePreviewImage(Grid <int> grid, ColorRamp ramp, bool useStdDevStretch, int quality) { var bmp = CreateBitmapSource(grid, QuantizedExtent, StatisticsQuantizedZ, useStdDevStretch, ramp, quality); //BitmapSource bmp = CreateSegmentationBitmap(grid); //BitmapSource bmp = CreatePlaneFittingBitmap(grid); return(bmp); }
public PlanetInfo CreateInfo() { PlanetInfo planetInfo = new PlanetInfo(); planetInfo.skybox = skyboxes [GameObject.Find("SkyBoxDropdown").GetComponent <dfDropdown> ().SelectedIndex]; planetInfo.normals = planetNormals [GameObject.Find("NormalDropdown").GetComponent <dfDropdown> ().SelectedIndex]; planetInfo.coalReserves = 10000 * GameObject.Find("CoalSlider").GetComponentInChildren <dfSlider> ().Value; planetInfo.oilFactor = GameObject.Find("OilSlider").GetComponentInChildren <dfSlider> ().Value; ; planetInfo.windFactor = GameObject.Find("WindSlider").GetComponentInChildren <dfSlider> ().Value; ; planetInfo.sunFactor = GameObject.Find("SunSlider").GetComponentInChildren <dfSlider> ().Value; ; planetInfo.pollutionClearance = 20; planetInfo.startPollution = 0; planetInfo.maxPollution = 5000; planetInfo.startEnergy = 20; planetInfo.population = 100; planetInfo.iq = 1; planetInfo.gameLength = 1000; planetInfo.planetSize = (int)GameObject.Find("SizeSlider").GetComponentInChildren <dfSlider> ().Value; print(planetInfo.planetSize); planetInfo.rotationSpeed = 1; planetInfo.windZones = 3; planetInfo.octaves = (int)GameObject.Find("OctavesSlider").GetComponentInChildren <dfSlider> ().Value; planetInfo.gain = GameObject.Find("GainSlider").GetComponentInChildren <dfSlider> ().Value; planetInfo.lacunarity = GameObject.Find("LacunaritySlider").GetComponentInChildren <dfSlider> ().Value; planetInfo.stretch = GameObject.Find("StretchSlider").GetComponentInChildren <dfSlider> ().Value; Color[] colors = new Color[6]; float[] ranges = new float[5]; for (int i = 0; i < colors.Length; i++) { Color c = GameObject.Find("ColorDisplay" + (i + 1)).GetComponentInChildren <dfSlicedSprite> ().Color; if (i == 0) { c.a = 0; } colors [i] = c; } for (int i = 0; i < ranges.Length; i++) { ranges [i] = GameObject.Find("Slider" + (i + 1)).GetComponentInChildren <dfSlider> ().Value / 100f; } ColorRamp r = new ColorRamp(colors, ranges); planetInfo.colorRamp = r; return(planetInfo); }
public ColorPickerLogic(Widget widget, ColorRamp initialRamp, Action <ColorRamp> onChange, Action <ColorRamp> onSelect, WorldRenderer worldRenderer) { var panel = widget; ramp = initialRamp; var hueSlider = panel.Get <SliderWidget>("HUE"); var satSlider = panel.Get <SliderWidget>("SAT"); var lumSlider = panel.Get <SliderWidget>("LUM"); Action sliderChanged = () => { ramp = new ColorRamp((byte)(255 * hueSlider.Value), (byte)(255 * satSlider.Value), (byte)(255 * lumSlider.Value), 10); onChange(ramp); }; hueSlider.OnChange += _ => sliderChanged(); satSlider.OnChange += _ => sliderChanged(); lumSlider.OnChange += _ => sliderChanged(); Action updateSliders = () => { hueSlider.Value = ramp.H / 255f; satSlider.Value = ramp.S / 255f; lumSlider.Value = ramp.L / 255f; }; panel.Get <ButtonWidget>("SAVE_BUTTON").OnClick = () => onSelect(ramp); var randomButton = panel.Get <ButtonWidget>("RANDOM_BUTTON"); if (randomButton != null) { randomButton.OnClick = () => { var hue = (byte)Game.CosmeticRandom.Next(255); var sat = (byte)Game.CosmeticRandom.Next(255); var lum = (byte)Game.CosmeticRandom.Next(51, 255); ramp = new ColorRamp(hue, sat, lum, 10); updateSliders(); sliderChanged(); } } ; // Set the initial state updateSliders(); onChange(ramp); } }
private void Form1_Load(object sender, EventArgs e) { _width = this.pictureBox1.Width; _height = this.pictureBox1.Height; _opacity = this.tbOpacity.Value / 10f; _count = this.tbHPCount.Value; _radius = this.tbHPRadius.Value; _points = randomPoints(_width, _height, _count); this.cmbColorRamp.SelectedIndex = 1; _colorRamp = (ColorRamp)Enum.Parse(typeof(ColorRamp), this.cmbColorRamp.SelectedItem.ToString()); make4Maps(_width, _height, _radius, _points, _opacity, _colorRamp); }
private void AddDefaultRasterSchemes() { var values = Enum.GetValues(typeof(PredefinedColors)); foreach (PredefinedColors value in values) { var sch = new ColorRamp(); sch.SetColors(value); var blend = sch.ColorScheme2ColorBlend(); _list.Add(blend); } }
private static List <ColorRamp> RegisterColorHandlers() { var instances = new List <ColorRamp>(); Type baseType = typeof(ColorRamp); ExtensionManager.ProcessLoadedTypes( 2, "ColorRamps", baseType.IsAssignableFrom, t => !t.IsAbstract, t => instances.Add(ColorRamp.LoadMap(t)) ); return(instances); }
public void Render(string outputDirectory, string outputFilename, ColorRamp colorRamp) { _log.InfoFormat("Creating image ({0:N0}x{1:N0})", _resolution.Width, _resolution.Height); var viewPort = AreaFactory.RenderingArea; viewPort.LogViewport(); _log.Info("Loading points..."); var listReader = new ComplexNumberListReader(_inputInputDirectory, _inputFilename); var points = listReader .GetNumbers() .Select(n => viewPort.GetPointFromNumber(_resolution, n)) .Distinct() .ToArray(); _log.Info("Done loading"); _log.DebugFormat("{0:N0} distinct points found (for the specified resolution)", points.Length); var middlePoint = new Point(_resolution.Width / 2, _resolution.Height / 2); var maximumDistance = CalculateDistance(middlePoint, new Point(0, 0)); _log.Info("Starting to render"); var outputImg = new Bitmap(_resolution.Width, _resolution.Height); foreach (var point in _resolution.GetAllPoints()) { outputImg.SetPixel(point.X, point.Y, Color.Black); } foreach (var point in points) { if ((point.X < 0) || (point.Y < 0)) { continue; } outputImg.SetPixel(point.X, point.Y, ComputeColor(point, middlePoint, maximumDistance, colorRamp)); } _log.Info("Finished rendering"); _log.Debug("Saving image"); outputImg.Save(Path.Combine(outputDirectory, String.Format("{0}.png", outputFilename))); _log.Debug("Done saving image"); }
ColorRamp GetColorRamp() { ColorRamp result = new ColorRamp(); //Red - Green - Blue //result.Add(Colors.Red , 0.0); //result.Add(Colors.Green, 0.5); //result.Add(Colors.Blue , 1.0); //White - Red - Green - Blue result.Add(Colors.White, 0.0); result.Add(Colors.Red, 1.0 / 3.0); result.Add(Colors.Green, 2.0 / 3.0); result.Add(Colors.Blue, 1.0); return(result); }
public Player(World world, Session.Client client, Session.Slot slot, PlayerReference pr) { World = world; InternalName = pr.Name; PlayerReference = pr; string botType = null; // Real player or host-created bot if (client != null) { ClientIndex = client.Index; ColorRamp = client.ColorRamp; PlayerName = client.Name; botType = client.Bot; Country = ChooseCountry(world, client.Country); } else { // Map player ClientIndex = 0; // Owned by the host (todo: fix this) ColorRamp = pr.ColorRamp; PlayerName = pr.Name; NonCombatant = pr.NonCombatant; botType = pr.Bot; Country = ChooseCountry(world, pr.Race); } PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) }); // Enable the bot logic on the host IsBot = botType != null; if (IsBot && Game.IsHost) { var logic = PlayerActor.TraitsImplementing <IBot>() .FirstOrDefault(b => b.Info.Name == botType); if (logic == null) { Log.Write("debug", "Invalid bot type: {0}", botType); } else { logic.Activate(this); } } }
// When field to summarize on changes, generate a new renderer from the map service private async void comboField_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e) { try { // Generate a new renderer GenerateRendererTask generateRenderer = new GenerateRendererTask( new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2")); var colorRamp = new ColorRamp() { Algorithm = Algorithm.Hsv, From = Color.FromArgb(0xFF, 0x99, 0x8E, 0xC3), To = Color.FromArgb(0xFF, 0xF1, 0xA3, 0x40) }; var classBreaksDef = new ClassBreaksDefinition() { BreakCount = 5, ClassificationField = ((Windows.UI.Xaml.Controls.ComboBoxItem)comboField.SelectedItem).Tag as string, ClassificationMethod = ClassificationMethod.Quantile, BaseSymbol = _baseSymbol, ColorRamps = new ObservableCollection <ColorRamp>() { colorRamp } }; var param = new GenerateRendererParameters() { ClassificationDefinition = classBreaksDef, Where = ((ServiceFeatureTable)_featureLayer.FeatureTable).Where }; var result = await generateRenderer.GenerateRendererAsync(param); _featureLayer.Renderer = result.Renderer; // Reset the legend txtLegendTitle.DataContext = comboField.SelectedValue.ToString(); await CreateLegend((ClassBreaksRenderer)result.Renderer); } catch (Exception ex) { var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } }
public static Color GetColorInRamp(int index, ColorRamp cr) { switch (cr) { case ColorRamp.RAINBOW: return(Color.FromArgb(RAINBOW[index])); case ColorRamp.RED_WHITE_BLUE: return(Color.FromArgb(RED_WHITE_BLUE[index])); case ColorRamp.THERMAL: return(Color.FromArgb(THERMAL[index])); default: return(Color.White); } }
private static void MakeStrip(IEnumerable <Tuple <HsvColor, double> > colorPoints, string filePath) { var ramp = new ColorRamp(colorPoints); var image = new Bitmap(500, 50); for (int x = 0; x < image.Width; x++) { var color = ramp.GetColor((double)x / image.Width).ToColor(); for (int y = 0; y < image.Height; y++) { image.SetPixel(x, y, color); } } image.Save(filePath); }
private async void make4Maps(int width, int height, int radius, List<HeatPoint> points, float opacity, ColorRamp cr) { var hmMaker = new HeatMapMaker { Width = width, Height = height, Radius = radius, ColorRamp = cr, HeatPoints = points, Opacity = opacity }; this.pictureBox2.BackgroundImage = await hmMaker.MakeHeatMap(); // this.pictureBox1.BackgroundImage = hmMaker.GrayMap; // displayInfo(); }
// When field to summarize on changes, generate a new renderer from the map service private async void comboField_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { // Generate a new renderer GenerateRendererTask generateRenderer = new GenerateRendererTask( new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2")); var colorRamp = new ColorRamp() { Algorithm = Algorithm.Hsv, From = Color.FromRgb(0x99, 0x8E, 0xC3), To = Color.FromRgb(0xF1, 0xA3, 0x40) }; var classBreaksDef = new ClassBreaksDefinition() { BreakCount = 5, ClassificationField = ((ComboBoxItem)comboField.SelectedItem).Tag as string, ClassificationMethod = ClassificationMethod.Quantile, BaseSymbol = _baseSymbol, ColorRamps = new ObservableCollection<ColorRamp>() { colorRamp } }; var param = new GenerateRendererParameters() { ClassificationDefinition = classBreaksDef, Where = ((ServiceFeatureTable)featureLayer.FeatureTable).Where }; var result = await generateRenderer.GenerateRendererAsync(param); featureLayer.Renderer = result.Renderer; // Reset the legend txtLegendTitle.DataContext = comboField.SelectedValue.ToString(); await CreateLegend((ClassBreaksRenderer)result.Renderer); } catch (Exception ex) { MessageBox.Show(ex.Message, "Generate Renderer Task Sample"); } }
private async void Make4Maps(int width, int height, int radius, List <HeatPoint> points, float opacity, ColorRamp cr) { HeatMapMaker hmMaker = new HeatMapMaker { Width = width, Height = height, Radius = radius, ColorRamp = cr, HeatPoints = points, Opacity = opacity }; pictureBox2.BackgroundImage = await hmMaker.MakeHeatMap(); // ***renklendirilmiş asıl heatmap*** pictureBox1.BackgroundImage = hmMaker.GrayMap; DisplayInfo(); }
//选择色带 private void ColorBar1_SelectedIndexChanged(object sender, EventArgs e) { if (_colors != null) { _colors.Clear(); } _selectedValue = UniqueValueList.SelectedItem.ToString(); _colorRamp = myColorRamps[ColorBar1.SelectedIndex]; if (listBox1.Items != null) { listBox1.Items.Clear(); } Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Black, 1); SolidBrush brush = new SolidBrush(_color); int i; Random rd = new Random(); for (i = 0; i < CurLayer.featureClass.Count; i++) { int r = rd.Next(_colorRamp.fromColor.R, 255); Color c = Color.FromArgb(r, _colorRamp.fromColor.G, _colorRamp.fromColor.B); _colors.Add(c); Font f = new Font("宋体", 9.0f, FontStyle.Bold); if (CurLayer.featureClass.featureType == FeatureType.POINT || CurLayer.featureClass.featureType == FeatureType.MULTIPOINT) { string str = "· " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue] + " 1"; listBox1.Items.Add(str); } else if (CurLayer.featureClass.featureType == FeatureType.POLYLINE) { string str = "— " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue] + " 1"; listBox1.Items.Add(str); } else { string str = "■ " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue] + " 1"; listBox1.Items.Add(str); } } _renderMethod = 1; }
/// <summary> /// Converts color blend to MapWinGis color scheme /// </summary> public static ColorRamp ToColorScheme(this ColorBlend blend) { if (blend == null) { return(null); } if (blend.Positions.Length == 0 || (blend.Positions.Length != blend.Colors.Length)) { return(null); } var scheme = new ColorRamp(); for (int i = 0; i < blend.Positions.Length; i++) { scheme.Add(new ColorInterval(blend.Positions[i], blend.Colors[i])); } return(scheme); }
public BitmapSource GeneratePreviewImage(ColorRamp ramp, bool useStdDevStretch, int quality) { //if (m_pixelGridSet == null) // GeneratePreviewGrid(); if (Preview == null || Preview.ColorHandler != ramp || Preview.UseStdDevStretch != useStdDevStretch || Preview.Quality != quality) { var source = GeneratePreviewImage(m_pixelGridSet.GridQuantized, ramp, useStdDevStretch, quality); Preview = new PreviewImage(source, ramp, useStdDevStretch, quality); //using (var fileStream = new FileStream(Path.Combine(Cache.APP_CACHE_DIR, "preview.jpg"), FileMode.Create)) //{ // var encoder = new JpegBitmapEncoder(); // encoder.Frames.Add(BitmapFrame.Create(source)); // encoder.QualityLevel = 100; // encoder.Save(fileStream); //} } return(Preview.Image); }
private void cmbColorRamp_SelectedIndexChanged(object sender, EventArgs e) { switch (this.cmbColorRamp.SelectedIndex) { case 0: this.pictureBox3.BackgroundImage = Resources.i_thermal; break; case 1: this.pictureBox3.BackgroundImage = Resources.i_rainbow; break; case 2: this.pictureBox3.BackgroundImage = Resources.i_redwhiteblue; break; } _colorRamp = (ColorRamp)Enum.Parse(typeof(ColorRamp), this.cmbColorRamp.SelectedItem.ToString()); make4Maps(_width, _height, _radius, _points, _opacity, _colorRamp); }
public void Render(string outputDirectory, string outputFilename, ColorRamp colorRamp) { _log.InfoFormat("Creating image ({0:N0}x{1:N0})", _resolution.Width, _resolution.Height); _log.Info("Loading trajectory..."); _hitPlot.LoadTrajectories(Path.Combine(_inputInputDirectory, _inputFilename)); _log.Info("Done loading; finding maximum..."); var max = _hitPlot.Max(); _log.DebugFormat("Found maximum: {0:N0}", max); _log.Info("Starting to render"); var outputImg = new Bitmap(_resolution.Width, _resolution.Height); var processedPixels = _resolution .GetAllPoints() .AsParallel() .WithDegreeOfParallelism(GlobalArguments.DegreesOfParallelism) .Select(p => ComputeColor(p, max, colorRamp)) .AsEnumerable(); foreach (var result in processedPixels) { outputImg.SetPixel(result.Item1.X, result.Item1.Y, result.Item2); } _log.Info("Finished rendering"); _log.Debug("Saving image"); outputImg.Save(Path.Combine(outputDirectory, String.Format("{0}.png", outputFilename))); _log.Debug("Done saving image"); }
private void fillList()//渐变色带初始化 { ColorRamp colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(176, 176, 176); colorRamp.toColor = Color.FromArgb(255, 0, 0); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(0, 0, 0); colorRamp.toColor = Color.FromArgb(255, 255, 255); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(104, 204, 255); colorRamp.toColor = Color.FromArgb(0, 0, 224); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(111, 229, 232); colorRamp.toColor = Color.FromArgb(46, 100, 140); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(103, 245, 234); colorRamp.toColor = Color.FromArgb(48, 207, 146); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(116, 242, 237); colorRamp.toColor = Color.FromArgb(21, 79, 74); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(140, 236, 170); colorRamp.toColor = Color.FromArgb(102, 72, 48); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(156, 85, 31); colorRamp.toColor = Color.FromArgb(33, 130, 145); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(48, 100, 102); colorRamp.toColor = Color.FromArgb(110, 70, 45); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(114, 47, 39); colorRamp.toColor = Color.FromArgb(69, 117, 181); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(145, 0, 245); colorRamp.toColor = Color.FromArgb(0, 245, 245); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(182, 237, 240); colorRamp.toColor = Color.FromArgb(9, 9, 145); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(175, 240, 233); colorRamp.toColor = Color.FromArgb(255, 252, 255); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(118, 219, 211); colorRamp.toColor = Color.FromArgb(255, 252, 255); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(200, 219, 219); colorRamp.toColor = Color.FromArgb(69, 69, 69); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(204, 255, 204); colorRamp.toColor = Color.FromArgb(14, 204, 14); myColorRamps.Add(colorRamp); colorRamp = new ColorRamp(); colorRamp.fromColor = Color.FromArgb(120, 245, 233); colorRamp.toColor = Color.FromArgb(34, 102, 51); myColorRamps.Add(colorRamp); }
//选择色带 private void ColorBar2_SelectedIndexChanged(object sender, EventArgs e) { if (_colors != null) { _colors.Clear(); } _colorRamp = myColorRamps[ColorBar2.SelectedIndex]; _selectedValue = rangeValueList.SelectedItem.ToString(); if (listBox2.Items != null) { listBox2.Items.Clear(); } Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Black, 1); SolidBrush brush = new SolidBrush(_color); int i; if (CurLayer.featureClass.Count > 5) { float max = (float)Convert.ToDouble(CurLayer.featureClass.AttributeData.Rows[0][_selectedValue]); float min = (float)Convert.ToDouble(CurLayer.featureClass.AttributeData.Rows[0][_selectedValue]); for (i = 0; i < CurLayer.featureClass.Count; i++) { if (max < (float)Convert.ToDouble(CurLayer.featureClass.AttributeData.Rows[i][_selectedValue])) { max = (float)Convert.ToDouble(CurLayer.featureClass.AttributeData.Rows[i][_selectedValue]); } if (min > (float)Convert.ToDouble(CurLayer.featureClass.AttributeData.Rows[i][_selectedValue])) { min = (float)Convert.ToDouble(CurLayer.featureClass.AttributeData.Rows[i][_selectedValue]); } } float step = (max - min) / 5; int r = _colorRamp.fromColor.R; //Color c = Color.FromArgb(r, _colorRamp.fromColor.G, _colorRamp.fromColor.B); for (i = 0; i < 5; i++) { r = r + 10; Color c = Color.FromArgb(r, _colorRamp.fromColor.G, _colorRamp.fromColor.B); _colors.Add(c); float smax = min + step * i; if (CurLayer.featureClass.featureType == FeatureType.POINT || CurLayer.featureClass.featureType == FeatureType.MULTIPOINT) { string str = "· " + min + "——" + smax + " " + min + "——" + smax; listBox2.Items.Add(str); } else if (CurLayer.featureClass.featureType == FeatureType.POLYLINE) { string str = "— " + min + "——" + smax + " " + min + "——" + smax; listBox2.Items.Add(str); } else { string str = "■ " + min + "——" + smax + " " + min + "——" + smax; listBox2.Items.Add(str); } } } else { int r = _colorRamp.fromColor.R; for (i = 0; i < CurLayer.featureClass.Count; i++) { r = r + 10; Color c = Color.FromArgb(r, _colorRamp.fromColor.G, _colorRamp.fromColor.B); _colors.Add(c); if (CurLayer.featureClass.featureType == FeatureType.POINT || CurLayer.featureClass.featureType == FeatureType.MULTIPOINT) { string str = "· " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue] + "——" + " " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue]; listBox2.Items.Add(str); } else if (CurLayer.featureClass.featureType == FeatureType.POLYLINE) { string str = "— " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue] + "——" + " " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue]; listBox2.Items.Add(str); } else { string str = "■ " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue] + "——" + " " + CurLayer.featureClass.AttributeData.Rows[i][_selectedValue]; listBox2.Items.Add(str); } } } _renderMethod = 2; }
private void RandomInfo() { planetInfo.skybox = skyboxes[Range(0, skyboxes.Length)]; planetInfo.normals = planetNormals[Range(0, planetNormals.Length)]; planetInfo.coalReserves = Range(500, 40000); planetInfo.oilFactor = Range(0, 4); planetInfo.windFactor = Range(0, 4); planetInfo.sunFactor = Range(0.1f, 4); planetInfo.pollutionClearance = Range(0, 40); planetInfo.startPollution = 0; planetInfo.maxPollution = Range(2500, 10000); planetInfo.startEnergy = 20; planetInfo.population = Range(50, 200); planetInfo.iq = Range(1, 2); planetInfo.gameLength = Range(750, 1500); planetInfo.planetSize = Range(250, 1000); planetInfo.rotationSpeed = Range(.5f, 2); planetInfo.windZones = Range(0, 10); planetInfo.octaves = Range(1, 6); planetInfo.gain = Range(2f, 7.0f); planetInfo.lacunarity = Range(2f, 7.0f); planetInfo.planetName = "QuiGon"; planetInfo.stretch = Range(0f, 10f); int numColors = Range(3, 15); Color[] colors = new Color[numColors]; float[] ranges = new float[numColors - 1]; float percentRemaining = 1f; float minPercent = .01f; float alpha = 0; for (int i = 0; i < colors.Length; i++) { colors[i] = new Color(Range(0f, 1f), Range(0f, 1f), Range(0f, 1f), alpha); alpha = 1; } for (int i = 0; i < ranges.Length - 1; i++) { if (i == 0) // water { float percent = Range(minPercent, .7f); ranges[i] = percent; percentRemaining -= percent; } else // else { int remainingColorsCount = ranges.Length - i - 1; float maxPercent = percentRemaining - (minPercent * remainingColorsCount); float percent = Range(minPercent, maxPercent); ranges[i] = percent; percentRemaining -= percent; } } ranges[ranges.Length - 1] = percentRemaining; float sum = 0; for (int i = 0; i < ranges.Length; i++) { sum += ranges[i]; } ColorRamp r = new ColorRamp(colors, ranges); planetInfo.colorRamp = r; }
private void UpdateRendererButton_Clicked(object sender, EventArgs e) { try { // Define the RasterLayer that will be used to display in the map. RasterLayer rasterLayerForDisplayInMap; // Define the ColorRamp that will be used by the BlendRenderer. ColorRamp colorRamp; // Get the user choice for the ColorRamps. string selection = Enum.GetNames(typeof(PresetColorRampType))[_colorRampsPicker.SelectedSegment]; // Based on ColorRamp type chosen by the user, create a different // RasterLayer and define the appropriate ColorRamp option. if (selection == "None") { // The user chose not to use a specific ColorRamp, therefore // need to create a RasterLayer based on general imagery (i.e. Shasta.tif) // for display in the map and use null for the ColorRamp as one of the // parameters in the BlendRenderer constructor. // Load the raster file using a path on disk. Raster rasterImagery = new Raster(DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif")); // Create the raster layer from the raster. rasterLayerForDisplayInMap = new RasterLayer(rasterImagery); // Set up the ColorRamp as being null. colorRamp = null; } else { // The user chose a specific ColorRamp (options: are Elevation, DemScreen, DemLight), // therefore create a RasterLayer based on an imagery with elevation // (i.e. Shasta_Elevation.tif) for display in the map. Also create a ColorRamp // based on the user choice, translated into an Enumeration, as one of the parameters // in the BlendRenderer constructor. // Load the raster file using a path on disk. Raster rasterElevation = new Raster(DataManager.GetDataFolder("caeef9aa78534760b07158bb8e068462", "Shasta_Elevation.tif")); // Create the raster layer from the raster. rasterLayerForDisplayInMap = new RasterLayer(rasterElevation); // Create a ColorRamp based on the user choice, translated into an Enumeration. PresetColorRampType myPresetColorRampType = (PresetColorRampType)Enum.Parse(typeof(PresetColorRampType), selection); colorRamp = ColorRamp.Create(myPresetColorRampType, 256); } // Define the parameters used by the BlendRenderer constructor. Raster rasterForMakingBlendRenderer = new Raster(DataManager.GetDataFolder("caeef9aa78534760b07158bb8e068462", "Shasta_Elevation.tif")); IEnumerable <double> myOutputMinValues = new List <double> { 9 }; IEnumerable <double> myOutputMaxValues = new List <double> { 255 }; IEnumerable <double> mySourceMinValues = new List <double>(); IEnumerable <double> mySourceMaxValues = new List <double>(); IEnumerable <double> myNoDataValues = new List <double>(); IEnumerable <double> myGammas = new List <double>(); // Get the user choice for the SlopeType. string slopeSelection = Enum.GetNames(typeof(SlopeType))[_slopeTypesPicker.SelectedSegment]; SlopeType mySlopeType = (SlopeType)Enum.Parse(typeof(SlopeType), slopeSelection); rasterLayerForDisplayInMap.Renderer = new BlendRenderer( rasterForMakingBlendRenderer, // elevationRaster - Raster based on a elevation source. myOutputMinValues, // outputMinValues - Output stretch values, one for each band. myOutputMaxValues, // outputMaxValues - Output stretch values, one for each band. mySourceMinValues, // sourceMinValues - Input stretch values, one for each band. mySourceMaxValues, // sourceMaxValues - Input stretch values, one for each band. myNoDataValues, // noDataValues - NoData values, one for each band. myGammas, // gammas - Gamma adjustment. colorRamp, // colorRamp - ColorRamp object to use, could be null. _altitudeSlider.Value, // altitude - Altitude angle of the light source. _azimuthSlider.Value, // azimuth - Azimuth angle of the light source, measured clockwise from north. 1, // zfactor - Factor to convert z unit to x,y units, default is 1. mySlopeType, // slopeType - Slope Type. 1, // pixelSizeFactor - Pixel size factor, default is 1. 1, // pixelSizePower - Pixel size power value, default is 1. 8); // outputBitDepth - Output bit depth, default is 8-bit. // Set the new base map to be the RasterLayer with the BlendRenderer applied. _map.Basemap = new Basemap(rasterLayerForDisplayInMap); } catch (Exception ex) { Console.WriteLine(ex); } }
private void RenderButton_Click(object sender, System.Windows.RoutedEventArgs e) { ObservableCollection<ColorRamp> colorRamps = new ObservableCollection<ColorRamp>(); colorRamp = new ColorRamp() { From = ((StartColorListBox.SelectedItem as ListBoxItem).Background as SolidColorBrush).Color, To = ((EndColorListBox.SelectedItem as ListBoxItem).Background as SolidColorBrush).Color, Algorithm = (Algorithm)AlgorithmListBox.SelectedItem, }; colorRamps.Add(colorRamp); generateClassesParameters.ClassificationDefinition = new ClassBreaksDefinition() { BaseSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleFillSymbol() { Fill = (ColorRampListBox.SelectedItem as ListBoxItem).Background }, ClassificationField = ((ClassificationFieldListBox.SelectedItem) as Field).Name, ClassificationMethod = (ClassificationMethod)ClassificationMethodListBox.SelectedItem, BreakCount = int.Parse(BreakCountTB.Text.Trim()), ColorRamps = colorRamps, }; ClassBreaksDefinition classBreakDef = generateClassesParameters.ClassificationDefinition as ClassBreaksDefinition; if (classBreakDef.ClassificationMethod == ClassificationMethod.StandardDeviation) classBreakDef.StandardDeviationInterval = (StandardDeviationInterval)IntervalListBox.SelectedItem; if (NormalizationTypeListBox.SelectedItem != null) { classBreakDef.NormalizationType = (NormalizationType)NormalizationTypeListBox.SelectedItem; if (classBreakDef.NormalizationType == NormalizationType.Field) { if (NormalizationFieldListBox.SelectedItem != null) classBreakDef.NormalizationField = ((NormalizationFieldListBox.SelectedItem) as Field).Name; else { MessageBox.Show("Normalization Field must be selected"); return; } } } if (generateRendererTask.IsBusy) generateRendererTask.CancelAsync(); generateRendererTask.ExecuteAsync(generateClassesParameters); ThematicPropertiesPage.IsOpen = false; }
private void AddDefaultVectorSchemes() { ColorBlend blend = null; // dummy single color blend must be always the first for shapefile blend = new ColorBlend(2); blend.Colors[0] = Color.White; blend.Positions[0] = 0.0f; blend.Colors[1] = Color.White; blend.Positions[1] = 1.0f; _list.Add(blend); blend = new ColorBlend(2); blend.Colors[0] = Color.LightBlue; blend.Positions[0] = 0.0f; blend.Colors[1] = Color.Orange; blend.Positions[1] = 1.0f; _list.Add(blend); blend = new ColorBlend(2); blend.Colors[0] = Color.Yellow; blend.Positions[0] = 0.0f; blend.Colors[1] = Color.Orange; blend.Positions[1] = 1.0f; _list.Add(blend); for (int i = 0; i < 2; i++) { var sch = new ColorRamp(); if (i == 0) { sch.SetColors(PredefinedColors.FallLeaves); } if (i == 1) { sch.SetColors(PredefinedColors.DeadSea); } blend = sch.ColorScheme2ColorBlend(); _list.Add(blend); } // adding to 2 color schemes, as there can be none in the list blend = new ColorBlend(7); blend.Colors[0] = Color.Red; blend.Positions[0] = 0.0f; blend.Colors[1] = Color.Orange; blend.Positions[1] = 1.0f / 6.0f; blend.Colors[2] = Color.Yellow; blend.Positions[2] = 2.0f / 6.0f; blend.Colors[3] = Color.LightGreen; blend.Positions[3] = 3.0f / 6.0f; blend.Colors[4] = Color.LightBlue; blend.Positions[4] = 4.0f / 6.0f; blend.Colors[5] = Color.Blue; blend.Positions[5] = 5.0f / 6.0f; blend.Colors[6] = Color.BlueViolet; blend.Positions[6] = 1.0f; _list.Add(blend); blend = new ColorBlend(2); blend.Colors[0] = Color.LightGray; blend.Positions[0] = 0.0f; blend.Colors[1] = Color.Gray; blend.Positions[1] = 1.0f; _list.Add(blend); blend = new ColorBlend(2); blend.Colors[0] = Color.Pink; blend.Positions[0] = 0.0f; blend.Colors[1] = Color.LightYellow; blend.Positions[1] = 1.0f; _list.Add(blend); }
private void UpdateRendererButton_Clicked(object sender, EventArgs e) { // This function acquires the user selection of the stretch renderer from the table view // along with the parameters specified, then a stretch renderer is created and applied to // the raster layer. // Convert the input text to doubles and return if they're invalid. double input1; double input2; try { input1 = Convert.ToDouble(_inputParameter1.Text); input2 = Convert.ToDouble(_inputParameter2.Text); } catch (Exception ex) { new UIAlertView("alert", ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show(); return; } // Create an IEnumerable from an empty list of doubles for the gamma values in the stretch render. IEnumerable <double> gammaValues = new List <double>(); // Create a color ramp for the stretch renderer. ColorRamp colorRamp = ColorRamp.Create(PresetColorRampType.DemLight, 1000); // Create the place holder for the stretch renderer. StretchRenderer stretchRenderer = null; switch (_rendererTypes.SelectedSegment) { case 0: // This section creates a stretch renderer based on a MinMaxStretchParameters. // TODO: Add you own logic to ensure that accurate min/max stretch values are used. try { // Create an IEnumerable from a list of double min stretch value doubles. IEnumerable <double> minValues = new List <double> { input1 }; // Create an IEnumerable from a list of double max stretch value doubles. IEnumerable <double> maxValues = new List <double> { input2 }; // Create a new MinMaxStretchParameters based on the user choice for min and max stretch values. MinMaxStretchParameters minMaxStretchParameters = new MinMaxStretchParameters(minValues, maxValues); // Create the stretch renderer based on the user defined min/max stretch values, empty gamma values, statistic estimates, and a predefined color ramp. stretchRenderer = new StretchRenderer(minMaxStretchParameters, gammaValues, true, colorRamp); } catch (ArgumentException) { ShowMessage("Error configuring renderer.", "Ensure all values are valid and try again."); return; } break; case 1: // This section creates a stretch renderer based on a PercentClipStretchParameters. // TODO: Add you own logic to ensure that accurate min/max percent clip values are used. try { // Create a new PercentClipStretchParameters based on the user choice for min and max percent clip values. PercentClipStretchParameters percentClipStretchParameters = new PercentClipStretchParameters(input1, input2); // Create the percent clip renderer based on the user defined min/max percent clip values, empty gamma values, statistic estimates, and a predefined color ramp. stretchRenderer = new StretchRenderer(percentClipStretchParameters, gammaValues, true, colorRamp); } catch (Exception) { ShowMessage("Error configuring renderer.", "Ensure all values are valid and try again."); return; } break; case 2: // This section creates a stretch renderer based on a StandardDeviationStretchParameters. // TODO: Add you own logic to ensure that an accurate standard deviation value is used try { // Create a new StandardDeviationStretchParameters based on the user choice for standard deviation value. StandardDeviationStretchParameters standardDeviationStretchParameters = new StandardDeviationStretchParameters(input1); // Create the standard deviation renderer based on the user defined standard deviation value, empty gamma values, statistic estimates, and a predefined color ramp. stretchRenderer = new StretchRenderer(standardDeviationStretchParameters, gammaValues, true, colorRamp); } catch (Exception) { ShowMessage("Error configuring renderer.", "Ensure all values are valid and try again."); return; } break; } // Get the existing raster layer in the map. RasterLayer rasterLayer = (RasterLayer)_myMapView.Map.OperationalLayers[0]; // Apply the stretch renderer to the raster layer. rasterLayer.Renderer = stretchRenderer; }
private void OnUpdateRendererClicked(object sender, EventArgs e) { // This function acquires the user selection of the stretch renderer from the table view // along with the parameters specified, then a stretch renderer is created and applied to // the raster layer // Get the user choice for the raster stretch render UITableViewSource myUITableViewSource = _myRenderChoiceType.Source; TableSource myTableSource = (TableSource)myUITableViewSource; string myRendererTypeChoice; if (myTableSource.SelectedValue == null) { // If the user does not click on a choice in the table but just clicks the // button, the selected value will be null so use the initial // stretch renderer option myRendererTypeChoice = "Min Max"; } else { // The user clicked on an option in the table and thus the selected value // will contain a valid choice myRendererTypeChoice = myTableSource.SelectedValue; } // Create an IEnumerable from an empty list of doubles for the gamma values in the stretch render IEnumerable <double> myGammaValues = new List <double>(); // Create a color ramp for the stretch renderer ColorRamp myColorRamp = ColorRamp.Create(PresetColorRampType.DemLight, 1000); // Create the place holder for the stretch renderer StretchRenderer myStretchRenderer = null; switch (myRendererTypeChoice) { case "Min Max": // This section creates a stretch renderer based on a MinMaxStretchParameters // TODO: Add you own logic to ensure that accurate min/max stretch values are used // Create an IEnumerable from a list of double min stretch value doubles IEnumerable <double> myMinValues = new List <double> { Convert.ToDouble(_Input_Parameter1.Text) }; // Create an IEnumerable from a list of double max stretch value doubles IEnumerable <double> myMaxValues = new List <double> { Convert.ToDouble(_Input_Parameter2.Text) }; // Create a new MinMaxStretchParameters based on the user choice for min and max stretch values MinMaxStretchParameters myMinMaxStretchParameters = new MinMaxStretchParameters(myMinValues, myMaxValues); // Create the stretch renderer based on the user defined min/max stretch values, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myMinMaxStretchParameters, myGammaValues, true, myColorRamp); break; case "Percent Clip": // This section creates a stretch renderer based on a PercentClipStretchParameters // TODO: Add you own logic to ensure that accurate min/max percent clip values are used // Create a new PercentClipStretchParameters based on the user choice for min and max percent clip values PercentClipStretchParameters myPercentClipStretchParameters = new PercentClipStretchParameters(Convert.ToDouble(_Input_Parameter1.Text), Convert.ToDouble(_Input_Parameter2.Text)); // Create the percent clip renderer based on the user defined min/max percent clip values, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myPercentClipStretchParameters, myGammaValues, true, myColorRamp); break; case "Standard Deviation": // This section creates a stretch renderer based on a StandardDeviationStretchParameters // TODO: Add you own logic to ensure that an accurate standard deviation value is used // Create a new StandardDeviationStretchParameters based on the user choice for standard deviation value StandardDeviationStretchParameters myStandardDeviationStretchParameters = new StandardDeviationStretchParameters(Convert.ToDouble(_Input_Parameter1.Text)); // Create the standard deviation renderer based on the user defined standard deviation value, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myStandardDeviationStretchParameters, myGammaValues, true, myColorRamp); break; } // Get the existing raster layer in the map RasterLayer myRasterLayer = (RasterLayer)_myMapView.Map.OperationalLayers[0]; // Apply the stretch renderer to the raster layer myRasterLayer.Renderer = myStretchRenderer; }
private Color ComputeColor(Point p, Point middlePoint, double maximumDistance, ColorRamp colorRamp) { var distance = CalculateDistance(p, middlePoint); var ratio = Gamma(1.0 - Math.Pow(Math.E, -10.0 * distance / maximumDistance)); return(colorRamp.GetColor(ratio).ToColor()); }
public BitmapSource GeneratePreviewImage(ColorRamp ramp, bool useStdDevStretch, int quality) { //if (m_pixelGridSet == null) // GeneratePreviewGrid(); if (Preview == null || Preview.ColorHandler != ramp || Preview.UseStdDevStretch != useStdDevStretch || Preview.Quality != quality) { var source = GeneratePreviewImage(m_pixelGridSet.GridQuantized, ramp, useStdDevStretch, quality); Preview = new PreviewImage(source, ramp, useStdDevStretch, quality); //using (var fileStream = new FileStream(Path.Combine(Cache.APP_CACHE_DIR, "preview.jpg"), FileMode.Create)) //{ // var encoder = new JpegBitmapEncoder(); // encoder.Frames.Add(BitmapFrame.Create(source)); // encoder.QualityLevel = 100; // encoder.Save(fileStream); //} } return Preview.Image; }
private BitmapSource GeneratePreviewImage(Grid<int> grid, ColorRamp ramp, bool useStdDevStretch, int quality) { var bmp = CreateBitmapSource(grid, QuantizedExtent, StatisticsQuantizedZ, useStdDevStretch, ramp, quality); //BitmapSource bmp = CreateSegmentationBitmap(grid); //BitmapSource bmp = CreatePlaneFittingBitmap(grid); return bmp; }
public PlanetInfo CreateInfo() { PlanetInfo planetInfo = new PlanetInfo (); planetInfo.skybox = skyboxes [GameObject.Find ("SkyBoxDropdown").GetComponent<dfDropdown> ().SelectedIndex]; planetInfo.normals = planetNormals [GameObject.Find ("NormalDropdown").GetComponent<dfDropdown> ().SelectedIndex]; planetInfo.coalReserves = 10000 * GameObject.Find ("CoalSlider").GetComponentInChildren<dfSlider> ().Value; planetInfo.oilFactor = GameObject.Find ("OilSlider").GetComponentInChildren<dfSlider> ().Value; ; planetInfo.windFactor = GameObject.Find ("WindSlider").GetComponentInChildren<dfSlider> ().Value; ; planetInfo.sunFactor = GameObject.Find ("SunSlider").GetComponentInChildren<dfSlider> ().Value; ; planetInfo.pollutionClearance = 20; planetInfo.startPollution = 0; planetInfo.maxPollution = 5000; planetInfo.startEnergy = 20; planetInfo.population = 100; planetInfo.iq = 1; planetInfo.gameLength = 1000; planetInfo.planetSize = (int)GameObject.Find ("SizeSlider").GetComponentInChildren<dfSlider> ().Value; print (planetInfo.planetSize); planetInfo.rotationSpeed = 1; planetInfo.windZones = 3; planetInfo.octaves = (int)GameObject.Find ("OctavesSlider").GetComponentInChildren<dfSlider> ().Value; planetInfo.gain = GameObject.Find ("GainSlider").GetComponentInChildren<dfSlider> ().Value; planetInfo.lacunarity = GameObject.Find ("LacunaritySlider").GetComponentInChildren<dfSlider> ().Value; planetInfo.stretch = GameObject.Find ("StretchSlider").GetComponentInChildren<dfSlider> ().Value; Color[] colors = new Color[6]; float[] ranges = new float[5]; for (int i = 0; i < colors.Length; i++) { Color c = GameObject.Find ("ColorDisplay" + (i + 1)).GetComponentInChildren<dfSlicedSprite> ().Color; if (i == 0) c.a = 0; colors [i] = c; } for (int i = 0; i < ranges.Length; i++) { ranges [i] = GameObject.Find ("Slider" + (i + 1)).GetComponentInChildren<dfSlider> ().Value / 100f; } ColorRamp r = new ColorRamp (colors, ranges); planetInfo.colorRamp = r; return planetInfo; }
private async void OnUpdateRendererClicked(object sender, RoutedEventArgs e) { // Convert the text to doubles and return if they're invalid. double input1; double input2; try { input1 = Convert.ToDouble(FirstParameterInput.Text); input2 = Convert.ToDouble(SecondParameterInput.Text); } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); return; } // Get the user choice for the raster stretch render string myRendererTypeChoice = RendererTypes.SelectedValue.ToString(); // Create an IEnumerable from an empty list of doubles for the gamma values in the stretch render IEnumerable <double> myGammaValues = new List <double>(); // Create a color ramp for the stretch renderer ColorRamp myColorRamp = ColorRamp.Create(PresetColorRampType.DemLight, 1000); // Create the place holder for the stretch renderer StretchRenderer myStretchRenderer = null; switch (myRendererTypeChoice) { case "Min Max": // This section creates a stretch renderer based on a MinMaxStretchParameters // TODO: Add you own logic to ensure that accurate min/max stretch values are used // Create an IEnumerable from a list of double min stretch value doubles IEnumerable <double> myMinValues = new List <double> { input1 }; // Create an IEnumerable from a list of double max stretch value doubles IEnumerable <double> myMaxValues = new List <double> { input2 }; // Create a new MinMaxStretchParameters based on the user choice for min and max stretch values MinMaxStretchParameters myMinMaxStretchParameters = new MinMaxStretchParameters(myMinValues, myMaxValues); // Create the stretch renderer based on the user defined min/max stretch values, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myMinMaxStretchParameters, myGammaValues, true, myColorRamp); break; case "Percent Clip": // This section creates a stretch renderer based on a PercentClipStretchParameters // TODO: Add you own logic to ensure that accurate min/max percent clip values are used // Create a new PercentClipStretchParameters based on the user choice for min and max percent clip values PercentClipStretchParameters myPercentClipStretchParameters = new PercentClipStretchParameters(input1, input2); // Create the percent clip renderer based on the user defined min/max percent clip values, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myPercentClipStretchParameters, myGammaValues, true, myColorRamp); break; case "Standard Deviation": // This section creates a stretch renderer based on a StandardDeviationStretchParameters // TODO: Add you own logic to ensure that an accurate standard deviation value is used // Create a new StandardDeviationStretchParameters based on the user choice for standard deviation value StandardDeviationStretchParameters myStandardDeviationStretchParameters = new StandardDeviationStretchParameters(input1); // Create the standard deviation renderer based on the user defined standard deviation value, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myStandardDeviationStretchParameters, myGammaValues, true, myColorRamp); break; } // Get the existing raster layer in the map RasterLayer myRasterLayer = (RasterLayer)MyMapView.Map.OperationalLayers[0]; // Apply the stretch renderer to the raster layer myRasterLayer.Renderer = myStretchRenderer; }
private void OnUpdateRendererClicked(object sender, EventArgs e) { // Get the user choice for the raster stretch render string myRendererTypeChoice = RendererTypes.SelectedItem.ToString(); // Create an IEnumerable from an empty list of doubles for the gamma values in the stretch render IEnumerable <double> myGammaValues = new List <double> { }; // Create a color ramp for the stretch renderer ColorRamp myColorRamp = ColorRamp.Create(PresetColorRampType.DemLight, 1000); // Create the place holder for the stretch renderer StretchRenderer myStretchRenderer = null; switch (myRendererTypeChoice) { case "Min Max": // This section creates a stretch renderer based on a MinMaxStretchParameters // TODO: Add you own logic to ensure that accurate min/max stretch values are used // Create an IEnumerable from a list of double min stretch value doubles IEnumerable <double> myMinValues = new List <double> { Convert.ToDouble(Input_Parameter1.Text) }; // Create an IEnumerable from a list of double max stretch value doubles IEnumerable <double> myMaxValues = new List <double> { Convert.ToDouble(Input_Parameter2.Text) }; // Create a new MinMaxStretchParameters based on the user choice for min and max stretch values MinMaxStretchParameters myMinMaxStretchParameters = new MinMaxStretchParameters(myMinValues, myMaxValues); // Create the stretch renderer based on the user defined min/max stretch values, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new Esri.ArcGISRuntime.Rasters.StretchRenderer(myMinMaxStretchParameters, myGammaValues, true, myColorRamp); break; case "Percent Clip": // This section creates a stretch renderer based on a PercentClipStretchParameters // TODO: Add you own logic to ensure that accurate min/max percent clip values are used // Create a new PercentClipStretchParameters based on the user choice for min and max percent clip values PercentClipStretchParameters myPercentClipStretchParameters = new PercentClipStretchParameters(Convert.ToDouble(Input_Parameter1.Text), Convert.ToDouble(Input_Parameter2.Text)); // Create the percent clip renderer based on the user defined min/max percent clip values, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myPercentClipStretchParameters, myGammaValues, true, myColorRamp); break; case "Standard Deviation": // This section creates a stretch renderer based on a StandardDeviationStretchParameters // TODO: Add you own logic to ensure that an accurate standard deviation value is used // Create a new StandardDeviationStretchParameters based on the user choice for standard deviation value StandardDeviationStretchParameters myStandardDeviationStretchParameters = new StandardDeviationStretchParameters(Convert.ToDouble(Input_Parameter1.Text)); // Create the standard deviation renderer based on the user defined standard deviation value, empty gamma values, statistic estimates, and a predefined color ramp myStretchRenderer = new StretchRenderer(myStandardDeviationStretchParameters, myGammaValues, true, myColorRamp); break; } // Get the existing raster layer in the map RasterLayer myRasterLayer = (RasterLayer)MyMapView.Map.OperationalLayers[0]; // Apply the stretch renderer to the raster layer myRasterLayer.Renderer = myStretchRenderer; }
private void OnUpdateRendererClicked(object sender, RoutedEventArgs e) { // Define the RasterLayer that will be used to display in the map RasterLayer rasterLayer_ForDisplayInMap; // Define the ColorRamp that will be used by the BlendRenderer ColorRamp myColorRamp; // Based on ColorRamp type chosen by the user, create a different // RasterLayer and define the appropriate ColorRamp option if (ColorRamps.SelectedValue.ToString() == "None") { // The user chose not to use a specific ColorRamp, therefore // need to create a RasterLayer based on general imagery (ie. Shasta.tif) // for display in the map and use null for the ColorRamp as one of the // parameters in the BlendRenderer constructor // Load the raster file using a path on disk Raster raster_Imagery = new Raster(GetRasterPath_Imagery()); // Create the raster layer from the raster rasterLayer_ForDisplayInMap = new RasterLayer(raster_Imagery); // Set up the ColorRamp as being null myColorRamp = null; } else { // The user chose a specific ColorRamp (options: are Elevation, DemScreen, DemLight), // therefore create a RasterLayer based on an imagery with elevation // (ie. Shasta_Elevation.tif) for display in the map. Also create a ColorRamp // based on the user choice, translated into an Enumeration, as one of the parameters // in the BlendRenderer constructor // Load the raster file using a path on disk Raster raster_Elevation = new Raster(GetRasterPath_Elevation()); // Create the raster layer from the raster rasterLayer_ForDisplayInMap = new RasterLayer(raster_Elevation); // Create a ColorRamp based on the user choice, translated into an Enumeration PresetColorRampType myPresetColorRampType = (PresetColorRampType)Enum.Parse(typeof(PresetColorRampType), ColorRamps.SelectedValue.ToString()); myColorRamp = ColorRamp.Create(myPresetColorRampType, 256); } // Define the parameters used by the BlendRenderer constructor Raster raster_ForMakingBlendRenderer = new Raster(GetRasterPath_Elevation()); IEnumerable <double> myOutputMinValues = new List <double> { 9 }; IEnumerable <double> myOutputMaxValues = new List <double> { 255 }; IEnumerable <double> mySourceMinValues = new List <double>(); IEnumerable <double> mySourceMaxValues = new List <double>(); IEnumerable <double> myNoDataValues = new List <double>(); IEnumerable <double> myGammas = new List <double>(); SlopeType mySlopeType = (SlopeType)Enum.Parse(typeof(SlopeType), SlopeTypes.SelectedValue.ToString()); BlendRenderer myBlendRenderer = new BlendRenderer( raster_ForMakingBlendRenderer, // elevationRaster - Raster based on a elevation source myOutputMinValues, // outputMinValues - Output stretch values, one for each band myOutputMaxValues, // outputMaxValues - Output stretch values, one for each band mySourceMinValues, // sourceMinValues - Input stretch values, one for each band mySourceMaxValues, // sourceMaxValues - Input stretch values, one for each band myNoDataValues, // noDataValues - NoData values, one for each band myGammas, // gammas - Gamma adjustment myColorRamp, // colorRamp - ColorRamp object to use, could be null Altitude_Slider.Value, // altitude - Altitude angle of the light source Azimuth_Slider.Value, // azimuth - Azimuth angle of the light source, measured clockwise from north 1, // zfactor - Factor to convert z unit to x,y units, default is 1 mySlopeType, // slopeType - Slope Type 1, // pixelSizeFactor - Pixel size factor, default is 1 1, // pixelSizePower - Pixel size power value, default is 1 8); // outputBitDepth - Output bit depth, default is 8-bi // Set the RasterLayer.Renderer to be the BlendRenderer rasterLayer_ForDisplayInMap.Renderer = myBlendRenderer; // Set the new base map to be the RasterLayer with the BlendRenderer applied MyMapView.Map.Basemap = new Basemap(rasterLayer_ForDisplayInMap); }
/// <summary> /// Default constructor /// </summary> public GradientPaint() { this.Ramp = new ColorRamp(); }