I need to convert the following 1D array of my class Frames to a 2D byte array (I need the 2D byte array for sending to a GPU, I cannot use jagged arrays, Lists, or other enumerables).
Right now, my conversion is very slow and stupid:
public byte[,] allBytes()
{
byte[,] output = new byte[this.frameListSize, this.ySize * this.xSize];
for (int y = 0; y < this.frameListSize; y++)
{
byte[] bits = this.frameList[y].getBytes();
for (int x = 0; x < this.ySize * this.xSize; x++)
{
output[y, x] = bits[x];
}
}
return output;
}
The snippets that define of frameList and Frame are below:
public Frame[] frameList;
public class Frame
{
public byte[] bits;
public byte[] getBytes()
{
return bits;
}
}