public static Bitmap drawPixelsN(MagicaVoxelData[] voxels) { Bitmap b = new Bitmap(22, 44); Graphics g = Graphics.FromImage((Image)b); //Image image = new Bitmap("cube_large.png"); Image image = new Bitmap("cube_ortho.png"); //Image reversed = new Bitmap("cube_reversed.png"); ImageAttributes imageAttributes = new ImageAttributes(); int width = 1; int height = 2; //g.DrawImage(image, 10, 10, width, height); float[][] colorMatrixElements = { new float[] { 1F, 0, 0, 0, 0 }, new float[] { 0, 1F, 0, 0, 0 }, new float[] { 0, 0, 1F, 0, 0 }, new float[] { 0, 0, 0, 1F, 0 }, new float[] { 0, 0, 0, 0, 1F } }; ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements); imageAttributes.SetColorMatrix( colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); MagicaVoxelData[] vls = new MagicaVoxelData[voxels.Length]; for (int i = 0; i < voxels.Length; i++) { byte tempX = (byte)(voxels[i].x - 11); byte tempY = (byte)(voxels[i].y - 11); vls[i].x = (byte)((tempX * -1) + 11 - 1); vls[i].y = (byte)((tempY * -1) + 11 - 1); vls[i].z = voxels[i].z; vls[i].color = voxels[i].color; } foreach (MagicaVoxelData vx in vls.OrderBy(v => v.x * 32 - v.y + v.z * 32 * 128)) //voxelData[i].x + voxelData[i].z * 32 + voxelData[i].y * 32 * 128 { int current_color = 249 - vx.color; if (current_color > 128) { current_color = 24; } colorMatrix = new ColorMatrix(new float[][] { new float[] { colors[current_color][0], 0, 0, 0, 0 }, new float[] { 0, colors[current_color][1], 0, 0, 0 }, new float[] { 0, 0, colors[current_color][2], 0, 0 }, new float[] { 0, 0, 0, 1F, 0 }, new float[] { 0, 0, 0, 0, 1F } }); imageAttributes.SetColorMatrix( colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); g.DrawImage( image, new Rectangle(vx.y, 44 - 1 - 20 - 2 + vx.x - vx.z, width, height), // destination rectangle // new Rectangle((vx.x + vx.y) * 4, 128 - 6 - 32 - vx.y * 2 + vx.x * 2 - 4 * vx.z, width, height), // destination rectangle 0, 0, // upper-left corner of source rectangle width, // width of source rectangle height, // height of source rectangle GraphicsUnit.Pixel, imageAttributes); } return(b); }