Пример #1
0
        public void ReadAndRenderFile(string _filename)
        {
            IAnsiDecoder vt100 = new AnsiDecoder();
            //vt100.Encoding = encodingInfo.GetEncoding (); // encodingInfo.Name, new EncoderExceptionFallback(), new DecoderReplacementFallback ("U") );
            TerminalFrameBuffer screen = new TerminalFrameBuffer(80, 160);

            vt100.Subscribe(screen);

            using (BinaryReader reader = new BinaryReader(File.Open(_filename, FileMode.Open)))
            {
                try
                {
                    int read = 0;
                    while ((read = reader.Read()) != -1)
                    {
                        vt100.Input(new byte[] { (byte)read });
                    }
                }
                catch (EndOfStreamException)
                {
                }
            }
            System.Console.Write(screen.ToString());
            // Bitmap bitmap = screen.ToBitmap ( new Font("Courier New", 10) );
            // bitmap.Save ( _filename + ".png", System.Drawing.Imaging.ImageFormat.Png );
        }
Пример #2
0
        public TerminalFrameBuffer ReadAndRenderFile(string _filename, Encoding _encoding, Size _size)
        {
            IAnsiDecoder vt100 = new AnsiDecoder();

            //vt100.Encoding = Encoding.GetEncoding ( encodingInfo.Name, new EncoderExceptionFallback(), new DecoderReplacementFallback ("U") );
            vt100.Encoding = _encoding;
            TerminalFrameBuffer screen = new TerminalFrameBuffer(_size.Width, _size.Height);

            vt100.Subscribe(screen);

            using (Stream stream = File.Open(_filename, FileMode.Open))
            {
                try
                {
                    int read = 0;
                    while ((read = stream.ReadByte()) != -1)
                    {
                        vt100.Input(new byte[] { (byte)read });
                    }
                }
                catch (EndOfStreamException)
                {
                }
            }
            //System.Console.Write ( screen.ToString() );
            // Bitmap bitmap = screen.ToBitmap ( new Font("Courier New", 6) );
            // bitmap.Save ( "..\\build\\" + Path.GetFileNameWithoutExtension(_filename) + "_" + _encoding.EncodingName + ".png", System.Drawing.Imaging.ImageFormat.Png );

            /*
             * foreach ( Screen.Character ch in screen )
             * {
             * if ( ch.Char != 0x20 )
             * {
             * System.Console.WriteLine ( "Non-space character: {0} 0x{1:X4}", ch.Char, (int) ch.Char );
             * }
             * }
             */
            return(screen);
        }