public void CreateAltitudeMap(double minToleranceValue, double maxToleranceValue, COLORCODE colorcode) { try { BuildHeightArray(); // Calculate the function's value over the area. int xwidth = heightArr.GetUpperBound(0) + 1; int zwidth = heightArr.GetUpperBound(1) + 1; double dx = (XIndexMax - XIndexMin) / xwidth; double dz = (ZIndexMax - ZIndexMin) / zwidth; // Get the upper and lower bounds on the values. SetColors(); // Make the BitmapPixelMaker. BitmapPixelMaker bm_texture_maker = new BitmapPixelMaker(xwidth, zwidth); var bm_solid_maker = new BitmapPixelMaker(xwidth, zwidth); // Set the pixel colors. for (int ix = 0; ix < xwidth; ix++) { for (int iz = 0; iz < zwidth; iz++) { System.Drawing.Color color = System.Drawing.Color.FromArgb(100, 100, 100); var cc = new ColorCoder(colorcode); switch (colorcode) { case COLORCODE.GREEN_RED: cc.SetValues(minToleranceValue, maxToleranceValue); break; case COLORCODE.MONO: break; case COLORCODE.RAINBOW: default: cc.SetValues(ScaledMinValue, ScaledMaxValue); break; } color = cc.MapColor(heightArr[ix, iz]); bm_texture_maker.SetPixel(ix, iz, color); } } // Convert the BitmapPixelMaker into a WriteableBitmap. AltitudeMap = bm_texture_maker.MakeBitmap(96, 96); } catch (Exception) { throw; } }
protected void SetColors() { try { var get_values = from double value in heightArr select value; ScaledMinValue = get_values.Min(); ScaledMaxValue = get_values.Max(); double unscaledMaxValue = ScaledMaxValue / scalingFactor; double unscaledMinValue = ScaledMinValue / scalingFactor; var cc = new ColorCoder(COLORCODE.RAINBOW); cc.SetValues(unscaledMinValue, unscaledMaxValue); BlueValue = cc.GetBlueValue(); AquaValue = cc.GetAquaValue(); GreenValue = cc.GetGreenValue(); YellowValue = cc.GetYellowValue(); RedValue = cc.GetRedValue(); } catch (Exception) { throw; } }