Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Linq;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
namespace CrackTheCode
{
class MainClass
{
public static void Main (string[] args)
{
FileStream fs = new FileStream ("../../SETI_message.txt", FileMode.Open, FileAccess.Read);
int w = 359;
int h = 757;
int c = 0;
int offset = 0;
byte[] arr = new byte[w * h];
int n = 0;
while ((c = fs.Read (arr, 0, w * h)) > 0) {
offset += c;
n++;
using (var img = new Bitmap (w, h)) {
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
int b = arr [j * w + i] - '0';
img.SetPixel (i, j, b == 0 ? Color.White : Color.Black);
}
}
img.Save ($"output-{n}.png", ImageFormat.Png);
}
arr = new byte[w * h];
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.