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)]; } } }
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); }
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); }