示例#1
0
        /// <summary>
        /// Constructs a <code>PackedColorModel</code> from a color mask array,
        /// which specifies which bits in an <code>int</code> pixel representation
        /// contain each of the color samples, and an alpha mask.  Color
        /// components are in the specified <code>ColorSpace</code>.  The length of
        /// <code>colorMaskArray</code> should be the number of components in
        /// the <code>ColorSpace</code>.  All of the bits in each mask
        /// must be contiguous and fit in the specified number of least significant
        /// bits of an <code>int</code> pixel representation.  If the
        /// <code>alphaMask</code> is 0, there is no alpha.  If there is alpha,
        /// the <code>boolean</code> <code>isAlphaPremultiplied</code> specifies
        /// how to interpret color and alpha samples in pixel values.  If the
        /// <code>boolean</code> is <code>true</code>, color samples are assumed
        /// to have been multiplied by the alpha sample.  The transparency,
        /// <code>trans</code>, specifies what alpha values can be represented
        /// by this color model.  The transfer type is the type of primitive
        /// array used to represent pixel values. </summary>
        /// <param name="space"> the specified <code>ColorSpace</code> </param>
        /// <param name="bits"> the number of bits in the pixel values </param>
        /// <param name="colorMaskArray"> array that specifies the masks representing
        ///         the bits of the pixel values that represent the color
        ///         components </param>
        /// <param name="alphaMask"> specifies the mask representing
        ///         the bits of the pixel values that represent the alpha
        ///         component </param>
        /// <param name="isAlphaPremultiplied"> <code>true</code> if color samples are
        ///        premultiplied by the alpha sample; <code>false</code> otherwise </param>
        /// <param name="trans"> specifies the alpha value that can be represented by
        ///        this color model </param>
        /// <param name="transferType"> the type of array used to represent pixel values </param>
        /// <exception cref="IllegalArgumentException"> if <code>bits</code> is less than
        ///         1 or greater than 32 </exception>
        public PackedColorModel(ColorSpace space, int bits, int[] colorMaskArray, int alphaMask, bool isAlphaPremultiplied, int trans, int transferType) : base(bits, PackedColorModel.CreateBitsArray(colorMaskArray, alphaMask), space, (alphaMask == 0 ? false : true), isAlphaPremultiplied, trans, transferType)
        {
            if (bits < 1 || bits > 32)
            {
                throw new IllegalArgumentException("Number of bits must be between" + " 1 and 32.");
            }
            MaskArray    = new int[NumComponents_Renamed];
            MaskOffsets  = new int[NumComponents_Renamed];
            ScaleFactors = new float[NumComponents_Renamed];

            for (int i = 0; i < NumColorComponents_Renamed; i++)
            {
                // Get the mask offset and #bits
                DecomposeMask(colorMaskArray[i], i, space.GetName(i));
            }
            if (alphaMask != 0)
            {
                DecomposeMask(alphaMask, NumColorComponents_Renamed, "alpha");
                if (NBits[NumComponents_Renamed - 1] == 1)
                {
                    Transparency_Renamed = java.awt.Transparency_Fields.BITMASK;
                }
            }
        }