Пример #1
0
        /// <summary>
        /// Set image by grid data
        /// </summary>
        public void SetImageByGridData()
        {
            ColorPalette cPal = null;

            if (Image != null)
            {
                cPal = Image.Palette;
            }

            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++)
                {
                    imageBytes[i * xNum + j] = (byte)GridData.Data[i, j];
                }
            }

            Image = DrawMeteoData.CreateBitmap(imageBytes, xNum, yNum);
            if (cPal != null)
            {
                Image.Palette = cPal;
            }
        }
Пример #2
0
        /// <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);
        }