Guest User

Untitled

a guest
Feb 6th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Drawing;
  8. using System.IO;
  9.  
  10. namespace ConsoleApplication1
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.  
  17.             Bitmap bitmap = new Bitmap("puzzle.png");
  18.  
  19.             BitArray b = new BitArray(8);
  20.             byte[] bytes = new byte[1];
  21.             string output = "";
  22.  
  23.             for (int i = 0; i<bitmap.Height; i++)
  24.             {
  25.                 for (int j = 0; j<bitmap.Width; j++)
  26.                 {
  27.                     b.Set(j % 8, bitmap.GetPixel(j, i).A == 254);
  28.  
  29.                     if (j % 8 == b.Length-1)
  30.                     {
  31.                         b.CopyTo(bytes, 0);
  32.                         output += Encoding.ASCII.GetString(bytes);
  33.                     }
  34.  
  35.                     //Console.Write(bitmap.GetPixel(j, i).A==254 ? 0 : 1);
  36.                     //Console.Write(",");
  37.                 }
  38.                 //Console.WriteLine();
  39.             }
  40.  
  41.             Console.WriteLine(output);
  42.             File.WriteAllText("output.txt",output);
  43.  
  44.             Console.ReadKey();
  45.         }
  46.     }
  47. }
Add Comment
Please, Sign In to add comment