StdPaint.ConsoleBuffer.FromFile C# (CSharp) Method

FromFile() public static method

Loads buffer data from a file and returns it as a ConsoleBuffer object.
public static FromFile ( string path ) : ConsoleBuffer
path string The path to the buffer file.
return ConsoleBuffer
        public static ConsoleBuffer FromFile(string path)
        {
            using(BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open)))
            {
                int width = reader.ReadInt32();
                int height = reader.ReadInt32();
                BufferUnitInfo[,] bufferData = new BufferUnitInfo[height, width];
                BufferUnitInfo temp = new BufferUnitInfo();
                for(int i = 0; i < width; i++)
                for(int j = 0; j < height; j++)
                {
                    temp._attrs = reader.ReadInt16();
                    temp.CharData = reader.ReadChar();
                    bufferData[j, i] = temp;
                }
                return new ConsoleBuffer(width, height, bufferData);
            }
        }