Someone ought to fix code formatting, lol.
C# code example:
C# code example:
Code:
public static Bitmap Create(Color[] palette, byte[] indices, int width, int height)
{
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
for (int y = 0; y < height; y++)
{
// we traverse through the image from top to bottom
for (int x = 0; x < width; x++)
{
// ..and from left to right
// x + (y * width)] means we get the current column and
// add the amount of traversed rows * the amount of traversed columns
// in a 2-dimensional array, this would be equal to indices[x][y]
bitmap.SetPixel(x, y, palette[indices[x + (y * width)]]);
// SetPixel() takes in the x and y coordinate and an ARGB Color value
}
}
return bitmap;
}