I am attempting to draw images to the console that overlap however the code I am using creates space characters when there is white to shift the cursor however this means that where there is blank space in the image it writes over the character already there.
The Script
using System;
using System.Drawing;
using System.Drawing.Imaging;
namespace ConsoleImage
{
class Program
{
static void Main(string[] args)
{
Image Picture = Image.FromFile(@"C:\Users\InfoKriegerX\Pictures\your_image.jpg");
Console.SetBufferSize((Picture.Width * 0x2), (Picture.Height * 0x2));
FrameDimension Dimension = new FrameDimension(Picture.FrameDimensionsList[0x0]);
int FrameCount = Picture.GetFrameCount(Dimension);
int Left = Console.WindowLeft, Top = Console.WindowTop;
char[] Chars = { '#', '#', '@', '%', '=', '+', '*', ':', '-', '.', ' ' };
Picture.SelectActiveFrame(Dimension, 0x0);
for (int i = 0x0; i < Picture.Height; i++)
{
for (int x = 0x0; x < Picture.Width; x++)
{
Color Color = ((Bitmap)Picture).GetPixel(x, i);
int Gray = (Color.R + Color.G + Color.B) / 0x3;
int Index = (Gray * (Chars.Length - 0x1)) / 0xFF;
Console.Write(Chars[Index]);
}
Console.Write('\n');
}
Console.SetCursorPosition(Left, Top);
Console.Read();
}
}
}
I have attempted to shift the console cursor right one instead of writing a blank character however this malforms the console output.
if (Chars[Index].Equals(" ")) { Console.SetCursorPosition(Console.WindowLeft + 1, Console.WindowTop); }
else
{
Console.Write(Chars[Index]);
}