public CodeChar[,] Recreate(string BMP) { byte[] fData = GetBytes(BMP, out int Width, out int Height); CodeChar[,] data = new CodeChar[Width, Height]; OutWriter.Debug($"[ BMPLOAD ] Image is {Width}x{Height}."); for (int field = 0; field < fData.Length; field += 4) { int xPos = (field / 4) % Width; int yPos = Height - 1 - (field / 4) / Width; CodeChar pos = (CodeChar)(new byte[] { fData[field + 2], fData[field + 1], fData[field] }); OutWriter.Debug($"[ BMPLOAD ] Filling @{xPos};{yPos}={pos}"); data[xPos, yPos] = pos; } OutWriter.Debug(" ==== IMAGE OVERVIEW ==== "); for (int y = 0; y < Height; y++) { string str = ""; for (int x = 0; x < Width; x++) { str += data[x, y].ToString() + " "; } OutWriter.Debug(str); } OutWriter.Debug(" ==== END OF OVERVIEW ==== "); return(data); }
public static CodeChar[,] ToCodeChar(this Color[,] vl) { CodeChar[,] ret = new CodeChar[vl.GetLength(0), vl.GetLength(1)]; for (int x = 0; x < vl.GetLength(0); x++) { for (int y = 0; y < vl.GetLength(1); y++) { ret[x, y] = (CodeChar)vl[x, y]; } } return(ret); }