/// <summary>
        /// Initializes a new instance of the ShadedReliefColorMap class.
        /// </summary>
        /// <param name="projectionGridMap">Input image grid.</param>
        public ShadedReliefColorMap(IProjectionGridMap projectionGridMap)
        {
            if (projectionGridMap == null)
            {
                throw new ArgumentNullException("projectionGridMap");
            }

            this.projectionGridMap = projectionGridMap;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the DataColorMap class.
        /// </summary>
        /// <param name="colorMapFile">
        /// Color map file path. This file will be used as Index of colors.
        /// </param>
        /// <param name="projectionGridMap">
        /// Input image grid map for specified projection.
        /// </param>
        /// <param name="orientation">
        /// Represents the orientation of the color map. 
        ///     For example : Vertical or Horizontal.
        /// </param>
        /// <param name="minimumValue">
        /// Represents minimum threshold value for color.
        /// </param>
        /// <param name="maximumValue">
        /// Represents maximum threshold value for color.
        /// </param>
        public DataColorMap(string colorMapFile, IProjectionGridMap projectionGridMap, ColorMapOrientation orientation, double minimumValue, double maximumValue)
        {
            if (string.IsNullOrEmpty(colorMapFile))
            {
                throw new ArgumentNullException("colorMapFile");
            }

            if (projectionGridMap == null)
            {
                throw new ArgumentNullException("projectionGridMap");
            }

            this.projectionGridMap = projectionGridMap;
            this.minimumThreshold = minimumValue;
            this.maximumThreshold = maximumValue;
            try
            {
                using (Bitmap bitmap = new Bitmap(Bitmap.FromFile(colorMapFile)))
                {
                    int samplingPoint = bitmap.Width / 2;
                    int numberOfColors = bitmap.Height;
                    if (orientation == ColorMapOrientation.Horizontal)
                    {
                        samplingPoint = bitmap.Height / 2;
                        numberOfColors = bitmap.Width;
                    }

                    this.colors = new List<Color>(numberOfColors);

                    if (orientation == ColorMapOrientation.Vertical)
                    {
                        for (int i = 0; i < numberOfColors; i++)
                        {
                            this.colors.Add(bitmap.GetPixel(samplingPoint, numberOfColors - i - 1));
                        }
                    }
                    else if (orientation == ColorMapOrientation.Horizontal)
                    {
                        for (int i = 0; i < numberOfColors; i++)
                        {
                            this.colors.Add(bitmap.GetPixel(numberOfColors - i - 1, samplingPoint));
                        }
                    }
                }
            }
            catch
            {
                throw new InvalidOperationException("Error reading the color map file. Check the color map and orientation.");
            }
        }