// Image Loading Component public static Dictionary <string, Image> LoadImages(string folderPath) { Dictionary <string, Image> images = new Dictionary <string, Image>(); foreach (string f in Directory.GetFiles(folderPath)) { //Need to make sure the file is actually .ci before loading, to prevent errors. if (f.Substring(f.Length - 3).ToLower() == ".ci") { Image image = LoadImage(f); images[image.Name] = image; } } return(images); }
public static void PrintImage(Image image, IntXYPair position) { // isolate the Y for incrementing as each line is printed if (IsInScope(position, image.Bitmap[0].Length, image.Bitmap.Count)) { int topLimit = Math.Max(0, 0 - position.y); int row = Math.Max(position.y, 0); for (int y = topLimit; y < image.Bitmap.Count; y += 2) { char[] nextLine1 = image.Bitmap[y].ToCharArray(); char[] nextLine2; if (y + 1 >= image.Bitmap.Count) { nextLine2 = new string('Z', image.Bitmap[y].Count()).ToCharArray(); } else { nextLine2 = image.Bitmap[y + 1].ToCharArray(); } for (int x = 0; x < Math.Min(nextLine1.Length, Console.BufferWidth - position.y); x++) { string nextPixel = nextLine1[x] + ""; int nextColorIndex; nextColorIndex = GetPixelCode(nextPixel); SetForeground(nextColorIndex, image.Colors); nextPixel = nextLine2[x] + ""; nextColorIndex = GetPixelCode(nextPixel); SetBackground(nextColorIndex, image.Colors); // A special character recognized by console that covers excactly the top half of the space // it's also very square. PrintComponent("▀", x + position.x, row); } row++; } System.Console.BackgroundColor = ConsoleColor.Black; System.Console.ForegroundColor = ConsoleColor.White; } CleanUp(); }
public static void PrintImage(Image image, int x, int y) { PrintImage(image, new IntXYPair(x, y)); }