/// <summary> /// Update image /// </summary> public void UpdateImage() { int xNum = GridData.XNum; int yNum = GridData.YNum; byte[] imageBytes = new byte[xNum * yNum]; for (int i = 0; i < yNum; i++) { for (int j = 0; j < xNum; j++) { int value = -1; int b; for (b = 0; b < LegendScheme.LegendBreaks.Count - 1; b++) { ColorBreak aCB = LegendScheme.LegendBreaks[b]; if (aCB.StartValue.ToString() == aCB.EndValue.ToString()) { if (GridData.Data[i, j] == double.Parse(aCB.StartValue.ToString())) { value = b; break; } } else { if (GridData.Data[i, j] >= double.Parse(aCB.StartValue.ToString()) && GridData.Data[i, j] < double.Parse(aCB.EndValue.ToString())) { value = b; break; } } } if (value == -1) { value = b; if (LegendScheme.LegendBreaks[LegendScheme.BreakNum - 1].IsNoData) { if (!MIMath.DoubleEquals(GridData.Data[i, j], LegendScheme.MissingValue)) { value = b - 1; } } } imageBytes[i * xNum + j] = (byte)value; } } Image = DrawMeteoData.CreateBitmap(imageBytes, xNum, yNum); List <Color> colors = LegendScheme.GetColors(); DrawMeteoData.SetPalette(colors, Image); }
/// <summary> /// Set color palette by legend scheme /// </summary> public void SetPaletteByLegend() { List <Color> colors = _legendScheme.GetColors(); SetPalette(colors); }