Beispiel #1
0
 /// <summary>
 /// Creates the HSVA data values corresponding to an array of UInt32 ARGB values.
 /// </summary>
 /// <param name="argbData">An array of UInt32 ARGB values.</param>
 /// <returns>HSVA data values corresponding to <paramref name="argbData"/>.</returns>
 public static ColorHSVA[] ToArrayColorHSVA(uint[] argbData)
 {
     ColorHSVA[] hsvaData = new ColorHSVA[argbData.Length];
     for (int i = 0; i < argbData.Length; i++)
     {
         hsvaData[i] = (ColorHSVA)argbData[i];
     }
     return(hsvaData);
 }
Beispiel #2
0
        /// <summary>
        /// Determine if <paramref name="obj"/> is a <see cref="ColorHSVA"/> equal
        /// to the current value.
        /// </summary>
        /// <param name="obj">Value to test for equality.</param>
        /// <returns>True if <paramref name="obj"/> is a <see cref="ColorHSVA"/> equal
        /// to the current value; otherwise false.</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is ColorHSVA))
            {
                return(false);
            }
            ColorHSVA other = (ColorHSVA)obj;

            return(h == other.h && s == other.s && v == other.v && a == other.a);
        }
Beispiel #3
0
        void MaskedHSVShift(DdsFile mask, ColorHSVA[] result, Channel channel, HSVShift hsvShift)
        {
            for (int y = 0; y < this.Size.Height; y++)
            {
                int imageOffset = y * this.Size.Width;
                int maskOffset = (y % mask.Size.Height) * mask.Size.Width;

                for (int x = 0; x < this.Size.Width; x++)
                {
                    uint maskPixel = mask.currentImage[maskOffset + x % mask.Size.Width];
                    if (channel(maskPixel)) result[imageOffset + x] = hsvData[imageOffset + x].HSVShift(hsvShift);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Apply <see cref="HSVShift"/> values to this DDS image based on the
        /// channels in the <paramref name="mask"/>.
        /// Each channel of the mask acts independently, in order "R", "G", "B", "A".
        /// </summary>
        /// <param name="mask">A DDS image file, each colourway acting as a mask channel.</param>
        /// <param name="ch1Shift">A shift to apply to the image when the first channel of the mask is active.</param>
        /// <param name="ch2Shift">A shift to apply to the image when the second channel of the mask is active.</param>
        /// <param name="ch3Shift">A shift to apply to the image when the third channel of the mask is active.</param>
        /// <param name="ch4Shift">A shift to apply to the image when the fourth channel of the mask is active.</param>
        public void MaskedHSVShiftNoBlend(DdsFile mask, HSVShift ch1Shift, HSVShift ch2Shift, HSVShift ch3Shift, HSVShift ch4Shift)
        {
            if (!SupportsHSV) return;

            maskInEffect = maskInEffect || !ch1Shift.IsEmpty || !ch2Shift.IsEmpty || !ch3Shift.IsEmpty || !ch4Shift.IsEmpty;

            if (!maskInEffect) return;

            ColorHSVA[] result = new ColorHSVA[hsvData.Length];
            Array.Copy(hsvData, 0, result, 0, result.Length);

            if (!ch1Shift.IsEmpty) MaskedHSVShift(mask, result, x => x.R() > 0, ch1Shift);
            if (!ch2Shift.IsEmpty) MaskedHSVShift(mask, result, x => x.G() > 0, ch2Shift);
            if (!ch3Shift.IsEmpty) MaskedHSVShift(mask, result, x => x.B() > 0, ch3Shift);
            if (!ch4Shift.IsEmpty) MaskedHSVShift(mask, result, x => x.A() > 0, ch4Shift);

            hsvData = result;
            currentImage = ColorHSVA.ToArrayARGB(hsvData);
        }
Beispiel #5
0
 /// <summary>
 /// Create a new <see cref="ColorHSVA"/> from an existing <see cref="ColorHSVA"/> value.
 /// </summary>
 /// <param name="hsva">An existing <see cref="ColorHSVA"/> value.</param>
 public ColorHSVA(ColorHSVA hsva) : this(hsva.h, hsva.s, hsva.v, hsva.a) { }
Beispiel #6
0
 /// <summary>
 /// Creates a Bitmap image corresponding to an HSVA image.
 /// </summary>
 /// <param name="hsvaData">An HSVA image.</param>
 /// <param name="hsvShift">An optional <see cref="HSVShift"/> to apply.</param>
 /// <returns>A Bitmap image corresponding to <paramref name="hsvaData"/>.</returns>
 public static uint[] ToArrayARGB(ColorHSVA[] hsvaData, HSVShift hsvShift = new HSVShift())
 {
     uint[] argbData = new uint[hsvaData.Length];
     for (int i = 0; i < hsvaData.Length; i++)
         argbData[i] = hsvShift.IsEmpty ? hsvaData[i].ToARGB() : hsvaData[i].HSVShift(hsvShift).ToARGB();
     return argbData;
 }
Beispiel #7
0
 /// <summary>
 /// Creates the HSVA data values corresponding to an array of UInt32 ARGB values.
 /// </summary>
 /// <param name="argbData">An array of UInt32 ARGB values.</param>
 /// <returns>HSVA data values corresponding to <paramref name="argbData"/>.</returns>
 public static ColorHSVA[] ToArrayColorHSVA(uint[] argbData)
 {
     ColorHSVA[] hsvaData = new ColorHSVA[argbData.Length];
     for (int i = 0; i < argbData.Length; i++)
         hsvaData[i] = (ColorHSVA)argbData[i];
     return hsvaData;
 }
Beispiel #8
0
 /// <summary>
 /// Create a new <see cref="ColorHSVA"/> from an existing <see cref="ColorHSVA"/> value.
 /// </summary>
 /// <param name="hsva">An existing <see cref="ColorHSVA"/> value.</param>
 public ColorHSVA(ColorHSVA hsva) : this(hsva.h, hsva.s, hsva.v, hsva.a)
 {
 }