Sorry mauka, but your solution seem a bit hard to understand for me,
so I try to make one myself and the result is here (in C#
)
PHP Code:
private static Color GetColor(byte b)
{
switch (b)
{
case 0: return Color.Green;
case 1: return Color.Yellow;
case 4: return Color.Navy;
default: return Color.Black;
}
}
private Bitmap RenderX(byte[] buffer)
{
Bitmap bmp = new Bitmap(TERRAIN_MATRIX_H, TERRAIN_MATRIX_V);
if (TType == TerrainType.NewClient)
for (int x = 0; x < 256; x++)
for (int y = 0; y < 256; y++)
bmp.SetPixel(x, y, GetColor(buffer[1 + x * 2 * 256 + y * 2]));
else
for (int x = 0; x < 256; x++)
for (int y = 0; y < 256; y++)
bmp.SetPixel(x, y, GetColor(buffer[x * 256 + y]));
return bmp;
}