Beispiel #1
0
        public static void GetPixels2DNonAlloc(
            Texture2D src,
            int startX, int startZ,
            Color[,] sample,
            Color defaultColor)
        {
            int sampleLength = sample.GetLength(0);
            int sampleWidth  = sample.GetLength(1);

            Color[] colors = GCommon.GetPixels(src, startX, startZ, sampleWidth, sampleLength, defaultColor);
            for (int z = 0; z < sampleLength; ++z)
            {
                for (int x = 0; x < sampleWidth; ++x)
                {
                    sample[z, x] = colors[GUtilities.To1DIndex(x, z, sampleWidth)];
                }
            }
        }
Beispiel #2
0
        public static Color[,] GetPixels2D(
            Texture2D src,
            int startX, int startZ,
            int sampleWidth, int sampleLength,
            Color defaultColor)
        {
            Color[,] sample = new Color[sampleLength, sampleWidth];

            Color[] colors = GCommon.GetPixels(src, startX, startZ, sampleWidth, sampleLength, defaultColor);
            for (int z = 0; z < sampleLength; ++z)
            {
                for (int x = 0; x < sampleWidth; ++x)
                {
                    sample[z, x] = colors[GUtilities.To1DIndex(x, z, sampleWidth)];
                }
            }

            return(sample);
        }
Beispiel #3
0
        public static float[,] GetPixels2D(
            Texture2D src,
            int startX, int startZ,
            int sampleWidth, int sampleLength,
            Color defaultColor,
            System.Func <Color, float> converter)
        {
            float[,] sample = new float[sampleLength, sampleWidth];

            Color[] colors = GCommon.GetPixels(src, startX, startZ, sampleWidth, sampleLength, defaultColor);
            for (int z = 0; z < sampleLength; ++z)
            {
                for (int x = 0; x < sampleWidth; ++x)
                {
                    sample[z, x] = converter(colors[GUtilities.To1DIndex(x, z, sampleWidth)]);
                }
            }

            return(sample);
        }