Ejemplo n.º 1
0
        private static unsafe void compressMasked(byte *rgba, int mask, byte *block, SquishFlags flags)
        {
            //
            // get the block locations
            //
            byte *colourBlock = block;
            byte *alphaBlock  = block;

            if ((flags & (SquishFlags.Dxt3 | SquishFlags.Dxt5)) != 0)
            {
                colourBlock = block + 8;
            }
            //
            // create the minimal point set
            //
            ColourSet colours = new ColourSet(rgba, mask, flags);

            //
            // check the compression type and compress colour
            //
            if (colours.Count == 1)
            {
                //
                // always do a single colour fit
                //
                SingleColourFit fit = new SingleColourFit(colours, flags);

                fit.Compress(colourBlock);
            }
            else if ((flags & SquishFlags.ColourRangeFit) != 0 || colours.Count == 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.Dxt3) != 0)
            {
                compressAlphaDxt3(rgba, mask, alphaBlock);
            }
            else if ((flags & SquishFlags.Dxt5) != 0)
            {
                compressAlphaDxt5(rgba, mask, alphaBlock);
            }
        }
Ejemplo n.º 2
0
    private static unsafe void compressMasked(byte *rgba, int mask, byte *block, SquishFlags flags) {
      //
      // get the block locations
      //
      byte *colourBlock = block;
      byte *alphaBlock  = block;

      if ((flags & (SquishFlags.Dxt3 | SquishFlags.Dxt5)) != 0) colourBlock = block + 8;
      //
      // create the minimal point set
      //
      ColourSet colours = new ColourSet(rgba, mask, flags);
      //
      // check the compression type and compress colour
      //
      if (colours.Count == 1) {
        //
        // always do a single colour fit
        //
        SingleColourFit fit = new SingleColourFit(colours, flags);

        fit.Compress(colourBlock);
      }
      else if ((flags & SquishFlags.ColourRangeFit) != 0 || colours.Count == 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.Dxt3) != 0) compressAlphaDxt3(rgba, mask, alphaBlock);
      else if ((flags & SquishFlags.Dxt5) != 0) compressAlphaDxt5(rgba, mask, alphaBlock);
    }