コード例 #1
0
        private static void CompressAlphaDxt3(byte[] rgba, int mask, ref byte[] block, int offset)
        {
            // quantise and pack the alpha values pairwise
            for (var i = 0; i < 8; ++i)
            {
                // quantise down to 4 bits
                var alpha1 = rgba[8 * i + 3] * (15.0f / 255.0f);
                var alpha2 = rgba[8 * i + 7] * (15.0f / 255.0f);
                var quant1 = ColourBlock.FloatToInt(alpha1, 15);
                var quant2 = ColourBlock.FloatToInt(alpha2, 15);

                // set alpha to zero where masked
                var bit1 = 1 << (2 * i);
                var bit2 = 1 << (2 * i + 1);
                if ((mask & bit1) == 0)
                {
                    quant1 = 0;
                }
                if ((mask & bit2) == 0)
                {
                    quant2 = 0;
                }

                // pack into the byte
                block[i + offset] = (byte)(quant1 | (quant2 << 4));
            }
        }
コード例 #2
0
        public SingleColourFit(ColourSet colours, SquishFlags flags)
            : base(colours, flags)
        {
            // grab the single colour
            var values = MColours.Points;

            _mColour[0] = (byte)ColourBlock.FloatToInt(255.0f * values[0].X, 255);
            _mColour[1] = (byte)ColourBlock.FloatToInt(255.0f * values[0].Y, 255);
            _mColour[2] = (byte)ColourBlock.FloatToInt(255.0f * values[0].Z, 255);

            // initialise the best error
            _mBesterror = int.MaxValue;
        }