-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrinter.cs
More file actions
40 lines (37 loc) · 1.04 KB
/
Printer.cs
File metadata and controls
40 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//#define DEBUG_CONSOLE
using System.Collections.Generic;
#if DEBUG_CONSOLE
using System;
using System.Text;
#endif
namespace BmArrayLoader
{
public static class Printer
{
public static void PrintImage(Indexmap master, IList<byte[]> palette)
{
#if DEBUG_CONSOLE
Console.OutputEncoding = Encoding.UTF8;
for (int i = 0; i < master.Size; i++)
{
int index = master[i];
int x = i % master.Width;
if (x < Console.BufferWidth / 2)
{
string color = GetAnsiColor(palette[index][0], palette[index][1], palette[index][2]);
Console.Write(color + "██");
}
if (x== master.Width - 1) Console.Write("\x1b[0m\n");
}
Console.Write("\x1b[0m\n");
#endif
}
#if DEBUG_CONSOLE
static string GetAnsiColor(byte r, byte g, byte b)
{
// 24-bit Truecolor ANSI
return $"\x1b[38;2;{r};{g};{b}m";
}
#endif
}
}