Inheritance: ColourFit
        static unsafe void CompressMasked(byte[] rgba, int mask, byte *pBlock, SquishFlags flags)
        {
            // fix any bad flags
            flags = FixFlags(flags);


            // get the block locations
            byte *colourBlock = pBlock;
            byte *alphaBock   = pBlock;

            if ((flags & (SquishFlags.kDxt3 | SquishFlags.kDxt5)) != 0)
            {
                colourBlock = pBlock + 8;
            }

            // create the minimal point set
            ColourSet colours = new ColourSet(rgba, mask, flags);

            // check the compression type and compress colour
            if (colours.GetCount() == 1)
            {
                // always do a single colour fit
                SingleColourFit fit = new SingleColourFit(colours, flags);
                fit.Compress(colourBlock);
            }
            else if ((flags & SquishFlags.kColourRangeFit) != 0 || colours.GetCount() == 0)
            {
                // do a range fit
                RangeFit fit = new RangeFit(colours, flags);
                fit.Compress(colourBlock);
            }
            else
            {
                // default to a cluster fit (could be iterative or not)
                ClusterFit fit = new ClusterFit(colours, flags);
                fit.Compress(colourBlock);
            }

            // compress alpha separately if necessary
            if ((flags & SquishFlags.kDxt3) != 0)
            {
                alpha.CompressAlphaDxt3(rgba, mask, alphaBock);
            }
            else if ((flags & SquishFlags.kDxt5) != 0)
            {
                alpha.CompressAlphaDxt5(rgba, mask, alphaBock);
            }
        }
Esempio n. 2
0
        static unsafe void CompressMasked(byte[] rgba, int mask, byte* pBlock, SquishFlags flags)
        {
            // fix any bad flags
            flags = FixFlags(flags);

            // get the block locations
            byte* colourBlock = pBlock;
            byte* alphaBock = pBlock;
            if ((flags & (SquishFlags.kDxt3 | SquishFlags.kDxt5)) != 0)
                colourBlock = pBlock + 8;

            // create the minimal point set
            ColourSet colours = new ColourSet(rgba, mask, flags);

            // check the compression type and compress colour
            if (colours.GetCount() == 1)
            {
                // always do a single colour fit
                SingleColourFit fit = new SingleColourFit(colours, flags);
                fit.Compress(colourBlock);
            }
            else if ((flags & SquishFlags.kColourRangeFit) != 0 || colours.GetCount() == 0)
            {
                // do a range fit
                RangeFit fit = new RangeFit(colours, flags);
                fit.Compress(colourBlock);
            }
            else
            {
                // default to a cluster fit (could be iterative or not)
                ClusterFit fit = new ClusterFit(colours, flags);
                fit.Compress(colourBlock);
            }

            // compress alpha separately if necessary
            if ((flags & SquishFlags.kDxt3) != 0)
            {
                alpha.CompressAlphaDxt3(rgba, mask, alphaBock);
            }
            else if ((flags & SquishFlags.kDxt5) != 0)
            {
                alpha.CompressAlphaDxt5(rgba, mask, alphaBock);
            }
        }