예제 #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);
 }
예제 #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);
        }
예제 #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);
                }
            }
        }
예제 #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);
        }
예제 #5
0
파일: RGBHSV.cs 프로젝트: Kuree/Sims4Tools
 /// <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) { }
예제 #6
0
파일: RGBHSV.cs 프로젝트: Kuree/Sims4Tools
 /// <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;
 }
예제 #7
0
파일: RGBHSV.cs 프로젝트: Kuree/Sims4Tools
 /// <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;
 }
예제 #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)
 {
 }