FloatToInt() public static méthode

public static FloatToInt ( float a, int limit ) : int
a float
limit int
Résultat int
Exemple #1
0
        public SingleColourFit(ColourSet colours, SquishFlags flags) : base(colours, flags)
        {
            //
            // grab the single colour
            //
            Vec3[] values = colours.Points;

            colour[0] = (byte)ColourBlock.FloatToInt(255.0f * values[0].X, 255);
            colour[1] = (byte)ColourBlock.FloatToInt(255.0f * values[0].Y, 255);
            colour[2] = (byte)ColourBlock.FloatToInt(255.0f * values[0].Z, 255);
            //
            // initialise the best error
            //
            bestError = Int32.MaxValue;
        }
        private static unsafe void compressAlphaDxt3(byte *rgba, int mask, byte *block)
        {
            byte *bytes = block;

            //
            // quantise and pack the alpha values pairwise
            //
            for (int i = 0; i < 8; ++i)
            {
                //
                // quantise down to 4 bits
                //
                float alpha1 = rgba[8 * i + 3] * (15.0f / 255.0f);
                float alpha2 = rgba[8 * i + 7] * (15.0f / 255.0f);

                int quant1 = ColourBlock.FloatToInt(alpha1, 15);
                int quant2 = ColourBlock.FloatToInt(alpha2, 15);
                //
                // set alpha to zero where masked
                //
                int bit1 = 1 << (2 * i);
                int bit2 = 1 << (2 * i + 1);

                if ((mask & bit1) == 0)
                {
                    quant1 = 0;
                }
                if ((mask & bit2) == 0)
                {
                    quant2 = 0;
                }
                //
                // pack into the byte
                //
                bytes[i] = (byte)(quant1 | (quant2 << 4));
            }
        }