Esempio n. 1
0
        /// <summary>
        /// Tests if the specified <code>Object</code> is an instance
        /// of <code>PackedColorModel</code> and equals this
        /// <code>PackedColorModel</code>. </summary>
        /// <param name="obj"> the <code>Object</code> to test for equality </param>
        /// <returns> <code>true</code> if the specified <code>Object</code>
        /// is an instance of <code>PackedColorModel</code> and equals this
        /// <code>PackedColorModel</code>; <code>false</code> otherwise. </returns>
        public override bool Equals(Object obj)
        {
            if (!(obj is PackedColorModel))
            {
                return(false);
            }

            if (!base.Equals(obj))
            {
                return(false);
            }

            PackedColorModel cm = (PackedColorModel)obj;
            int numC            = cm.NumComponents;

            if (numC != NumComponents_Renamed)
            {
                return(false);
            }
            for (int i = 0; i < numC; i++)
            {
                if (MaskArray[i] != cm.GetMask(i))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a <code>PackedColorModel</code> from the specified
        /// masks which indicate which bits in an <code>int</code> pixel
        /// representation contain the alpha, red, green and blue color samples.
        /// Color components are in the specified <code>ColorSpace</code>, which
        /// must be of type ColorSpace.TYPE_RGB.  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
        /// <code>amask</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="rmask"> specifies the mask representing
        ///         the bits of the pixel values that represent the red
        ///         color component </param>
        /// <param name="gmask"> specifies the mask representing
        ///         the bits of the pixel values that represent the green
        ///         color component </param>
        /// <param name="bmask"> specifies the mask representing
        ///         the bits of the pixel values that represent
        ///         the blue color component </param>
        /// <param name="amask"> 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>space</code> is not a
        ///         TYPE_RGB space </exception>
        /// <seealso cref= ColorSpace </seealso>
        public PackedColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, bool isAlphaPremultiplied, int trans, int transferType) : base(bits, PackedColorModel.CreateBitsArray(rmask, gmask, bmask, amask), space, (amask == 0 ? false : true), isAlphaPremultiplied, trans, transferType)
        {
            if (space.Type != ColorSpace.TYPE_RGB)
            {
                throw new IllegalArgumentException("ColorSpace must be TYPE_RGB.");
            }
            MaskArray    = new int[NumComponents_Renamed];
            MaskOffsets  = new int[NumComponents_Renamed];
            ScaleFactors = new float[NumComponents_Renamed];

            DecomposeMask(rmask, 0, "red");

            DecomposeMask(gmask, 1, "green");

            DecomposeMask(bmask, 2, "blue");

            if (amask != 0)
            {
                DecomposeMask(amask, 3, "alpha");
                if (NBits[3] == 1)
                {
                    Transparency_Renamed = java.awt.Transparency_Fields.BITMASK;
                }
            }
        }
Esempio n. 3
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;
                }
            }
        }