InfoKriegerX66

Simple Console Image

Mar 24th, 2012
5,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Imaging;
  4.  
  5. namespace ConsoleImage
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Image Picture = Image.FromFile(@"C:\Users\InfoKriegerX\Pictures\your_image.jpg");
  12.             Console.SetBufferSize((Picture.Width * 0x2), (Picture.Height * 0x2));
  13.             FrameDimension Dimension = new FrameDimension(Picture.FrameDimensionsList[0x0]);
  14.             int FrameCount = Picture.GetFrameCount(Dimension);
  15.             int Left = Console.WindowLeft, Top = Console.WindowTop;
  16.             char[] Chars = { '#', '#', '@', '%', '=', '+', '*', ':', '-', '.', ' ' };
  17.             Picture.SelectActiveFrame(Dimension, 0x0);
  18.             for (int i = 0x0; i < Picture.Height; i++)
  19.             {
  20.                 for (int x = 0x0; x < Picture.Width; x++)
  21.                 {
  22.                     Color Color = ((Bitmap)Picture).GetPixel(x, i);
  23.                     int Gray = (Color.R + Color.G + Color.B) / 0x3;
  24.                     int Index = (Gray * (Chars.Length - 0x1)) / 0xFF;
  25.                     Console.Write(Chars[Index]);
  26.                 }
  27.                 Console.Write('\n');
  28.             }
  29.             Console.SetCursorPosition(Left, Top);
  30.             Console.Read();
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment