Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a true color presentation.
        /// </summary>
        /// <param name="indexOfRedBand">The zero based index of the red band.</param>
        /// <param name="indexOfGreenBand">The zero based index of the green band.</param>
        /// <param name="indexOfBlueBand">The zero based index of the blue band.</param>
        /// <returns>A true color raster presentation using RGB color space with the specified band order.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// The index of the red band is less than 0.
        /// or
        /// The index of the green band is less than 0.
        /// or
        /// The index of the blue band is less than 0.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The red and green bands are specified for the same index.
        /// or
        /// The red and blue bands are specified for the same index.
        /// or
        /// The green and blue bands are specified for the same index.
        /// </exception>
        public static RasterPresentation CreateTrueColorPresentation(Int32 indexOfRedBand, Int32 indexOfGreenBand, Int32 indexOfBlueBand)
        {
            if (indexOfRedBand < 0)
            {
                throw new ArgumentOutOfRangeException("indexOfRedBand", "The index of the red band is less than 0.");
            }
            if (indexOfGreenBand < 0)
            {
                throw new ArgumentOutOfRangeException("indexOfGreenBand", "The index of the green band is less than 0.");
            }
            if (indexOfBlueBand < 0)
            {
                throw new ArgumentOutOfRangeException("indexOfBlueBand", "The index of the blue band is less than 0.");
            }
            if (indexOfGreenBand == indexOfRedBand)
            {
                throw new ArgumentException("The red and green bands are specified for the same index.", "indexOfGreenBand");
            }
            if (indexOfBlueBand == indexOfRedBand)
            {
                throw new ArgumentException("The red and blue bands are specified for the same index.", "indexOfBlueBand");
            }
            if (indexOfBlueBand == indexOfGreenBand)
            {
                throw new ArgumentException("The green and blue bands are specified for the same index.", "indexOfBlueBand");
            }

            RasterColorSpaceBand[] bands = new RasterColorSpaceBand[Calculator.Max(indexOfRedBand, indexOfGreenBand, indexOfBlueBand) + 1];

            bands[indexOfRedBand]   = RasterColorSpaceBand.Red;
            bands[indexOfGreenBand] = RasterColorSpaceBand.Green;
            bands[indexOfBlueBand]  = RasterColorSpaceBand.Blue;

            return(new RasterPresentation(RasterPresentationModel.TrueColor, RasterColorSpace.RGB, bands));
        }