Esempio n. 1
0
        private void combColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            curCorlor = cb.SelectedItem as LinearColors;

            var mi = imgMain.Tag as MatImage;

            if (mi != null && curLengend != null)
            {
                curLengend.colors = curCorlor;
                legend.setValue(curLengend);
                imgMain.Source = mi.ToBitMap(curCorlor);
            }
        }
Esempio n. 2
0
 private System.Drawing.Color normalizeDEM(double dem, LinearColors colors)
 {
     if (dem != NODATA_value && maxData != NODATA_value && maxData > 0)
     {
         var v = (int)Math.Round((dem - minData) * 255 * 1.0 / (maxData - minData));
         if (v < 0 || v > 255)
         {
             throw new Exception("异常值" + v);
         }
         var c = colors.getColor(v);
         return(System.Drawing.Color.FromArgb(c.R, c.G, c.B));
         // return v;
     }
     else
     {
         return(System.Drawing.Color.Black);
     }
 }
Esempio n. 3
0
 public ImageSource ToBitMap(LinearColors colors)
 {
     try
     {
         var bmp = new Bitmap(ncols, nrows);
         for (int i = 0; i < bmp.Height; i++)
         {
             for (int j = 0; j < bmp.Width; j++)
             {
                 double dem = data[i][j];
                 var    c   = normalizeDEM(dem, colors);
                 bmp.SetPixel(j, i, c);
             }
         }
         return(BitmapToImageSource(bmp));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Esempio n. 4
0
        public override object Clone()
        {
            LinearGradientBrush copy = (LinearGradientBrush)InternalClone();

            if (copy._nativeObject != null)
            {
                copy._nativeObject = null;
            }

            if (_interpolationColors != null)
            {
                copy._interpolationColors = new ColorBlend();
                if (_interpolationColors.Colors != null)
                {
                    copy._interpolationColors.Colors = (Color[])_interpolationColors.Colors.Clone();
                }
                if (_interpolationColors.Positions != null)
                {
                    copy._interpolationColors.Positions = (float[])_interpolationColors.Positions.Clone();
                }
            }

            if (_blend != null)
            {
                copy._blend = new Blend();
                if (_blend.Factors != null)
                {
                    copy._blend.Factors = (float[])_blend.Factors.Clone();
                }
                if (_blend.Positions != null)
                {
                    copy._blend.Positions = (float[])_blend.Positions.Clone();
                }
            }

            copy.LinearColors = (Color[])LinearColors.Clone();
            return(copy);
        }
Esempio n. 5
0
        public IBrush ToItem(AGSSerializationContext context)
        {
            switch (Type)
            {
            case BrushType.Solid:
                return(_brushes.LoadSolidBrush(Color.FromHexa(MainColor)));

            case BrushType.Linear:
                return(_brushes.LoadLinearBrush(LinearColors.Select(c => Color.FromHexa(c)).ToArray(),
                                                Blend.ToItem(context), InterpolationColors.ToItem(context), Transform.ToItem(context), WrapMode, GammaCorrection));

            case BrushType.Hatch:
                return(_brushes.LoadHatchBrush(HatchStyle, Color.FromHexa(MainColor), Color.FromHexa(BackgroundColor)));

            case BrushType.Path:
                return(_brushes.LoadPathsGradientBrush(Color.FromHexa(MainColor), CenterPoint.ToItem(context), Blend.ToItem(context),
                                                       FocusScales.ToItem(context), LinearColors.Select(c => Color.FromHexa(c)).ToArray(),
                                                       InterpolationColors.ToItem(context), Transform.ToItem(context), WrapMode));

            default:
                throw new NotSupportedException(Type + " brush is not supported!");
            }
        }