Пример #1
0
        /// <summary>
        /// Creates a true color presentation.
        /// </summary>
        /// <param name="colorSpace">The color space.</param>
        /// <returns>A true color raster representing the specified color space.</returns>
        /// <exception cref="System.ArgumentException">The specified color space is not supported.</exception>
        public static RasterPresentation CreateTrueColorPresentation(RasterColorSpace colorSpace)
        {
            RasterColorSpaceBand[] bands;

            switch (colorSpace)
            {
            case RasterColorSpace.CIELab:
                bands = new RasterColorSpaceBand[] { RasterColorSpaceBand.Lightness, RasterColorSpaceBand.A, RasterColorSpaceBand.B };
                break;

            case RasterColorSpace.CMYK:
                bands = new RasterColorSpaceBand[] { RasterColorSpaceBand.Cyan, RasterColorSpaceBand.Magenta, RasterColorSpaceBand.Yellow, RasterColorSpaceBand.Black };
                break;

            case RasterColorSpace.HSL:
                bands = new RasterColorSpaceBand[] { RasterColorSpaceBand.Hue, RasterColorSpaceBand.Saturation, RasterColorSpaceBand.Lightness };
                break;

            case RasterColorSpace.HSV:
                bands = new RasterColorSpaceBand[] { RasterColorSpaceBand.Hue, RasterColorSpaceBand.Saturation, RasterColorSpaceBand.Value };
                break;

            case RasterColorSpace.RGB:
                bands = new RasterColorSpaceBand[] { RasterColorSpaceBand.Red, RasterColorSpaceBand.Green, RasterColorSpaceBand.Blue };
                break;

            case RasterColorSpace.YCbCr:
                bands = new RasterColorSpaceBand[] { RasterColorSpaceBand.Luma, RasterColorSpaceBand.BlueDifferenceChroma, RasterColorSpaceBand.RedDifferenceChroma };
                break;

            default:
                throw new ArgumentException("The specified color space is not supported.", "colorSpace");
            }
            return(new RasterPresentation(RasterPresentationModel.TrueColor, colorSpace, bands));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RasterPresentation" /> class.
        /// </summary>
        /// <param name="model">The presentation model.</param>
        /// <param name="colorSpace">The color space.</param>
        /// <param name="bands">The bands.</param>
        /// <exception cref="System.ArgumentException">Pseudo-color and density slicing models must define a color map.</exception>
        public RasterPresentation(RasterPresentationModel model, RasterColorSpace colorSpace, params RasterColorSpaceBand[] bands)
        {
            if (model == RasterPresentationModel.DensitySlicing || model == RasterPresentationModel.PseudoColor)
            {
                throw new ArgumentException("Pseudo-color and density slicing models must define a color map.", "model");
            }

            Model      = model;
            ColorSpace = colorSpace;
            _bands     = bands.ToArray();
        }