issue reordering pixel data in byte array

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];
}
 
I fixed my algorithm to reorder the bytes of the bitmap. A new problem has popped up. My image is displaying but it is much darker than it should be. Very confused since the WinForms version of my app was displaying them just fine in the PictureBox control.
 
A new problem has popped up.

Then you should probably start a new thread with a title that reflects that problem and containing all the information relevant to that problem.
 
Back
Top Bottom