当前位置: 首页>>代码示例>>C#>>正文


C# Screen.ToBitmap方法代码示例

本文整理汇总了C#中Screen.ToBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Screen.ToBitmap方法的具体用法?C# Screen.ToBitmap怎么用?C# Screen.ToBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Screen的用法示例。


在下文中一共展示了Screen.ToBitmap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadAndRenderFile

 public void ReadAndRenderFile ( string _filename )
 {
     IAnsiDecoder vt100 = new AnsiDecoder();
     //vt100.Encoding = encodingInfo.GetEncoding (); // encodingInfo.Name, new EncoderExceptionFallback(), new DecoderReplacementFallback ("U") );
     Screen screen = new Screen ( 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 );
 }
开发者ID:taterbase,项目名称:libvt100,代码行数:25,代码来源:TestPrograms.cs

示例2: ReadAndRenderFile

        public Screen 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;
            Screen screen = new Screen ( _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;
        }
开发者ID:taterbase,项目名称:libvt100,代码行数:37,代码来源:TestAnsiArt.cs

示例3: Main

      static int Main( string[] args )
      {
         string inputFilename = null;
         string outputFilename = null;
         int width = 80;
         int height = 25;
         string fontName = "Courier New";
         int fontSize = 6;
         string encoding = "ibm437";
         for ( int i = 0 ; i < args.Length ; i++ )
         {
            switch ( args[i] )
            {
               case "-w":
                  i++;
                  width = Int32.Parse( args[i] );
                  break;

               case "-h":
                  i++;
                  height = Int32.Parse( args[i] );
                  break;

               case "-f":
                  i++;
                  fontName = args[i];
                  break;

               case "-s":
                  i++;
                  fontSize = Int32.Parse( args[i] );
                  break;
                  
               case "-e":
                  i++;
                  encoding = args[i];
                  break;
                  
               default:
                  if ( inputFilename == null )
                  {
                     inputFilename = args[i];
                  }
                  else if ( outputFilename == null )
                  {
                     outputFilename = args[i];
                  }
                  else
                  {
                     System.Console.WriteLine( "Unrecognized command line parameter ({0}): {1}", i, args[i] );
                  }
                  break;
            }
         }

         if ( inputFilename == null || outputFilename == null )
         {
            System.Console.WriteLine( "Syntax:" );
            System.Console.WriteLine( "    {0} [-w width] [-h height] [-f fontName] [-s fontSize] [-e encoding] <input.txt> <output.png>", System.Reflection.Assembly.GetCallingAssembly().GetName().Name );
            return -1;
         }
         
         IAnsiDecoder vt100 = new AnsiDecoder();
         Screen screen = new Screen(width, height );
         vt100.Encoding = Encoding.GetEncoding( encoding );
         vt100.Subscribe( screen );

         using ( Stream stream = File.Open( inputFilename, FileMode.Open ) )
         {
            int read = 0;
            while ( (read = stream.ReadByte()) != -1 )
            {
               vt100.Input( new byte[] { (byte) read } );
            }
         }

         Bitmap bitmap = screen.ToBitmap( new Font( fontName, fontSize ) );
         bitmap.Save( outputFilename, System.Drawing.Imaging.ImageFormat.Png );
         return 0;
      }
开发者ID:taterbase,项目名称:libvt100,代码行数:80,代码来源:Program.cs


注:本文中的Screen.ToBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。