dennis48309
New member
- Joined
- Jul 29, 2018
- Messages
- 2
- Programming Experience
- 5-10
I am making an art editor for an old game, 8-bit graphics with 256 color palette. The sprite pixel data is unfortunately written in columns instead of rows. I need to reorder the pixel bytes into rows so that it can be accepted by the BitmapSource's Create method. I seem to have made a mistake and it is throwing an out of bounds error on the fixedArray byte array.
C#:
int width = tileWidths[index];
int height = tileHeights[index];
byte[] fixedArray = new byte[width * height];
for (int i = 0; i < tileData[index].Length; i++)
{
int y = i / height;
int x = i % height;
fixedArray[(y * width) + x] = tileData[index][i];
}