title: Need C# function to convert grayscale TIFF to black & white (monochrome/1BPP) TIFF
body: <p>I need a C# function that will take a Byte[] of an 8 bit grayscale TIFF, and return a Byte[] of a 1 bit (black &amp; white) TIFF.</p>
  
  <p>I'm fairly new to working with TIFFs, but the general idea is that we need to convert them from grayscale or color to black and white/monochrome/binary image format.</p>
  
  <p>We receive the images via a WCF as a Byte[], then we need to make this conversion to black &amp; white in order to send them to a component which does further processing.  We do not plan at this point, to ever save them as files.</p>
  
  <p>For reference, in our test client, this is how we create the Byte[]:</p>
  
  <pre><code>        FileStream fs = new FileStream("test1.tif", FileMode.Open, FileAccess.Read);
          this.image = new byte[fs.Length];
          fs.Read(this.image, 0, System.Convert.ToInt32(fs.Length));
          fs.Close();
  </code></pre>
  
  <p>--------update---------</p>
  
  <p>I think there may be more than 1 good answer here, but we ended up using the code from the CodeProject site with the following method added to overload the convert function to accept Byte[] as well as bitmap:</p>
  
  <pre><code>public static Byte[] ConvertToBitonal(Byte[] original)
      {
          Bitmap bm = new Bitmap(new System.IO.MemoryStream(original, false));
          bm = ConvertToBitonal(bm);
          System.IO.MemoryStream s = new System.IO.MemoryStream();
          bm.Save(s, System.Drawing.Imaging.ImageFormat.Tiff);
          return s.ToArray();
      }
  </code></pre>