Skip to content

Instantly share code, notes, and snippets.

@johnboker
Created May 6, 2016 04:07
Show Gist options
  • Save johnboker/d306040935025b86c1bec06504aa5813 to your computer and use it in GitHub Desktop.
Save johnboker/d306040935025b86c1bec06504aa5813 to your computer and use it in GitHub Desktop.
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